From 093eb7a985b42da6ec2a881e092b59cc97c8c4aa Mon Sep 17 00:00:00 2001 From: Thomas Eichinger Date: Fri, 7 Jul 2017 09:11:28 -0700 Subject: [PATCH] drivers/at86rf2xx: remove `at86rf2xx_reset_state_machine` This function was only used once in the initialization procedure. Inlining the actual state change reduces overhead and lines to maintain. If ever needed, undo this commit. --- drivers/at86rf2xx/at86rf2xx.c | 4 +++- drivers/at86rf2xx/at86rf2xx_getset.c | 20 +++----------------- drivers/at86rf2xx/at86rf2xx_internal.c | 10 +++++----- drivers/include/at86rf2xx.h | 11 ----------- 4 files changed, 11 insertions(+), 34 deletions(-) diff --git a/drivers/at86rf2xx/at86rf2xx.c b/drivers/at86rf2xx/at86rf2xx.c index acae63783a..73e22f0a59 100644 --- a/drivers/at86rf2xx/at86rf2xx.c +++ b/drivers/at86rf2xx/at86rf2xx.c @@ -56,7 +56,9 @@ void at86rf2xx_reset(at86rf2xx_t *dev) at86rf2xx_hardware_reset(dev); /* Reset state machine to ensure a known state */ - at86rf2xx_reset_state_machine(dev); + if (dev->state == AT86RF2XX_STATE_P_ON) { + at86rf2xx_set_state(dev, AT86RF2XX_STATE_FORCE_TRX_OFF); + } /* reset options and sequence number */ dev->netdev.seq = 0; diff --git a/drivers/at86rf2xx/at86rf2xx_getset.c b/drivers/at86rf2xx/at86rf2xx_getset.c index 5b9a615cd0..4a50675c45 100644 --- a/drivers/at86rf2xx/at86rf2xx_getset.c +++ b/drivers/at86rf2xx/at86rf2xx_getset.c @@ -440,9 +440,9 @@ static inline void _set_state(at86rf2xx_t *dev, uint8_t state, uint8_t cmd) if (state != AT86RF2XX_STATE_RX_AACK_ON) { while (at86rf2xx_get_status(dev) != state) {} } - /* Although RX_AACK_ON state doesn't get read back, - * at least make sure if state transition is in progress or not - */ + /* Although RX_AACK_ON state doesn't get read back, + * at least make sure if state transition is in progress or not + */ else { while (at86rf2xx_get_status(dev) == AT86RF2XX_STATE_IN_PROGRESS) {} } @@ -498,17 +498,3 @@ uint8_t at86rf2xx_set_state(at86rf2xx_t *dev, uint8_t state) return old_state; } - -void at86rf2xx_reset_state_machine(at86rf2xx_t *dev) -{ - uint8_t old_state; - - at86rf2xx_assert_awake(dev); - - /* Wait for any state transitions to complete before forcing TRX_OFF */ - do { - old_state = at86rf2xx_get_status(dev); - } while (old_state == AT86RF2XX_STATE_IN_PROGRESS); - - at86rf2xx_set_state(dev, AT86RF2XX_STATE_FORCE_TRX_OFF); -} diff --git a/drivers/at86rf2xx/at86rf2xx_internal.c b/drivers/at86rf2xx/at86rf2xx_internal.c index 9db91e78d7..26d1c8e0f7 100644 --- a/drivers/at86rf2xx/at86rf2xx_internal.c +++ b/drivers/at86rf2xx/at86rf2xx_internal.c @@ -127,9 +127,9 @@ void at86rf2xx_assert_awake(at86rf2xx_t *dev) gpio_clear(dev->params.sleep_pin); xtimer_usleep(AT86RF2XX_WAKEUP_DELAY); - /* update state: on some platforms, the timer behind xtimer - * may be inaccurate or the radio itself may take longer - * to wake up due to extra capacitance on the oscillator. + /* update state: on some platforms, the timer behind xtimer + * may be inaccurate or the radio itself may take longer + * to wake up due to extra capacitance on the oscillator. * Spin until we are actually awake */ do { @@ -147,8 +147,8 @@ void at86rf2xx_hardware_reset(at86rf2xx_t *dev) gpio_set(dev->params.reset_pin); xtimer_usleep(AT86RF2XX_RESET_DELAY); - /* update state: if the radio state was P_ON (initialization phase), - * it remains P_ON. Otherwise, it should go to TRX_OFF + /* update state: if the radio state was P_ON (initialization phase), + * it remains P_ON. Otherwise, it should go to TRX_OFF */ do { dev->state = at86rf2xx_reg_read(dev, AT86RF2XX_REG__TRX_STATUS) & diff --git a/drivers/include/at86rf2xx.h b/drivers/include/at86rf2xx.h index aa5df2a86e..66527f61da 100644 --- a/drivers/include/at86rf2xx.h +++ b/drivers/include/at86rf2xx.h @@ -391,17 +391,6 @@ void at86rf2xx_set_option(at86rf2xx_t *dev, uint16_t option, bool state); */ uint8_t at86rf2xx_set_state(at86rf2xx_t *dev, uint8_t state); -/** - * @brief Reset the internal state machine to TRX_OFF mode. - * - * This will force a transition to TRX_OFF regardless of whether the transceiver - * is currently busy sending or receiving. This function is used to get back to - * a known state during driver initialization. - * - * @param[in] dev device to operate on - */ -void at86rf2xx_reset_state_machine(at86rf2xx_t *dev); - /** * @brief Convenience function for simply sending data *