1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #15140 from fjmolinas/pr_tx_start_radio_hal

sys/net/ieee802154/radio: add IEEE802154_RADIO_INDICATION_TX_START
This commit is contained in:
José Alamos 2020-10-22 16:57:27 +02:00 committed by GitHub
commit 9fd49581e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 83 additions and 3 deletions

View File

@ -65,9 +65,11 @@ static const init_pair_t init_table[] = {
{&RFCORE_XREG_FRMCTRL1, 0x00 },
{&RFCORE_XREG_SRCMATCH, 0x00 },
{&RFCORE_XREG_FIFOPCTRL, CC2538_RF_MAX_DATA_LEN },
{&RFCORE_XREG_RFIRQM0, FIFOP | RXPKTDONE },
#if IS_USED(MODULE_IEEE802154_RADIO_HAL)
{&RFCORE_XREG_RFIRQM1, TXDONE | CSP_STOP },
{&RFCORE_XREG_RFIRQM0, FIFOP | RXPKTDONE | SFD },
{&RFCORE_XREG_RFIRQM1, TXDONE | CSP_STOP | TXACKDONE },
#else
{&RFCORE_XREG_RFIRQM0, FIFOP | RXPKTDONE },
#endif
{&RFCORE_XREG_RFERRM, STROBE_ERR | TXUNDERF | TXOVERF | RXUNDERF | RXOVERF | NLOCK},
{NULL, 0},

View File

@ -44,6 +44,8 @@ static bool cc2538_cca_status; /**< status of the last CCA request */
static bool cc2538_cca; /**< used to check whether the last CCA result
corresponds to a CCA request or send with
CSMA-CA */
static bool cc2538_sfd_listen; /**< used to check whether we should ignore
the SFD flag */
static int _write(ieee802154_dev_t *dev, const iolist_t *iolist)
{
@ -315,22 +317,45 @@ void cc2538_irq_handler(void)
RFCORE_SFR_RFIRQF0 = 0;
RFCORE_SFR_RFIRQF1 = 0;
if ((flags_f0 & SFD) && cc2538_sfd_listen) {
if (RFCORE->XREG_FSMSTAT1bits.TX_ACTIVE) {
cc2538_rf_dev.cb(&cc2538_rf_dev, IEEE802154_RADIO_INDICATION_TX_START);
}
}
if (flags_f1 & TXDONE) {
cc2538_rf_dev.cb(&cc2538_rf_dev, IEEE802154_RADIO_CONFIRM_TX_DONE);
}
if ((flags_f0 & SFD) && cc2538_sfd_listen) {
if (RFCORE->XREG_FSMSTAT1bits.RX_ACTIVE) {
cc2538_rf_dev.cb(&cc2538_rf_dev, IEEE802154_RADIO_INDICATION_RX_START);
}
}
if (flags_f0 & RXPKTDONE) {
/* CRC check */
uint8_t pkt_len = rfcore_peek_rx_fifo(0);
if (rfcore_peek_rx_fifo(pkt_len) & CC2538_CRC_BIT_MASK) {
RFCORE_XREG_RFIRQM0 &= RXPKTDONE;
/* Disable RX while the frame has not been processed */
RFCORE_XREG_RXMASKCLR = 0xFF;
/* If AUTOACK is enabled and the ACK request bit is set */
if (RFCORE->XREG_FRMCTRL0bits.AUTOACK &&
(rfcore_peek_rx_fifo(1) & IEEE802154_FCF_ACK_REQ)) {
/* The next SFD will be the ACK's, ignore it */
cc2538_sfd_listen = false;
}
cc2538_rf_dev.cb(&cc2538_rf_dev, IEEE802154_RADIO_INDICATION_RX_DONE);
}
else {
/* CRC failed; discard packet */
RFCORE_SFR_RFST = ISFLUSHRX;
}
}
/* Re-Enable SFD ISR after ACK is received */
if (flags_f1 & TXACKDONE) {
cc2538_sfd_listen = true;
}
/* Check if the interrupt was triggered because the CSP finished its routine
@ -368,6 +393,8 @@ static bool _get_cap(ieee802154_dev_t *dev, ieee802154_rf_caps_t cap)
case IEEE802154_CAP_24_GHZ:
case IEEE802154_CAP_IRQ_TX_DONE:
case IEEE802154_CAP_IRQ_CCA_DONE:
case IEEE802154_CAP_IRQ_RX_START:
case IEEE802154_CAP_IRQ_TX_START:
case IEEE802154_CAP_AUTO_CSMA:
return true;
default:
@ -414,6 +441,8 @@ static int _request_on(ieee802154_dev_t *dev)
{
(void) dev;
/* TODO */
/* when turned on listen for SFD interrupts */
cc2538_sfd_listen = true;
return 0;
}

View File

@ -457,6 +457,16 @@ void isr_radio(void)
{
ieee802154_dev_t *dev = &nrf802154_hal_dev;
if (NRF_RADIO->EVENTS_FRAMESTART) {
NRF_RADIO->EVENTS_FRAMESTART = 0;
if (_state == STATE_TX) {
dev->cb(dev, IEEE802154_RADIO_INDICATION_TX_START);
}
else if (_state == STATE_RX) {
dev->cb(dev, IEEE802154_RADIO_INDICATION_RX_START);
}
}
if (NRF_RADIO->EVENTS_CCAIDLE) {
NRF_RADIO->EVENTS_CCAIDLE = 0;
if (_state != STATE_TX) {
@ -590,6 +600,7 @@ static int _request_on(ieee802154_dev_t *dev)
/* enable interrupts */
NVIC_EnableIRQ(RADIO_IRQn);
NRF_RADIO->INTENSET = RADIO_INTENSET_END_Msk |
RADIO_INTENSET_FRAMESTART_Msk |
RADIO_INTENSET_CCAIDLE_Msk |
RADIO_INTENSET_CCABUSY_Msk;
@ -644,6 +655,8 @@ static bool _get_cap(ieee802154_dev_t *dev, ieee802154_rf_caps_t cap)
(void) dev;
switch (cap) {
case IEEE802154_CAP_24_GHZ:
case IEEE802154_CAP_IRQ_RX_START:
case IEEE802154_CAP_IRQ_TX_START:
case IEEE802154_CAP_IRQ_TX_DONE:
case IEEE802154_CAP_IRQ_CCA_DONE:
return true;

View File

@ -122,6 +122,10 @@ ifneq (,$(filter sntp,$(USEMODULE)))
USEMODULE += xtimer
endif
ifneq (,$(filter ieee802154_radio_hal,$(USEMODULE)))
USEMODULE += ieee802154
endif
ifneq (,$(filter gnrc_netdev_default,$(USEMODULE)))
USEMODULE += netdev_default
USEMODULE += gnrc_netif

View File

@ -100,6 +100,10 @@ typedef enum {
* @brief the device reports the start of a frame (SFD) when received.
*/
IEEE802154_CAP_IRQ_RX_START,
/**
* @brief the device reports the start of a frame (SFD) was sent.
*/
IEEE802154_CAP_IRQ_TX_START,
/**
* @brief the device reports the end of the CCA procedure
*/
@ -186,6 +190,15 @@ typedef enum {
*/
IEEE802154_RADIO_INDICATION_RX_START,
/**
* @brief the transceiver sent out a valid SFD
*
* This event is present if radio has @ref IEEE802154_CAP_IRQ_TX_START cap.
*
* @note The SFD of an outgoing ACK (AUTOACK) should not be indicated
*/
IEEE802154_RADIO_INDICATION_TX_START,
/**
* @brief the transceiver received a frame and lies in the
* internal framebuffer.
@ -1073,6 +1086,22 @@ static inline bool ieee802154_radio_has_irq_rx_start(ieee802154_dev_t *dev)
return dev->driver->get_cap(dev, IEEE802154_CAP_IRQ_RX_START);
}
/**
* @brief Check if the device supports TX start interrupt
*
* Internally this function calls ieee802154_radio_ops::get_cap with @ref
* IEEE802154_CAP_IRQ_TX_START.
*
* @param[in] dev IEEE802.15.4 device descriptor
*
* @return true if the device has support
* @return false otherwise
*/
static inline bool ieee802154_radio_has_irq_tx_start(ieee802154_dev_t *dev)
{
return dev->driver->get_cap(dev, IEEE802154_CAP_IRQ_TX_START);
}
/**
* @brief Check if the device supports CCA done interrupt
*

View File

@ -233,6 +233,9 @@ static int _init(void)
ieee802154_phy_conf_t conf = {.channel=CONFIG_IEEE802154_DEFAULT_CHANNEL, .page=CONFIG_IEEE802154_DEFAULT_SUBGHZ_PAGE, .pow=CONFIG_IEEE802154_DEFAULT_TXPOWER};
ieee802154_radio_config_phy(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID), &conf);
/* ieee802154_radio_set_cca_mode*/
ieee802154_radio_set_cca_mode(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID), IEEE802154_CCA_MODE_ED_THRESHOLD);
ieee802154_radio_set_cca_threshold(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID), CONFIG_IEEE802154_CCA_THRESH_DEFAULT);
/* Set the transceiver state to RX_ON in order to receive packets */