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);
45typedef void (*
nrf_ce_fn)(embed_bool level,
void *ctx);
68 embed_bool (*
send)(
const uint8_t *,
const nrf_bus *,
const uint8_t *, uint8_t);
71 int (*
recv)(
const 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);
void(* nrf_ce_fn)(embed_bool level, void *ctx)
Drive the CE pin (true = high).
void protocore_nrf24_set_rx(const uint8_t *work, const nrf_bus *bus)
Enter receive mode (PRX + CE high); then poll protocore_nrf24_recv().
int protocore_nrf24_recv(const 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 .
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).
embed_bool protocore_nrf24_send(const uint8_t *work, const nrf_bus *bus, const uint8_t *data, uint8_t len)
Transmit len bytes (zero-padded to PROTOCORE_NRF24_PAYLOAD). Poll .
embed_bool protocore_nrf24_tx_done(const uint8_t *work, const nrf_bus *bus)
True once a transmit finished (STATUS TX_DS); clears the flag.
embed_bool protocore_nrf24_init(const uint8_t *work, const nrf_bus *bus, const nrf_config *cfg)
Configure the nRF24L01+ and power it up (standby).
#define PROTOCORE_UNUSED
Suppress the unused warning. Every module ends in a namespace most callers only partly use.
#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.
int(* recv)(const uint8_t *, const nrf_bus *, uint8_t *, uint8_t, uint8_t *)
embed_bool(* send)(const uint8_t *, const nrf_bus *, const uint8_t *, uint8_t)
embed_bool(* tx_done)(const uint8_t *, const nrf_bus *)
embed_bool(* init)(const uint8_t *, const nrf_bus *, const nrf_config *)
void(* set_rx)(const uint8_t *, const nrf_bus *)
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).