MCU driver/HAL for the Picocell Gateway concentrator board. The firmware implements either a USB CDC protocol or a UART protocol to bridge commands coming from host to the SX1308 SPI interface.

Committer:
dgabino
Date:
Wed Apr 11 14:42:47 2018 +0000
Revision:
0:c76361bd82e8
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dgabino 0:c76361bd82e8 1 /*
dgabino 0:c76361bd82e8 2 / _____) _ | |
dgabino 0:c76361bd82e8 3 ( (____ _____ ____ _| |_ _____ ____| |__
dgabino 0:c76361bd82e8 4 \____ \| ___ | (_ _) ___ |/ ___) _ \
dgabino 0:c76361bd82e8 5 _____) ) ____| | | || |_| ____( (___| | | |
dgabino 0:c76361bd82e8 6 (______/|_____)_|_|_| \__)_____)\____)_| |_|
dgabino 0:c76361bd82e8 7 (C)2017 Semtech
dgabino 0:c76361bd82e8 8 */
dgabino 0:c76361bd82e8 9
dgabino 0:c76361bd82e8 10 #include "board.h"
dgabino 0:c76361bd82e8 11 #include "mbed.h"
dgabino 0:c76361bd82e8 12
dgabino 0:c76361bd82e8 13 #ifndef USE_UART
dgabino 0:c76361bd82e8 14 Serial pc(PB_6, PB_7);
dgabino 0:c76361bd82e8 15 #endif
dgabino 0:c76361bd82e8 16
dgabino 0:c76361bd82e8 17 #ifdef V2
dgabino 0:c76361bd82e8 18 SX1308 Sx1308(PA_4, PA_7, PA_6, PA_5, PB_4, PA_3);
dgabino 0:c76361bd82e8 19 DigitalOut FEM_EN(PB_0); // enable ldo 2V for PA
dgabino 0:c76361bd82e8 20 DigitalOut RADIO_RST (PA_0); // reset sx1257 but sx1257 deliver HSE clk for stm32 so use HSI clk before to reset sx1257
dgabino 0:c76361bd82e8 21 DigitalOut HSCLKEN (PB_2); // clk to switch off the correlators
dgabino 0:c76361bd82e8 22 #endif
dgabino 0:c76361bd82e8 23 #ifdef V1
dgabino 0:c76361bd82e8 24 SX1308 Sx1308(PA_4, PA_7, PA_6, PA_5, PB_1, PA_3);
dgabino 0:c76361bd82e8 25 DigitalOut RADIO_RST (PA_0);
dgabino 0:c76361bd82e8 26 DigitalOut HSCLKEN (PB_14);
dgabino 0:c76361bd82e8 27 #endif
dgabino 0:c76361bd82e8 28
dgabino 0:c76361bd82e8 29 void FLASH_Prog( uint32_t Address, uint8_t Data ) {
dgabino 0:c76361bd82e8 30 HAL_FLASH_Unlock();
dgabino 0:c76361bd82e8 31 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);
dgabino 0:c76361bd82e8 32 FLASH_Erase_Sector(FLASH_SECTOR_4, VOLTAGE_RANGE_3); //sector4 0x8010000 0x801FFFF
dgabino 0:c76361bd82e8 33 HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, Address, Data);
dgabino 0:c76361bd82e8 34 HAL_FLASH_Lock();
dgabino 0:c76361bd82e8 35 }