![](/media/cache/group/Semtech_stack_color_logo_highres.jpg.50x50_q85.jpg)
This code holds the complete demo set for the sx1280: PingPong, PER and Ranging Outdoor demo application. >>>>> This code MUST run on the mbed library release 127 or everything will be painfully slow.
Dependencies: mbed SX1280Lib DmTftLibrary
* This code MUST run on the mbed library release 127 or everything will be painfully slow.*
main.cpp@17:a0bbfc228415, 2018-07-18 (annotated)
- Committer:
- GregCr
- Date:
- Wed Jul 18 08:51:53 2018 +0000
- Revision:
- 17:a0bbfc228415
- Parent:
- 15:ed7ed20b7114
- Child:
- 19:45d0ce0f0677
Updated DevKit with the latest drivers
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GregCr | 0:9c0917bfde97 | 1 | /* |
GregCr | 0:9c0917bfde97 | 2 | ______ _ |
GregCr | 0:9c0917bfde97 | 3 | / _____) _ | | |
GregCr | 0:9c0917bfde97 | 4 | ( (____ _____ ____ _| |_ _____ ____| |__ |
GregCr | 0:9c0917bfde97 | 5 | \____ \| ___ | (_ _) ___ |/ ___) _ \ |
GregCr | 0:9c0917bfde97 | 6 | _____) ) ____| | | || |_| ____( (___| | | | |
GregCr | 0:9c0917bfde97 | 7 | (______/|_____)_|_|_| \__)_____)\____)_| |_| |
GregCr | 0:9c0917bfde97 | 8 | (C)2016 Semtech |
GregCr | 0:9c0917bfde97 | 9 | |
GregCr | 0:9c0917bfde97 | 10 | Description: Main program |
GregCr | 0:9c0917bfde97 | 11 | |
GregCr | 0:9c0917bfde97 | 12 | Maintainer: Gregory Cristian & Gilbert Menth |
GregCr | 0:9c0917bfde97 | 13 | */ |
GregCr | 0:9c0917bfde97 | 14 | |
GregCr | 0:9c0917bfde97 | 15 | #include "mbed.h" |
GregCr | 0:9c0917bfde97 | 16 | #include "Timers.h" |
GregCr | 0:9c0917bfde97 | 17 | #include "Menu.h" |
GregCr | 0:9c0917bfde97 | 18 | #include "Eeprom.h" |
GregCr | 0:9c0917bfde97 | 19 | #include "GpsMax7.h" |
GregCr | 0:9c0917bfde97 | 20 | #include "SX9306.h" |
mverdy | 14:ebd89dacc807 | 21 | #include "sx1280-hal.h" |
mverdy | 15:ed7ed20b7114 | 22 | #include "main.h" |
GregCr | 0:9c0917bfde97 | 23 | |
GregCr | 0:9c0917bfde97 | 24 | |
GregCr | 0:9c0917bfde97 | 25 | /*! |
GregCr | 0:9c0917bfde97 | 26 | * \brief Define IO for Unused Pin |
GregCr | 0:9c0917bfde97 | 27 | */ |
GregCr | 0:9c0917bfde97 | 28 | DigitalOut F_CS( D6 ); // MBED description of pin |
GregCr | 0:9c0917bfde97 | 29 | DigitalOut SD_CS( D8 ); // MBED description of pin |
mverdy | 15:ed7ed20b7114 | 30 | DigitalIn userButton( USER_BUTTON ); |
mverdy | 15:ed7ed20b7114 | 31 | |
GregCr | 0:9c0917bfde97 | 32 | |
GregCr | 0:9c0917bfde97 | 33 | /*! |
GregCr | 0:9c0917bfde97 | 34 | * \brief Specify serial datarate for UART debug output |
GregCr | 0:9c0917bfde97 | 35 | */ |
GregCr | 0:9c0917bfde97 | 36 | void baud( int baudrate ) |
GregCr | 0:9c0917bfde97 | 37 | { |
GregCr | 0:9c0917bfde97 | 38 | Serial s( USBTX, USBRX ); |
GregCr | 0:9c0917bfde97 | 39 | s.baud( baudrate ); |
GregCr | 0:9c0917bfde97 | 40 | } |
GregCr | 0:9c0917bfde97 | 41 | |
mverdy | 14:ebd89dacc807 | 42 | extern SX1280Hal Radio; |
mverdy | 14:ebd89dacc807 | 43 | |
GregCr | 0:9c0917bfde97 | 44 | int main( ) |
GregCr | 0:9c0917bfde97 | 45 | { |
GregCr | 0:9c0917bfde97 | 46 | uint8_t currentPage = START_PAGE; |
GregCr | 0:9c0917bfde97 | 47 | uint8_t demoStatusUpdate = 0; // used for screen display status |
GregCr | 0:9c0917bfde97 | 48 | |
GregCr | 0:9c0917bfde97 | 49 | baud( 115200 ); |
GregCr | 0:9c0917bfde97 | 50 | |
GregCr | 0:9c0917bfde97 | 51 | F_CS = 1; |
GregCr | 0:9c0917bfde97 | 52 | SD_CS = 1; |
GregCr | 0:9c0917bfde97 | 53 | |
mverdy | 14:ebd89dacc807 | 54 | printf( "Starting SX1280DevKit : %s\n\r", FIRMWARE_VERSION ); |
mverdy | 14:ebd89dacc807 | 55 | |
GregCr | 0:9c0917bfde97 | 56 | EepromInit( ); |
mverdy | 15:ed7ed20b7114 | 57 | |
mverdy | 15:ed7ed20b7114 | 58 | if( userButton == 0 ) |
mverdy | 15:ed7ed20b7114 | 59 | { |
mverdy | 15:ed7ed20b7114 | 60 | FactoryReset( ); |
mverdy | 15:ed7ed20b7114 | 61 | } |
mverdy | 15:ed7ed20b7114 | 62 | |
GregCr | 0:9c0917bfde97 | 63 | InitDemoApplication( ); |
GregCr | 0:9c0917bfde97 | 64 | MenuInit( ); |
GregCr | 17:a0bbfc228415 | 65 | /* Not currently used |
GregCr | 17:a0bbfc228415 | 66 | |
GregCr | 0:9c0917bfde97 | 67 | TimersInit( ); |
GregCr | 0:9c0917bfde97 | 68 | Max7GpsInit( ); |
GregCr | 0:9c0917bfde97 | 69 | SX9306ProximityInit( ); |
GregCr | 17:a0bbfc228415 | 70 | */ |
GregCr | 0:9c0917bfde97 | 71 | |
mverdy | 14:ebd89dacc807 | 72 | printf( "Radio version: 0x%x\n\r", Radio.GetFirmwareVersion( ) ); |
GregCr | 0:9c0917bfde97 | 73 | |
GregCr | 0:9c0917bfde97 | 74 | while( 1 ) |
GregCr | 0:9c0917bfde97 | 75 | { |
GregCr | 0:9c0917bfde97 | 76 | currentPage = MenuHandler( demoStatusUpdate ); |
GregCr | 0:9c0917bfde97 | 77 | |
GregCr | 0:9c0917bfde97 | 78 | switch( currentPage ) |
GregCr | 0:9c0917bfde97 | 79 | { |
GregCr | 0:9c0917bfde97 | 80 | case START_PAGE: |
GregCr | 0:9c0917bfde97 | 81 | break; |
GregCr | 0:9c0917bfde97 | 82 | |
GregCr | 0:9c0917bfde97 | 83 | case PAGE_PING_PONG: |
GregCr | 0:9c0917bfde97 | 84 | demoStatusUpdate = RunDemoApplicationPingPong( ); |
GregCr | 0:9c0917bfde97 | 85 | break; |
GregCr | 0:9c0917bfde97 | 86 | |
GregCr | 0:9c0917bfde97 | 87 | case PAGE_PER: |
GregCr | 0:9c0917bfde97 | 88 | demoStatusUpdate = RunDemoApplicationPer( ); |
GregCr | 0:9c0917bfde97 | 89 | break; |
GregCr | 0:9c0917bfde97 | 90 | |
GregCr | 0:9c0917bfde97 | 91 | case PAGE_RANGING_MASTER: |
GregCr | 0:9c0917bfde97 | 92 | case PAGE_RANGING_SLAVE: |
GregCr | 0:9c0917bfde97 | 93 | demoStatusUpdate = RunDemoApplicationRanging( ); |
GregCr | 0:9c0917bfde97 | 94 | break; |
GregCr | 0:9c0917bfde97 | 95 | |
GregCr | 0:9c0917bfde97 | 96 | case PAGE_SLEEP_MODE: |
GregCr | 0:9c0917bfde97 | 97 | demoStatusUpdate = RunDemoSleepMode( ); |
GregCr | 0:9c0917bfde97 | 98 | break; |
GregCr | 0:9c0917bfde97 | 99 | |
GregCr | 0:9c0917bfde97 | 100 | case PAGE_STBY_RC_MODE: |
GregCr | 0:9c0917bfde97 | 101 | demoStatusUpdate = RunDemoStandbyRcMode( ); |
GregCr | 0:9c0917bfde97 | 102 | break; |
GregCr | 0:9c0917bfde97 | 103 | |
GregCr | 0:9c0917bfde97 | 104 | case PAGE_STBY_XOSC_MODE: |
GregCr | 0:9c0917bfde97 | 105 | demoStatusUpdate = RunDemoStandbyXoscMode( ); |
GregCr | 0:9c0917bfde97 | 106 | break; |
GregCr | 0:9c0917bfde97 | 107 | |
GregCr | 0:9c0917bfde97 | 108 | case PAGE_TX_CW: |
GregCr | 0:9c0917bfde97 | 109 | demoStatusUpdate = RunDemoTxCw( ); |
GregCr | 0:9c0917bfde97 | 110 | break; |
GregCr | 0:9c0917bfde97 | 111 | |
GregCr | 0:9c0917bfde97 | 112 | case PAGE_CONT_MODULATION: |
GregCr | 0:9c0917bfde97 | 113 | demoStatusUpdate = RunDemoTxContinuousModulation( ); |
GregCr | 0:9c0917bfde97 | 114 | break; |
GregCr | 0:9c0917bfde97 | 115 | |
GregCr | 0:9c0917bfde97 | 116 | case PAGE_UTILITIES: |
GregCr | 0:9c0917bfde97 | 117 | // Extracts time and position information from the GPS module |
GregCr | 0:9c0917bfde97 | 118 | Max7GpsHandle( ); |
GregCr | 0:9c0917bfde97 | 119 | SX9306ProximityHandle( ); //Deals with the proximity IC readings |
GregCr | 0:9c0917bfde97 | 120 | break; |
GregCr | 0:9c0917bfde97 | 121 | |
GregCr | 0:9c0917bfde97 | 122 | default: // Any page not running a demo |
GregCr | 0:9c0917bfde97 | 123 | break; |
GregCr | 0:9c0917bfde97 | 124 | } |
GregCr | 0:9c0917bfde97 | 125 | } |
GregCr | 0:9c0917bfde97 | 126 | } |
mverdy | 15:ed7ed20b7114 | 127 | |
mverdy | 15:ed7ed20b7114 | 128 | void FactoryReset( void ) |
mverdy | 15:ed7ed20b7114 | 129 | { |
mverdy | 15:ed7ed20b7114 | 130 | EepromFactoryReset( ); |
mverdy | 15:ed7ed20b7114 | 131 | HAL_NVIC_SystemReset( ); |
mverdy | 15:ed7ed20b7114 | 132 | } |