瀏覽代碼

Print status registers on boot

Thomas Buck 8 年之前
父節點
當前提交
9460edd0b0
共有 3 個文件被更改,包括 39 次插入0 次删除
  1. 2
    0
      include/serial.h
  2. 11
    0
      src/rx.c
  3. 26
    0
      src/serial.c

+ 2
- 0
include/serial.h 查看文件

@@ -121,5 +121,7 @@ uint8_t serialTxBufferFull(uint8_t uart);
121 121
  */
122 122
 uint8_t serialTxBufferEmpty(uint8_t uart);
123 123
 
124
+void serialWriteHex(uint8_t uart, uint8_t value);
125
+
124 126
 #endif // _serial_h
125 127
 /** @} */

+ 11
- 0
src/rx.c 查看文件

@@ -118,6 +118,17 @@ static void initialize(uint8_t bind) {
118 118
 
119 119
     cc2500Strobe(CC2500_SIDLE); // Go to idle...
120 120
 
121
+#ifdef DEBUG
122
+    uint8_t part = cc2500ReadReg(CC2500_30_PARTNUM);
123
+    uint8_t version = cc2500ReadReg(CC2500_31_VERSION);
124
+
125
+    serialWriteString(0, "CC2500 Part Number: 0x");
126
+    serialWriteHex(0, part);
127
+    serialWriteString(0, "\nCC2500 Version: 0x");
128
+    serialWriteHex(0, version);
129
+    serialWriteString(0, "\n");
130
+#endif
131
+
121 132
     // hack: Append status, filter by address, auto-flush on bad crc, PQT=0
122 133
     cc2500WriteReg(CC2500_07_PKTCTRL1, 0x0D);
123 134
 

+ 26
- 0
src/serial.c 查看文件

@@ -307,6 +307,32 @@ void serialWriteString(uint8_t uart, const char *data) {
307 307
     }
308 308
 }
309 309
 
310
+void serialWriteHex(uint8_t uart, uint8_t value) {
311
+    char buff[3] = { 0, 0, '\0' };
312
+
313
+    if (value >= 16) {
314
+        buff[0] = value / 16;
315
+        value = value % 16;
316
+    }
317
+    buff[1] = value;
318
+
319
+    if ((buff[0] >= 0) && (buff[0] <= 9)) {
320
+        buff[0] += '0';
321
+    } else {
322
+        buff[0] -= 10;
323
+        buff[0] += 'A';
324
+    }
325
+
326
+    if ((buff[1] >= 0) && (buff[1] <= 9)) {
327
+        buff[1] += '0';
328
+    } else {
329
+        buff[1] -= 10;
330
+        buff[1] += 'A';
331
+    }
332
+
333
+    serialWriteString(uart, buff);
334
+}
335
+
310 336
 uint8_t serialTxBufferFull(uint8_t uart) {
311 337
     if (uart >= UART_COUNT)
312 338
         return 0;

Loading…
取消
儲存