-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnrf24l01_user.c
98 lines (86 loc) · 4.28 KB
/
nrf24l01_user.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/******************************************************************************
* Original source: S. Brennen Ball, 2006-2007 @ http://blog.diyembedded.com/
* Modified: Domen Jurkovic @ https://www.damogranlabs.com
*****************************************************************************/
#include "nrf24l01.h"
/******************************************************************************
* TODO IO pin configuration:
* User should configure GPIO pins before nRF24 init function.
* - CE: GPIO OUT, Push-Pull, high state by default.
* - CSN: GPIO OUT, Push-Pull, PULL UP, low state by default.
* - IRQ: This is used so that the routines can poll for IRQ or create an ISR.
* - GPIO INPUT, PULL UP: Monitor pin state with (nrf24l01_irq_pin_active) OR
* - GPIO INPUT, PULL UP: External interrupt on Fallin Edge
* Note: If interrupt pin as external interrupt is used, user should add any of
* "interrupt check/clear functions" to ISR and optionally read/write data.
* For instance, read data with: "nrf24l01_read_rx_payload()".
* Remember to clear interrupt source after it is handled!
******************************************************************************/
// #include "TODO_your_GPIO_lib.h"
/******************************************************************************
* SPI configuration:
* User should init SPI driver and SPI pins somewhere in the code before nRF24 init function:
* - 8-bit, MSB-first
* - CPOL=LOW, CPHA=LOW (1 Edge)
* - no hardware NSS/CSN output (CSN pin is handled in software by this library
******************************************************************************/
// #include "TODO_your_spi_lib.h"
/******************************************************************************
* TODO Microsecond delay function.
* User must define a function that delays for the specified number of
* microseconds. This function needs to be as precise as possible, and the use
* of a timer module within your microcontroller is highly recommended.
* Init delay before nRF init function.
******************************************************************************/
// #include "TODO_your_delay_us_lib"
inline void nrf24l01_delay_us(uint32_t microseconds)
{
}
/******************************************************************************
* TODO: Return `true` if IRQ pin is low, `false` otherwise.
******************************************************************************/
bool nrf24l01_irq_pin_active()
{
}
/******************************************************************************
* TODO: Write low state on CE pin.
******************************************************************************/
void nrf24l01_clear_ce()
{
}
/******************************************************************************
* TODO: Write high state on CE pin.
******************************************************************************/
void nrf24l01_set_ce()
{
}
/******************************************************************************
* TODO: Return `true` if current CE pin state is high, `false` otherwise.
******************************************************************************/
bool nrf24l01_ce_pin_active()
{
}
/******************************************************************************
* TODO: Write low state on CSN pin.
******************************************************************************/
void nrf24l01_clear_csn()
{
}
/******************************************************************************
* TODO: Write high state on CSN pin.
******************************************************************************/
void nrf24l01_set_csn()
{
}
/******************************************************************************
* TODO: Return `true` if current CSN pin state is high, `false` otherwise.
******************************************************************************/
bool nrf24l01_csn_pin_active()
{
}
/******************************************************************************
* TODO: Send given `byte` over chosen SPI interface, wait and return received byte.
******************************************************************************/
uint8_t nrf24l01_spi_send_read_byte(uint8_t byte)
{
}