Browse Source

Add macros for FUSB302B TX FIFO tokens

Clara Hobbs 7 years ago
parent
commit
206dc3f629
2 changed files with 25 additions and 3 deletions
  1. 14
    3
      src/fusb302b.c
  2. 11
    0
      src/fusb302b.h

+ 14
- 3
src/fusb302b.c View File

@@ -70,8 +70,19 @@ static void fusb_write_buf(uint8_t addr, uint8_t size, const uint8_t *buf)
70 70
 void fusb_send_message(const union pd_msg *msg)
71 71
 {
72 72
     /* Token sequences for the FUSB302B */
73
-    static uint8_t sop_seq[5] = {0x12, 0x12, 0x12, 0x13, 0x80};
74
-    static uint8_t eop_seq[4] = {0xFF, 0x14, 0xFE, 0xA1};
73
+    static uint8_t sop_seq[5] = {
74
+        FUSB_FIFO_TX_SOP1,
75
+        FUSB_FIFO_TX_SOP1,
76
+        FUSB_FIFO_TX_SOP1,
77
+        FUSB_FIFO_TX_SOP2,
78
+        FUSB_FIFO_TX_PACKSYM
79
+    };
80
+    static uint8_t eop_seq[4] = {
81
+        FUSB_FIFO_TX_JAM_CRC,
82
+        FUSB_FIFO_TX_EOP,
83
+        FUSB_FIFO_TX_TXOFF,
84
+        FUSB_FIFO_TX_TXON
85
+    };
75 86
 
76 87
     /* Take the I2C2 mutex now so there can't be a race condition on sop_seq */
77 88
     i2cAcquireBus(&I2CD2);
@@ -81,7 +92,7 @@ void fusb_send_message(const union pd_msg *msg)
81 92
     uint8_t msg_len = 2 + 4 * PD_NUMOBJ_GET(msg);
82 93
 
83 94
     /* Set the number of bytes to be transmitted in the packet */
84
-    sop_seq[4] = 0x80 | msg_len;
95
+    sop_seq[4] = FUSB_FIFO_TX_PACKSYM | msg_len;
85 96
 
86 97
     /* Write all three parts of the message to the TX FIFO */
87 98
     fusb_write_buf(FUSB_FIFOS, 5, sop_seq);

+ 11
- 0
src/fusb302b.h View File

@@ -224,6 +224,17 @@
224 224
 /* FIFOs register */
225 225
 #define FUSB_FIFOS 0x43
226 226
 
227
+#define FUSB_FIFO_TX_TXON 0xA1
228
+#define FUSB_FIFO_TX_SOP1 0x12
229
+#define FUSB_FIFO_TX_SOP2 0x13
230
+#define FUSB_FIFO_TX_SOP3 0x1B
231
+#define FUSB_FIFO_TX_RESET1 0x15
232
+#define FUSB_FIFO_TX_RESET2 0x16
233
+#define FUSB_FIFO_TX_PACKSYM 0x80
234
+#define FUSB_FIFO_TX_JAM_CRC 0xFF
235
+#define FUSB_FIFO_TX_EOP 0x14
236
+#define FUSB_FIFO_TX_TXOFF 0xFE
237
+
227 238
 #define FUSB_FIFO_RX_TOKEN_BITS 0xE0
228 239
 #define FUSB_FIFO_RX_SOP 0xE0
229 240
 #define FUSB_FIFO_RX_SOP1 0xC0

Loading…
Cancel
Save