4#ifndef PROTOCORE_NRF24_H
5#define PROTOCORE_NRF24_H
42typedef void (*
nrf_spi_fn)(
const uint8_t *tx, uint8_t *rx, uint8_t len,
void *ctx);
70 void (*set_rx)(uint8_t *,
const nrf_bus *);
71 int (*recv)(uint8_t *,
const nrf_bus *, uint8_t *, uint8_t, uint8_t *);
117typedef void (*
nrf_spi_fn)(
const uint8_t *tx, uint8_t *rx, uint8_t len,
void *ctx);
proto_bool protocore_nrf24_tx_done(uint8_t *work, const nrf_bus *bus)
True once a transmit has finished (STATUS TX_DS); clears the flag.
PROTOCORE_NS Nrf24Ns Nrf24 PROTOCORE_UNUSED
Module namespace.
void(* nrf_spi_fn)(const uint8_t *tx, uint8_t *rx, uint8_t len, void *ctx)
Full-duplex SPI transfer of len bytes (chip-select toggled by the callback).
int protocore_nrf24_recv(uint8_t *work, const nrf_bus *bus, uint8_t *buf, uint8_t cap, uint8_t *pipe)
If a frame is waiting, copy it into buf and report the pipe it .
proto_bool protocore_nrf24_init(uint8_t *work, const nrf_bus *bus, const nrf_config *cfg)
Configure the nRF24L01+ and power it up (standby).
void protocore_nrf24_set_rx(uint8_t *work, const nrf_bus *bus)
Enter receive mode (PRX + CE high); then poll protocore_nrf24_recv().
proto_bool protocore_nrf24_send(uint8_t *work, const nrf_bus *bus, const uint8_t *data, uint8_t len)
Transmit len bytes (zero-padded to PROTOCORE_NRF24_PAYLOAD). Poll .
void(* nrf_ce_fn)(proto_bool level, void *ctx)
Drive the CE pin (true = high).
#define PROTOCORE_NS_LAYOUT(T,...)
Pin every dispatch slot of a table that is nothing but function pointers.
#define PROTOCORE_NS
Storage for a dispatch table. The const is load bearing.
Dispatch table. Addressed by offset, so the layout is asserted below.
proto_bool(* init)(uint8_t *, const nrf_bus *, const nrf_config *)
The bus a driver call uses: your SPI transfer + CE control behind it.
Radio configuration applied by protocore_nrf24_init().
uint8_t data_rate
0 = 1 Mbps, 1 = 2 Mbps, 2 = 250 kbps.
uint8_t tx_power
power level 0..3 (-18, -12, -6, 0 dBm).
uint8_t channel
RF channel 0..125 (2400 + channel MHz).
const uint8_t * address
5-byte pipe-0 / TX address (RX and TX share it here).
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTOCORE_END_DECLS