nrf24L01Plus.h
Go to the documentation of this file.
1 /*
2  * SocialLedge.com - Copyright (C) 2013
3  *
4  * This file is part of free software framework for embedded processors.
5  * You can use it and/or distribute it as long as this copyright header
6  * remains unmodified. The code is free for personal use and requires
7  * permission to use in a commercial product.
8  *
9  * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
10  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
12  * I SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
13  * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
14  *
15  * You can reach the author of this software at :
16  * p r e e t . w i k i @ g m a i l . c o m
17  */
18 
50 #ifndef NRF24L01PLUS_H_
51 #define NRF24L01PLUS_H_
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 #include <stdbool.h>
57 #include "utilities.h" // delay_us()
58 #include "bio.h" // board_io* functions
59 #include "ssp0.h" // SPI Bus functions
60 
61 
62 
63 #define NORDIC_EXCHANGE_SPI(byte) ssp0_exchange_byte(byte)
64 #define NORDIC_EXCHANGE_MULTI_BYTE(ptr, len) ssp0_exchange_data(ptr, len)
65 
66 #define NORDIC_LOCK_SPI()
67 #define NORDIC_UNLOCK_SPI()
68 #define NORDIC_DELAY_US(us) delay_us(us)
69 #define NORDIC_CS_ENABLE() board_io_nordic_cs()
70 #define NORDIC_CS_DISABLE() board_io_nordic_ds()
71 #define NORDIC_CE_HIGH() board_io_nordic_ce_high()
72 #define NORDIC_CE_LOW() board_io_nordic_ce_low()
73 #define NORDIC_INT_SIGNAL() (!board_io_nordic_irq_sig()) /* Signal is active low */
74 
75 
76 
83 void nordic_init(unsigned char payload, unsigned short mhz, unsigned short bitrate_kbps);
84 
87 bool nordic_is_air_free();
88 
90 static inline bool nordic_intr_signal() { return NORDIC_INT_SIGNAL(); }
91 
92 /* ******************************************************************************************************* */
93 /* ****************************** Nordic Modes of Operations ******************************* */
94 /* ******************************************************************************************************* */
95 
99 
102 void nordic_standby1_to_rx();
103 
108 
115 
119 
120 
121 
122 
123 
124 /* ******************************************************************************************************* */
125 /* ***************************** Nordic Transmission functions ****************************** */
126 /* ******************************************************************************************************* */
127 
130 
133 
136 
143 void nordic_queue_tx_fifo(char *data, unsigned short length);
144 
147 void nordic_mode1_send_single_packet(char *data, unsigned short length);
148 
150 bool nordic_is_packet_sent();
151 
154 
157 
160 
162 void nordic_flush_tx_fifo();
163 
164 
165 
166 /* ******************************************************************************************************* */
167 /* ****************************** Nordic Receive functions ******************************* */
168 /* ******************************************************************************************************* */
169 
172 
175 
181 char nordic_read_rx_fifo(char *data, unsigned short length);
182 
184 void nordic_flush_rx_fifo();
185 
186 
187 
188 
189 
190 
191 
192 /* ******************************************************************************************************* */
193 /* ***************************** Nordic Configuration Functions ****************************** */
194 /* ******************************************************************************************************* */
195 
199 void nordic_set_intr_signals(bool rx, bool tx, bool maxTransmissions);
200 
202 char nordic_get_intr_reg_status(void);
203 
206 void nordic_set_crc(unsigned char length);
207 
209 void nordic_power_up();
210 
212 void nordic_power_down();
213 
217 void nordic_set_channel(unsigned short MHz);
218 
220 void nordic_set_continous_carrier_transmit(bool enable);
221 
225 void nordic_set_air_data_rate(unsigned short kbps);
226 
229 void nordic_set_power_level(unsigned char powerLevel);
230 
231 
232 
233 
234 
235 /* ******************************************************************************************************* */
236 /* ************************* Nordic Enhanced Shockburst functions ************************** */
237 /* ******************************************************************************************************* */
238 
242 void nordic_set_auto_transmit_options(unsigned short txDelayUs, unsigned char retries);
243 
247 char nordic_get_lost_packet_cnt(bool clear);
248 
252 
253 
254 
255 
256 /* ******************************************************************************************************* */
257 /* ************************* Nordic Pipes & Addresses functions ************************** */
258 /* ******************************************************************************************************* */
259 
263 void nordic_set_payload_for_pipe(unsigned char pipeNumber, unsigned char payload);
264 
268 void nordic_set_addr_width(unsigned short width);
269 
273 void nordic_set_tx_address(char* address, unsigned short length);
274 
278 void nordic_set_rx_pipe0_addr(char* address, unsigned short length);
279 
283 void nordic_set_rx_pipe1_addr(char* address, unsigned short length);
284 
288 
289 void nordic_set_rx_pipe2_lsb_addr(char address);
290 void nordic_set_rx_pipe3_lsb_addr(char address);
291 void nordic_set_rx_pipe4_lsb_addr(char address);
292 void nordic_set_rx_pipe5_lsb_addr(char address);
294 
297 void nordic_set_auto_ack_for_pipes(bool pipe0, bool pipe1, bool pipe2, bool pipe3, bool pipe4, bool pipe5);
298 
301 void nordic_enable_pipes(bool pipe0, bool pipe1, bool pipe2, bool pipe3, bool pipe4, bool pipe5);
302 
303 
304 
305 
306 
307 #ifdef __cplusplus
308 }
309 #endif
310 
311 #endif /* NRF24L01PLUS_H_ */
void nordic_clear_packet_available_flag()
Clears the RX Packet Received Flag.
Definition: nrf24L01Plus.c:224
void nordic_set_rx_pipe5_lsb_addr(char address)
Definition: nrf24L01Plus.c:400
void nordic_clear_all_intr_flags()
Clears all interrupt flags to de-assert interrupt signal.
Definition: nrf24L01Plus.c:120
void nordic_power_down()
Powers down the Nordic chip (uses few nano-amps in power-down)
Definition: nrf24L01Plus.c:277
void nordic_standby1_to_tx_mode2()
Definition: nrf24L01Plus.c:150
void nordic_clear_packet_sent_flag()
Clears the Tx Packet sent flag.
Definition: nrf24L01Plus.c:196
bool nordic_is_max_retries_reached()
Definition: nrf24L01Plus.c:200
void nordic_clear_max_retries_flag()
Clears the Max retries reached flag.
Definition: nrf24L01Plus.c:204
Provides the map of all Board Pins, and initializes all connected signals of the board.
void nordic_set_rx_pipe3_lsb_addr(char address)
Definition: nrf24L01Plus.c:392
void nordic_tx_mode2_to_standby1_through_power_down()
Definition: nrf24L01Plus.c:184
bool nordic_is_tx_fifo_full()
Definition: nrf24L01Plus.c:112
void nordic_set_air_data_rate(unsigned short kbps)
Definition: nrf24L01Plus.c:296
void nordic_standby1_to_tx_mode1()
Definition: nrf24L01Plus.c:146
bool nordic_is_packet_available()
Definition: nrf24L01Plus.c:213
void nordic_enable_pipes(bool pipe0, bool pipe1, bool pipe2, bool pipe3, bool pipe4, bool pipe5)
Definition: nrf24L01Plus.c:418
char nordic_get_lost_packet_cnt(bool clear)
Definition: nrf24L01Plus.c:335
void nordic_set_crc(unsigned char length)
Definition: nrf24L01Plus.c:261
void nordic_init(unsigned char payload, unsigned short mhz, unsigned short bitrate_kbps)
Definition: nrf24L01Plus.c:71
char nordic_read_rx_fifo(char *data, unsigned short length)
Definition: nrf24L01Plus.c:228
void nordic_flush_tx_fifo()
Flushes(clears) the TX FIFO Data.
Definition: nrf24L01Plus.c:208
bool nordic_is_tx_fifo_empty()
Definition: nrf24L01Plus.c:116
void nordic_queue_tx_fifo(char *data, unsigned short length)
Definition: nrf24L01Plus.c:124
void nordic_set_power_level(unsigned char powerLevel)
Definition: nrf24L01Plus.c:306
void nordic_set_continous_carrier_transmit(bool enable)
Enables or disables continuous carrier transmission.
Definition: nrf24L01Plus.c:289
void nordic_set_payload_for_pipe(unsigned char pipeNumber, unsigned char payload)
Definition: nrf24L01Plus.c:354
void nordic_power_up()
Powers up the Nordic Chip.
Definition: nrf24L01Plus.c:273
void nordic_set_auto_transmit_options(unsigned short txDelayUs, unsigned char retries)
Definition: nrf24L01Plus.c:324
void nordic_flush_rx_fifo()
Flushes(clears) the RX FIFO Data.
Definition: nrf24L01Plus.c:232
void nordic_standby1_to_rx()
Definition: nrf24L01Plus.c:160
void nordic_set_rx_pipe1_addr(char *address, unsigned short length)
Definition: nrf24L01Plus.c:384
void nordic_set_rx_pipe0_addr(char *address, unsigned short length)
Definition: nrf24L01Plus.c:380
char nordic_get_intr_reg_status(void)
Definition: nrf24L01Plus.c:256
void nordic_set_tx_address(char *address, unsigned short length)
Definition: nrf24L01Plus.c:376
bool nordic_is_packet_sent()
Definition: nrf24L01Plus.c:192
void nordic_set_addr_width(unsigned short width)
Definition: nrf24L01Plus.c:367
void nordic_set_rx_pipe4_lsb_addr(char address)
Definition: nrf24L01Plus.c:396
void nordic_set_channel(unsigned short MHz)
Definition: nrf24L01Plus.c:281
void nordic_set_intr_signals(bool rx, bool tx, bool maxTransmissions)
Definition: nrf24L01Plus.c:245
void nordic_set_rx_pipe2_lsb_addr(char address)
Definition: nrf24L01Plus.c:388
void nordic_set_auto_ack_for_pipes(bool pipe0, bool pipe1, bool pipe2, bool pipe3, bool pipe4, bool pipe5)
Definition: nrf24L01Plus.c:405
bool nordic_is_air_free()
Definition: nrf24L01Plus.c:107
void nordic_mode1_send_single_packet(char *data, unsigned short length)
Definition: nrf24L01Plus.c:129
char nordic_get_retransmit_count()
Definition: nrf24L01Plus.c:343
#define NORDIC_INT_SIGNAL()
Definition: nrf24L01Plus.h:73
void nordic_rx_to_Stanby1()
Definition: nrf24L01Plus.c:156