TM STM32Fxxx HAL Libraries  v1.0.0
Libraries for STM32Fxxx (F0, F4 and F7 series) devices based on HAL drivers from ST from Tilen Majerle
tm_stm32_nrf24l01.h
1 
37 #ifndef TM_NRF24L01_H
38 #define TM_NRF24L01_H 100
39 
40 /* C++ detection */
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
114 #include "stm32fxxx_hal.h"
115 #include "defines.h"
116 #include "tm_stm32_spi.h"
117 #include "tm_stm32_gpio.h"
118 
125 /* Default SPI used */
126 #ifndef NRF24L01_SPI
127 #define NRF24L01_SPI SPI3
128 #define NRF24L01_SPI_PINS TM_SPI_PinsPack_2
129 #endif
130 
131 /* SPI chip enable pin */
132 #ifndef NRF24L01_CSN_PIN
133 #define NRF24L01_CSN_PORT GPIOD
134 #define NRF24L01_CSN_PIN GPIO_PIN_7
135 #endif
136 
137 /* Chip enable for transmitting */
138 #ifndef NRF24L01_CE_PIN
139 #define NRF24L01_CE_PORT GPIOD
140 #define NRF24L01_CE_PIN GPIO_PIN_8
141 #endif
142 
143 /* Pins configuration */
144 #define NRF24L01_CE_LOW TM_GPIO_SetPinLow(NRF24L01_CE_PORT, NRF24L01_CE_PIN)
145 #define NRF24L01_CE_HIGH TM_GPIO_SetPinHigh(NRF24L01_CE_PORT, NRF24L01_CE_PIN)
146 #define NRF24L01_CSN_LOW TM_GPIO_SetPinLow(NRF24L01_CSN_PORT, NRF24L01_CSN_PIN)
147 #define NRF24L01_CSN_HIGH TM_GPIO_SetPinHigh(NRF24L01_CSN_PORT, NRF24L01_CSN_PIN)
148 
149 /* Interrupt masks */
150 #define NRF24L01_IRQ_DATA_READY 0x40
151 #define NRF24L01_IRQ_TRAN_OK 0x20
152 #define NRF24L01_IRQ_MAX_RT 0x10
167 typedef union _TM_NRF24L01_IRQ_t {
168  struct {
169  uint8_t reserved0:4;
170  uint8_t MaxRT:1;
171  uint8_t DataSent:1;
172  uint8_t DataReady:1;
173  uint8_t reserved1:1;
174  } F;
175  uint8_t Status;
177 
186 
195 
205 
226 uint8_t TM_NRF24L01_Init(uint8_t channel, uint8_t payload_size);
227 
235 void TM_NRF24L01_SetMyAddress(uint8_t* adr);
236 
244 void TM_NRF24L01_SetTxAddress(uint8_t* adr);
245 
252 
259 void TM_NRF24L01_PowerUpTx(void);
260 
268 void TM_NRF24L01_PowerUpRx(void);
269 
277 void TM_NRF24L01_PowerDown(void);
278 
285 
292 void TM_NRF24L01_Transmit(uint8_t *data);
293 
301 uint8_t TM_NRF24L01_DataReady(void);
302 
308 void TM_NRF24L01_GetData(uint8_t *data);
309 
317 void TM_NRF24L01_SetChannel(uint8_t channel);
318 
326 
332 uint8_t TM_NRF24L01_GetStatus(void);
333 
342 
349 
350 /* Private */
351 void TM_NRF24L01_WriteRegister(uint8_t reg, uint8_t value);
352 
365 /* C++ detection */
366 #ifdef __cplusplus
367 }
368 #endif
369 
370 #endif
371 
void TM_NRF24L01_SetMyAddress(uint8_t *adr)
Sets own address. This is used for settings own id when communication with other modules.
enum _TM_NRF24L01_Transmit_Status_t TM_NRF24L01_Transmit_Status_t
Transmission status enumeration.
void TM_NRF24L01_SetTxAddress(uint8_t *adr)
Sets address you will communicate with.
Definition: tm_stm32_nrf24l01.h:182
uint8_t TM_NRF24L01_Read_Interrupts(TM_NRF24L01_IRQ_t *IRQ)
Reads interrupts from NRF.
TM_NRF24L01_Transmit_Status_t TM_NRF24L01_GetTransmissionStatus(void)
Gets transmissions status.
union _TM_NRF24L01_IRQ_t TM_NRF24L01_IRQ_t
Interrupt structure.
void TM_NRF24L01_Transmit(uint8_t *data)
Transmits data with NRF24L01+ to another NRF module.
void TM_NRF24L01_PowerDown(void)
Sets NRF24L01+ to power down mode.
Definition: tm_stm32_nrf24l01.h:193
void TM_NRF24L01_PowerUpTx(void)
Sets NRF24L01+ to TX mode.
Interrupt structure.
Definition: tm_stm32_nrf24l01.h:167
void TM_NRF24L01_Clear_Interrupts(void)
Clears interrupt status.
Definition: tm_stm32_nrf24l01.h:191
enum _TM_NRF24L01_OutputPower_t TM_NRF24L01_OutputPower_t
Output power enumeration.
Definition: tm_stm32_nrf24l01.h:203
Definition: tm_stm32_nrf24l01.h:192
uint8_t TM_NRF24L01_DataReady(void)
Checks if data is ready to be read from NRF24L01+.
_TM_NRF24L01_DataRate_t
Data rate enumeration.
Definition: tm_stm32_nrf24l01.h:190
Definition: tm_stm32_nrf24l01.h:200
uint8_t TM_NRF24L01_GetRetransmissionsCount(void)
Gets number of retransmissions needed in last transmission.
Definition: tm_stm32_nrf24l01.h:183
enum _TM_NRF24L01_DataRate_t TM_NRF24L01_DataRate_t
Data rate enumeration.
void TM_NRF24L01_PowerUpRx(void)
Sets NRF24L01+ to RX mode.
uint8_t TM_NRF24L01_Init(uint8_t channel, uint8_t payload_size)
Initializes NRF24L01+ module.
Definition: tm_stm32_nrf24l01.h:202
Definition: tm_stm32_nrf24l01.h:184
void TM_NRF24L01_SetChannel(uint8_t channel)
Sets working channel.
_TM_NRF24L01_Transmit_Status_t
Transmission status enumeration.
Definition: tm_stm32_nrf24l01.h:181
Definition: tm_stm32_nrf24l01.h:201
_TM_NRF24L01_OutputPower_t
Output power enumeration.
Definition: tm_stm32_nrf24l01.h:199
uint8_t Status
Definition: tm_stm32_nrf24l01.h:175
void TM_NRF24L01_GetData(uint8_t *data)
Gets data from NRF24L01+.
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+.