TM STM32F4xx Libraries  v1.0.0
Libraries for STM32F4xx devices from Tilen Majerle
tm_stm32f4_nrf24l01.h
1 
30 #ifndef TM_NRF24L01_H
31 #define TM_NRF24L01_H 111
32 
33 /* C++ detection */
34 #ifdef __cplusplus
35 extern C {
36 #endif
37 
119 #include "stm32f4xx.h"
120 #include "defines.h"
121 #include "tm_stm32f4_spi.h"
122 #include "tm_stm32f4_gpio.h"
123 
130 /* Default SPI used */
131 #ifndef NRF24L01_SPI
132 #define NRF24L01_SPI SPI3
133 #define NRF24L01_SPI_PINS TM_SPI_PinsPack_2
134 #endif
135 
136 /* SPI chip enable pin */
137 #ifndef NRF24L01_CSN_PIN
138 #define NRF24L01_CSN_PORT GPIOD
139 #define NRF24L01_CSN_PIN GPIO_PIN_7
140 #endif
141 
142 /* Chip enable for transmitting */
143 #ifndef NRF24L01_CE_PIN
144 #define NRF24L01_CE_PORT GPIOD
145 #define NRF24L01_CE_PIN GPIO_PIN_8
146 #endif
147 
148 /* Pins configuration */
149 #define NRF24L01_CE_LOW TM_GPIO_SetPinLow(NRF24L01_CE_PORT, NRF24L01_CE_PIN)
150 #define NRF24L01_CE_HIGH TM_GPIO_SetPinHigh(NRF24L01_CE_PORT, NRF24L01_CE_PIN)
151 #define NRF24L01_CSN_LOW TM_GPIO_SetPinLow(NRF24L01_CSN_PORT, NRF24L01_CSN_PIN)
152 #define NRF24L01_CSN_HIGH TM_GPIO_SetPinHigh(NRF24L01_CSN_PORT, NRF24L01_CSN_PIN)
153 
167 typedef enum {
172 
176 typedef enum {
181 
185 typedef enum {
191 
192 /* Clear interrupt flags */
193 #define NRF24L01_CLEAR_INTERRUPTS do { TM_NRF24L01_WriteRegister(0x07, 0x70); } while (0)
194 
195 /* Gets interrupt status from device */
196 #define NRF24L01_GET_INTERRUPTS TM_NRF24L01_GetStatus()
197 
198 /* Interrupt masks */
199 #define NRF24L01_IRQ_DATA_READY 0x40
200 #define NRF24L01_IRQ_TRAN_OK 0x20
201 #define NRF24L01_IRQ_MAX_RT 0x10
223 uint8_t TM_NRF24L01_Init(uint8_t channel, uint8_t payload_size);
224 
232 void TM_NRF24L01_SetMyAddress(uint8_t* adr);
233 
241 void TM_NRF24L01_SetTxAddress(uint8_t* adr);
242 
249 
256 void TM_NRF24L01_PowerUpTx(void);
257 
265 void TM_NRF24L01_PowerUpRx(void);
266 
274 void TM_NRF24L01_PowerDown(void);
275 
282 
289 void TM_NRF24L01_Transmit(uint8_t *data);
290 
298 uint8_t TM_NRF24L01_DataReady(void);
299 
305 void TM_NRF24L01_GetData(uint8_t *data);
306 
314 void TM_NRF24L01_SetChannel(uint8_t channel);
315 
323 
329 uint8_t TM_NRF24L01_GetStatus(void);
330 
331 /* Private */
332 void TM_NRF24L01_WriteRegister(uint8_t reg, uint8_t value);
333 
346 /* C++ detection */
347 #ifdef __cplusplus
348 }
349 #endif
350 
351 #endif
352 
Definition: tm_stm32f4_nrf24l01.h:177
void TM_NRF24L01_SetMyAddress(uint8_t *adr)
Sets own address. This is used for settings own id when communication with other modules.
void TM_NRF24L01_SetTxAddress(uint8_t *adr)
Sets address you will communicate with.
TM_NRF24L01_Transmit_Status_t TM_NRF24L01_GetTransmissionStatus(void)
Gets transmissions status.
TM_NRF24L01_Transmit_Status_t
Transmission status enumeration.
Definition: tm_stm32f4_nrf24l01.h:167
void TM_NRF24L01_Transmit(uint8_t *data)
Transmits data with NRF24L01+ to another NRF module.
Definition: tm_stm32f4_nrf24l01.h:178
Definition: tm_stm32f4_nrf24l01.h:179
Definition: tm_stm32f4_nrf24l01.h:168
void TM_NRF24L01_PowerDown(void)
Sets NRF24L01+ to power down mode.
void TM_NRF24L01_PowerUpTx(void)
Sets NRF24L01+ to TX mode.
Definition: tm_stm32f4_nrf24l01.h:189
TM_NRF24L01_DataRate_t
Data rate enumeration.
Definition: tm_stm32f4_nrf24l01.h:176
Definition: tm_stm32f4_nrf24l01.h:169
Definition: tm_stm32f4_nrf24l01.h:186
Definition: tm_stm32f4_nrf24l01.h:170
uint8_t TM_NRF24L01_DataReady(void)
Checks if data is ready to be read from NRF24L01+.
uint8_t TM_NRF24L01_GetRetransmissionsCount(void)
Gets number of retransmissions needed in last transmission.
void TM_NRF24L01_PowerUpRx(void)
Sets NRF24L01+ to RX mode.
Definition: tm_stm32f4_nrf24l01.h:187
TM_NRF24L01_OutputPower_t
Output power enumeration.
Definition: tm_stm32f4_nrf24l01.h:185
void TM_NRF24L01_SetChannel(uint8_t channel)
Sets working channel.
void TM_NRF24L01_GetData(uint8_t *data)
Gets data from NRF24L01+.
Definition: tm_stm32f4_nrf24l01.h:188
uint8_t TM_NRF24L01_GetStatus(void)
Gets NRLF+ status register value.
void TM_NRF24L01_SetRF(TM_NRF24L01_DataRate_t DataRate, TM_NRF24L01_OutputPower_t OutPwr)
Sets RF parameters for NRF24L01+.