EFM32 Giant Gecko Software Documentation  efm32gg-doc-5.1.2
ezradio_plugin_manager.h
Go to the documentation of this file.
1 /***************************************************************************/
34 #ifndef EZRADIO_PLUGIN_MANAGER_H_
35 #define EZRADIO_PLUGIN_MANAGER_H_
36 
37 #include "ecode.h"
38 
39 // Include the generated EzRadio application configuration file.
40 #include "app-config.h"
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
47 
48 #define RADIO_CHIP_FAMILY_EZRADIO 1u
49 #define RADIO_CHIP_FAMILY_EZRADIOPRO 2u
50 
51 #define FALSE 0u
52 #define TRUE 1u
53 
55 
56 /* Question: How to use my own radio configuration header file?
57  *
58  * Answer (Simplicity Studio): Simply open the bundled radio configurator
59  * located in the RadioConfig source group. Whenever a new header file
60  * is generated the project will reconfigure itself to use the generated
61  * instead of the default.
62  * If one is to go back to use the default radio header file, the
63  * RADIO_USE_GENERATED_CONFIGURATION macro should be removed (or set to 0)
64  * under the 'Path and Symbols' menu in the 'Properties' of the project.
65  *
66  * Answer (Other development tool: Add the following definition to your project
67  * in order to use your own generated radio configuration header file, instead
68  * of the kit default one.
69  * #define RADIO_USE_GENERATED_CONFIGURATION
70  */
71 
72 #if defined(RADIO_USE_GENERATED_CONFIGURATION) && (RADIO_USE_GENERATED_CONFIGURATION == 1)
73 /* Include the generated radio configuration */
74 #include "radio-config-wds-gen.h"
75 #else
76 /* Include the default radio configuration for the board */
77 #if defined(SL_WSTK6200A) || defined(SL_WSTK6220A)
78 #include "radio-config-wds-gen_R60-868MHz-13dBm.h"
79 #elif defined(SL_WSTK6240A)
80 #include "radio-config-wds-gen_R68-868MHz-16dBm.h"
81 #elif defined(SL_WSTK6201A) || defined(SL_WSTK6221A) || defined(SL_WSTK6241A)
82 #include "radio-config-wds-gen_R55-434MHz-10dBm.h"
83 #elif defined(SL_WSTK6202A) || defined(SL_WSTK6222A)
84 #include "radio-config-wds-gen_R63-915MHz-20dBm.h"
85 #elif defined(SL_WSTK6242A)
86 #include "radio-config-wds-gen_R68-915MHz-20dBm.h"
87 #elif defined(SL_WSTK6223A) || defined(SL_WSTK6243A)
88 #include "radio-config-wds-gen_R63-490MHz-20dBm.h"
89 #elif defined(SL_WSTK6224A) || defined(SL_WSTK6244A)
90 #include "radio-config-wds-gen_R63-169MHz-20dBm.h"
91 #else
92 #error No radio configuration is defined! Create your own radio configuration or define your kit properly!
93 #endif
94 #endif
95 
96 /***************************************************************************/
101 /***************************************************************************/
106 /***************************************************************************/
113 /***************************************************************************/
120 // Error code definitions of EZRadioDrv
121 #define ECODE_EMDRV_EZRADIODRV_OK ( ECODE_OK )
122 #define ECODE_EMDRV_EZRADIODRV_ILLEGAL_HANDLE ( ECODE_EMDRV_EZRADIODRV_BASE | 0x00000001 )
123 
124 #define ECODE_EMDRV_EZRADIODRV_TRANSMIT_PLUGIN_BASE ( ECODE_EMDRV_EZRADIODRV_BASE | 0x00000100 )
125 #define ECODE_EMDRV_EZRADIODRV_RECEIVE_PLUGIN_BASE ( ECODE_EMDRV_EZRADIODRV_BASE | 0x00000200 )
126 #define ECODE_EMDRV_EZRADIODRV_CRC_ERROR_PLUGIN_BASE ( ECODE_EMDRV_EZRADIODRV_BASE | 0x00000300 )
127 #define ECODE_EMDRV_EZRADIODRV_AUTO_ACK_PLUGIN_BASE ( ECODE_EMDRV_EZRADIODRV_BASE | 0x00000400 )
128 #define ECODE_EMDRV_EZRADIODRV_UNMOD_CARRIER_PLUGIN_BASE ( ECODE_EMDRV_EZRADIODRV_BASE | 0x00000500 )
129 #define ECODE_EMDRV_EZRADIODRV_PN9_PLUGIN_BASE ( ECODE_EMDRV_EZRADIODRV_BASE | 0x00000600 )
130 #define ECODE_EMDRV_EZRADIODRV_DIRECT_TRANSMIT_PLUGIN_BASE ( ECODE_EMDRV_EZRADIODRV_BASE | 0x00000700 )
131 #define ECODE_EMDRV_EZRADIODRV_DIRECT_RECEIVE_PLUGIN_BASE ( ECODE_EMDRV_EZRADIODRV_BASE | 0x00000800 )
132 
133 
134 #if !defined(RADIO_CONFIGURATION_DATA_RADIO_CHIP_FAMILY)
135 #error RADIO_CONFIGURATION_DATA_RADIO_CHIP_FAMILY is not defined!
136 #elif ( !(RADIO_CONFIGURATION_DATA_RADIO_CHIP_FAMILY == RADIO_CHIP_FAMILY_EZRADIO) && !(RADIO_CONFIGURATION_DATA_RADIO_CHIP_FAMILY == RADIO_CHIP_FAMILY_EZRADIOPRO) )
137 #error RADIO_CONFIGURATION_DATA_RADIO_CHIP_FAMILY is not defined properly!
138 #endif
139 
140 
141 #if defined(EZRADIO_PLUGIN_TRANSMIT) || defined(EZRADIO_PLUGIN_RECEIVE)
142 // Radio packet field length array definition for various radio chip families
143 #if (RADIO_CONFIGURATION_DATA_RADIO_CHIP_FAMILY == RADIO_CHIP_FAMILY_EZRADIO)
144 #define RADIO_CONFIG_DATA_FIELD_LENGTH \
145  { \
146  RADIO_CONFIG_DATA_FIELD1_LENGTH, \
147  0u, \
148  0u, \
149  0u, \
150  0u, \
151  }
152 #elif (RADIO_CONFIGURATION_DATA_RADIO_CHIP_FAMILY == RADIO_CHIP_FAMILY_EZRADIOPRO)
153 #define RADIO_CONFIG_DATA_FIELD_LENGTH \
154  { \
155  RADIO_CONFIG_DATA_FIELD1_LENGTH, \
156  RADIO_CONFIG_DATA_FIELD2_LENGTH, \
157  RADIO_CONFIG_DATA_FIELD3_LENGTH, \
158  RADIO_CONFIG_DATA_FIELD4_LENGTH, \
159  RADIO_CONFIG_DATA_FIELD5_LENGTH \
160  }
161 #endif
162 
163 // Max radio packet length definition for various radio chip families
164 #if (RADIO_CONFIGURATION_DATA_RADIO_CHIP_FAMILY == RADIO_CHIP_FAMILY_EZRADIO)
165 #define RADIO_CONFIG_DATA_MAX_PACKET_LENGTH RADIO_CONFIG_DATA_FIELD1_LENGTH
166 #elif (RADIO_CONFIGURATION_DATA_RADIO_CHIP_FAMILY == RADIO_CHIP_FAMILY_EZRADIOPRO)
167 #define RADIO_CONFIG_DATA_MAX_PACKET_LENGTH \
168  RADIO_CONFIG_DATA_FIELD1_LENGTH + \
169  RADIO_CONFIG_DATA_FIELD2_LENGTH + \
170  RADIO_CONFIG_DATA_FIELD3_LENGTH + \
171  RADIO_CONFIG_DATA_FIELD4_LENGTH + \
172  RADIO_CONFIG_DATA_FIELD5_LENGTH
173 #endif
174 #endif //#if ( defined( EZRADIO_PLUGIN_TRANSMIT ) || defined( EZRADIO_PLUGIN_RECEIVE ) )
175 
176 // Various build time error messages, to make sure, that all necessary definitions are defined properly.
177 #if ( defined(RADIO_CONFIGURATION_DATA_PKT_VARIABLE_PACKET_LENGTH_ENABLE ) && (RADIO_CONFIGURATION_DATA_PKT_VARIABLE_PACKET_LENGTH_ENABLE > 0) )
178 
179 #if (RADIO_CONFIGURATION_DATA_RADIO_CHIP_FAMILY == RADIO_CHIP_FAMILY_EZRADIO)
180 #if ( !defined(RADIO_CONFIGURATION_DATA_PKT_VARIABLE_LENGTH_FIELD ) || !(RADIO_CONFIGURATION_DATA_PKT_VARIABLE_LENGTH_FIELD == 1))
181 #error RADIO_CONFIGURATION_DATA_PKT_VARIABLE_LENGTH_FIELD is not defined properly!
182 #endif
183 #elif (RADIO_CONFIGURATION_DATA_RADIO_CHIP_FAMILY == RADIO_CHIP_FAMILY_EZRADIOPRO)
184 #if ( !defined(RADIO_CONFIGURATION_DATA_PKT_VARIABLE_LENGTH_FIELD ) || (RADIO_CONFIGURATION_DATA_PKT_VARIABLE_LENGTH_FIELD < 2) || (RADIO_CONFIGURATION_DATA_PKT_VARIABLE_LENGTH_FIELD > 5) )
185 #error RADIO_CONFIGURATION_DATA_PKT_VARIABLE_LENGTH_FIELD is not defined properly!
186 #endif
187 #endif
188 
189 #if !defined(RADIO_CONFIGURATION_DATA_PH_FIELD_SPLIT) || (RADIO_CONFIGURATION_DATA_PH_FIELD_SPLIT == FALSE)
190 #error EzRadio plugin manager can only support variable packet configuration for split packets curently!
191 #endif
192 
193 #if defined(RADIO_CONFIGURATION_DATA_PKT_LEN_ADD_TO_RX_FIFO) && (RADIO_CONFIGURATION_DATA_PKT_LEN_ADD_TO_RX_FIFO > 0)
194 
195 #if (RADIO_CONFIGURATION_DATA_RADIO_CHIP_FAMILY == RADIO_CHIP_FAMILY_EZRADIO)
196 #if !defined(RADIO_CONFIGURATION_DATA_PKT_FIELD_CONTAINING_LENGTH ) || !(RADIO_CONFIGURATION_DATA_PKT_FIELD_CONTAINING_LENGTH == 1)
197 #error RADIO_CONFIGURATION_DATA_PKT_FIELD_CONTAINING_LENGTH is not defined properly!
198 #endif
199 #elif (RADIO_CONFIGURATION_DATA_RADIO_CHIP_FAMILY == RADIO_CHIP_FAMILY_EZRADIOPRO)
200 #if !defined(RADIO_CONFIGURATION_DATA_PKT_FIELD_CONTAINING_LENGTH ) || (RADIO_CONFIGURATION_DATA_PKT_FIELD_CONTAINING_LENGTH < 1) || (RADIO_CONFIGURATION_DATA_PKT_FIELD_CONTAINING_LENGTH > 4)
201 #error RADIO_CONFIGURATION_DATA_PKT_FIELD_CONTAINING_LENGTH is not defined properly!
202 #endif
203 #endif
204 
205 #if (RADIO_CONFIGURATION_DATA_RADIO_CHIP_FAMILY == RADIO_CHIP_FAMILY_EZRADIO)
206 #if !defined(RADIO_CONFIGURATION_DATA_PKT_LENGTH_SIZE ) || !(RADIO_CONFIGURATION_DATA_PKT_LENGTH_SIZE == 1)
207 #error RADIO_CONFIGURATION_DATA_PKT_LENGTH_SIZE is not defined properly!
208 #endif
209 #elif (RADIO_CONFIGURATION_DATA_RADIO_CHIP_FAMILY == RADIO_CHIP_FAMILY_EZRADIOPRO)
210 #if !defined(RADIO_CONFIGURATION_DATA_PKT_LENGTH_SIZE ) || (RADIO_CONFIGURATION_DATA_PKT_LENGTH_SIZE < 1) || (RADIO_CONFIGURATION_DATA_PKT_LENGTH_SIZE > 2)
211 #error RADIO_CONFIGURATION_DATA_PKT_LENGTH_SIZE is not defined properly!
212 #endif
213 #endif
214 
215 #if (RADIO_CONFIGURATION_DATA_RADIO_CHIP_FAMILY == RADIO_CHIP_FAMILY_EZRADIO)
216 #define EZRADIO_LENGTH_WORD_START 0u
217 
218 #elif (RADIO_CONFIGURATION_DATA_RADIO_CHIP_FAMILY == RADIO_CHIP_FAMILY_EZRADIOPRO)
219 #if (RADIO_CONFIGURATION_DATA_PKT_FIELD_CONTAINING_LENGTH == 1)
220 #define EZRADIO_LENGTH_WORD_START 0u
221 
222 #elif (RADIO_CONFIGURATION_DATA_PKT_FIELD_CONTAINING_LENGTH == 2)
223 #define EZRADIO_LENGTH_WORD_START RADIO_CONFIG_DATA_FIELD1_LENGTH
224 
225 #elif (RADIO_CONFIGURATION_DATA_PKT_FIELD_CONTAINING_LENGTH == 3)
226 #define EZRADIO_LENGTH_WORD_START (RADIO_CONFIG_DATA_FIELD1_LENGTH + RADIO_CONFIG_DATA_FIELD2_LENGTH)
227 
228 #elif (RADIO_CONFIGURATION_DATA_PKT_FIELD_CONTAINING_LENGTH == 4)
229 #define EZRADIO_LENGTH_WORD_START (RADIO_CONFIG_DATA_FIELD1_LENGTH + RADIO_CONFIG_DATA_FIELD2_LENGTH + RADIO_CONFIG_DATA_FIELD3_LENGTH)
230 
231 #endif // RADIO_CONFIGURATION_DATA_PKT_FIELD_CONTAINING_LENGTH
232 #endif //#elif (RADIO_CONFIGURATION_DATA_RADIO_CHIP_FAMILY == RADIO_CHIP_FAMILY_EZRADIOPRO)
233 
234 #else //#if defined(RADIO_CONFIGURATION_DATA_PKT_LEN_ADD_TO_RX_FIFO) && (RADIO_CONFIGURATION_DATA_PKT_LEN_ADD_TO_RX_FIFO > 0)
235 #undef RADIO_CONFIGURATION_DATA_PKT_LENGTH_SIZE
236 #define RADIO_CONFIGURATION_DATA_PKT_LENGTH_SIZE 0u
237 #endif //#if defined(RADIO_CONFIGURATION_DATA_PKT_LEN_ADD_TO_RX_FIFO) && (RADIO_CONFIGURATION_DATA_PKT_LEN_ADD_TO_RX_FIFO > 0)
238 
239 #if (RADIO_CONFIGURATION_DATA_RADIO_CHIP_FAMILY == RADIO_CHIP_FAMILY_EZRADIO)
240 #define EZRADIO_VARIABLE_DATA_START RADIO_CONFIGURATION_DATA_PKT_LENGTH_SIZE
241 
242 #elif (RADIO_CONFIGURATION_DATA_RADIO_CHIP_FAMILY == RADIO_CHIP_FAMILY_EZRADIOPRO)
243 #if (RADIO_CONFIGURATION_DATA_PKT_VARIABLE_LENGTH_FIELD == 2)
244 #define EZRADIO_VARIABLE_DATA_START RADIO_CONFIG_DATA_FIELD1_LENGTH
245 
246 #elif (RADIO_CONFIGURATION_DATA_PKT_VARIABLE_LENGTH_FIELD == 3)
247 #define EZRADIO_VARIABLE_DATA_START (RADIO_CONFIG_DATA_FIELD1_LENGTH + RADIO_CONFIG_DATA_FIELD2_LENGTH)
248 
249 #elif (RADIO_CONFIGURATION_DATA_PKT_VARIABLE_LENGTH_FIELD == 4)
250 #define EZRADIO_VARIABLE_DATA_START (RADIO_CONFIG_DATA_FIELD1_LENGTH + RADIO_CONFIG_DATA_FIELD2_LENGTH + RADIO_CONFIG_DATA_FIELD3_LENGTH)
251 
252 #elif (RADIO_CONFIGURATION_DATA_PKT_VARIABLE_LENGTH_FIELD == 5)
253 #define EZRADIO_VARIABLE_DATA_START (RADIO_CONFIG_DATA_FIELD1_LENGTH + RADIO_CONFIG_DATA_FIELD2_LENGTH + RADIO_CONFIG_DATA_FIELD3_LENGTH + RADIO_CONFIG_DATA_FIELD4_LENGTH)
254 
255 #endif // RADIO_CONFIGURATION_DATA_PKT_VARIABLE_LENGTH_FIELD
256 #endif //#elif (RADIO_CONFIGURATION_DATA_RADIO_CHIP_FAMILY == RADIO_CHIP_FAMILY_EZRADIOPRO)
257 
258 #else //#if defined(RADIO_CONFIGURATION_DATA_PKT_VARIABLE_PACKET_LENGTH_ENABLE ) && (RADIO_CONFIGURATION_DATA_PKT_VARIABLE_PACKET_LENGTH_ENABLE > 0)
259 /* Note: Neither EZRADIO_LENGTH_WORD_START or EZRADIO_VARIABLE_DATA_START is defined, so application knows
260  * that incoming data starts at the really beginning of the packet. */
261 #endif //#if defined(RADIO_CONFIGURATION_DATA_PKT_VARIABLE_PACKET_LENGTH_ENABLE ) && (RADIO_CONFIGURATION_DATA_PKT_VARIABLE_PACKET_LENGTH_ENABLE > 0)
262 
264 struct EZRADIODRV_HandleData;
265 
268 
271 
273 typedef ezradio_cmd_reply_t * EZRADIODRV_ReplyHandle_t;
274 
275 /***************************************************************************/
284 typedef void (*EZRADIODRV_Callback_t)( EZRADIODRV_Handle_t handle,
285  Ecode_t status );
286 
287 // Inclusion of all the underlying EzRadio plug-in headers.
288 #include "ezradio_transmit_plugin.h"
289 #include "ezradio_receive_plugin.h"
290 #include "ezradio_crcerror_plugin.h"
291 #include "ezradio_auto_ack_plugin.h"
293 #include "ezradio_pn9_plugin.h"
296 
297 
306 {
307 
308 #if defined(EZRADIO_PLUGIN_TRANSMIT)
310 #endif
311 
312 #if defined(EZRADIO_PLUGIN_RECEIVE)
314 #endif
315 
316 #if defined(EZRADIO_PLUGIN_CRC_ERROR)
318 #endif
319 
320 #if defined(EZRADIO_PLUGIN_AUTO_ACK) && defined(EZRADIO_PLUGIN_TRANSMIT) && defined(EZRADIO_PLUGIN_RECEIVE)
322 #endif
323 
324 #if defined(EZRADIO_PLUGIN_UNMOD_CARRIER)
326 #endif
327 
328 #if defined(EZRADIO_PLUGIN_PN9)
330 #endif
331 
332 #if defined(EZRADIO_PLUGIN_DIRECT_TRANSMIT)
334 #endif
335 
336 #if defined(EZRADIO_PLUGIN_DIRECT_RECEIVE)
338 #endif
339 
340 };
341 
342 
344 #define EZRADIODRV_INIT_DEFAULT \
345 { \
346  EZRADIODRV_TRANSMIT_PLUGIN_INIT_DEFAULT /* Tx plugin init */ \
347  EZRADIODRV_RECEIVE_PLUGIN_INIT_DEFAULT /* Rx plugin init */ \
348  EZRADIODRV_CRC_ERROR_PLUGIN_INIT_DEFAULT /* CRC error plugin init */ \
349  EZRADIODRV_AUTO_ACK_PLUGIN_INIT_DEFAULT /* Auto-ack plugin init */ \
350  EZRADIODRV_UNMOD_CARRIER_PLUGIN_INIT_DEFAULT /* CW plugin init */ \
351  EZRADIODRV_PN9_PLUGIN_INIT_DEFAULT /* PN9 plugin init */ \
352  EZRADIODRV_DIRECT_TRANSMIT_PLUGIN_INIT_DEFAULT /* Direct Tx plugin init */ \
353  EZRADIODRV_DIRECT_RECEIVE_PLUGIN_INIT_DEFAULT /* Direct Rx plugin init */ \
354 }
355 
356 void ezradioInit( EZRADIODRV_Handle_t handle );
357 Ecode_t ezradioPluginManager( EZRADIODRV_Handle_t handle );
358 void ezradioResetTRxFifo(void);
359 
365 #ifdef __cplusplus
366 }
367 #endif
368 
369 #endif /* EZRADIO_PLUGIN_MANAGER_H_ */
void ezradioResetTRxFifo(void)
Resets both the TX and RX FIFOs.
void ezradioInit(EZRADIODRV_Handle_t handle)
Radio Initialization.
EZRADIODRV_PacketTxHandle_t packetTx
Packet transmission plug-in handler.
EzRadio transmit plug-in managed by the plug-in manager if enabled.
EzRadio auto acknowledge plug-in managed by the plug-in manager if enabled.
EZRADIODRV_PacketCrcErrorHandle_t packetCrcError
Packet reception with CRC error plug-in handler.
EZRADIODRV_UnmodCarrierHandle_t unmodCarrier
Unmodulated carrier plug-in handler.
Energy Aware drivers error code definitions.
EzRadio direct transmission plug-in managed by the plug-in manager if enabled.
EzRadio transmit plug-in managed by the plug-in manager if enabled.
EzRadio PN9 plug-in instance initialization and handler structure.
EZRADIODRV_AutoAckHandle_t autoAck
Auto-acknowledge plug-in handler.
EZRADIODRV_DirectRxHandle_t directRx
Direct reception plug-in handler.
EZRADIODRV_Pn9Handle_t pn9
PN9 plug-in handler.
EZRADIODRV_HandleData_t * EZRADIODRV_Handle_t
EZRadio driver instance handle.
EzRadio PN9 plug-in managed by the plug-in manager if enabled.
uint32_t Ecode_t
Typedef for API function error code return values.
Definition: ecode.h:51
EzRadio transmit plug-in instance initialization and handler structure.
EzRadio CRC error packet receive plug-in instance initialization and handler structure.
void(* EZRADIODRV_Callback_t)(EZRADIODRV_Handle_t handle, Ecode_t status)
EZRADIODRV feature callback function interface.
EZRADIODRV_DirectTxHandle_t directTx
Direct transmission plug-in handler.
EZRADIODRV_PacketRxHandle_t packetRx
Packet reception plug-in handler.
EzRadio auto acknowledge plug-in instance initialization and handler structure.
EzRadio receive plug-in instance initialization and handler structure.
EzRadio direct rx plug-in instance initialization and handler structure.
EzRadio unmodulated carrier plug-in instance initialization and handler structure.
EzRadio direct reception plug-in managed by the plug-in manager if enabled.
EzRadio direct tx plug-in instance initialization and handler structure.
ezradio_cmd_reply_t * EZRADIODRV_ReplyHandle_t
EZradio reply union handle.
EzRadio unmodulated carrier plug-in managed by the plug-in manager if enabled.
EzRadio CRC error plug-in managed by the plug-in manager if enabled.
Ecode_t ezradioPluginManager(EZRADIODRV_Handle_t handle)
EzRadio plugin manager state machine handler. This function should be called in the application in an...