34#define PN512_IRQ_TX (1<<6)
35#define PN512_IRQ_RX (1<<5)
36#define PN512_IRQ_IDLE (1<<4)
37#define PN512_IRQ_HIGH_ALERT (1<<3)
38#define PN512_IRQ_LOW_ALERT (1<<2)
39#define PN512_IRQ_ERR (1<<1)
40#define PN512_IRQ_TIMER (1<<0)
42#define PN512_IRQ_SIGIN (1<<(4+8))
43#define PN512_IRQ_MODE (1<<(3+8))
44#define PN512_IRQ_CRC (1<<(2+8))
45#define PN512_IRQ_RF_ON (1<<(1+8))
46#define PN512_IRQ_RF_OFF (1<<(0+8))
48#define PN512_IRQ_NONE 0x00
49#define PN512_IRQ_ALL 0x1F7F
51#define PN512_REG_COMIEN_MASK 0x7F
52#define PN512_REG_COMIEN_VAL 0x00
54#define PN512_REG_DIVIEN_MASK 0x1F
55#define PN512_REG_DIVIEN_VAL 0x80
57#define PN512_REG_COMIRQ_MASK 0x7F
58#define PN512_REG_COMIRQ_CLEAR 0x00
60#define PN512_REG_DIVIRQ_MASK 0x1F
61#define PN512_REG_DIVIRQ_CLEAR 0x00
67static inline void pn512_irq_set(
pn512_t *pPN512, uint16_t irqs)
69 pn512_register_write(pPN512, PN512_REG_COMIEN, PN512_REG_COMIEN_VAL | (PN512_REG_COMIEN_MASK & (irqs & 0xFF)));
70 pn512_register_write(pPN512, PN512_REG_DIVIEN, PN512_REG_DIVIEN_VAL | (PN512_REG_DIVIEN_MASK & (irqs >> 8)));
71 pPN512->irqsEn = irqs;
78static inline uint16_t pn512_irq_enabled(
pn512_t *pPN512)
88static inline uint16_t pn512_irq_get(
pn512_t *pPN512)
90 return ((pn512_register_read(pPN512, PN512_REG_COMIRQ) & PN512_REG_COMIEN_MASK)
91 | ((pn512_register_read(pPN512, PN512_REG_DIVIRQ) & PN512_REG_DIVIEN_MASK) << 8)) & pPN512->irqsEn;
98static inline void pn512_irq_clear(
pn512_t *pPN512, uint16_t irqs)
100 pn512_register_write(pPN512, PN512_REG_COMIRQ, PN512_REG_COMIRQ_CLEAR | (PN512_REG_COMIRQ_MASK & (irqs & 0xFF)));
101 pn512_register_write(pPN512, PN512_REG_DIVIRQ, PN512_REG_DIVIRQ_CLEAR | (PN512_REG_DIVIRQ_MASK & (irqs >> 8)));