standalone sx1276 demo program

Dependencies:   SX1276Lib mbed

Fork of SX1276_GPS by CaryCoders

Committer:
ftagius
Date:
Tue Jul 14 14:58:23 2015 +0000
Revision:
31:2c813f321db7
Parent:
29:0ea07cc7124b
Child:
32:a2472bbe7c92
refactored sx1276 demo code

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 void check_gps(void);
ftagius 29:0ea07cc7124b 67 int get_kbd_str(char* buf, int size);
ftagius 29:0ea07cc7124b 68 void console_chat();
ftagius 29:0ea07cc7124b 69 void console();
ftagius 29:0ea07cc7124b 70 void check_rx_chat();
ftagius 29:0ea07cc7124b 71 void configRxTx();
ftagius 29:0ea07cc7124b 72 void print_status();
ftagius 29:0ea07cc7124b 73 void print_help();
ftagius 29:0ea07cc7124b 74 void print_bandwidth();
ftagius 29:0ea07cc7124b 75 void print_cr();
ftagius 29:0ea07cc7124b 76 void print_power();
ftagius 29:0ea07cc7124b 77
ftagius 29:0ea07cc7124b 78 /*
ftagius 29:0ea07cc7124b 79 * Global variables declarations
ftagius 29:0ea07cc7124b 80 */
ftagius 29:0ea07cc7124b 81 extern Serial pc;
ftagius 29:0ea07cc7124b 82 //extern char pcbuf[];
ftagius 29:0ea07cc7124b 83
ftagius 29:0ea07cc7124b 84 #define RX_TIMEOUT_VALUE 5000000 // in us
ftagius 29:0ea07cc7124b 85 #define TX_TIMEOUT_VALUE 4000000 // in us
ftagius 29:0ea07cc7124b 86 #define BUFFER_SIZE 256 // Define the payload size here
ftagius 29:0ea07cc7124b 87 #define RADIO_INSTALLED true
ftagius 29:0ea07cc7124b 88
ftagius 29:0ea07cc7124b 89 #if( defined ( TARGET_KL25Z ) || defined ( TARGET_LPC11U6X ) )
ftagius 29:0ea07cc7124b 90 extern DigitalOut led;
ftagius 29:0ea07cc7124b 91 #else
ftagius 29:0ea07cc7124b 92 extern DigitalOut led;
ftagius 29:0ea07cc7124b 93 #endif
ftagius 29:0ea07cc7124b 94
ftagius 29:0ea07cc7124b 95 typedef RadioState States_t;
ftagius 29:0ea07cc7124b 96 extern LCDadafruit cLCD;
ftagius 29:0ea07cc7124b 97 extern volatile States_t State;
ftagius 29:0ea07cc7124b 98 extern SX1276MB1xAS Radio;
ftagius 29:0ea07cc7124b 99 extern GPS gpsd;
ftagius 29:0ea07cc7124b 100 extern uint8_t PingMsg[];
ftagius 29:0ea07cc7124b 101 extern uint8_t PongMsg[];
ftagius 29:0ea07cc7124b 102 extern uint8_t HelloMsg[];
ftagius 29:0ea07cc7124b 103 extern uint16_t BufferSize;
ftagius 29:0ea07cc7124b 104 extern uint8_t BufferTx[];
ftagius 29:0ea07cc7124b 105 extern uint8_t BufferRx[];
ftagius 31:2c813f321db7 106 // radfta extern vt100 ctrl;
ftagius 29:0ea07cc7124b 107 extern float Frequency;
ftagius 29:0ea07cc7124b 108 extern int TxPower;
ftagius 29:0ea07cc7124b 109 extern int Bandwidth;
ftagius 29:0ea07cc7124b 110 extern int SpreadingFactor;
ftagius 29:0ea07cc7124b 111 extern int CodingRate;
ftagius 29:0ea07cc7124b 112 extern int pkt_count;
ftagius 29:0ea07cc7124b 113 extern int pkt_data[];
ftagius 29:0ea07cc7124b 114 extern int max_pkts;
ftagius 29:0ea07cc7124b 115 extern int per;
ftagius 29:0ea07cc7124b 116 extern bool isMaster;
ftagius 29:0ea07cc7124b 117 extern bool AlwaysMaster;
ftagius 29:0ea07cc7124b 118 extern bool AlwaysSlave;
ftagius 29:0ea07cc7124b 119 extern bool rxTimeout;
ftagius 29:0ea07cc7124b 120 extern char pcbuf[];
ftagius 29:0ea07cc7124b 121 extern bool ackRcvd;
ftagius 29:0ea07cc7124b 122 extern bool gpsEnabled;
ftagius 29:0ea07cc7124b 123 extern int txLen;
ftagius 29:0ea07cc7124b 124 extern int16_t RssiValue;
ftagius 29:0ea07cc7124b 125 extern int8_t SnrValue;
ftagius 29:0ea07cc7124b 126 #define PCBUF_SIZE 64
ftagius 29:0ea07cc7124b 127
ftagius 29:0ea07cc7124b 128 typedef enum {
ftagius 29:0ea07cc7124b 129 APP_NONE = 0,
ftagius 29:0ea07cc7124b 130 APP_PING,
ftagius 29:0ea07cc7124b 131 APP_CHAT,
ftagius 29:0ea07cc7124b 132 APP_HELLO,
ftagius 29:0ea07cc7124b 133 APP_CONSOLE,
ftagius 29:0ea07cc7124b 134 APP_GPS
ftagius 29:0ea07cc7124b 135 } app_e;
ftagius 29:0ea07cc7124b 136
ftagius 29:0ea07cc7124b 137 extern app_e app;
ftagius 29:0ea07cc7124b 138
ftagius 29:0ea07cc7124b 139 #endif // __MAIN_H__