standalone sx1276 demo program

Dependencies:   SX1276Lib mbed

Fork of SX1276_GPS by CaryCoders

Committer:
ftagius
Date:
Wed Jul 29 12:14:42 2015 +0000
Revision:
32:a2472bbe7c92
Parent:
31:2c813f321db7
Child:
33:319cbac3b6eb
cleanup

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ftagius 29:0ea07cc7124b 1 /*
ftagius 29:0ea07cc7124b 2 / _____) _ | |
ftagius 29:0ea07cc7124b 3 ( (____ _____ ____ _| |_ _____ ____| |__
ftagius 29:0ea07cc7124b 4 \____ \| ___ | (_ _) ___ |/ ___) _ \
ftagius 29:0ea07cc7124b 5 _____) ) ____| | | || |_| ____( (___| | | |
ftagius 29:0ea07cc7124b 6 (______/|_____)_|_|_| \__)_____)\____)_| |_|
ftagius 29:0ea07cc7124b 7 ( C )2014 Semtech
ftagius 29:0ea07cc7124b 8
ftagius 29:0ea07cc7124b 9 Description: Contains the callbacks for the IRQs and any application related details
ftagius 29:0ea07cc7124b 10
ftagius 29:0ea07cc7124b 11 License: Revised BSD License, see LICENSE.TXT file include in the project
ftagius 29:0ea07cc7124b 12
ftagius 29:0ea07cc7124b 13 Maintainer: Miguel Luis and Gregory Cristian
ftagius 29:0ea07cc7124b 14 */
ftagius 29:0ea07cc7124b 15 #ifndef __MAIN_H__
ftagius 29:0ea07cc7124b 16 #define __MAIN_H__
ftagius 29:0ea07cc7124b 17 #include "lcdadafruit.h"
ftagius 29:0ea07cc7124b 18 #include "GPS.h"
ftagius 31:2c813f321db7 19 #include "enums.h"
ftagius 31:2c813f321db7 20 #include "typedefs.h"
ftagius 31:2c813f321db7 21
ftagius 29:0ea07cc7124b 22 /*
ftagius 29:0ea07cc7124b 23 * Callback functions prototypes
ftagius 29:0ea07cc7124b 24 */
ftagius 29:0ea07cc7124b 25 /*!
ftagius 29:0ea07cc7124b 26 * @brief Function to be executed on Radio Tx Done event
ftagius 29:0ea07cc7124b 27 */
ftagius 29:0ea07cc7124b 28 void OnTxDone( void );
ftagius 29:0ea07cc7124b 29
ftagius 29:0ea07cc7124b 30 /*!
ftagius 29:0ea07cc7124b 31 * @brief Function to be executed on Radio Rx Done event
ftagius 29:0ea07cc7124b 32 */
ftagius 29:0ea07cc7124b 33 void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr );
ftagius 29:0ea07cc7124b 34
ftagius 29:0ea07cc7124b 35 /*!
ftagius 29:0ea07cc7124b 36 * @brief Function executed on Radio Tx Timeout event
ftagius 29:0ea07cc7124b 37 */
ftagius 29:0ea07cc7124b 38 void OnTxTimeout( void );
ftagius 29:0ea07cc7124b 39
ftagius 29:0ea07cc7124b 40 /*!
ftagius 29:0ea07cc7124b 41 * @brief Function executed on Radio Rx Timeout event
ftagius 29:0ea07cc7124b 42 */
ftagius 29:0ea07cc7124b 43 void OnRxTimeout( void );
ftagius 29:0ea07cc7124b 44
ftagius 29:0ea07cc7124b 45 /*!
ftagius 29:0ea07cc7124b 46 * @brief Function executed on Radio Rx Error event
ftagius 29:0ea07cc7124b 47 */
ftagius 29:0ea07cc7124b 48 void OnRxError( void );
ftagius 29:0ea07cc7124b 49
ftagius 29:0ea07cc7124b 50 /*!
ftagius 29:0ea07cc7124b 51 * @brief Function executed on Radio Fhss Change Channel event
ftagius 29:0ea07cc7124b 52 */
ftagius 29:0ea07cc7124b 53 void OnFhssChangeChannel( uint8_t channelIndex );
ftagius 29:0ea07cc7124b 54
ftagius 29:0ea07cc7124b 55 /*!
ftagius 29:0ea07cc7124b 56 * @brief Function executed on CAD Done event
ftagius 29:0ea07cc7124b 57 */
ftagius 29:0ea07cc7124b 58 void OnCadDone( void );
ftagius 29:0ea07cc7124b 59
ftagius 29:0ea07cc7124b 60 char* itoa(int val, int base);
ftagius 29:0ea07cc7124b 61 unsigned int randomSeed(void);
ftagius 29:0ea07cc7124b 62 void start_ping_pong(void);
ftagius 29:0ea07cc7124b 63 void ping_pong(void);
ftagius 29:0ea07cc7124b 64 void start_hello(void);
ftagius 29:0ea07cc7124b 65 void hello(void);
ftagius 29:0ea07cc7124b 66 int get_kbd_str(char* buf, int size);
ftagius 29:0ea07cc7124b 67 void console_chat();
ftagius 29:0ea07cc7124b 68 void console();
ftagius 29:0ea07cc7124b 69 void check_rx_chat();
ftagius 29:0ea07cc7124b 70 void configRxTx();
ftagius 29:0ea07cc7124b 71 void print_status();
ftagius 29:0ea07cc7124b 72 void print_help();
ftagius 29:0ea07cc7124b 73 void print_bandwidth();
ftagius 29:0ea07cc7124b 74 void print_cr();
ftagius 29:0ea07cc7124b 75 void print_power();
ftagius 32:a2472bbe7c92 76 void gps_setup(void);
ftagius 32:a2472bbe7c92 77 int check_gps(void);
ftagius 29:0ea07cc7124b 78
ftagius 29:0ea07cc7124b 79 /*
ftagius 29:0ea07cc7124b 80 * Global variables declarations
ftagius 29:0ea07cc7124b 81 */
ftagius 29:0ea07cc7124b 82 extern Serial pc;
ftagius 29:0ea07cc7124b 83 //extern char pcbuf[];
ftagius 29:0ea07cc7124b 84
ftagius 29:0ea07cc7124b 85 #define RX_TIMEOUT_VALUE 5000000 // in us
ftagius 29:0ea07cc7124b 86 #define TX_TIMEOUT_VALUE 4000000 // in us
ftagius 29:0ea07cc7124b 87 #define BUFFER_SIZE 256 // Define the payload size here
ftagius 29:0ea07cc7124b 88 #define RADIO_INSTALLED true
ftagius 32:a2472bbe7c92 89 /* Set this flag to '1' to display debug messages on the console */
ftagius 32:a2472bbe7c92 90 #define DEBUG_MESSAGE 1
ftagius 32:a2472bbe7c92 91 #define TX_OUTPUT_POWER 20 // 14 dBm
ftagius 32:a2472bbe7c92 92 #define LORA_BANDWIDTH 2 // [0: 125 kHz,
ftagius 32:a2472bbe7c92 93 // 1: 250 kHz,
ftagius 32:a2472bbe7c92 94 // 2: 500 kHz,
ftagius 32:a2472bbe7c92 95 // 3: Reserved]
ftagius 32:a2472bbe7c92 96 // #define LORA_SPREADING_FACTOR 7 // [SF7..SF12]
ftagius 32:a2472bbe7c92 97 #define LORA_SPREADING_FACTOR 12 // [SF7..SF12]
ftagius 32:a2472bbe7c92 98 // #define LORA_CODINGRATE 1 // [1: 4/5,
ftagius 32:a2472bbe7c92 99 #define LORA_CODINGRATE 2 // [1: 4/5,
ftagius 32:a2472bbe7c92 100 // 2: 4/6,
ftagius 32:a2472bbe7c92 101 // 3: 4/7,
ftagius 32:a2472bbe7c92 102 // 4: 4/8]
ftagius 32:a2472bbe7c92 103 #define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx
ftagius 32:a2472bbe7c92 104 #define LORA_SYMBOL_TIMEOUT 5 // Symbols
ftagius 32:a2472bbe7c92 105 #define LORA_FIX_LENGTH_PAYLOAD_ON false
ftagius 32:a2472bbe7c92 106 #define LORA_FHSS_ENABLED false
ftagius 32:a2472bbe7c92 107 #define LORA_NB_SYMB_HOP 4
ftagius 32:a2472bbe7c92 108 #define LORA_IQ_INVERSION_ON false
ftagius 32:a2472bbe7c92 109 #define LORA_CRC_ENABLED true
ftagius 29:0ea07cc7124b 110
ftagius 29:0ea07cc7124b 111 #if( defined ( TARGET_KL25Z ) || defined ( TARGET_LPC11U6X ) )
ftagius 29:0ea07cc7124b 112 extern DigitalOut led;
ftagius 29:0ea07cc7124b 113 #else
ftagius 29:0ea07cc7124b 114 extern DigitalOut led;
ftagius 29:0ea07cc7124b 115 #endif
ftagius 29:0ea07cc7124b 116
ftagius 29:0ea07cc7124b 117 typedef RadioState States_t;
ftagius 29:0ea07cc7124b 118 extern LCDadafruit cLCD;
ftagius 29:0ea07cc7124b 119 extern volatile States_t State;
ftagius 29:0ea07cc7124b 120 extern SX1276MB1xAS Radio;
ftagius 29:0ea07cc7124b 121 extern GPS gpsd;
ftagius 29:0ea07cc7124b 122 extern uint8_t PingMsg[];
ftagius 29:0ea07cc7124b 123 extern uint8_t PongMsg[];
ftagius 29:0ea07cc7124b 124 extern uint8_t HelloMsg[];
ftagius 29:0ea07cc7124b 125 extern uint16_t BufferSize;
ftagius 29:0ea07cc7124b 126 extern uint8_t BufferTx[];
ftagius 29:0ea07cc7124b 127 extern uint8_t BufferRx[];
ftagius 31:2c813f321db7 128 // radfta extern vt100 ctrl;
ftagius 29:0ea07cc7124b 129 extern float Frequency;
ftagius 32:a2472bbe7c92 130 extern float distance;
ftagius 32:a2472bbe7c92 131 extern float r_latitude;
ftagius 32:a2472bbe7c92 132 extern float r_longitude;
ftagius 29:0ea07cc7124b 133 extern int TxPower;
ftagius 29:0ea07cc7124b 134 extern int Bandwidth;
ftagius 29:0ea07cc7124b 135 extern int SpreadingFactor;
ftagius 29:0ea07cc7124b 136 extern int CodingRate;
ftagius 29:0ea07cc7124b 137 extern int pkt_count;
ftagius 29:0ea07cc7124b 138 extern int pkt_data[];
ftagius 29:0ea07cc7124b 139 extern int max_pkts;
ftagius 29:0ea07cc7124b 140 extern int per;
ftagius 29:0ea07cc7124b 141 extern bool isMaster;
ftagius 29:0ea07cc7124b 142 extern bool AlwaysMaster;
ftagius 29:0ea07cc7124b 143 extern bool AlwaysSlave;
ftagius 29:0ea07cc7124b 144 extern bool rxTimeout;
ftagius 29:0ea07cc7124b 145 extern char pcbuf[];
ftagius 29:0ea07cc7124b 146 extern bool ackRcvd;
ftagius 29:0ea07cc7124b 147 extern bool gpsEnabled;
ftagius 29:0ea07cc7124b 148 extern int txLen;
ftagius 29:0ea07cc7124b 149 extern int16_t RssiValue;
ftagius 29:0ea07cc7124b 150 extern int8_t SnrValue;
ftagius 29:0ea07cc7124b 151 #define PCBUF_SIZE 64
ftagius 32:a2472bbe7c92 152 #define PI 3.14159265
ftagius 29:0ea07cc7124b 153
ftagius 29:0ea07cc7124b 154 typedef enum {
ftagius 29:0ea07cc7124b 155 APP_NONE = 0,
ftagius 29:0ea07cc7124b 156 APP_PING,
ftagius 29:0ea07cc7124b 157 APP_CHAT,
ftagius 29:0ea07cc7124b 158 APP_HELLO,
ftagius 29:0ea07cc7124b 159 APP_CONSOLE,
ftagius 29:0ea07cc7124b 160 APP_GPS
ftagius 29:0ea07cc7124b 161 } app_e;
ftagius 29:0ea07cc7124b 162
ftagius 29:0ea07cc7124b 163 extern app_e app;
ftagius 29:0ea07cc7124b 164
ftagius 29:0ea07cc7124b 165 #endif // __MAIN_H__