nrf24l01p.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Hamburg University of Applied Sciences
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser General
5  * Public License v2.1. See the file LICENSE in the top level directory for more
6  * details.
7  */
8 
23 #ifndef NRF24L01P_H
24 #define NRF24L01P_H
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #include <stdint.h>
31 #include <stdio.h>
32 #include "periph/gpio.h"
33 #include "periph/spi.h"
34 
38 typedef struct {
40  gpio_t ce;
41  gpio_t cs;
42  gpio_t irq;
43  int listener;
44 } nrf24l01p_t;
45 
49 typedef enum {
54 
55 
59 typedef enum {
64 
68 typedef enum {
74 
78 typedef enum {
86 
90 typedef enum {
94 
99 typedef enum {
117 
121 typedef enum {
124 
125 
136 int nrf24l01p_read_reg(nrf24l01p_t *dev, char reg, char *answer);
137 
148 int nrf24l01p_write_reg(nrf24l01p_t *dev, char reg, char write);
149 
165 int nrf24l01p_init(nrf24l01p_t *dev, spi_t spi, gpio_t ce, gpio_t csn, gpio_t irq);
166 
175 int nrf24l01p_on(nrf24l01p_t *dev);
176 
185 int nrf24l01p_off(nrf24l01p_t *dev);
186 
194 
205 int nrf24l01p_read_payload(nrf24l01p_t *dev, char *answer, unsigned int size);
206 
214 void nrf24l01p_register(nrf24l01p_t *dev, unsigned int *pid);
215 
226 
236 
246 int nrf24l01p_unregister(nrf24l01p_t *dev, unsigned int pid);
247 
255 void nrf24l01p_get_id(nrf24l01p_t *dev, unsigned int *pid);
256 
263 void nrf24l01p_start(nrf24l01p_t *dev);
264 
271 void nrf24l01p_stop(nrf24l01p_t *dev);
272 
283 int nrf24l01p_preload(nrf24l01p_t *dev, char *data, unsigned int size);
284 
298 int nrf24l01p_set_channel(nrf24l01p_t *dev, uint8_t chan);
299 
310 
326 
342 int nrf24l01p_set_tx_address(nrf24l01p_t *dev, char *saddr, unsigned int length);
343 
354 int nrf24l01p_set_tx_address_long(nrf24l01p_t *dev, uint64_t saddr, unsigned int length);
355 
372 int nrf24l01p_set_rx_address(nrf24l01p_t *dev, nrf24l01p_rx_pipe_t pipe, char *saddr, unsigned int length);
373 
385 int nrf24l01p_set_rx_address_long(nrf24l01p_t *dev, nrf24l01p_rx_pipe_t pipe, uint64_t saddr, unsigned int length);
386 
396 
407 
421 
430 
443 int nrf24l01p_set_power(nrf24l01p_t *dev, int pwr);
444 
453 
463 
473 
483 
493 int nrf24l01p_reset_interrupts(nrf24l01p_t *dev, char intrs);
494 
509 int nrf24l01p_mask_interrupt(nrf24l01p_t *dev, char intr);
510 
525 int nrf24l01p_unmask_interrupt(nrf24l01p_t *dev, char intr);
526 
537 
548 
557 
568 
585 int nrf24l01p_setup_auto_ack(nrf24l01p_t *dev, nrf24l01p_rx_pipe_t pipe, nrf24l01p_retransmit_delay_t delay_retrans, char count_retrans);
586 
596 
606 
616 
623 void nrf24l01p_rx_cb(void *arg);
624 
625 #ifdef __cplusplus
626 }
627 #endif
628 
629 #endif /* NRF24L01P_H */
630 
uint64_t nrf24l01p_get_tx_address_long(nrf24l01p_t *dev)
Get the TX address for the nrf24l01+ transceiver (long int).
transceiver received data
Definition: nrf24l01p.h:122
RX pipe 1.
Definition: nrf24l01p.h:80
int nrf24l01p_set_txmode(nrf24l01p_t *dev)
Set the nrf24l01+ into TX mode.
int nrf24l01p_enable_pipe(nrf24l01p_t *dev, nrf24l01p_rx_pipe_t pipe)
Enable RX datapipe on the nrf24l01+ transceiver.
power is -18dBm
Definition: nrf24l01p.h:69
encoding scheme generates 2 Bytes redundancy
Definition: nrf24l01p.h:92
int nrf24l01p_get_power(nrf24l01p_t *dev)
Get the transmit power for the nrf24l01+ transceiver device.
void nrf24l01p_transmit(nrf24l01p_t *dev)
Transmit payload laying in TX FIFO of the nrf24l01+ transceiver.
retransmit delay is 3500us
Definition: nrf24l01p.h:113
int nrf24l01p_setup_auto_ack(nrf24l01p_t *dev, nrf24l01p_rx_pipe_t pipe, nrf24l01p_retransmit_delay_t delay_retrans, char count_retrans)
Setup and enable automatic ACK and retransmission on the nrf24l01+ transceiver.
int nrf24l01p_disable_crc(nrf24l01p_t *dev)
Disable CRC error detection on the nrf24l01+ transceiver.
RX pipe 4.
Definition: nrf24l01p.h:83
gpio_t irq
GPIO pin to initialize as interrupt request.
Definition: nrf24l01p.h:42
Low-level GPIO peripheral driver interface definitions.
int nrf24l01p_set_rx_address(nrf24l01p_t *dev, nrf24l01p_rx_pipe_t pipe, char *saddr, unsigned int length)
Set the RX address for the nrf24l01+ transceiver (byte array).
int nrf24l01p_set_channel(nrf24l01p_t *dev, uint8_t chan)
Set the RF channel for the nrf24l01+ transceiver.
void nrf24l01p_get_id(nrf24l01p_t *dev, unsigned int *pid)
Get ID from the nrf24l01p transceiver.
nrf24l01p_retransmit_delay_t
Defines the automatic retransmission delay defined from end of transmission to start of next treansmi...
Definition: nrf24l01p.h:99
RX pipe 2.
Definition: nrf24l01p.h:81
RX pipe 0.
Definition: nrf24l01p.h:79
gpio_t cs
GPIO pin to initialize as chip select.
Definition: nrf24l01p.h:41
Structure that represents the hardware setup of the nrf24l01+ transceiver.
Definition: nrf24l01p.h:38
address width is 5 Byte
Definition: nrf24l01p.h:52
nrf24l01p_pwr_t
Defines the RF power level.
Definition: nrf24l01p.h:68
retransmit delay is 1750us
Definition: nrf24l01p.h:106
int nrf24l01p_unregister(nrf24l01p_t *dev, unsigned int pid)
Unregister the nrf24l01+ transceiver from his ID.
power is - 6dBm
Definition: nrf24l01p.h:71
void nrf24l01p_stop(nrf24l01p_t *dev)
Stop searching packets while in RX mode.
int nrf24l01p_set_payload_width(nrf24l01p_t *dev, nrf24l01p_rx_pipe_t pipe, char width)
Set the RX payload width for the nrf24l01+ transceiver.
Low-level SPI peripheral driver interface definition.
RX pipe 5.
Definition: nrf24l01p.h:84
int nrf24l01p_off(nrf24l01p_t *dev)
Power off the nrf24l01+ transceiver.
retransmit delay is 2000us
Definition: nrf24l01p.h:107
int nrf24l01p_disable_pipe(nrf24l01p_t *dev, nrf24l01p_rx_pipe_t pipe)
Disable RX datapipe on the nrf24l01+ transceiver.
retransmit delay is 2250us
Definition: nrf24l01p.h:108
address width is 4 Byte
Definition: nrf24l01p.h:51
int nrf24l01p_set_power(nrf24l01p_t *dev, int pwr)
Set the transmit power for the nrf24l01+ transceiver device.
RX pipe 3.
Definition: nrf24l01p.h:82
nrf24l01p_dr_t
Defines the RF datarate.
Definition: nrf24l01p.h:59
int nrf24l01p_get_status(nrf24l01p_t *dev)
Get the status (register) of the nrf24l01+ transceiver device.
int nrf24l01p_reset_all_interrupts(nrf24l01p_t *dev)
Reset all interrupts on the nrf24l01+ transceiver.
retransmit delay is 250us
Definition: nrf24l01p.h:100
nrf24l01p_aw_t
Defines the address width of the nrf24l01+ transceiver.
Definition: nrf24l01p.h:49
int nrf24l01p_set_rx_address_long(nrf24l01p_t *dev, nrf24l01p_rx_pipe_t pipe, uint64_t saddr, unsigned int length)
Set the RX address for the nrf24l01+ transceiver (long int).
int nrf24l01p_set_address_width(nrf24l01p_t *dev, nrf24l01p_aw_t aw)
Set the address width for the nrf24l01+ transceiver.
retransmit delay is 3000us
Definition: nrf24l01p.h:111
void nrf24l01p_start(nrf24l01p_t *dev)
Start searching packets while in RX mode.
int nrf24l01p_enable_dynamic_ack(nrf24l01p_t *dev)
Enable dynamic ack for the nrf24l01+ transceiver.
int nrf24l01p_unmask_interrupt(nrf24l01p_t *dev, char intr)
Unmask one interrupt on the nrf24l01+ transceiver.
int nrf24l01p_reset_interrupts(nrf24l01p_t *dev, char intrs)
Reset interrupts on the nrf24l01+ transceiver.
int listener
Place to store an ID in.
Definition: nrf24l01p.h:43
nrf24l01p_crc_t
Defines the error detection encoding scheme for the nrf24l01p transceiver.
Definition: nrf24l01p.h:90
nrf24l01p_rx_pipe_t
Defines the datapipe on which the receiver searches for packets.
Definition: nrf24l01p.h:78
retransmit delay is 500us
Definition: nrf24l01p.h:101
power is 0dBm
Definition: nrf24l01p.h:72
gpio_t ce
GPIO pin to initialize as chip enable.
Definition: nrf24l01p.h:40
retransmit delay is 1250us
Definition: nrf24l01p.h:104
retransmit delay is 3250us
Definition: nrf24l01p.h:112
void nrf24l01p_rx_cb(void *arg)
Callback that is called when interrupt occurs on interrupt pin from the nrf24l01+ transceiver...
datarate is 250 kbps
Definition: nrf24l01p.h:60
int nrf24l01p_init(nrf24l01p_t *dev, spi_t spi, gpio_t ce, gpio_t csn, gpio_t irq)
Initialize the nrf24l01+ transceiver.
int nrf24l01p_write_reg(nrf24l01p_t *dev, char reg, char write)
Write one register to the nrf24l01+ transceiver.
encoding scheme generates 1 Byte redundancy
Definition: nrf24l01p.h:91
stdio.h wrapper for MSP430
address width is 3 Byte
Definition: nrf24l01p.h:50
retransmit delay is 3750us
Definition: nrf24l01p.h:114
retransmit delay is 2500us
Definition: nrf24l01p.h:109
int nrf24l01p_on(nrf24l01p_t *dev)
Power on the nrf24l01+ transceiver.
int nrf24l01p_read_reg(nrf24l01p_t *dev, char reg, char *answer)
Read one register of the nrf24l01+ transceiver.
int nrf24l01p_flush_rx_fifo(nrf24l01p_t *dev)
Flush RX FIFO on the nrf24l01+ transceiver.
power is -12dBm
Definition: nrf24l01p.h:70
int nrf24l01p_preload(nrf24l01p_t *dev, char *data, unsigned int size)
Preload TX FIFO with payload to transmit.
int nrf24l01p_set_tx_address(nrf24l01p_t *dev, char *saddr, unsigned int length)
Set the TX address for the nrf24l01+ transceiver (byte array).
int nrf24l01p_disable_all_auto_ack(nrf24l01p_t *dev)
Disable automatic ACK on the nrf24l01+ transceiver.
retransmit delay is 2750us
Definition: nrf24l01p.h:110
int nrf24l01p_enable_crc(nrf24l01p_t *dev, nrf24l01p_crc_t crc)
Enable CRC error detection on the nrf24l01+ transceiver.
uint64_t nrf24l01p_get_rx_address_long(nrf24l01p_t *dev, nrf24l01p_rx_pipe_t pipe)
Get the RX address for the nrf24l01+ transceiver (long int).
nrf24l01p_rx_event_t
Defines states for the nrf24l01+ transceiver.
Definition: nrf24l01p.h:121
int nrf24l01p_flush_tx_fifo(nrf24l01p_t *dev)
Flush TX FIFO on the nrf24l01+ transceiver.
int nrf24l01p_set_tx_address_long(nrf24l01p_t *dev, uint64_t saddr, unsigned int length)
Set the TX address for the nrf24l01+ transceiver (long int).
int nrf24l01p_read_payload(nrf24l01p_t *dev, char *answer, unsigned int size)
Read payload from RX FIFO of the nrf24l01+ transceiver.
spi_t spi
SPI device to initialize.
Definition: nrf24l01p.h:39
int nrf24l01p_set_rxmode(nrf24l01p_t *dev)
Set the nrf24l01+ into RX mode.
retransmit delay is 1500us
Definition: nrf24l01p.h:105
datarate is 2 Mbps
Definition: nrf24l01p.h:62
int nrf24l01p_mask_interrupt(nrf24l01p_t *dev, char intr)
Mask one interrupt on the nrf24l01+ transceiver.
datarate is 1 Mbps
Definition: nrf24l01p.h:61
void nrf24l01p_register(nrf24l01p_t *dev, unsigned int *pid)
Register a given ID to the nrf24l01+ transceiver.
retransmit delay is 750us
Definition: nrf24l01p.h:102
retransmit delay is 4000us
Definition: nrf24l01p.h:115
int nrf24l01p_set_datarate(nrf24l01p_t *dev, nrf24l01p_dr_t dr)
Get the TX address for the nrf24l01+ transceiver (long int).
retransmit delay is 1000us
Definition: nrf24l01p.h:103
unsigned int spi_t
Default type for SPI devices.
Definition: spi.h:105
int nrf24l01p_enable_dynamic_payload(nrf24l01p_t *dev, nrf24l01p_rx_pipe_t pipe)
Enable dynamic payload for the pipe on give nrf24l01+ transceiver.