Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SX127x sx12xx_hal TSL2561
board/board.cpp
- Committer:
- dudmuck
- Date:
- 2017-06-06
- Revision:
- 7:e238827f0e47
- Parent:
- 3:aead8f8fdc1f
- Child:
- 9:08692264148b
File content as of revision 7:e238827f0e47:
/* / _____) _ | | ( (____ _____ ____ _| |_ _____ ____| |__ \____ \| ___ | (_ _) ___ |/ ___) _ \ _____) ) ____| | | || |_| ____( (___| | | | (______/|_____)_|_|_| \__)_____)\____)_| |_| (C)2015 Semtech Description: Target board general functions implementation License: Revised BSD License, see LICENSE.TXT file include in the project Maintainer: Miguel Luis and Gregory Cristian */ #include "mbed.h" #include "board.h" #if defined(ENABLE_SX1272) SX1272MB2xAS Radio( NULL ); #elif defined(ENABLE_SX1276) SX1276MB1xAS Radio( NULL ); #endif /*! * Nested interrupt counter. * * \remark Interrupt should only be fully disabled once the value is 0 */ static uint8_t IrqNestLevel = 0; void BoardDisableIrq( void ) { __disable_irq( ); IrqNestLevel++; } void BoardEnableIrq( void ) { IrqNestLevel--; if( IrqNestLevel == 0 ) { __enable_irq( ); } } void BoardInit( void ) { } uint8_t BoardGetBatteryLevel( void ) { return 0xFE; } #ifdef TARGET_STM32L1 /* TARGET_NUCLEO_L152RE */ #define ID1 ( 0x1ff800d0 ) #define ID2 ( 0x1ff800d4 ) #define ID3 ( 0x1ff800d4 ) DigitalOut rx_debug_pin(PC_3); #elif defined(TARGET_STM32L0) /* TARGET_NUCLEO_L073RZ */ #define ID1 ( 0x1ff80050 ) #define ID2 ( 0x1ff80054 ) #define ID3 ( 0x1ff80064 ) #ifdef TYPE_ABZ DigitalOut rx_debug_pin(PA_0); #else DigitalOut rx_debug_pin(PC_3); #endif #else #error "provide signature address for target" #endif void BoardGetUniqueId( uint8_t *id ) { id[7] = ( ( *( uint32_t* )ID1 )+ ( *( uint32_t* )ID3 ) ) >> 24; id[6] = ( ( *( uint32_t* )ID1 )+ ( *( uint32_t* )ID3 ) ) >> 16; id[5] = ( ( *( uint32_t* )ID1 )+ ( *( uint32_t* )ID3 ) ) >> 8; id[4] = ( ( *( uint32_t* )ID1 )+ ( *( uint32_t* )ID3 ) ); id[3] = ( ( *( uint32_t* )ID2 ) ) >> 24; id[2] = ( ( *( uint32_t* )ID2 ) ) >> 16; id[1] = ( ( *( uint32_t* )ID2 ) ) >> 8; id[0] = ( ( *( uint32_t* )ID2 ) ); } #define UART_TX_BUF_SIZE 256 char uart_tx_buf[UART_TX_BUF_SIZE]; unsigned uart_tx_buf_in, uart_tx_buf_out; unsigned filled; #define PRINT_BUF_SIZE 96 int isr_printf( const char* format, ... ) { va_list arg; char print_buf[PRINT_BUF_SIZE]; unsigned int i, printed_length; va_start(arg, format); printed_length = vsnprintf(print_buf, PRINT_BUF_SIZE, format, arg); va_end(arg); for (i = 0; i < printed_length; i ++) { if (++filled >= UART_TX_BUF_SIZE) { for (;;) __NOP(); } uart_tx_buf[uart_tx_buf_in] = print_buf[i]; if (++uart_tx_buf_in == UART_TX_BUF_SIZE) uart_tx_buf_in = 0; } return i; } RawSerial pc( USBTX, USBRX ); void bottom_half() { while (uart_tx_buf_in != uart_tx_buf_out) { if (filled == 0) { for (;;) __NOP(); } else filled--; pc.putc(uart_tx_buf[uart_tx_buf_out]); if (++uart_tx_buf_out == UART_TX_BUF_SIZE) uart_tx_buf_out = 0; } }