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
- Committer:
- orangeway
- Date:
- 2016-11-10
- Revision:
- 7:4fd11bbd131e
- Parent:
- 6:b2e833061c1f
File content as of revision 7:4fd11bbd131e:
/*******************************************************************************
* Copyright (c) 2014-2015 IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Zurich Research Lab - initial API, implementation and documentation
* Semtech Apps Team - Adapted for MBED
*******************************************************************************/
#include <stdio.h>
#include "mbed.h"
#include "stm32f103c8t6.h"
#include "lmic.h"
#include "debug.h"
Serial pc(PA_2, PA_3);
void debug_init () {
pc.baud(57600);
// print banner
debug_str("\r\n============== DEBUG STARTED ==============\r\n");
}
void debug_led (u1_t val) {
debug_val( "LED = ", val );
}
void debug_char (u1_t c) {
pc.printf("%c", c);
}
void debug_hex (u1_t b) {
pc.printf("%02X", b );
}
void debug_buf (const u1_t* buf, u2_t len) {
while( len-- ) {
debug_hex( *buf++ );
debug_char( ' ' );
}
debug_char( '\r' );
debug_char( '\n' );
}
void debug_uint (u4_t v) {
for( s1_t n = 24; n >= 0; n -= 8 ) {
debug_hex( v >> n );
}
}
void debug_str (const u1_t* str) {
while( *str ) {
debug_char( *str++ );
}
}
void debug_val (const u1_t* label, u4_t val) {
debug_str( label );
debug_uint( val );
debug_char( '\r' );
debug_char( '\n' );
}
void debug_event (int ev) {
static const u1_t* evnames[] = {
[EV_SCAN_TIMEOUT] = "SCAN_TIMEOUT",
[EV_BEACON_FOUND] = "BEACON_FOUND",
[EV_BEACON_MISSED] = "BEACON_MISSED",
[EV_BEACON_TRACKED] = "BEACON_TRACKED",
[EV_JOINING] = "JOINING",
[EV_JOINED] = "JOINED",
[EV_RFU1] = "RFU1",
[EV_JOIN_FAILED] = "JOIN_FAILED",
[EV_REJOIN_FAILED] = "REJOIN_FAILED",
[EV_TXCOMPLETE] = "TXCOMPLETE",
[EV_LOST_TSYNC] = "LOST_TSYNC",
[EV_RESET] = "RESET",
[EV_RXCOMPLETE] = "RXCOMPLETE",
[EV_LINK_DEAD] = "LINK_DEAD",
[EV_LINK_ALIVE] = "LINK_ALIVE",
};
debug_str(evnames[ev]);
debug_char('\r');
debug_char('\n');
}
