Skip to content

Instantly share code, notes, and snippets.

@pamaury
Created March 27, 2015 09:04
Show Gist options
  • Save pamaury/581cab8e327fe140c32d to your computer and use it in GitHub Desktop.
Save pamaury/581cab8e327fe140c32d to your computer and use it in GitHub Desktop.
#define HW_ICOLL_ENABLE_ADDR (0x80000000 + 0x8)
#define HW_ICOLL_ENABLE_SET_ADDR (0x80000000 + 0xc)
#define HW_ICOLL_ENABLE (*(volatile uint16_t *)(0x80000000 + 0x8))
#define HW_ICOLL_ENABLE_SET (*(volatile uint16_t *)(0x80000000 + 0xc))
#define BP_ICOLL_ENABLE_VDDIO_BO 0
#define BM_ICOLL_ENABLE_VDDIO_BO 0x3
#define BV_ICOLL_ENABLE_VDDIO_BO__DISABLED 0x0
#define BV_ICOLL_ENABLE_VDDIO_BO__ENABLED 0x1
#define BV_ICOLL_ENABLE_VDDIO_BO__NMI 0x2
#define BF_ICOLL_ENABLE_VDDIO_BO(_v) (((_v) << 0) & 0x3)
#define BF_ICOLL_ENABLE_VDDIO_BO_V(_v) ((BV_ICOLL_ENABLE_VDDIO_BO__##_v << 0) & 0x3)
#define BP_ICOLL_ENABLE_VDDA_BO 2
#define BM_ICOLL_ENABLE_VDDA_BO 0x7
#define BV_ICOLL_ENABLE_VDDA_BO__DISABLED 0x0
#define BV_ICOLL_ENABLE_VDDA_BO__ENABLED 0x1
#define BV_ICOLL_ENABLE_VDDA_BO__NMI 0x2
#define BF_ICOLL_ENABLE_VDDA_BO(_v) (((_v) << 2) & 0x7)
#define BF_ICOLL_ENABLE_VDDA_BO_V(_v) ((BV_ICOLL_ENABLE_VDDIO_BO__##_v << 3) & 0x7)
/* we can write: */
HW_ICOLL_ENABLE = BF_OR(ICOLL_ENABLE, VDDIO_BO(0x1), VDDA_BO_V(NMI));
/* and also: */
HW_ICOLL_ENABLE_SET = BF_ICOLL_ENABLE_VDDA_BO_V(ENABLE);
/* PROPOSAL: create new macros: */
#define BW_ICOLL_ENABLE(...) HW_ICOLL_ENABLE = BF_OR(ICOLL_ENABLE, __VA_ARGS__)
#define BW_ICOLL_ENABLE_SET(...) HW_ICOLL_ENABLE = BF_OR(ICOLL_ENABLE, __VA_ARGS__)
/* so that we can write: */
BW_ICOLL_ENABLE(VDDIO_BO(0x1), VDDA_BO_V(NMI));
BW_ICOLL_ENABLE_SET(VDDA_BO_V(ENABLE));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment