Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
radio.h
00001 #include "sx12xx.h" 00002 00003 #ifdef SX127x_H 00004 #include "sx127x_lora.h" 00005 #include "sx127x_fsk.h" 00006 #endif /* SX127x_H */ 00007 00008 #define PA_OFF_DBM -127 00009 00010 typedef enum { 00011 _READ_, 00012 _WRITE_ 00013 } action_e; 00014 00015 typedef struct { 00016 uint8_t row; 00017 uint8_t col; 00018 } pos_t; 00019 00020 #define _ITEM_VALUE 0xbb 00021 #define _ITEM_DROPDOWN 0xaa 00022 #define _ITEM_BUTTON 0xcc 00023 #define _ITEM_TOGGLE 0xdd 00024 00025 typedef enum { 00026 MENUMODE_NONE = 0, 00027 MENUMODE_ENTRY, 00028 MENUMODE_DROPDOWN, 00029 MENUMODE_REDRAW, 00030 MENUMODE_REINIT_MENU, 00031 } menuMode_e; 00032 00033 typedef struct { 00034 uint8_t itemType; 00035 00036 const char* const * printed_strs; // displayed values index from read callback return 00037 const char* const * selectable_strs; // choices 00038 00039 unsigned (*const read)(bool forWriting); 00040 menuMode_e (*const write)(unsigned); 00041 } dropdown_item_t; 00042 00043 typedef struct { 00044 uint8_t itemType; 00045 00046 unsigned width; // num columns printed 00047 00048 void (*const print)(void); 00049 bool (*const write)(const char*); // NULL for read-only. return true: redraw menu 00050 } value_item_t; 00051 00052 typedef struct { 00053 uint8_t itemType; 00054 00055 const char * const label; 00056 void (*const push)(void); 00057 } button_item_t; 00058 00059 typedef struct { 00060 uint8_t itemType; 00061 00062 const char * const label0; 00063 const char * const label1; 00064 bool (*const read)(void); 00065 bool (*const push)(void); 00066 } toggle_item_t; 00067 00068 #define FLAG_MSGTYPE_ALL 0x07 00069 #define FLAG_MSGTYPE_PKT 0x01 00070 #define FLAG_MSGTYPE_PER 0x02 00071 #define FLAG_MSGTYPE_PING 0x04 00072 00073 typedef struct { 00074 pos_t pos; // on screen position, both row & col with 1 starting value 00075 const char* const label; 00076 00077 const void* const itemPtr; 00078 00079 uint8_t flags; 00080 00081 const void* refreshReadItem; 00082 } menu_t; 00083 #define FIRST_CHIP_MENU_ROW 3 00084 00085 00086 typedef struct { 00087 menuMode_e mode; 00088 uint8_t sel_idx; 00089 const menu_t* sm; 00090 uint8_t dropdown_col; 00091 } menuState_t; 00092 00093 extern menuState_t menuState; 00094 #define MAX_MENU_COLUMNS 6 00095 extern menu_t* menu[][MAX_MENU_COLUMNS]; 00096 extern int8_t StopMenuCols[]; 00097 00098 extern uint8_t entry_buf_idx; 00099 extern char entry_buf[]; 00100 00101 void log_printf(const char* format, ...); 00102 00103 typedef struct 00104 { 00105 void (*const TxDone_botHalf)(void); // read irqAt for timestamp of interrupt 00106 void (*const RxDone)(uint8_t size, float rssi, float snr); // read radio.rx_buf for payload, irqAt for timestamp of interrupt 00107 } RadioEvents_t; 00108 00109 class Radio { 00110 public: 00111 static const char* const chipNum_str; 00112 00113 static void boardInit(const RadioEvents_t* e); 00114 static void hw_reset(void); 00115 static void clearIrqFlags(void); 00116 static void readChip(void); 00117 static void tx_carrier(void); 00118 static void tx_preamble(void); 00119 static void txPkt(void); 00120 static void Rx(void); 00121 static void setFS(void); 00122 00123 static const value_item_t tx_dbm_item; 00124 00125 static const menu_t* get_modem_menu(void); 00126 static const menu_t* get_modem_sub_menu(void); 00127 00128 static unsigned pktType_read(bool); 00129 static menuMode_e pktType_write(unsigned); 00130 static const char* const pktType_strs[]; 00131 00132 static void tx_dbm_print(void); 00133 static bool tx_dbm_write(const char*); 00134 00135 static unsigned tx_ramp_read(bool); 00136 static menuMode_e tx_ramp_write(unsigned); 00137 static const char* tx_ramp_strs[]; 00138 00139 static const char* const opmode_status_strs[]; 00140 static const char* const opmode_select_strs[]; 00141 static unsigned opmode_read(bool); 00142 static menuMode_e opmode_write(unsigned); 00143 00144 static uint8_t get_payload_length(void); 00145 static void set_payload_length(uint8_t); 00146 00147 static void tx_payload_length_print(void); 00148 static bool tx_payload_length_write(const char*); 00149 #ifdef SX127x_H 00150 static SX127x radio; 00151 static SX127x_lora lora; 00152 static SX127x_fsk fsk; 00153 static void rfsw_callback(void); 00154 static void ocp(uint8_t ma); 00155 static InterruptIn dio0; 00156 static InterruptIn dio1; 00157 #elif defined(SX126x_H) 00158 static SX126x radio; 00159 static ModulationParams_t mpFSK, mpLORA; 00160 static PacketParams_t ppFSK, ppLORA; 00161 #elif defined(SX128x_H) 00162 static SX128x radio; 00163 static uint8_t tx_param_buf[]; 00164 static ModulationParams_t mpFLRC, mpBLE_GFSK, mpLORA; 00165 static PacketParams_t ppGFSK, ppFLRC, ppLORA, ppBLE; 00166 #else 00167 #error import radio driver library 00168 #endif 00169 static bool service(int8_t); 00170 static const menu_t common_menu[]; 00171 00172 static void test(void); 00173 00174 static unsigned read_register(unsigned); 00175 static void write_register(unsigned, unsigned); 00176 00177 private: 00178 static const RadioEvents_t* RadioEvents; 00179 00180 static void txDoneBottom(void); 00181 00182 static const menu_t lora_menu[]; 00183 00184 static LowPowerTimer lpt; 00185 00186 #if defined(SX128x_H) 00187 #include "radio_sx128x_private.h" 00188 #elif defined(SX127x_H) 00189 #include "radio_sx127x_private.h" 00190 #elif defined(SX126x_H) 00191 #include "radio_sx126x_private.h" 00192 #endif 00193 }; 00194 00195 extern RawSerial pc; 00196
Generated on Tue Jul 12 2022 16:29:49 by
1.7.2