Skip to contentSkip to conversation

add trac reg to tx done

RFC Superseded Alexander Aring 1 participant 2 messages Sep 5, 2022 IEEE 802.15.4

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC 1/1 add trac reg to tx done

This patch adds an additional byte for tx done for the trac status register which can then evaluated by the atusb Linux driver.
---

Just an RFC, need another weekend to test it.

 atusb/fw/mac.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
atusb/fw/mac.c +10 -4
index 835002c..045d5fa 100644
@@ -32,7 +32,7 @@ static uint8_t tx_buf[MAX_PSDU];
 static uint8_t tx_size = 0;
 static bool txing = 0;
 static bool queued_tx_ack = 0;
-static uint8_t next_seq, this_seq, queued_seq;
+static uint8_t next_seq, this_seq, queued_seq, queued_tx_trac;
 
 
 /* ----- Receive buffer management ----------------------------------------- */
@@ -57,6 +57,7 @@ static void tx_ack_done(void *user);
 static void usb_next(void)
 {
 	const uint8_t *buf;
+	uint8_t data[2];
 
 	if (rx_in != rx_out) {
 		buf = rx_buf[rx_out];
@@ -65,7 +66,9 @@ static void usb_next(void)
 	}
 
 	if (queued_tx_ack) {
-		usb_send(&eps[1], &queued_seq, 1, tx_ack_done, NULL);
+		data[0] = queued_seq;
+		data[1] = queued_tx_trac;
+		usb_send(&eps[1], data, sizeof(data), tx_ack_done, NULL);
 		queued_tx_ack = 0;	
 	}
 }
@@ -116,7 +119,7 @@ static void receive_frame(void)
 
 static bool handle_irq(void)
 {
-	uint8_t irq;
+	uint8_t irq, data[2];
 
 	irq = reg_read(REG_IRQ_STATUS);
 	if (!(irq & IRQ_TRX_END))
@@ -124,10 +127,13 @@ static bool handle_irq(void)
 
 	if (txing) {
 		if (eps[1].state == EP_IDLE) {
-			usb_send(&eps[1], &this_seq, 1, tx_ack_done, NULL);
+			data[0] = this_seq;
+			data[1] = reg_read(REG_TRX_STATE);
+			usb_send(&eps[1], data, sizeof(data), tx_ack_done, NULL);
 		} else {
 			queued_tx_ack = 1;
 			queued_seq = this_seq;
+			queued_tx_trac = reg_read(REG_TRX_STATE);
 		}
 		txing = 0;
 		return 1;
Signature · 1 line
2.31.1
#1 lore raw

Hi,

Quoted 55 lines · Alexander Aring

This patch adds an additional byte for tx done for the trac status register which can then evaluated by the atusb Linux driver.
---

Just an RFC, need another weekend to test it.

 atusb/fw/mac.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
atusb/fw/mac.c +6 -3
index 835002c..045d5fa 100644
@@ -32,7 +32,7 @@ static uint8_t tx_buf[MAX_PSDU];
 static uint8_t tx_size = 0;
 static bool txing = 0;
 static bool queued_tx_ack = 0;
-static uint8_t next_seq, this_seq, queued_seq;
+static uint8_t next_seq, this_seq, queued_seq, queued_tx_trac;
 
 
 /* ----- Receive buffer management ----------------------------------------- */
@@ -57,6 +57,7 @@ static void tx_ack_done(void *user);
 static void usb_next(void)
 {
        const uint8_t *buf;
+       uint8_t data[2];
 
        if (rx_in != rx_out) {
                buf = rx_buf[rx_out];
@@ -65,7 +66,9 @@ static void usb_next(void)
        }
 
        if (queued_tx_ack) {
-               usb_send(&eps[1], &queued_seq, 1, tx_ack_done, NULL);
+               data[0] = queued_seq;
+               data[1] = queued_tx_trac;
+               usb_send(&eps[1], data, sizeof(data), tx_ack_done, NULL);
                queued_tx_ack = 0;
        }
 }
@@ -116,7 +119,7 @@ static void receive_frame(void)
 
 static bool handle_irq(void)
 {
-       uint8_t irq;
+       uint8_t irq, data[2];
 
        irq = reg_read(REG_IRQ_STATUS);
        if (!(irq & IRQ_TRX_END))
@@ -124,10 +127,13 @@ static bool handle_irq(void)
 
        if (txing) {
                if (eps[1].state == EP_IDLE) {

atusb/fw/mac.c static bool handle_irq(void) · line 138

Quoted 10 lines
atusb/fw/mac.c +4 -1
-                       usb_send(&eps[1], &this_seq, 1, tx_ack_done, NULL);
+                       data[0] = this_seq;
+                       data[1] = reg_read(REG_TRX_STATE);
+                       usb_send(&eps[1], data, sizeof(data), tx_ack_done, NULL);
                } else {
                        queued_tx_ack = 1;
                        queued_seq = this_seq;
+                       queued_tx_trac = reg_read(REG_TRX_STATE);
                }
                txing = 0;

There is probably some race the trac register also have values stored for RX_AACK_ON state which is being changed after the transmit but we need at first to get the trac and then turn into RX_AACK_ON, so I think the state change "change_state(TRX_CMD_RX_AACK_ON);" should be moved after reading the trac.

- Alex