standalone sx1276 demo program

Dependencies:   SX1276Lib mbed

Fork of SX1276_GPS by CaryCoders

Committer:
ftagius
Date:
Tue Jun 16 11:53:20 2015 +0000
Revision:
29:0ea07cc7124b
Child:
31:2c813f321db7
working version of the sx1276 radio with integrated gps and lcd;

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 "vt100.h"
ftagius 29:0ea07cc7124b 18 #include "lcdadafruit.h"
ftagius 29:0ea07cc7124b 19 #include "GPS.h"
ftagius 29:0ea07cc7124b 20 /*
ftagius 29:0ea07cc7124b 21 * Callback functions prototypes
ftagius 29:0ea07cc7124b 22 */
ftagius 29:0ea07cc7124b 23 /*!
ftagius 29:0ea07cc7124b 24 * @brief Function to be executed on Radio Tx Done event
ftagius 29:0ea07cc7124b 25 */
ftagius 29:0ea07cc7124b 26 void OnTxDone( void );
ftagius 29:0ea07cc7124b 27
ftagius 29:0ea07cc7124b 28 /*!
ftagius 29:0ea07cc7124b 29 * @brief Function to be executed on Radio Rx Done event
ftagius 29:0ea07cc7124b 30 */
ftagius 29:0ea07cc7124b 31 void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr );
ftagius 29:0ea07cc7124b 32
ftagius 29:0ea07cc7124b 33 /*!
ftagius 29:0ea07cc7124b 34 * @brief Function executed on Radio Tx Timeout event
ftagius 29:0ea07cc7124b 35 */
ftagius 29:0ea07cc7124b 36 void OnTxTimeout( void );
ftagius 29:0ea07cc7124b 37
ftagius 29:0ea07cc7124b 38 /*!
ftagius 29:0ea07cc7124b 39 * @brief Function executed on Radio Rx Timeout event
ftagius 29:0ea07cc7124b 40 */
ftagius 29:0ea07cc7124b 41 void OnRxTimeout( void );
ftagius 29:0ea07cc7124b 42
ftagius 29:0ea07cc7124b 43 /*!
ftagius 29:0ea07cc7124b 44 * @brief Function executed on Radio Rx Error event
ftagius 29:0ea07cc7124b 45 */
ftagius 29:0ea07cc7124b 46 void OnRxError( void );
ftagius 29:0ea07cc7124b 47
ftagius 29:0ea07cc7124b 48 /*!
ftagius 29:0ea07cc7124b 49 * @brief Function executed on Radio Fhss Change Channel event
ftagius 29:0ea07cc7124b 50 */
ftagius 29:0ea07cc7124b 51 void OnFhssChangeChannel( uint8_t channelIndex );
ftagius 29:0ea07cc7124b 52
ftagius 29:0ea07cc7124b 53 /*!
ftagius 29:0ea07cc7124b 54 * @brief Function executed on CAD Done event
ftagius 29:0ea07cc7124b 55 */
ftagius 29:0ea07cc7124b 56 void OnCadDone( void );
ftagius 29:0ea07cc7124b 57
ftagius 29:0ea07cc7124b 58 char* itoa(int val, int base);
ftagius 29:0ea07cc7124b 59 unsigned int randomSeed(void);
ftagius 29:0ea07cc7124b 60 void start_ping_pong(void);
ftagius 29:0ea07cc7124b 61 void ping_pong(void);
ftagius 29:0ea07cc7124b 62 void start_hello(void);
ftagius 29:0ea07cc7124b 63 void hello(void);
ftagius 29:0ea07cc7124b 64 void check_gps(void);
ftagius 29:0ea07cc7124b 65 int get_kbd_str(char* buf, int size);
ftagius 29:0ea07cc7124b 66 void console_chat();
ftagius 29:0ea07cc7124b 67 void console();
ftagius 29:0ea07cc7124b 68 void check_rx_chat();
ftagius 29:0ea07cc7124b 69 void configRxTx();
ftagius 29:0ea07cc7124b 70 void print_status();
ftagius 29:0ea07cc7124b 71 void print_help();
ftagius 29:0ea07cc7124b 72 void print_bandwidth();
ftagius 29:0ea07cc7124b 73 void print_cr();
ftagius 29:0ea07cc7124b 74 void print_power();
ftagius 29:0ea07cc7124b 75
ftagius 29:0ea07cc7124b 76 /*
ftagius 29:0ea07cc7124b 77 * Global variables declarations
ftagius 29:0ea07cc7124b 78 */
ftagius 29:0ea07cc7124b 79 extern Serial pc;
ftagius 29:0ea07cc7124b 80 //extern char pcbuf[];
ftagius 29:0ea07cc7124b 81
ftagius 29:0ea07cc7124b 82 #define RX_TIMEOUT_VALUE 5000000 // in us
ftagius 29:0ea07cc7124b 83 #define TX_TIMEOUT_VALUE 4000000 // in us
ftagius 29:0ea07cc7124b 84 #define BUFFER_SIZE 256 // Define the payload size here
ftagius 29:0ea07cc7124b 85 #define RADIO_INSTALLED true
ftagius 29:0ea07cc7124b 86
ftagius 29:0ea07cc7124b 87 #if( defined ( TARGET_KL25Z ) || defined ( TARGET_LPC11U6X ) )
ftagius 29:0ea07cc7124b 88 extern DigitalOut led;
ftagius 29:0ea07cc7124b 89 #else
ftagius 29:0ea07cc7124b 90 extern DigitalOut led;
ftagius 29:0ea07cc7124b 91 #endif
ftagius 29:0ea07cc7124b 92
ftagius 29:0ea07cc7124b 93 typedef RadioState States_t;
ftagius 29:0ea07cc7124b 94 extern LCDadafruit cLCD;
ftagius 29:0ea07cc7124b 95 extern volatile States_t State;
ftagius 29:0ea07cc7124b 96 extern SX1276MB1xAS Radio;
ftagius 29:0ea07cc7124b 97 extern GPS gpsd;
ftagius 29:0ea07cc7124b 98 extern uint8_t PingMsg[];
ftagius 29:0ea07cc7124b 99 extern uint8_t PongMsg[];
ftagius 29:0ea07cc7124b 100 extern uint8_t HelloMsg[];
ftagius 29:0ea07cc7124b 101 extern uint16_t BufferSize;
ftagius 29:0ea07cc7124b 102 extern uint8_t BufferTx[];
ftagius 29:0ea07cc7124b 103 extern uint8_t BufferRx[];
ftagius 29:0ea07cc7124b 104 extern vt100 ctrl;
ftagius 29:0ea07cc7124b 105 extern float Frequency;
ftagius 29:0ea07cc7124b 106 extern int TxPower;
ftagius 29:0ea07cc7124b 107 extern int Bandwidth;
ftagius 29:0ea07cc7124b 108 extern int SpreadingFactor;
ftagius 29:0ea07cc7124b 109 extern int CodingRate;
ftagius 29:0ea07cc7124b 110 extern int pkt_count;
ftagius 29:0ea07cc7124b 111 extern int pkt_data[];
ftagius 29:0ea07cc7124b 112 extern int max_pkts;
ftagius 29:0ea07cc7124b 113 extern int per;
ftagius 29:0ea07cc7124b 114 extern bool isMaster;
ftagius 29:0ea07cc7124b 115 extern bool AlwaysMaster;
ftagius 29:0ea07cc7124b 116 extern bool AlwaysSlave;
ftagius 29:0ea07cc7124b 117 extern bool rxTimeout;
ftagius 29:0ea07cc7124b 118 extern char pcbuf[];
ftagius 29:0ea07cc7124b 119 extern bool ackRcvd;
ftagius 29:0ea07cc7124b 120 extern bool gpsEnabled;
ftagius 29:0ea07cc7124b 121 extern int txLen;
ftagius 29:0ea07cc7124b 122 extern int16_t RssiValue;
ftagius 29:0ea07cc7124b 123 extern int8_t SnrValue;
ftagius 29:0ea07cc7124b 124 #define PCBUF_SIZE 64
ftagius 29:0ea07cc7124b 125
ftagius 29:0ea07cc7124b 126 typedef enum {
ftagius 29:0ea07cc7124b 127 APP_NONE = 0,
ftagius 29:0ea07cc7124b 128 APP_PING,
ftagius 29:0ea07cc7124b 129 APP_CHAT,
ftagius 29:0ea07cc7124b 130 APP_HELLO,
ftagius 29:0ea07cc7124b 131 APP_CONSOLE,
ftagius 29:0ea07cc7124b 132 APP_GPS
ftagius 29:0ea07cc7124b 133 } app_e;
ftagius 29:0ea07cc7124b 134
ftagius 29:0ea07cc7124b 135 extern app_e app;
ftagius 29:0ea07cc7124b 136
ftagius 29:0ea07cc7124b 137 #endif // __MAIN_H__