22 #ifndef __NRF5_ESB_H__
23 #define __NRF5_ESB_H__
29 #if MAX_MESSAGE_SIZE > (32)
30 #error "Unsupported message size. (MAX_MESSAGE_SIZE)"
34 #if MY_NRF5_ESB_RX_BUFFER_SIZE < (4)
35 #error "MY_NRF5_ESB_RX_BUFFER_SIZE must be greater than 3."
46 #define NRF5_ESB_ACK_WAIT \
47 ((NRF5_ESB_RAMP_UP_TIME << 1) + (9 << NRF5_ESB_byte_time()))
50 #define NRF5_ESB_ARD (1500)
53 #define NRF5_ESB_ARC_ACK (15)
56 #define NRF5_ESB_ARC_NOACK (3)
59 #define NRF5_ESB_BC_ARC (3)
62 #define NRF5_ESB_NODE_ADDR (0)
63 #define NRF5_ESB_NODE_ADDR_MSK (0xffffff00UL)
66 #define NRF5_ESB_TX_ADDR (4)
67 #define NRF5_ESB_TX_ADDR_MSK (0xffffff00UL)
70 #define NRF5_ESB_BC_ADDR (7)
71 #define NRF5_ESB_BC_ADDR_MSK (0xffffffffUL)
74 #define NRF5_ESB_SHORTS_RX \
75 (RADIO_SHORTS_READY_START_Msk | RADIO_SHORTS_END_START_Msk | \
76 RADIO_SHORTS_DISABLED_RXEN_Msk | RADIO_SHORTS_ADDRESS_BCSTART_Msk | \
77 RADIO_SHORTS_ADDRESS_RSSISTART_Msk | RADIO_SHORTS_DISABLED_RSSISTOP_Msk)
80 #define NRF5_ESB_SHORTS_TX \
81 (RADIO_SHORTS_READY_START_Msk | RADIO_SHORTS_END_START_Msk | \
82 RADIO_SHORTS_DISABLED_TXEN_Msk | RADIO_SHORTS_ADDRESS_BCSTART_Msk)
85 #define NRF5_ESB_SHORTS_RX_TX \
86 (RADIO_SHORTS_END_DISABLE_Msk | RADIO_SHORTS_DISABLED_TXEN_Msk | \
87 RADIO_SHORTS_READY_START_Msk | RADIO_SHORTS_ADDRESS_BCSTART_Msk)
90 #define NRF5_ESB_SHORTS_TX_RX \
91 (RADIO_SHORTS_END_DISABLE_Msk | RADIO_SHORTS_DISABLED_RXEN_Msk | \
92 RADIO_SHORTS_READY_START_Msk | RADIO_SHORTS_ADDRESS_BCSTART_Msk | \
93 RADIO_SHORTS_ADDRESS_RSSISTART_Msk | RADIO_SHORTS_DISABLED_RSSISTOP_Msk)
96 #if (NRF5_RADIO_TIMER_IRQN != TIMER0_IRQn)
98 #define NRF5_ESB_PPI_TIMER_START 14
99 #define NRF5_ESB_PPI_TIMER_RADIO_DISABLE 15
102 #define NRF5_ESB_USE_PREDEFINED_PPI
103 #define NRF5_ESB_PPI_TIMER_START 15
104 #define NRF5_ESB_PPI_TIMER_RADIO_DISABLE 22
106 #define NRF5_ESB_PPI_BITS \
107 ((1 << NRF5_ESB_PPI_TIMER_START) | \
108 (1 << NRF5_ESB_PPI_TIMER_RADIO_DISABLE))
113 #define NRF5_ESB_BITCOUNTER (9)
118 #define NRF5_ESB_RAMP_UP_TIME (140)
121 static bool NRF5_ESB_initialize();
122 static void NRF5_ESB_powerDown();
123 static void NRF5_ESB_powerUp();
124 static void NRF5_ESB_sleep();
125 static void NRF5_ESB_standBy();
126 static bool NRF5_ESB_sanityCheck();
128 static void NRF5_ESB_setNodeAddress(
const uint8_t address);
129 static uint8_t NRF5_ESB_getNodeID();
131 static void NRF5_ESB_startListening();
132 static bool NRF5_ESB_isDataAvailable();
133 static uint8_t NRF5_ESB_readMessage(
void *
data);
135 static bool NRF5_ESB_sendMessage(uint8_t recipient,
const void *buf, uint8_t len,
const bool noACK);
137 static int16_t NRF5_ESB_getSendingRSSI();
138 static int16_t NRF5_ESB_getReceivingRSSI();
141 static inline uint8_t NRF5_ESB_byte_time();
159 #ifdef MY_DEBUG_VERBOSE_NRF5_ESB
168 #ifdef MY_DEBUG_VERBOSE_NRF5_ESB
169 static uint32_t intcntr_bcmatch;
170 static uint32_t intcntr_ready;
171 static uint32_t intcntr_end;