Date:2013-04-02 03:04:05 (6 years 8 months ago)
Author:Werner Almesberger
Commit:367c1abb0ee5fd16c8ac5be0a22052596f447f1a
Message:atusb/fw/: echo back TX ACK sequence number; don't panic if driver times out TX

Files: atusb/fw/ep0.c (1 diff)
atusb/fw/include/atusb/atusb.h (1 diff)
atusb/fw/mac.c (6 diffs)
atusb/fw/mac.h (1 diff)

Change Details

atusb/fw/ep0.c
245245    case ATUSB_TO_DEV(ATUSB_RX_MODE):
246246        return mac_rx(setup->wValue);
247247    case ATUSB_TO_DEV(ATUSB_TX):
248        return mac_tx(setup->wValue, setup->wLength);
248        return mac_tx(setup->wValue, setup->wIndex, setup->wLength);
249249
250250    default:
251251        error("Unrecognized SETUP: 0x%02x 0x%02x ...\n",
atusb/fw/include/atusb/atusb.h
7676 * ->host ATUSB_SPI_WRITE2_SYNC byte0 byte1 0/1
7777 *
7878 * host-> ATUSB_RX_MODE on - 0
79 * host-> ATUSB_TX flags 0 #bytes
79 * host-> ATUSB_TX flags ack_seq #bytes
8080 */
8181
8282#define ATUSB_REQ_FROM_DEV (USB_TYPE_VENDOR | USB_DIR_IN)
atusb/fw/mac.c
3131static bool txing = 0;
3232static bool queued_tx_ack = 0;
3333static bool queued_rx = 0;
34static uint8_t next_seq, this_seq, queued_seq;
3435
3536
3637static uint8_t reg_read(uint8_t reg)
...... 
6768        return;
6869    }
6970    if (queued_tx_ack) {
70        usb_send(&eps[1], "", 1, rx_done, NULL);
71        usb_send(&eps[1], &queued_seq, 1, rx_done, NULL);
7172        queued_tx_ack = 0;
7273    }
7374}
...... 
114115        return 1;
115116
116117    if (txing) {
117        if (eps[1].state == EP_IDLE)
118            usb_send(&eps[1], "", 1, rx_done, NULL);
119        else {
120            if (queued_tx_ack)
121                panic();
118        if (eps[1].state == EP_IDLE) {
119            usb_send(&eps[1], &this_seq, 1, rx_done, NULL);
120        } else {
122121            queued_tx_ack = 1;
122            queued_seq = this_seq;
123123        }
124124        txing = 0;
125125        return 1;
...... 
198198    slp_tr();
199199
200200    txing = 1;
201    this_seq = next_seq;
201202
202203    /*
203204     * Wait until we reach BUSY_TX, so that we command the transition to
...... 
207208}
208209
209210
210bool mac_tx(uint16_t flags, uint16_t len)
211bool mac_tx(uint16_t flags, uint8_t seq, uint16_t len)
211212{
212213    if (len > MAX_PSDU)
213214        return 0;
214215    tx_size = len;
216    next_seq = seq;
215217    usb_recv(&eps[0], tx_buf, len, do_tx, NULL);
216218    return 1;
217219}
...... 
223225    txing = 0;
224226    queued_tx_ack = 0;
225227    queued_rx = 0;
228    next_seq = this_seq = queued_seq = 0;
226229
227230    /* enable CRC and PHY_RSSI (with RX_CRC_VALID) in SPI status return */
228231    reg_write(REG_TRX_CTRL_1,
atusb/fw/mac.h
2020extern bool (*mac_irq)(void);
2121
2222bool mac_rx(int on);
23bool mac_tx(uint16_t flags, uint16_t len);
23bool mac_tx(uint16_t flags, uint8_t seq, uint16_t len);
2424void mac_reset(void);
2525
2626#endif /* !MAC_H */

Archive Download the corresponding diff file



interactive