Skip to content

Conversation

jia200x
Copy link
Member

@jia200x jia200x commented Aug 23, 2019

Contribution description

This PR summarizes in:

1. Define PHY states for the at86rf2xx.

Now the at86rf2xx_set_state function receives a PHY state instead of an internal AT86RF2XX representation.This simplifies the state machine and integration of Basic Mode:

E.g at86rf2xx_set_state(dev, AT86RF2XX_PHY_RX) will internally set the transceiver to AT86RF2XX_STATE_RX_AACK_ON in Extended Mode but to AT86RF2XX_STATE_RX_ON in Basic Mode.

2. Now it's possible to retrieve the TRX state with a variable, instead of polling via at86rf2xx_get_status.

This variable is synchronized with the transceiver via interrupts (e.g RX_START interrupt set dev->state=AT86RF2XX_PHY_RX_BUSY. Then, the RX_DONE event sets the variable back to a non BUSY event).

See how this simplifies the _isr function and how this prevents race conditions (send command is rejected if "dev->state" is in one of the BUSY states. No need to poll the device).

3. Move from Dynamic buffer protection to Static buffer protection:

Dynamic buffer protection is released on at86rf2xx_fb_stop. The current work around was to go set the transceiver state to PLL_ON before reading the frame buffer.
With static buffer protection the detection of SFD is disabled on RX_END, and re-enabled on packet read/drop.

This changes fix the issue described on #11256 (it makes @miri64 tests pass), so it's an alternative to #11264

Basic Mode support comes next :)

Discussion/RFC

In practice, the RX_START event tells the PHY layer that the SFD was detected. Thus, this event is mandatory for synchronizing the dev->state variable.

Also, the transmission (regardless of Basic or Extended mode) always ends with the TX_DONE event. So, RX_START and TRX_END must be mandatory if a PHY layer is present (so far, the at86rf2xx_netdev.c is the PHY layer implementation of the driver).

The question is, do we still want the TELL_RX_START, TELL_RX_DONE and TELL_TX_DONE configurations?
If yes, they MUST be activated in the at86rf2xx_netdev layer.

Testing procedure

Run #11256. Check the test passes (that means no "Unexpected payload. This test failed!").

Issues/PRs references

Fixes #11256
Alternative to #11264
Depends on #12062

@jia200x jia200x added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Area: network Area: Networking Area: drivers Area: Device drivers labels Aug 23, 2019
@jia200x jia200x added the State: waiting for other PR State: The PR requires another PR to be merged first label Aug 23, 2019
@jia200x
Copy link
Member Author

jia200x commented Aug 23, 2019

btw the PHY header is ready on RX_START. It's possible to read the packet length there (e.g cache the pkt size there so RX_END already know the size)

@jia200x jia200x force-pushed the pr/at86rf2xx_phy_states branch from 0e97caf to a8b911a Compare August 23, 2019 14:50
@jia200x jia200x force-pushed the pr/at86rf2xx_phy_states branch from a8b911a to c624117 Compare August 27, 2019 11:42
This commit removes the SLEEP state and adds a dedicated function for
turning the radio on and off. The motivation for removing the SLEEP
state is to simplify the state machine of `at86rf2xx_set_state`
This change defines PHY states for the radio. Although the internal
states differ between Basic Mode and Extended Mode operation, they have
an equivalent in PHY states (e.g RX_AACK_ON is equivalent to RX_ON).
With this it will be easier to implement Basic Mode support for this
radio
Due to the design of netdev, it's more convenient to use static buffer
protection instead of dynamic. As soon as the frame buffer is accessed,
the SFD detection is disabled until the whole recv procedure finished
(dropping or fetching from FB). This way it's not necessary to switch to
PLL_ON mode on reception.
The current driver SPI polls the states of the transceiver. This doesn't
prevent race conditions to happen, since these states are very volatile.
With this change the PHY states of the transceiver are represented with
the `dev->state` variable, which syncs to the device via interrupts.
Now it's possible to safely check if the device is busy without chances
of race conditions.
@jia200x jia200x force-pushed the pr/at86rf2xx_phy_states branch from c624117 to 76c8d9d Compare August 27, 2019 13:45
@jia200x
Copy link
Member Author

jia200x commented Mar 12, 2020

Same as some other PRs, this driver has changed quite a lot. I will re-open if needed

@jia200x jia200x closed this Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: drivers Area: Device drivers Area: network Area: Networking State: waiting for other PR State: The PR requires another PR to be merged first Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant