works with TTN and cheap STM32F103C8T6 boards
Dependencies: LMiC_CFG_eu868 SX1276Lib mbed-STM32F103C8T6 mbed
Fork of LoRaWAN-lmic-app by
STM32F103C8T6 + RFM95 LoRa Node
flash board wirh STLink
openocd -f interface/stlink-v2.cfg -f target/stm32f1x_stlink.cfg \ -c "program STM32F103C8T6_LoRaWAN-lmic-app_NUCLEO_F103RB.bin exit verify reset 0x08000000"
debug.cpp@6:b2e833061c1f, 2016-11-10 (annotated)
- Committer:
- orangeway
- Date:
- Thu Nov 10 23:14:53 2016 +0000
- Revision:
- 6:b2e833061c1f
- Parent:
- 1:60184eda0066
made some minor changes to work with TTN and STM32F103C8T6
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mluis | 1:60184eda0066 | 1 | /******************************************************************************* |
mluis | 1:60184eda0066 | 2 | * Copyright (c) 2014-2015 IBM Corporation. |
mluis | 1:60184eda0066 | 3 | * All rights reserved. This program and the accompanying materials |
mluis | 1:60184eda0066 | 4 | * are made available under the terms of the Eclipse Public License v1.0 |
mluis | 1:60184eda0066 | 5 | * which accompanies this distribution, and is available at |
mluis | 1:60184eda0066 | 6 | * http://www.eclipse.org/legal/epl-v10.html |
mluis | 1:60184eda0066 | 7 | * |
mluis | 1:60184eda0066 | 8 | * Contributors: |
mluis | 1:60184eda0066 | 9 | * IBM Zurich Research Lab - initial API, implementation and documentation |
mluis | 1:60184eda0066 | 10 | * Semtech Apps Team - Adapted for MBED |
mluis | 1:60184eda0066 | 11 | *******************************************************************************/ |
mluis | 1:60184eda0066 | 12 | #include <stdio.h> |
orangeway | 6:b2e833061c1f | 13 | #include "mbed.h" |
orangeway | 6:b2e833061c1f | 14 | #include "stm32f103c8t6.h" |
mluis | 1:60184eda0066 | 15 | #include "lmic.h" |
mluis | 1:60184eda0066 | 16 | #include "debug.h" |
mluis | 1:60184eda0066 | 17 | |
orangeway | 6:b2e833061c1f | 18 | Serial pc(PA_2, PA_3); |
orangeway | 6:b2e833061c1f | 19 | |
mluis | 1:60184eda0066 | 20 | void debug_init () { |
orangeway | 6:b2e833061c1f | 21 | pc.baud(57600); |
mluis | 1:60184eda0066 | 22 | // print banner |
mluis | 1:60184eda0066 | 23 | debug_str("\r\n============== DEBUG STARTED ==============\r\n"); |
mluis | 1:60184eda0066 | 24 | } |
mluis | 1:60184eda0066 | 25 | |
mluis | 1:60184eda0066 | 26 | void debug_led (u1_t val) { |
mluis | 1:60184eda0066 | 27 | debug_val( "LED = ", val ); |
mluis | 1:60184eda0066 | 28 | } |
mluis | 1:60184eda0066 | 29 | |
mluis | 1:60184eda0066 | 30 | void debug_char (u1_t c) { |
orangeway | 6:b2e833061c1f | 31 | pc.printf("%c", c); |
mluis | 1:60184eda0066 | 32 | } |
mluis | 1:60184eda0066 | 33 | |
mluis | 1:60184eda0066 | 34 | void debug_hex (u1_t b) { |
orangeway | 6:b2e833061c1f | 35 | pc.printf("%02X", b ); |
mluis | 1:60184eda0066 | 36 | } |
mluis | 1:60184eda0066 | 37 | |
mluis | 1:60184eda0066 | 38 | void debug_buf (const u1_t* buf, u2_t len) { |
mluis | 1:60184eda0066 | 39 | while( len-- ) { |
mluis | 1:60184eda0066 | 40 | debug_hex( *buf++ ); |
mluis | 1:60184eda0066 | 41 | debug_char( ' ' ); |
mluis | 1:60184eda0066 | 42 | } |
mluis | 1:60184eda0066 | 43 | debug_char( '\r' ); |
mluis | 1:60184eda0066 | 44 | debug_char( '\n' ); |
mluis | 1:60184eda0066 | 45 | } |
mluis | 1:60184eda0066 | 46 | |
mluis | 1:60184eda0066 | 47 | void debug_uint (u4_t v) { |
mluis | 1:60184eda0066 | 48 | for( s1_t n = 24; n >= 0; n -= 8 ) { |
mluis | 1:60184eda0066 | 49 | debug_hex( v >> n ); |
mluis | 1:60184eda0066 | 50 | } |
mluis | 1:60184eda0066 | 51 | } |
mluis | 1:60184eda0066 | 52 | |
mluis | 1:60184eda0066 | 53 | void debug_str (const u1_t* str) { |
mluis | 1:60184eda0066 | 54 | while( *str ) { |
mluis | 1:60184eda0066 | 55 | debug_char( *str++ ); |
mluis | 1:60184eda0066 | 56 | } |
mluis | 1:60184eda0066 | 57 | } |
mluis | 1:60184eda0066 | 58 | |
mluis | 1:60184eda0066 | 59 | void debug_val (const u1_t* label, u4_t val) { |
mluis | 1:60184eda0066 | 60 | debug_str( label ); |
mluis | 1:60184eda0066 | 61 | debug_uint( val ); |
mluis | 1:60184eda0066 | 62 | debug_char( '\r' ); |
mluis | 1:60184eda0066 | 63 | debug_char( '\n' ); |
mluis | 1:60184eda0066 | 64 | } |
mluis | 1:60184eda0066 | 65 | |
mluis | 1:60184eda0066 | 66 | void debug_event (int ev) { |
mluis | 1:60184eda0066 | 67 | static const u1_t* evnames[] = { |
mluis | 1:60184eda0066 | 68 | [EV_SCAN_TIMEOUT] = "SCAN_TIMEOUT", |
mluis | 1:60184eda0066 | 69 | [EV_BEACON_FOUND] = "BEACON_FOUND", |
mluis | 1:60184eda0066 | 70 | [EV_BEACON_MISSED] = "BEACON_MISSED", |
mluis | 1:60184eda0066 | 71 | [EV_BEACON_TRACKED] = "BEACON_TRACKED", |
mluis | 1:60184eda0066 | 72 | [EV_JOINING] = "JOINING", |
mluis | 1:60184eda0066 | 73 | [EV_JOINED] = "JOINED", |
mluis | 1:60184eda0066 | 74 | [EV_RFU1] = "RFU1", |
mluis | 1:60184eda0066 | 75 | [EV_JOIN_FAILED] = "JOIN_FAILED", |
mluis | 1:60184eda0066 | 76 | [EV_REJOIN_FAILED] = "REJOIN_FAILED", |
mluis | 1:60184eda0066 | 77 | [EV_TXCOMPLETE] = "TXCOMPLETE", |
mluis | 1:60184eda0066 | 78 | [EV_LOST_TSYNC] = "LOST_TSYNC", |
mluis | 1:60184eda0066 | 79 | [EV_RESET] = "RESET", |
mluis | 1:60184eda0066 | 80 | [EV_RXCOMPLETE] = "RXCOMPLETE", |
mluis | 1:60184eda0066 | 81 | [EV_LINK_DEAD] = "LINK_DEAD", |
mluis | 1:60184eda0066 | 82 | [EV_LINK_ALIVE] = "LINK_ALIVE", |
mluis | 1:60184eda0066 | 83 | }; |
mluis | 1:60184eda0066 | 84 | debug_str(evnames[ev]); |
mluis | 1:60184eda0066 | 85 | debug_char('\r'); |
mluis | 1:60184eda0066 | 86 | debug_char('\n'); |
mluis | 1:60184eda0066 | 87 | } |