drivers: ieee802154: cc13xx_cc26xx: raw mode support
This change adds IEEE802154_RAW_MODE support for the cc1352r. This allows using the cc1352r 2.4 GHz radio and Sub Ghz radio as a transceiver (PHY) instead of using L2 networking. Signed-off-by: Erik Larson <erik@statropy.com>
This commit is contained in:
parent
bc6d16e422
commit
0a0404df29
5 changed files with 106 additions and 26 deletions
|
@ -20,11 +20,47 @@ config IEEE802154_CC13XX_CC26XX_INIT_PRIO
|
||||||
help
|
help
|
||||||
Set the initialization priority number.
|
Set the initialization priority number.
|
||||||
|
|
||||||
|
config IEEE802154_CC13XX_CC26XX_RADIO_TX_RETRIES
|
||||||
|
int "Radio Transmission attempts"
|
||||||
|
default NET_L2_IEEE802154_RADIO_TX_RETRIES if NET_L2_IEEE802154
|
||||||
|
default 3
|
||||||
|
range 1 7
|
||||||
|
help
|
||||||
|
Number of transmission attempts radio driver should do, before
|
||||||
|
replying it could not send the packet.
|
||||||
|
|
||||||
|
config IEEE802154_CC13XX_CC26XX_RADIO_CSMA_CA_MAX_BO
|
||||||
|
int "CSMA maximum backoffs"
|
||||||
|
default NET_L2_IEEE802154_RADIO_CSMA_CA_MAX_BO if NET_L2_IEEE802154_RADIO_CSMA_CA
|
||||||
|
default 4
|
||||||
|
range 1 5
|
||||||
|
help
|
||||||
|
The maximum number of backoffs the CSMA-CA algorithm will attempt
|
||||||
|
before declaring a channel access failure.
|
||||||
|
|
||||||
|
config IEEE802154_CC13XX_CC26XX_RADIO_CSMA_CA_MIN_BE
|
||||||
|
int "CSMA MAC minimum backoff exponent"
|
||||||
|
default NET_L2_IEEE802154_RADIO_CSMA_CA_MIN_BE if NET_L2_IEEE802154_RADIO_CSMA_CA
|
||||||
|
default 3
|
||||||
|
range 1 8
|
||||||
|
help
|
||||||
|
The minimum value of the backoff exponent (BE) in the CSMA-CA
|
||||||
|
algorithm.
|
||||||
|
|
||||||
|
config IEEE802154_CC13XX_CC26XX_RADIO_CSMA_CA_MAX_BE
|
||||||
|
int "CSMA MAC maximum backoff exponent"
|
||||||
|
default NET_L2_IEEE802154_RADIO_CSMA_CA_MAX_BE if NET_L2_IEEE802154_RADIO_CSMA_CA
|
||||||
|
default 5
|
||||||
|
range 1 8
|
||||||
|
help
|
||||||
|
The maximum value of the backoff exponent (BE) in the CSMA-CA
|
||||||
|
algorithm.
|
||||||
|
|
||||||
endif # IEEE802154_CC13XX_CC26XX
|
endif # IEEE802154_CC13XX_CC26XX
|
||||||
|
|
||||||
menuconfig IEEE802154_CC13XX_CC26XX_SUB_GHZ
|
menuconfig IEEE802154_CC13XX_CC26XX_SUB_GHZ
|
||||||
bool "TI CC13xx / CC26xx IEEE 802.15.4g driver support"
|
bool "TI CC13xx / CC26xx IEEE 802.15.4g driver support"
|
||||||
select NET_L2_IEEE802154_SUB_GHZ
|
select NET_L2_IEEE802154_SUB_GHZ if NET_L2_IEEE802154
|
||||||
|
|
||||||
if IEEE802154_CC13XX_CC26XX_SUB_GHZ
|
if IEEE802154_CC13XX_CC26XX_SUB_GHZ
|
||||||
|
|
||||||
|
@ -54,4 +90,13 @@ config IEEE802154_CC13XX_CC26XX_SUB_GHZ_INIT_PRIO
|
||||||
help
|
help
|
||||||
Set the initialization priority number.
|
Set the initialization priority number.
|
||||||
|
|
||||||
|
config IEEE802154_CC13XX_CC26XX_SUB_GHZ_RADIO_TX_RETRIES
|
||||||
|
int "Radio Transmission attempts"
|
||||||
|
default NET_L2_IEEE802154_RADIO_TX_RETRIES if NET_L2_IEEE802154
|
||||||
|
default 3
|
||||||
|
range 1 7
|
||||||
|
help
|
||||||
|
Number of transmission attempts radio driver should do, before
|
||||||
|
replying it could not send the packet.
|
||||||
|
|
||||||
endif # IEEE802154_CC13XX_CC26XX_SUB_GHZ
|
endif # IEEE802154_CC13XX_CC26XX_SUB_GHZ
|
||||||
|
|
|
@ -287,7 +287,7 @@ static int ieee802154_cc13xx_cc26xx_tx(const struct device *dev,
|
||||||
};
|
};
|
||||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = get_dev_data(dev);
|
struct ieee802154_cc13xx_cc26xx_data *drv_data = get_dev_data(dev);
|
||||||
bool ack = ieee802154_is_ar_flag_set(frag);
|
bool ack = ieee802154_is_ar_flag_set(frag);
|
||||||
int retry = CONFIG_NET_L2_IEEE802154_RADIO_TX_RETRIES;
|
int retry = CONFIG_IEEE802154_CC13XX_CC26XX_RADIO_TX_RETRIES;
|
||||||
|
|
||||||
if (mode != IEEE802154_TX_MODE_CSMA_CA) {
|
if (mode != IEEE802154_TX_MODE_CSMA_CA) {
|
||||||
NET_ERR("TX mode %d not supported", mode);
|
NET_ERR("TX mode %d not supported", mode);
|
||||||
|
@ -385,20 +385,31 @@ static void ieee802154_cc13xx_cc26xx_rx_done(
|
||||||
struct ieee802154_cc13xx_cc26xx_data *drv_data)
|
struct ieee802154_cc13xx_cc26xx_data *drv_data)
|
||||||
{
|
{
|
||||||
struct net_pkt *pkt;
|
struct net_pkt *pkt;
|
||||||
uint8_t len, seq, corr;
|
uint8_t len, seq, corr, lqi;
|
||||||
int8_t rssi;
|
int8_t rssi;
|
||||||
uint8_t *sdu;
|
uint8_t *sdu;
|
||||||
|
|
||||||
for (int i = 0; i < CC13XX_CC26XX_NUM_RX_BUF; i++) {
|
for (int i = 0; i < CC13XX_CC26XX_NUM_RX_BUF; i++) {
|
||||||
if (drv_data->rx_entry[i].status == DATA_ENTRY_FINISHED) {
|
if (drv_data->rx_entry[i].status == DATA_ENTRY_FINISHED) {
|
||||||
|
/* rx_data contains length, psdu, fcs, rssi, corr */
|
||||||
len = drv_data->rx_data[i][0];
|
len = drv_data->rx_data[i][0];
|
||||||
sdu = drv_data->rx_data[i] + 1;
|
sdu = drv_data->rx_data[i] + 1;
|
||||||
seq = drv_data->rx_data[i][3];
|
seq = drv_data->rx_data[i][3];
|
||||||
corr = drv_data->rx_data[i][len--] & 0x3F;
|
corr = drv_data->rx_data[i][len--] & 0x3F;
|
||||||
rssi = drv_data->rx_data[i][len--];
|
rssi = drv_data->rx_data[i][len--];
|
||||||
|
|
||||||
|
/* remove fcs as it is not expected by L2
|
||||||
|
* But keep it for RAW mode
|
||||||
|
*/
|
||||||
|
if (IS_ENABLED(CONFIG_NET_L2_IEEE802154)) {
|
||||||
|
len -= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* scale 6-bit corr to 8-bit lqi */
|
||||||
|
lqi = corr << 2;
|
||||||
|
|
||||||
LOG_DBG("Received: len = %u, seq = %u, rssi = %d, lqi = %u",
|
LOG_DBG("Received: len = %u, seq = %u, rssi = %d, lqi = %u",
|
||||||
len, seq, rssi, corr);
|
len, seq, rssi, lqi);
|
||||||
|
|
||||||
pkt = net_pkt_rx_alloc_with_buffer(
|
pkt = net_pkt_rx_alloc_with_buffer(
|
||||||
drv_data->iface, len, AF_UNSPEC, 0, K_NO_WAIT);
|
drv_data->iface, len, AF_UNSPEC, 0, K_NO_WAIT);
|
||||||
|
@ -415,8 +426,7 @@ static void ieee802154_cc13xx_cc26xx_rx_done(
|
||||||
|
|
||||||
drv_data->rx_entry[i].status = DATA_ENTRY_PENDING;
|
drv_data->rx_entry[i].status = DATA_ENTRY_PENDING;
|
||||||
|
|
||||||
/* TODO Convert to LQI in 0 to 255 range */
|
net_pkt_set_ieee802154_lqi(pkt, lqi);
|
||||||
net_pkt_set_ieee802154_lqi(pkt, corr);
|
|
||||||
net_pkt_set_ieee802154_rssi(
|
net_pkt_set_ieee802154_rssi(
|
||||||
pkt,
|
pkt,
|
||||||
ieee802154_cc13xx_cc26xx_convert_rssi(rssi));
|
ieee802154_cc13xx_cc26xx_convert_rssi(rssi));
|
||||||
|
@ -604,7 +614,7 @@ static struct ieee802154_cc13xx_cc26xx_data ieee802154_cc13xx_cc26xx_data = {
|
||||||
.bAutoFlushCrc = 1,
|
.bAutoFlushCrc = 1,
|
||||||
.bAutoFlushIgn = 1,
|
.bAutoFlushIgn = 1,
|
||||||
.bIncludePhyHdr = 0,
|
.bIncludePhyHdr = 0,
|
||||||
.bIncludeCrc = 0,
|
.bIncludeCrc = 1,
|
||||||
.bAppendRssi = 1,
|
.bAppendRssi = 1,
|
||||||
.bAppendCorrCrc = 1,
|
.bAppendCorrCrc = 1,
|
||||||
.bAppendSrcInd = 0,
|
.bAppendSrcInd = 0,
|
||||||
|
@ -677,9 +687,10 @@ static struct ieee802154_cc13xx_cc26xx_data ieee802154_cc13xx_cc26xx_data = {
|
||||||
.startTrigger.triggerType = TRIG_NOW,
|
.startTrigger.triggerType = TRIG_NOW,
|
||||||
.condition.rule = COND_STOP_ON_FALSE,
|
.condition.rule = COND_STOP_ON_FALSE,
|
||||||
.randomState = 0,
|
.randomState = 0,
|
||||||
.macMaxBE = CONFIG_NET_L2_IEEE802154_RADIO_CSMA_CA_MAX_BE,
|
.macMaxBE =
|
||||||
|
CONFIG_IEEE802154_CC13XX_CC26XX_RADIO_CSMA_CA_MAX_BE,
|
||||||
.macMaxCSMABackoffs =
|
.macMaxCSMABackoffs =
|
||||||
CONFIG_NET_L2_IEEE802154_RADIO_CSMA_CA_MAX_BO,
|
CONFIG_IEEE802154_CC13XX_CC26XX_RADIO_CSMA_CA_MAX_BO,
|
||||||
.csmaConfig = {
|
.csmaConfig = {
|
||||||
/* Initial value of CW for unslotted CSMA */
|
/* Initial value of CW for unslotted CSMA */
|
||||||
.initCW = 1,
|
.initCW = 1,
|
||||||
|
@ -689,7 +700,7 @@ static struct ieee802154_cc13xx_cc26xx_data ieee802154_cc13xx_cc26xx_data = {
|
||||||
.rxOffMode = 0,
|
.rxOffMode = 0,
|
||||||
},
|
},
|
||||||
.NB = 0,
|
.NB = 0,
|
||||||
.BE = CONFIG_NET_L2_IEEE802154_RADIO_CSMA_CA_MIN_BE,
|
.BE = CONFIG_IEEE802154_CC13XX_CC26XX_RADIO_CSMA_CA_MIN_BE,
|
||||||
.remainingPeriods = 0,
|
.remainingPeriods = 0,
|
||||||
.endTrigger.triggerType = TRIG_NEVER,
|
.endTrigger.triggerType = TRIG_NEVER,
|
||||||
},
|
},
|
||||||
|
@ -747,6 +758,7 @@ static struct ieee802154_cc13xx_cc26xx_data ieee802154_cc13xx_cc26xx_data = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(CONFIG_NET_L2_IEEE802154)
|
||||||
NET_DEVICE_INIT(ieee802154_cc13xx_cc26xx,
|
NET_DEVICE_INIT(ieee802154_cc13xx_cc26xx,
|
||||||
CONFIG_IEEE802154_CC13XX_CC26XX_DRV_NAME,
|
CONFIG_IEEE802154_CC13XX_CC26XX_DRV_NAME,
|
||||||
ieee802154_cc13xx_cc26xx_init, device_pm_control_nop,
|
ieee802154_cc13xx_cc26xx_init, device_pm_control_nop,
|
||||||
|
@ -754,3 +766,10 @@ NET_DEVICE_INIT(ieee802154_cc13xx_cc26xx,
|
||||||
CONFIG_IEEE802154_CC13XX_CC26XX_INIT_PRIO,
|
CONFIG_IEEE802154_CC13XX_CC26XX_INIT_PRIO,
|
||||||
&ieee802154_cc13xx_cc26xx_radio_api, IEEE802154_L2,
|
&ieee802154_cc13xx_cc26xx_radio_api, IEEE802154_L2,
|
||||||
NET_L2_GET_CTX_TYPE(IEEE802154_L2), IEEE802154_MTU);
|
NET_L2_GET_CTX_TYPE(IEEE802154_L2), IEEE802154_MTU);
|
||||||
|
#else
|
||||||
|
DEVICE_AND_API_INIT(ieee802154_cc13xx_cc26xx,
|
||||||
|
CONFIG_IEEE802154_CC13XX_CC26XX_DRV_NAME,
|
||||||
|
ieee802154_cc13xx_cc26xx_init, &ieee802154_cc13xx_cc26xx_data,
|
||||||
|
NULL, POST_KERNEL, CONFIG_IEEE802154_CC13XX_CC26XX_INIT_PRIO,
|
||||||
|
&ieee802154_cc13xx_cc26xx_radio_api);
|
||||||
|
#endif
|
||||||
|
|
|
@ -51,8 +51,8 @@
|
||||||
|
|
||||||
#define CC13XX_CC26XX_NUM_RX_BUF 2
|
#define CC13XX_CC26XX_NUM_RX_BUF 2
|
||||||
|
|
||||||
/* Two additional bytes for RSSI and correlation values from CPE. */
|
/* Three additional bytes for length, RSSI and correlation values from CPE. */
|
||||||
#define CC13XX_CC26XX_RX_BUF_SIZE (IEEE802154_MAX_PHY_PACKET_SIZE + 2)
|
#define CC13XX_CC26XX_RX_BUF_SIZE (IEEE802154_MAX_PHY_PACKET_SIZE + 3)
|
||||||
|
|
||||||
#define CC13XX_CC26XX_CPE0_IRQ (INT_RFC_CPE_0 - 16)
|
#define CC13XX_CC26XX_CPE0_IRQ (INT_RFC_CPE_0 - 16)
|
||||||
#define CC13XX_CC26XX_CPE1_IRQ (INT_RFC_CPE_1 - 16)
|
#define CC13XX_CC26XX_CPE1_IRQ (INT_RFC_CPE_1 - 16)
|
||||||
|
|
|
@ -17,6 +17,7 @@ LOG_MODULE_REGISTER(ieee802154_cc13xx_cc26xx_subg);
|
||||||
#include <random/rand32.h>
|
#include <random/rand32.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/sys_io.h>
|
#include <sys/sys_io.h>
|
||||||
|
#include <sys/crc.h>
|
||||||
|
|
||||||
#include <driverlib/rf_mailbox.h>
|
#include <driverlib/rf_mailbox.h>
|
||||||
#include <driverlib/rf_prop_mailbox.h>
|
#include <driverlib/rf_prop_mailbox.h>
|
||||||
|
@ -328,7 +329,7 @@ static int ieee802154_cc13xx_cc26xx_subg_tx(const struct device *dev,
|
||||||
{
|
{
|
||||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data =
|
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data =
|
||||||
get_dev_data(dev);
|
get_dev_data(dev);
|
||||||
int retry = CONFIG_NET_L2_IEEE802154_RADIO_TX_RETRIES;
|
int retry = CONFIG_IEEE802154_CC13XX_CC26XX_SUB_GHZ_RADIO_TX_RETRIES;
|
||||||
RF_EventMask reason;
|
RF_EventMask reason;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -434,17 +435,27 @@ static void ieee802154_cc13xx_cc26xx_subg_rx_done(
|
||||||
{
|
{
|
||||||
struct net_pkt *pkt;
|
struct net_pkt *pkt;
|
||||||
uint8_t len;
|
uint8_t len;
|
||||||
int8_t rssi;
|
int8_t rssi, status;
|
||||||
uint8_t *sdu;
|
uint8_t *sdu;
|
||||||
|
|
||||||
for (int i = 0; i < CC13XX_CC26XX_NUM_RX_BUF; i++) {
|
for (int i = 0; i < CC13XX_CC26XX_NUM_RX_BUF; i++) {
|
||||||
if (drv_data->rx_entry[i].status == DATA_ENTRY_FINISHED) {
|
if (drv_data->rx_entry[i].status == DATA_ENTRY_FINISHED) {
|
||||||
len = drv_data->rx_data[i][1];
|
len = drv_data->rx_data[i][0];
|
||||||
sdu = &drv_data->rx_data[i][3];
|
sdu = drv_data->rx_data[i] + 1;
|
||||||
rssi = sdu[len - 2];
|
status = drv_data->rx_data[i][len--];
|
||||||
len -= 2;
|
rssi = drv_data->rx_data[i][len--];
|
||||||
|
|
||||||
LOG_DBG("Received: len = %u, rssi = %d", len, rssi);
|
if (IS_ENABLED(CONFIG_IEEE802154_RAW_MODE)) {
|
||||||
|
/* append CRC-16/CCITT */
|
||||||
|
uint16_t crc = 0;
|
||||||
|
|
||||||
|
crc = crc16_ccitt(0, sdu, len);
|
||||||
|
sdu[len++] = crc;
|
||||||
|
sdu[len++] = crc >> 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_DBG("Received: len = %u, rssi = %d status = %u",
|
||||||
|
len, rssi, status);
|
||||||
|
|
||||||
pkt = net_pkt_rx_alloc_with_buffer(
|
pkt = net_pkt_rx_alloc_with_buffer(
|
||||||
drv_data->iface, len, AF_UNSPEC, 0, K_NO_WAIT);
|
drv_data->iface, len, AF_UNSPEC, 0, K_NO_WAIT);
|
||||||
|
@ -697,8 +708,8 @@ static struct ieee802154_cc13xx_cc26xx_subg_data
|
||||||
.rxConf = {
|
.rxConf = {
|
||||||
.bAutoFlushIgnored = true,
|
.bAutoFlushIgnored = true,
|
||||||
.bAutoFlushCrcErr = true,
|
.bAutoFlushCrcErr = true,
|
||||||
.bIncludeHdr = true,
|
|
||||||
.bAppendRssi = true,
|
.bAppendRssi = true,
|
||||||
|
.bAppendStatus = true,
|
||||||
},
|
},
|
||||||
/* Preamble & SFD for 2-FSK SUN PHY. 802.15.4-2015, 20.2.1 */
|
/* Preamble & SFD for 2-FSK SUN PHY. 802.15.4-2015, 20.2.1 */
|
||||||
.syncWord0 = 0x0055904E,
|
.syncWord0 = 0x0055904E,
|
||||||
|
@ -745,6 +756,7 @@ static struct ieee802154_cc13xx_cc26xx_subg_data
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(CONFIG_NET_L2_IEEE802154_SUB_GHZ)
|
||||||
NET_DEVICE_INIT(ieee802154_cc13xx_cc26xx_subg,
|
NET_DEVICE_INIT(ieee802154_cc13xx_cc26xx_subg,
|
||||||
CONFIG_IEEE802154_CC13XX_CC26XX_SUB_GHZ_DRV_NAME,
|
CONFIG_IEEE802154_CC13XX_CC26XX_SUB_GHZ_DRV_NAME,
|
||||||
ieee802154_cc13xx_cc26xx_subg_init, device_pm_control_nop,
|
ieee802154_cc13xx_cc26xx_subg_init, device_pm_control_nop,
|
||||||
|
@ -752,3 +764,11 @@ NET_DEVICE_INIT(ieee802154_cc13xx_cc26xx_subg,
|
||||||
CONFIG_IEEE802154_CC13XX_CC26XX_SUB_GHZ_INIT_PRIO,
|
CONFIG_IEEE802154_CC13XX_CC26XX_SUB_GHZ_INIT_PRIO,
|
||||||
&ieee802154_cc13xx_cc26xx_subg_radio_api, IEEE802154_L2,
|
&ieee802154_cc13xx_cc26xx_subg_radio_api, IEEE802154_L2,
|
||||||
NET_L2_GET_CTX_TYPE(IEEE802154_L2), IEEE802154_MTU);
|
NET_L2_GET_CTX_TYPE(IEEE802154_L2), IEEE802154_MTU);
|
||||||
|
#else
|
||||||
|
DEVICE_AND_API_INIT(ieee802154_cc13xx_cc26xx_subg,
|
||||||
|
CONFIG_IEEE802154_CC13XX_CC26XX_SUB_GHZ_DRV_NAME,
|
||||||
|
ieee802154_cc13xx_cc26xx_subg_init,
|
||||||
|
&ieee802154_cc13xx_cc26xx_subg_data, NULL, POST_KERNEL,
|
||||||
|
CONFIG_IEEE802154_CC13XX_CC26XX_SUB_GHZ_INIT_PRIO,
|
||||||
|
&ieee802154_cc13xx_cc26xx_subg_radio_api);
|
||||||
|
#endif
|
||||||
|
|
|
@ -57,12 +57,8 @@
|
||||||
#define CC13XX_CC26XX_NUM_RX_BUF \
|
#define CC13XX_CC26XX_NUM_RX_BUF \
|
||||||
CONFIG_IEEE802154_CC13XX_CC26XX_SUB_GHZ_NUM_RX_BUF
|
CONFIG_IEEE802154_CC13XX_CC26XX_SUB_GHZ_NUM_RX_BUF
|
||||||
|
|
||||||
/*
|
/* Three additional bytes for length, RSSI and status values from CPE */
|
||||||
* Two additional bytes for the PHR in PROP mode
|
#define CC13XX_CC26XX_RX_BUF_SIZE (IEEE802154_MAX_PHY_PACKET_SIZE + 3)
|
||||||
* One additional byte for RSSI value from CPE
|
|
||||||
*/
|
|
||||||
#define CC13XX_CC26XX_RX_BUF_SIZE (IEEE802154_MAX_PHY_PACKET_SIZE \
|
|
||||||
+ IEEE802154_SUN_PHY_FSK_PHR_LEN + 1)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Two additional bytes for the SUN FSK PHY HDR
|
* Two additional bytes for the SUN FSK PHY HDR
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue