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

drivers/at86rf2xx: make TX/RX IRQs read only

This brings the implementation in sync with the API.
This commit is contained in:
Marian Buschsieweke 2021-02-26 11:32:45 +01:00
parent 08063bebfe
commit 1d0ee42046
No known key found for this signature in database
GPG Key ID: 61F64C6599B1539F
4 changed files with 16 additions and 66 deletions

View File

@ -169,6 +169,7 @@ static void at86rf2xx_enable_smart_idle(at86rf2xx_t *dev)
void at86rf2xx_reset(at86rf2xx_t *dev)
{
uint8_t tmp;
netdev_ieee802154_reset(&dev->netdev);
/* Reset state machine to ensure a known state */
@ -204,7 +205,7 @@ void at86rf2xx_reset(at86rf2xx_t *dev)
#if !defined(MODULE_AT86RFA1) && !defined(MODULE_AT86RFR2)
/* don't populate masked interrupt flags to IRQ_STATUS register */
uint8_t tmp = at86rf2xx_reg_read(dev, AT86RF2XX_REG__TRX_CTRL_1);
tmp = at86rf2xx_reg_read(dev, AT86RF2XX_REG__TRX_CTRL_1);
tmp &= ~(AT86RF2XX_TRX_CTRL_1_MASK__IRQ_MASK_MODE);
at86rf2xx_reg_write(dev, AT86RF2XX_REG__TRX_CTRL_1, tmp);
#endif
@ -243,6 +244,11 @@ void at86rf2xx_reset(at86rf2xx_t *dev)
/* go into RX state */
at86rf2xx_set_state(dev, AT86RF2XX_PHY_STATE_RX);
/* Enable RX start IRQ */
tmp = at86rf2xx_reg_read(dev, AT86RF2XX_REG__IRQ_MASK);
tmp |= AT86RF2XX_IRQ_STATUS_MASK__RX_START;
at86rf2xx_reg_write(dev, AT86RF2XX_REG__IRQ_MASK, tmp);
DEBUG("at86rf2xx_reset(): reset complete.\n");
}
@ -292,8 +298,7 @@ void at86rf2xx_tx_exec(at86rf2xx_t *dev)
/* trigger sending of pre-loaded frame */
at86rf2xx_reg_write(dev, AT86RF2XX_REG__TRX_STATE,
AT86RF2XX_TRX_STATE__TX_START);
if (netdev->event_callback &&
(dev->flags & AT86RF2XX_OPT_TELL_TX_START)) {
if (netdev->event_callback) {
netdev->event_callback(netdev, NETDEV_EVENT_TX_STARTED);
}
}

View File

@ -446,14 +446,6 @@ void at86rf2xx_set_option(at86rf2xx_t *dev, uint16_t option, bool state)
: (tmp | AT86RF2XX_CSMA_SEED_1__AACK_DIS_ACK);
at86rf2xx_reg_write(dev, AT86RF2XX_REG__CSMA_SEED_1, tmp);
break;
case AT86RF2XX_OPT_TELL_RX_START:
DEBUG("[at86rf2xx] opt: %s SFD IRQ\n",
(state ? "enable" : "disable"));
tmp = at86rf2xx_reg_read(dev, AT86RF2XX_REG__IRQ_MASK);
tmp = (state) ? (tmp | AT86RF2XX_IRQ_STATUS_MASK__RX_START)
: (tmp & ~AT86RF2XX_IRQ_STATUS_MASK__RX_START);
at86rf2xx_reg_write(dev, AT86RF2XX_REG__IRQ_MASK, tmp);
break;
case AT86RF2XX_OPT_ACK_PENDING:
DEBUG("[at86rf2xx] opt: enabling pending ACKs\n");
tmp = at86rf2xx_reg_read(dev, AT86RF2XX_REG__CSMA_SEED_1);

View File

