After transmitting a frame the rf231 changes its state from
BUSY_TX back to PLL_ON. To receive frames we need to change
the state to RX_ON. Requesting the state change to RX_ON
while the radio is still in state BUSY_TX will reduce the
time needed to switch the radio back to receive mode after
the current frame was transmitted. This will eliminated
some situations where frames get lost while the radio
is switching back to RX_ON state.

Signed-off-by: Sascha Herrmann <sas...@ps.nvbi.de>
---
 drivers/net/ieee802154/at86rf230.c |   44 +++++++++++++++++++++++++++---------
 1 file changed, 33 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ieee802154/at86rf230.c 
b/drivers/net/ieee802154/at86rf230.c
index 230ff6a..77adbcf 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -449,6 +449,22 @@ at86rf230_ed(struct ieee802154_dev *dev, u8 *level)
 }
 
 static int
+at86rf230_read_state(struct ieee802154_dev *dev, u8 *state)
+{
+       struct at86rf230_local *lp = dev->priv;
+       int rc;
+
+       do {
+               rc = at86rf230_read_subreg(lp, SR_TRX_STATUS, state);
+               if (rc)
+                       goto out;
+       } while (*state == STATE_TRANSITION_IN_PROGRESS);
+
+out:
+       return rc;
+}
+
+static int
 at86rf230_state(struct ieee802154_dev *dev, int state)
 {
        struct at86rf230_local *lp = dev->priv;
@@ -465,11 +481,9 @@ at86rf230_state(struct ieee802154_dev *dev, int state)
        else
                desired_status = state;
 
-       do {
-               rc = at86rf230_read_subreg(lp, SR_TRX_STATUS, &val);
-               if (rc)
-                       goto err;
-       } while (val == STATE_TRANSITION_IN_PROGRESS);
+       rc = at86rf230_read_state(dev, &val);
+       if (rc)
+               goto err;
 
        if (val == desired_status)
                return 0;
@@ -479,12 +493,9 @@ at86rf230_state(struct ieee802154_dev *dev, int state)
        if (rc)
                goto err;
 
-       do {
-               rc = at86rf230_read_subreg(lp, SR_TRX_STATUS, &val);
-               if (rc)
-                       goto err;
-       } while (val == STATE_TRANSITION_IN_PROGRESS);
-
+       rc = at86rf230_read_state(dev, &val);
+       if (rc)
+               goto err;
 
        if (val == desired_status)
                return 0;
@@ -542,6 +553,7 @@ at86rf230_xmit(struct ieee802154_dev *dev, struct sk_buff 
*skb)
        struct at86rf230_local *lp = dev->priv;
        int rc;
        unsigned long flags;
+       u8 state;
 
        spin_lock(&lp->lock);
        if  (lp->irq_busy) {
@@ -569,6 +581,16 @@ at86rf230_xmit(struct ieee802154_dev *dev, struct sk_buff 
*skb)
        if (rc)
                goto err_rx;
 
+       /* wait for state change to complete */
+       rc = at86rf230_read_state(dev, &state);
+       if (rc)
+               goto err_rx;
+
+       /* state change will be defered until rf230 leaves state BUSY_TX */
+       rc = at86rf230_write_subreg(lp, SR_TRX_CMD, STATE_RX_ON);
+       if (rc)
+               goto err_rx;
+
        rc = wait_for_completion_interruptible(&lp->tx_complete);
        if (rc < 0)
                goto err_rx;
-- 
1.7.10.4


------------------------------------------------------------------------------
Own the Future-Intel&reg; Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest.
Compete for recognition, cash, and the chance to get your game 
on Steam. $5K grand prize plus 10 genre and skill prizes. 
Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d
_______________________________________________
Linux-zigbee-devel mailing list
Linux-zigbee-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel

Reply via email to