diff --git a/drivers/ng_at86rf2xx/ng_at86rf2xx.c b/drivers/ng_at86rf2xx/ng_at86rf2xx.c index 7707fb69c0..0995b15ffc 100644 --- a/drivers/ng_at86rf2xx/ng_at86rf2xx.c +++ b/drivers/ng_at86rf2xx/ng_at86rf2xx.c @@ -154,8 +154,7 @@ void ng_at86rf2xx_reset(ng_at86rf2xx_t *dev) ng_at86rf2xx_reg_write(dev, NG_AT86RF2XX_REG__TRX_CTRL_2, tmp); /* enable interrupts */ ng_at86rf2xx_reg_write(dev, NG_AT86RF2XX_REG__IRQ_MASK, - (NG_AT86RF2XX_IRQ_STATUS_MASK__RX_START | - NG_AT86RF2XX_IRQ_STATUS_MASK__TRX_END)); + NG_AT86RF2XX_IRQ_STATUS_MASK__TRX_END); /* go into RX state */ ng_at86rf2xx_set_state(dev, NG_AT86RF2XX_STATE_RX_AACK_ON); diff --git a/drivers/ng_at86rf2xx/ng_at86rf2xx_getset.c b/drivers/ng_at86rf2xx/ng_at86rf2xx_getset.c index cdfaf41267..067d5ca4c4 100644 --- a/drivers/ng_at86rf2xx/ng_at86rf2xx_getset.c +++ b/drivers/ng_at86rf2xx/ng_at86rf2xx_getset.c @@ -154,6 +154,12 @@ void ng_at86rf2xx_set_option(ng_at86rf2xx_t *dev, uint16_t option, bool state) tmp &= ~(NG_AT86RF2XX_CSMA_SEED_1__AACK_DIS_ACK); ng_at86rf2xx_reg_write(dev, NG_AT86RF2XX_REG__CSMA_SEED_1, tmp); break; + case NG_AT86RF2XX_OPT_TELL_RX_START: + DEBUG("[ng_at86rf2xx] opt: enabling SFD IRQ\n"); + tmp = ng_at86rf2xx_reg_read(dev, NG_AT86RF2XX_REG__IRQ_MASK); + tmp |= NG_AT86RF2XX_IRQ_STATUS_MASK__RX_START; + ng_at86rf2xx_reg_write(dev, NG_AT86RF2XX_REG__IRQ_MASK, tmp); + break; default: /* do nothing */ break; @@ -185,6 +191,12 @@ void ng_at86rf2xx_set_option(ng_at86rf2xx_t *dev, uint16_t option, bool state) tmp |= NG_AT86RF2XX_CSMA_SEED_1__AACK_DIS_ACK; ng_at86rf2xx_reg_write(dev, NG_AT86RF2XX_REG__CSMA_SEED_1, tmp); break; + case NG_AT86RF2XX_OPT_TELL_RX_START: + DEBUG("[ng_at86rf2xx] opt: disabling SFD IRQ\n"); + tmp = ng_at86rf2xx_reg_read(dev, NG_AT86RF2XX_REG__IRQ_MASK); + tmp &= ~NG_AT86RF2XX_IRQ_STATUS_MASK__RX_START; + ng_at86rf2xx_reg_write(dev, NG_AT86RF2XX_REG__IRQ_MASK, tmp); + break; default: /* do nothing */ break; diff --git a/drivers/ng_at86rf2xx/ng_at86rf2xx_netdev.c b/drivers/ng_at86rf2xx/ng_at86rf2xx_netdev.c index 30c75194a5..2ee80a69ff 100644 --- a/drivers/ng_at86rf2xx/ng_at86rf2xx_netdev.c +++ b/drivers/ng_at86rf2xx/ng_at86rf2xx_netdev.c @@ -487,6 +487,26 @@ static int _get(ng_netdev_t *device, ng_netconf_opt_t opt, } return sizeof(ng_netconf_enable_t); + case NETCONF_OPT_RX_START_IRQ: + *((ng_netconf_enable_t *)val) = + !!(dev->options & NG_AT86RF2XX_OPT_TELL_RX_START); + return sizeof(ng_netconf_enable_t); + + case NETCONF_OPT_RX_END_IRQ: + *((ng_netconf_enable_t *)val) = + !!(dev->options & NG_AT86RF2XX_OPT_TELL_RX_END); + return sizeof(ng_netconf_enable_t); + + case NETCONF_OPT_TX_START_IRQ: + *((ng_netconf_enable_t *)val) = + !!(dev->options & NG_AT86RF2XX_OPT_TELL_TX_START); + return sizeof(ng_netconf_enable_t); + + case NETCONF_OPT_TX_END_IRQ: + *((ng_netconf_enable_t *)val) = + !!(dev->options & NG_AT86RF2XX_OPT_TELL_TX_END); + return sizeof(ng_netconf_enable_t); + default: return -ENOTSUP; } @@ -599,6 +619,26 @@ static int _set(ng_netdev_t *device, ng_netconf_opt_t opt, ((bool *)val)[0]); return sizeof(ng_netconf_enable_t); + case NETCONF_OPT_RX_START_IRQ: + ng_at86rf2xx_set_option(dev, NG_AT86RF2XX_OPT_TELL_RX_START, + ((bool *)val)[0]); + return sizeof(ng_netconf_enable_t); + + case NETCONF_OPT_RX_END_IRQ: + ng_at86rf2xx_set_option(dev, NG_AT86RF2XX_OPT_TELL_RX_END, + ((bool *)val)[0]); + return sizeof(ng_netconf_enable_t); + + case NETCONF_OPT_TX_START_IRQ: + ng_at86rf2xx_set_option(dev, NG_AT86RF2XX_OPT_TELL_TX_START, + ((bool *)val)[0]); + return sizeof(ng_netconf_enable_t); + + case NETCONF_OPT_TX_END_IRQ: + ng_at86rf2xx_set_option(dev, NG_AT86RF2XX_OPT_TELL_TX_END, + ((bool *)val)[0]); + return sizeof(ng_netconf_enable_t); + default: return -ENOTSUP; } @@ -643,9 +683,7 @@ static void _isr_event(ng_netdev_t *device, uint32_t event_type) state = ng_at86rf2xx_get_state(dev); if (irq_mask & NG_AT86RF2XX_IRQ_STATUS_MASK__RX_START) { - if (dev->event_cb && (dev->options & NG_AT86RF2XX_OPT_TELL_RX_START)) { - dev->event_cb(NETDEV_EVENT_RX_STARTED, NULL); - } + dev->event_cb(NETDEV_EVENT_RX_STARTED, NULL); DEBUG("[ng_at86rf2xx] EVT - RX_START\n"); } if (irq_mask & NG_AT86RF2XX_IRQ_STATUS_MASK__TRX_END) { diff --git a/sys/include/net/ng_netconf.h b/sys/include/net/ng_netconf.h index eb092d3b13..0ebbf65b58 100644 --- a/sys/include/net/ng_netconf.h +++ b/sys/include/net/ng_netconf.h @@ -17,6 +17,7 @@ * @brief Definition of global configuration options * * @author Hauke Petersen + * @author Oliver Hahm */ #ifndef NG_NET_CONF_H_ @@ -78,6 +79,45 @@ typedef enum { NETCONF_OPT_RAWMODE, /**< en/disable the pre-processing of data in a network device driver as type ng_nettype_t */ + + /** + * @brief en/disable the interrupt at reception start. + * + * It is mostly triggered after the preamble is correctly received + * + * @note not all transceivers may support this interrupt + */ + NETCONF_OPT_RX_START_IRQ, + + /** + * @brief en/disable the interrupt after packet reception. + * + * This interrupt is triggered after a complete packet is received. + * + * @note in case a transceiver does not support this interrupt, the event + * may be triggered by the driver + */ + NETCONF_OPT_RX_END_IRQ, + + /** + * @brief en/disable the interrupt right in the beginning of transmission. + * + * This interrupt is triggered when the transceiver starts to send out the + * packet. + * + * @note in case a transceiver does not support this interrupt, the event + * may be triggered by the driver + */ + NETCONF_OPT_TX_START_IRQ, + + /** + * @brief en/disable the interrupt after packet transmission. + * + * This interrupt is triggered when the full packet is transmitted. + * + * @note not all transceivers may support this interrupt + */ + NETCONF_OPT_TX_END_IRQ, /* add more options if needed */ } ng_netconf_opt_t;