@ -346,23 +346,10 @@ static int _get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len)
break;
case NETOPT_RX_START_IRQ:
*((netopt_enable_t *)val) =
!!(dev->flags & AT86RF2XX_OPT_TELL_RX_START);
return sizeof(netopt_enable_t);
case NETOPT_RX_END_IRQ:
*((netopt_enable_t *)val) =
!!(dev->flags & AT86RF2XX_OPT_TELL_RX_END);
return sizeof(netopt_enable_t);
case NETOPT_TX_START_IRQ:
*((netopt_enable_t *)val) =
!!(dev->flags & AT86RF2XX_OPT_TELL_TX_START);
return sizeof(netopt_enable_t);
case NETOPT_TX_END_IRQ:
*((netopt_enable_t *)val) =
!!(dev->flags & AT86RF2XX_OPT_TELL_TX_END);
*((netopt_enable_t *)val) = NETOPT_ENABLE;
return sizeof(netopt_enable_t);
case NETOPT_CSMA:
@ -601,30 +588,6 @@ static int _set(netdev_t *netdev, netopt_t opt, const void *val, size_t len)
}
break;
case NETOPT_RX_START_IRQ:
at86rf2xx_set_option(dev, AT86RF2XX_OPT_TELL_RX_START,
((const bool *)val)[0]);
res = sizeof(netopt_enable_t);
break;
case NETOPT_RX_END_IRQ:
at86rf2xx_set_option(dev, AT86RF2XX_OPT_TELL_RX_END,
((const bool *)val)[0]);
res = sizeof(netopt_enable_t);
break;
case NETOPT_TX_START_IRQ:
at86rf2xx_set_option(dev, AT86RF2XX_OPT_TELL_TX_START,
((const bool *)val)[0]);
res = sizeof(netopt_enable_t);
break;
case NETOPT_TX_END_IRQ:
at86rf2xx_set_option(dev, AT86RF2XX_OPT_TELL_TX_END,
((const bool *)val)[0]);
res = sizeof(netopt_enable_t);
break;
case NETOPT_CSMA:
if (!IS_ACTIVE(AT86RF2XX_BASIC_MODE)) {
at86rf2xx_set_option(dev, AT86RF2XX_OPT_CSMA,
@ -716,7 +679,7 @@ static void _isr_send_complete(at86rf2xx_t *dev, uint8_t trac_status)
DEBUG("[at86rf2xx] EVT - TX_END\n");
if (netdev->event_callback && (dev->flags & AT86RF2XX_OPT_TELL_TX_END)) {
if (netdev->event_callback) {
switch (trac_status) {
#ifdef MODULE_OPENTHREAD
case AT86RF2XX_TRX_STATE__TRAC_SUCCESS:
@ -751,7 +714,10 @@ static void _isr_send_complete(at86rf2xx_t *dev, uint8_t trac_status)
static inline void _isr_recv_complete(netdev_t *netdev)
{
at86rf2xx_t *dev = (at86rf2xx_t *) netdev;
at86rf2xx_t *dev = (at86rf2xx_t *)netdev;
if (!netdev->event_callback) {
return;
}
if (IS_ACTIVE(AT86RF2XX_BASIC_MODE)) {
uint8_t phy_status = at86rf2xx_reg_read(dev, AT86RF2XX_REG__PHY_RSSI);
bool crc_ok = phy_status & AT86RF2XX_PHY_RSSI_MASK__RX_CRC_VALID;
@ -803,9 +769,6 @@ static void _isr(netdev_t *netdev)
if ((state == AT86RF2XX_PHY_STATE_RX)
|| (state == AT86RF2XX_PHY_STATE_RX_BUSY)) {
DEBUG("[at86rf2xx] EVT - RX_END\n");
if (!(dev->flags & AT86RF2XX_OPT_TELL_RX_END)) {
return;
}
_isr_recv_complete(netdev);

View File

@ -177,21 +177,11 @@ extern "C" {
* @name Internal device option flags
* @{
*/
#define AT86RF2XX_OPT_TELL_TX_START (0x0001) /**< notify MAC layer on TX
* start */
#define AT86RF2XX_OPT_TELL_TX_END (0x0002) /**< notify MAC layer on TX
* finished */
#define AT86RF2XX_OPT_TELL_RX_START (0x0004) /**< notify MAC layer on RX
* start */
#define AT86RF2XX_OPT_TELL_RX_END (0x0008) /**< notify MAC layer on RX
* finished */
#define AT86RF2XX_OPT_CSMA (0x0010) /**< CSMA active */
#define AT86RF2XX_OPT_PROMISCUOUS (0x0020) /**< promiscuous mode
* active */
#define AT86RF2XX_OPT_PROMISCUOUS (0x0020) /**< promiscuous mode active */
#define AT86RF2XX_OPT_PRELOADING (0x0040) /**< preloading enabled */
#define AT86RF2XX_OPT_AUTOACK (0x0080) /**< Auto ACK active */
#define AT86RF2XX_OPT_ACK_PENDING (0x0100) /**< ACK frames with data
* pending */
#define AT86RF2XX_OPT_ACK_PENDING (0x0100) /**< ACK frames with data pending */
/** @} */