Senet-ized LMIC for MOTE_L152RC

Fork of lmic_MOTE_L152RC by Semtech

Committer:
shaunkrnelson
Date:
Tue Mar 08 08:19:44 2016 -0500
Revision:
12:be4139e16c6f
Parent:
9:83ae7f34e88c
Fix compiler error for unsupported compiler array initializer

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dudmuck 0:f2716e543d97 1 //#include "oslmic.h"
dudmuck 0:f2716e543d97 2 #include "lmic.h"
dudmuck 0:f2716e543d97 3 #include "debug.h"
dudmuck 0:f2716e543d97 4 #include "mbed.h"
dudmuck 0:f2716e543d97 5
dudmuck 0:f2716e543d97 6 Serial pc(USBTX, USBRX);
dudmuck 0:f2716e543d97 7
dudmuck 0:f2716e543d97 8 static DigitalOut red_led(PB_1);
dudmuck 0:f2716e543d97 9 #define LED_ON 0
dudmuck 0:f2716e543d97 10 #define LED_OFF 1
dudmuck 0:f2716e543d97 11
dudmuck 0:f2716e543d97 12 void debug_init()
dudmuck 0:f2716e543d97 13 {
dudmuck 0:f2716e543d97 14 pc.baud(115200);
dudmuck 0:f2716e543d97 15
dudmuck 0:f2716e543d97 16 // print banner
dudmuck 0:f2716e543d97 17 debug_str("\r\n============== DEBUG STARTED ==============\r\n");
dudmuck 0:f2716e543d97 18
dudmuck 0:f2716e543d97 19 red_led = LED_OFF;
dudmuck 0:f2716e543d97 20 }
dudmuck 0:f2716e543d97 21
dudmuck 0:f2716e543d97 22 void debug_str (const char* str)
dudmuck 0:f2716e543d97 23 {
dudmuck 0:f2716e543d97 24 debug("%s", str);
dudmuck 0:f2716e543d97 25 }
dudmuck 0:f2716e543d97 26
dudmuck 0:f2716e543d97 27 void debug_event (int ev)
dudmuck 0:f2716e543d97 28 {
shaunkrnelson 12:be4139e16c6f 29 static const char* evnames[16] = {
shaunkrnelson 12:be4139e16c6f 30 "???",
shaunkrnelson 12:be4139e16c6f 31 "SCAN_TIMEOUT",
shaunkrnelson 12:be4139e16c6f 32 "BEACON_FOUND",
shaunkrnelson 12:be4139e16c6f 33 "BEACON_MISSED",
shaunkrnelson 12:be4139e16c6f 34 "BEACON_TRACKED",
shaunkrnelson 12:be4139e16c6f 35 "JOINING",
shaunkrnelson 12:be4139e16c6f 36 "JOINED",
shaunkrnelson 12:be4139e16c6f 37 "RFU1",
shaunkrnelson 12:be4139e16c6f 38 "JOIN_FAILED",
shaunkrnelson 12:be4139e16c6f 39 "REJOIN_FAILED",
shaunkrnelson 12:be4139e16c6f 40 "TXCOMPLETE",
shaunkrnelson 12:be4139e16c6f 41 "LOST_TSYNC",
shaunkrnelson 12:be4139e16c6f 42 "RESET",
shaunkrnelson 12:be4139e16c6f 43 "RXCOMPLETE",
shaunkrnelson 12:be4139e16c6f 44 "LINK_DEAD",
shaunkrnelson 12:be4139e16c6f 45 "LINK_ALIVE"
dudmuck 0:f2716e543d97 46 };
dudmuck 0:f2716e543d97 47
dudmuck 0:f2716e543d97 48 debug("%s\r\n", evnames[ev]);
dudmuck 0:f2716e543d97 49 }
dudmuck 0:f2716e543d97 50
dudmuck 0:f2716e543d97 51 void debug_val (const char* label, u4_t val)
dudmuck 0:f2716e543d97 52 {
dudmuck 0:f2716e543d97 53 debug("%s%d\r\n", label, val);
dudmuck 0:f2716e543d97 54 }
dudmuck 0:f2716e543d97 55
dudmuck 0:f2716e543d97 56 void debug_buf(const u1_t* buf, u2_t len)
dudmuck 0:f2716e543d97 57 {
dudmuck 0:f2716e543d97 58 while (len--) {
dudmuck 0:f2716e543d97 59 debug("%02x ", *buf++);
dudmuck 0:f2716e543d97 60 }
dudmuck 0:f2716e543d97 61 debug("\r\n");
dudmuck 0:f2716e543d97 62 }
dudmuck 0:f2716e543d97 63
dudmuck 0:f2716e543d97 64 void debug_led(unsigned char on)
dudmuck 0:f2716e543d97 65 {
dudmuck 0:f2716e543d97 66 if (on)
dudmuck 0:f2716e543d97 67 red_led = LED_ON;
dudmuck 0:f2716e543d97 68 else
dudmuck 0:f2716e543d97 69 red_led = LED_OFF;
dudmuck 0:f2716e543d97 70 }
dudmuck 0:f2716e543d97 71
dudmuck 0:f2716e543d97 72 void debug_done()
dudmuck 0:f2716e543d97 73 {
dudmuck 0:f2716e543d97 74 /* block until last bit sent out debug UART */
dudmuck 0:f2716e543d97 75 while (!(USART2->SR & UART_FLAG_TC))
dudmuck 0:f2716e543d97 76 __NOP();
dudmuck 0:f2716e543d97 77 }