end node on synchronous star LoRa network.
Dependencies: SX127x sx12xx_hal TSL2561
board.cpp
00001 /* 00002 / _____) _ | | 00003 ( (____ _____ ____ _| |_ _____ ____| |__ 00004 \____ \| ___ | (_ _) ___ |/ ___) _ \ 00005 _____) ) ____| | | || |_| ____( (___| | | | 00006 (______/|_____)_|_|_| \__)_____)\____)_| |_| 00007 (C)2015 Semtech 00008 00009 Description: Target board general functions implementation 00010 00011 License: Revised BSD License, see LICENSE.TXT file include in the project 00012 00013 Maintainer: Miguel Luis and Gregory Cristian 00014 */ 00015 #include "mbed.h" 00016 #include "board.h" 00017 #define __STDC_FORMAT_MACROS 00018 #include <inttypes.h> 00019 00020 /*! 00021 * Nested interrupt counter. 00022 * 00023 * \remark Interrupt should only be fully disabled once the value is 0 00024 */ 00025 static uint8_t IrqNestLevel = 0; 00026 00027 UnbufferedSerial pc( USBTX, USBRX ); 00028 00029 void app_printf(const char *fmt, ...) 00030 { 00031 char n, str[64]; 00032 va_list arg_ptr; 00033 00034 pc.write("\e[35m", 5); 00035 00036 va_start(arg_ptr, fmt); 00037 n = vsnprintf(str, sizeof(str), fmt, arg_ptr); 00038 va_end(arg_ptr); 00039 pc.write(str, n); 00040 00041 pc.write("\e[0m", 4); 00042 } 00043 00044 void mac_printf(const char *fmt, ...) 00045 { 00046 char n, str[64]; 00047 va_list arg_ptr; 00048 00049 pc.write("\e[36m", 5); 00050 00051 va_start(arg_ptr, fmt); 00052 n = vsnprintf(str, sizeof(str), fmt, arg_ptr); 00053 va_end(arg_ptr); 00054 pc.write(str, n); 00055 00056 pc.write("\e[0m", 4); 00057 } 00058 00059 void pc_printf(const char *fmt, ...) 00060 { 00061 char n, str[64]; 00062 va_list arg_ptr; 00063 00064 va_start(arg_ptr, fmt); 00065 n = vsnprintf(str, sizeof(str), fmt, arg_ptr); 00066 va_end(arg_ptr); 00067 pc.write(str, n); 00068 } 00069 00070 void BoardDisableIrq( void ) 00071 { 00072 __disable_irq( ); 00073 IrqNestLevel++; 00074 } 00075 00076 void BoardEnableIrq( void ) 00077 { 00078 IrqNestLevel--; 00079 if( IrqNestLevel == 0 ) 00080 { 00081 __enable_irq( ); 00082 } 00083 } 00084 00085 void BoardInit( void ) 00086 { 00087 /* TODO: ban low-speed internal osc 00088 if (!LL_RCC_LSE_IsReady()) { 00089 for (;;) __NOP(); 00090 } 00091 */ 00092 } 00093 00094 uint8_t BoardGetBatteryLevel( void ) 00095 { 00096 return 0xFE; 00097 } 00098 00099 #ifdef TARGET_STM32L1 /* TARGET_NUCLEO_L152RE */ 00100 /* 0x1ff80050: Cat1, Cat2 */ 00101 #define ID1 ( 0x1ff800d0 ) /* Cat3, Cat4, Cat5 */ 00102 #define ID2 ( ID1 + 0x04 ) 00103 #define ID3 ( ID1 + 0x14 ) 00104 DigitalOut rx_debug_pin(PC_3); 00105 #elif defined(TARGET_STM32L0) /* TARGET_NUCLEO_L073RZ */ 00106 #define ID1 ( 0x1ff80050 ) 00107 #define ID2 ( ID1 + 0x04 ) 00108 #define ID3 ( ID1 + 0x14 ) 00109 #ifdef TARGET_DISCO_L072CZ_LRWAN1 00110 DigitalOut rx_debug_pin(PA_0); 00111 #else 00112 DigitalOut rx_debug_pin(PC_3); 00113 #endif 00114 #elif defined(TARGET_STM32L4) /* TARGET_NUCLEO_L476RG */ 00115 #define ID1 ( 0x1fff7590 ) 00116 #define ID2 ( ID1 + 0x04 ) 00117 #define ID3 ( ID1 + 0x08 ) 00118 DigitalOut rx_debug_pin(PC_3); 00119 #else 00120 #error "provide signature address for target" 00121 #endif 00122 00123 void BoardGetUniqueId( uint8_t *id ) 00124 { 00125 id[7] = ( ( *( uint32_t* )ID1 )+ ( *( uint32_t* )ID3 ) ) >> 24; 00126 id[6] = ( ( *( uint32_t* )ID1 )+ ( *( uint32_t* )ID3 ) ) >> 16; 00127 id[5] = ( ( *( uint32_t* )ID1 )+ ( *( uint32_t* )ID3 ) ) >> 8; 00128 id[4] = ( ( *( uint32_t* )ID1 )+ ( *( uint32_t* )ID3 ) ); 00129 id[3] = ( ( *( uint32_t* )ID2 ) ) >> 24; 00130 id[2] = ( ( *( uint32_t* )ID2 ) ) >> 16; 00131 id[1] = ( ( *( uint32_t* )ID2 ) ) >> 8; 00132 id[0] = ( ( *( uint32_t* )ID2 ) ); 00133 } 00134
Generated on Wed Jul 13 2022 01:56:41 by 1.7.2