ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
cc1101.h File Reference

CC1101 sub-GHz radio driver (PROTOCORE_ENABLE_CC1101) - TI 300-928 MHz over SPI. More...

#include "protocore_config.h"

Go to the source code of this file.

Classes

struct  protocore_cc1101_bus
 The bus a driver call uses: your SPI transfer behind it. More...
 
struct  protocore_cc1101_reg
 One modem-config register write (address + value). More...
 
struct  protocore_cc1101_config
 Radio configuration applied by protocore_cc1101_init(). More...
 
struct  Cc1101Ns
 Dispatch table. Addressed by offset, so the layout is asserted below. More...
 

Typedefs

typedef void(* protocore_cc1101_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).
 

Functions

 PROTOCORE_NS_LAYOUT (Cc1101Ns, init, send, tx_done, set_rx, recv, rssi_dbm)
 
proto_bool protocore_cc1101_init (uint8_t *work, const protocore_cc1101_bus *bus, const protocore_cc1101_config *cfg)
 Reset the CC1101, apply cfg, set the channel, and confirm it is .
 
proto_bool protocore_cc1101_send (uint8_t *work, const protocore_cc1101_bus *bus, const uint8_t *data, uint8_t len)
 Transmit len bytes as a variable-length packet (leading length .
 
proto_bool protocore_cc1101_tx_done (uint8_t *work, const protocore_cc1101_bus *bus)
 True once the state machine has returned to IDLE after a transmit.
 
void protocore_cc1101_set_rx (uint8_t *work, const protocore_cc1101_bus *bus)
 Flush RX and enter receive mode (strobe RX). Then poll .
 
int protocore_cc1101_recv (uint8_t *work, const protocore_cc1101_bus *bus, uint8_t *buf, uint8_t cap, int16_t *rssi_dbm)
 If a packet is waiting, read it (length byte + payload + appended .
 
int16_t protocore_cc1101_rssi_dbm (uint8_t *work, uint8_t raw)
 Convert a raw CC1101 RSSI register value to dBm (TI datasheet .
 

Variables

PROTOCORE_NS Cc1101Ns Cc1101 PROTOCORE_UNUSED
 Module namespace.
 

Detailed Description

CC1101 sub-GHz radio driver (PROTOCORE_ENABLE_CC1101) - TI 300-928 MHz over SPI.

A radio driver plugin for the gateway (PROTOCORE_ENABLE_GATEWAY): generic ISM-band remotes and sensors (OOK / 2-FSK on 315/433/868/915 MHz) bridged to the web stack. Like the nRF24, the CC1101 speaks an SPI header protocol - every transaction begins with a header byte (bit7 = read, bit6 = burst, bits5-0 = address) and returns the chip status byte (CHIP_RDYn, the 3-bit state machine value, and the FIFO-bytes-available count). Config registers live at 0x00-0x2E, the 13 command strobes at 0x30-0x3D (a single write triggers the command), the read-only status registers at 0x30-0x3D read with the burst bit set, and both FIFOs at 0x3F.

The huge modem configuration (band, data rate, deviation, sync word) is board/tool-specific, so the caller supplies it as a register table (a TI SmartRF Studio export); the driver resets the chip, writes that table, sets the channel, and verifies the VERSION status register talks back. Packets use variable length mode (a leading length byte) with appended RSSI/LQI status. Bridge received payloads northbound with protocore_gateway_uplink. The register/strobe/FIFO protocol is host-testable against a mock; the RF link needs the module.

work is bytes the CALLER holds. This module reads none of them: it carries nothing between calls, so there is no state to keep and nothing to wipe. The parameter is there so a caller drives every namespace the same way.

Definition in file cc1101.h.

Typedef Documentation

◆ protocore_cc1101_spi_fn

typedef void(* protocore_cc1101_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).

Definition at line 40 of file cc1101.h.

Function Documentation

◆ PROTOCORE_NS_LAYOUT()

PROTOCORE_NS_LAYOUT ( Cc1101Ns  ,
init  ,
send  ,
tx_done  ,
set_rx  ,
recv  ,
rssi_dbm   
)

◆ protocore_cc1101_init()

proto_bool protocore_cc1101_init ( uint8_t *  work,
const protocore_cc1101_bus *  bus,
const protocore_cc1101_config *  cfg 
)

Reset the CC1101, apply cfg, set the channel, and confirm it is .

Parameters
workPROTOCORE_CC1101_BORROW bytes the caller took. Not held past the call.
busBus
cfgCfg
Returns
PROTO_TRUE on success.

◆ protocore_cc1101_send()

proto_bool protocore_cc1101_send ( uint8_t *  work,
const protocore_cc1101_bus *  bus,
const uint8_t *  data,
uint8_t  len 
)

Transmit len bytes as a variable-length packet (leading length .

Parameters
workPROTOCORE_CC1101_BORROW bytes the caller took. Not held past the call.
busBus
dataData
lenLen
Returns
PROTO_TRUE on success.

◆ protocore_cc1101_tx_done()

proto_bool protocore_cc1101_tx_done ( uint8_t *  work,
const protocore_cc1101_bus *  bus 
)

True once the state machine has returned to IDLE after a transmit.

Parameters
workPROTOCORE_CC1101_BORROW bytes the caller took. Not held past the call.
busBus
Returns
PROTO_TRUE on success.

◆ protocore_cc1101_set_rx()

void protocore_cc1101_set_rx ( uint8_t *  work,
const protocore_cc1101_bus *  bus 
)

Flush RX and enter receive mode (strobe RX). Then poll .

Parameters
workPROTOCORE_CC1101_BORROW bytes the caller took. Not held past the call.
busBus

◆ protocore_cc1101_recv()

int protocore_cc1101_recv ( uint8_t *  work,
const protocore_cc1101_bus *  bus,
uint8_t *  buf,
uint8_t  cap,
int16_t *  rssi_dbm 
)

If a packet is waiting, read it (length byte + payload + appended .

Parameters
workPROTOCORE_CC1101_BORROW bytes the caller took. Not held past the call.
busBus
bufBuf
capCap
rssi_dbmRssi dbm
Returns
The int.

◆ protocore_cc1101_rssi_dbm()

int16_t protocore_cc1101_rssi_dbm ( uint8_t *  work,
uint8_t  raw 
)

Convert a raw CC1101 RSSI register value to dBm (TI datasheet .

Parameters
workPROTOCORE_CC1101_BORROW bytes the caller took. Not held past the call.
rawRaw
Returns
The int16_t.

Variable Documentation

◆ PROTOCORE_UNUSED

PROTOCORE_NS Cc1101Ns Cc1101 PROTOCORE_UNUSED
Initial value:
int16_t protocore_cc1101_rssi_dbm(uint8_t *work, uint8_t raw)
Convert a raw CC1101 RSSI register value to dBm (TI datasheet .
void protocore_cc1101_set_rx(uint8_t *work, const protocore_cc1101_bus *bus)
Flush RX and enter receive mode (strobe RX). Then poll .
proto_bool protocore_cc1101_tx_done(uint8_t *work, const protocore_cc1101_bus *bus)
True once the state machine has returned to IDLE after a transmit.
proto_bool protocore_cc1101_init(uint8_t *work, const protocore_cc1101_bus *bus, const protocore_cc1101_config *cfg)
Reset the CC1101, apply cfg, set the channel, and confirm it is .
proto_bool protocore_cc1101_send(uint8_t *work, const protocore_cc1101_bus *bus, const uint8_t *data, uint8_t len)
Transmit len bytes as a variable-length packet (leading length .
int protocore_cc1101_recv(uint8_t *work, const protocore_cc1101_bus *bus, uint8_t *buf, uint8_t cap, int16_t *rssi_dbm)
If a packet is waiting, read it (length byte + payload + appended .

Module namespace.

Definition at line 128 of file cc1101.h.