Merge pull request #32 from foogod/regs_fixups0

Remove packed attribute from register structs
This commit is contained in:
Angus Gratton 2015-08-26 14:14:33 +10:00
commit bf44bc61d1

View file

@ -20,12 +20,21 @@
* and shift) constants. Used primarily with ESP8266 register access.
*/
#define VAL2FIELD(fieldname, value) (((value) & fieldname##_M) << fieldname##_S)
#define VAL2FIELD(fieldname, value) ((value) << fieldname##_S)
#define FIELD2VAL(fieldname, regbits) (((regbits) >> fieldname##_S) & fieldname##_M)
#define FIELD_MASK(fieldname) (fieldname##_M << fieldname##_S)
#define SET_FIELD(regbits, fieldname, value) (((regbits) & ~FIELD_MASK(fieldname)) | VAL2FIELD(fieldname, value))
/* VAL2FIELD/SET_FIELD do not normally check to make sure that the passed value
* will fit in the specified field (without clobbering other bits). This makes
* them faster and is usually fine. If you do need to make sure that the value
* will not overflow the field, use VAL2FIELD_M or SET_FIELD_M (which will
* first mask the supplied value to only the allowed number of bits) instead.
*/
#define VAL2FIELD_M(fieldname, value) (((value) & fieldname##_M) << fieldname##_S)
#define SET_FIELD_M(regbits, fieldname, value) (((regbits) & ~FIELD_MASK(fieldname)) | VAL2FIELD_M(fieldname, value))
/* Use this macro to store constant values in IROM flash instead
of having them loaded into rodata (which resides in DRAM)