Thank you Jeremy/Kerry/Ping, I have also found this useful, many months later.
It seems to cover different IDEs - good.
With the default default IDE settings on my MCUXpresso 11.1.1 BME.h generates 21 trivial warnings to remind that it might not be able to inline the code in all circumstances. This does not matter, it works just fine as far as I can tell and the machine-code was smaller than non BME code. Thank you.
So, using your excellent code I modified it to simpler macros that worked specifically for my target FRDM-KL27 evaluation board, possibly at the cost of your portability.
Surprisingly the macros generated a smaller binary and still worked properly after extensive testing.
There are interesting operational details to note when using BME that require clarification. So they are documented in the header.
I have attached the header file in the hope that it will help anyone - even if only the comments on BME details are useful.
Bear in mind this code is targeted at the KL27z MCU so the comments suggest the macros should only be used for peripheral address space registers as advised in the MCU KL27z32/64 reference manual. Other MCUs might allow use with RAM. I tried Using Upper and lower RAM anyway and found that for BME access to one area a hard fault exception was generated, and for the other area no hard fault. So do NOTuse it for RAM unless your MCU explicitly supports it and you are certain which part of RAM is being accessed.
There are no asserts in the macros.
Regards, Rob