EFR32 Mighty Gecko 1 Software Documentation  efr32mg1-doc-5.1.2
ezradio_api_lib.c
Go to the documentation of this file.
1 /**************************************************************************/
34 #include <stddef.h>
35 #include <stdint.h>
36 #include <stdarg.h>
37 #include "em_gpio.h"
38 #include "gpiointerrupt.h"
39 #include "ustimer.h"
40 
41 #include "ezradio_cmd.h"
42 #include "ezradio_prop.h"
43 #include "ezradio_comm.h"
44 #include "ezradio_hal.h"
45 #include "ezradio_api_lib.h"
46 
54 void ezradio_reset(void)
55 {
56  /* Initialize ustimer */
57  USTIMER_Init();
58  /* Put radio in shutdown */
60  /* Delay for 20us */
61  USTIMER_Delay( 10u );
62  /* Release radio from shutdown */
64  /* Delay for 100us */
65  USTIMER_Delay( 100u );
66  /* Clear CTS signal. */
68  /* Deinit ustimer */
70 }
71 
80 void ezradio_power_up(uint8_t boot_options, uint8_t xtal_options, uint32_t xo_freq)
81 {
82  /* EZRadio command buffer */
83  uint8_t ezradioCmd[7u];
84 
85  ezradioCmd[0] = EZRADIO_CMD_ID_POWER_UP;
86  ezradioCmd[1] = boot_options;
87  ezradioCmd[2] = xtal_options;
88  ezradioCmd[3] = (uint8_t)(xo_freq >> 24);
89  ezradioCmd[4] = (uint8_t)(xo_freq >> 16);
90  ezradioCmd[5] = (uint8_t)(xo_freq >> 8);
91  ezradioCmd[6] = (uint8_t)(xo_freq);
92 
93  ezradio_comm_SendCmd( EZRADIO_CMD_ARG_COUNT_POWER_UP, ezradioCmd );
94 }
95 
101 void ezradio_part_info(ezradio_cmd_reply_t *ezradioReply)
102 {
103  /* EZRadio command buffer */
104  uint8_t ezradioCmd[EZRADIO_CMD_REPLY_COUNT_PART_INFO];
105 
106  ezradioCmd[0] = EZRADIO_CMD_ID_PART_INFO;
107 
108  ezradio_comm_SendCmdGetResp( EZRADIO_CMD_ARG_COUNT_PART_INFO,
109  ezradioCmd,
110  EZRADIO_CMD_REPLY_COUNT_PART_INFO,
111  ezradioCmd );
112 
113  if (ezradioReply != NULL)
114  {
115  ezradioReply->PART_INFO.CHIPREV = ezradioCmd[0];
116  ezradioReply->PART_INFO.PART = (((uint16_t)ezradioCmd[1] << 8) & 0xFF00) +
117  ((uint16_t)ezradioCmd[2] & 0x00FF);
118  ezradioReply->PART_INFO.PBUILD = ezradioCmd[3];
119  ezradioReply->PART_INFO.ID = (((uint16_t)ezradioCmd[4] << 8) & 0xFF00) +
120  ((uint16_t)ezradioCmd[5] & 0x00FF);
121  ezradioReply->PART_INFO.CUSTOMER = ezradioCmd[6];
122  ezradioReply->PART_INFO.ROMID = ezradioCmd[7];
123  }
124 }
125 
132 void ezradio_start_tx(uint8_t channel, uint8_t condition, uint16_t tx_len)
133 {
134  /* EZRadio command buffer */
135  uint8_t ezradioCmd[7u];
136 
137  ezradioCmd[0] = EZRADIO_CMD_ID_START_TX;
138  ezradioCmd[1] = channel;
139  ezradioCmd[2] = condition;
140  ezradioCmd[3] = (uint8_t)(tx_len >> 8);
141  ezradioCmd[4] = (uint8_t)(tx_len);
142  ezradioCmd[5] = 0x00;
143 
144  // Don't repeat the packet,
145  // ie. transmit the packet only once
146  ezradioCmd[6] = 0x00;
147 
148  ezradio_comm_SendCmd( EZRADIO_CMD_ARG_COUNT_START_TX, ezradioCmd );
149 }
150 
161  void ezradio_start_rx(uint8_t channel, uint8_t condition, uint16_t rx_len, uint8_t next_state1, uint8_t next_state2, uint8_t next_state3)
162 {
163  /* EZRadio command buffer */
164  uint8_t ezradioCmd[8u];
165 
166  ezradioCmd[0] = EZRADIO_CMD_ID_START_RX;
167  ezradioCmd[1] = channel;
168  ezradioCmd[2] = condition;
169  ezradioCmd[3] = (uint8_t)(rx_len >> 8);
170  ezradioCmd[4] = (uint8_t)(rx_len);
171  ezradioCmd[5] = next_state1;
172  ezradioCmd[6] = next_state2;
173  ezradioCmd[7] = next_state3;
174 
175  ezradio_comm_SendCmd( EZRADIO_CMD_ARG_COUNT_START_RX, ezradioCmd );
176 }
177 
186 void ezradio_get_int_status(uint8_t ph_clr_pend, uint8_t modem_clr_pend, uint8_t chip_clr_pend,
187  ezradio_cmd_reply_t *ezradioReply)
188 {
189  /* EZRadio command buffer */
190  uint8_t ezradioCmd[EZRADIO_CMD_REPLY_COUNT_GET_INT_STATUS];
191 
192  ezradioCmd[0] = EZRADIO_CMD_ID_GET_INT_STATUS;
193  ezradioCmd[1] = ph_clr_pend;
194  ezradioCmd[2] = modem_clr_pend;
195  ezradioCmd[3] = chip_clr_pend;
196 
197  ezradio_comm_SendCmdGetResp( EZRADIO_CMD_ARG_COUNT_GET_INT_STATUS,
198  ezradioCmd,
199  EZRADIO_CMD_REPLY_COUNT_GET_INT_STATUS,
200  ezradioCmd );
201 
202  if (ezradioReply != NULL)
203  {
204  ezradioReply->GET_INT_STATUS.INT_PEND = ezradioCmd[0];
205  ezradioReply->GET_INT_STATUS.INT_STATUS = ezradioCmd[1];
206  ezradioReply->GET_INT_STATUS.PH_PEND = ezradioCmd[2];
207  ezradioReply->GET_INT_STATUS.PH_STATUS = ezradioCmd[3];
208  ezradioReply->GET_INT_STATUS.MODEM_PEND = ezradioCmd[4];
209  ezradioReply->GET_INT_STATUS.MODEM_STATUS = ezradioCmd[5];
210  ezradioReply->GET_INT_STATUS.CHIP_PEND = ezradioCmd[6];
211  ezradioReply->GET_INT_STATUS.CHIP_STATUS = ezradioCmd[7];
212  }
213 }
214 
228 void ezradio_gpio_pin_cfg(uint8_t gpio0, uint8_t gpio1, uint8_t gpio2, uint8_t gpio3, uint8_t nirq, uint8_t sdo, uint8_t gen_config,
229  ezradio_cmd_reply_t *ezradioReply)
230 {
231  /* EZRadio command buffer */
232  uint8_t ezradioCmd[EZRADIO_CMD_ARG_COUNT_GPIO_PIN_CFG];
233 
234  ezradioCmd[0] = EZRADIO_CMD_ID_GPIO_PIN_CFG;
235  ezradioCmd[1] = gpio0;
236  ezradioCmd[2] = gpio1;
237  ezradioCmd[3] = gpio2;
238  ezradioCmd[4] = gpio3;
239  ezradioCmd[5] = nirq;
240  ezradioCmd[6] = sdo;
241  ezradioCmd[7] = gen_config;
242 
243  ezradio_comm_SendCmdGetResp( EZRADIO_CMD_ARG_COUNT_GPIO_PIN_CFG,
244  ezradioCmd,
245  EZRADIO_CMD_REPLY_COUNT_GPIO_PIN_CFG,
246  ezradioCmd );
247 
248  if (ezradioReply != NULL)
249  {
250  ezradioReply->GPIO_PIN_CFG.gpIO[0] = ezradioCmd[0];
251  ezradioReply->GPIO_PIN_CFG.gpIO[1] = ezradioCmd[1];
252  ezradioReply->GPIO_PIN_CFG.gpIO[2] = ezradioCmd[2];
253  ezradioReply->GPIO_PIN_CFG.gpIO[3] = ezradioCmd[3];
254  ezradioReply->GPIO_PIN_CFG.NIRQ = ezradioCmd[4];
255  ezradioReply->GPIO_PIN_CFG.SDO = ezradioCmd[5];
256  ezradioReply->GPIO_PIN_CFG.GEN_CONFIG = ezradioCmd[6];
257  }
258 }
259 
269 #ifdef __C51__
270 #pragma maxargs (13) /* allow 13 bytes for parameters */
271 #endif
272 void ezradio_set_property( uint8_t group, uint8_t num_props, uint8_t start_prop, ... )
273 {
274  /* EZRadio command buffer */
275  uint8_t ezradioCmd[16u];
276 
277  va_list argList;
278  uint8_t cmdIndex;
279 
280  ezradioCmd[0] = EZRADIO_CMD_ID_SET_PROPERTY;
281  ezradioCmd[1] = group;
282  ezradioCmd[2] = num_props;
283  ezradioCmd[3] = start_prop;
284 
285  va_start (argList, start_prop);
286  cmdIndex = 4;
287  while(num_props--)
288  {
289  ezradioCmd[cmdIndex] = (uint8_t)va_arg (argList, int);
290  cmdIndex++;
291  }
292  va_end(argList);
293 
294  ezradio_comm_SendCmd( cmdIndex, ezradioCmd );
295 }
296 
302 void ezradio_change_state(uint8_t next_state1)
303 {
304  /* EZRadio command buffer */
305  uint8_t ezradioCmd[2u];
306 
307  ezradioCmd[0] = EZRADIO_CMD_ID_CHANGE_STATE;
308  ezradioCmd[1] = next_state1;
309 
310  ezradio_comm_SendCmd( EZRADIO_CMD_ARG_COUNT_CHANGE_STATE, ezradioCmd );
311 }
312 
313 #ifdef EZRADIO_DRIVER_EXTENDED_SUPPORT
314 /* Extended driver support functions */
315 
319 void ezradio_nop(void)
320 {
321  /* EZRadio command buffer */
322  uint8_t ezradioCmd[1u];
323 
324  ezradioCmd[0] = EZRADIO_CMD_ID_NOP;
325 
326  ezradio_comm_SendCmd( EZRADIO_CMD_ARG_COUNT_NOP, ezradioCmd );
327 }
328 
336 void ezradio_fifo_info(uint8_t fifo,
337  ezradio_cmd_reply_t *ezradioReply)
338 {
339  /* EZRadio command buffer */
340  uint8_t ezradioCmd[EZRADIO_CMD_REPLY_COUNT_FIFO_INFO];
341 
342  ezradioCmd[0] = EZRADIO_CMD_ID_FIFO_INFO;
343  ezradioCmd[1] = fifo;
344 
345  ezradio_comm_SendCmdGetResp( EZRADIO_CMD_ARG_COUNT_FIFO_INFO,
346  ezradioCmd,
347  EZRADIO_CMD_REPLY_COUNT_FIFO_INFO,
348  ezradioCmd );
349 
350  if (ezradioReply != NULL)
351  {
352  ezradioReply->FIFO_INFO.RX_FIFO_COUNT = ezradioCmd[0];
353  ezradioReply->FIFO_INFO.TX_FIFO_SPACE = ezradioCmd[1];
354  }
355 }
356 
363 void ezradio_write_tx_fifo(uint8_t numBytes, uint8_t* pTxData)
364 {
365  ezradio_comm_WriteData( EZRADIO_CMD_ID_WRITE_TX_FIFO, 0, numBytes, pTxData );
366 }
367 
374 void ezradio_read_rx_fifo(uint8_t numBytes, uint8_t* pRxData)
375 {
376  ezradio_comm_ReadData( EZRADIO_CMD_ID_READ_RX_FIFO, 0, numBytes, pRxData );
377 }
378 
387 void ezradio_get_property(uint8_t group, uint8_t num_props, uint8_t start_prop,
388  ezradio_cmd_reply_t *ezradioReply)
389 {
390  /* EZRadio command buffer */
391  uint8_t ezradioCmd[16u];
392 
393  ezradioCmd[0] = EZRADIO_CMD_ID_GET_PROPERTY;
394  ezradioCmd[1] = group;
395  ezradioCmd[2] = num_props;
396  ezradioCmd[3] = start_prop;
397 
398  ezradio_comm_SendCmdGetResp( EZRADIO_CMD_ARG_COUNT_GET_PROPERTY,
399  ezradioCmd,
400  ezradioCmd[2],
401  ezradioCmd );
402 
403  if (ezradioReply != NULL)
404  {
405  ezradioReply->GET_PROPERTY.DATA[0] = ezradioCmd[0];
406  ezradioReply->GET_PROPERTY.DATA[1] = ezradioCmd[1];
407  ezradioReply->GET_PROPERTY.DATA[2] = ezradioCmd[2];
408  ezradioReply->GET_PROPERTY.DATA[3] = ezradioCmd[3];
409  ezradioReply->GET_PROPERTY.DATA[4] = ezradioCmd[4];
410  ezradioReply->GET_PROPERTY.DATA[5] = ezradioCmd[5];
411  ezradioReply->GET_PROPERTY.DATA[6] = ezradioCmd[6];
412  ezradioReply->GET_PROPERTY.DATA[7] = ezradioCmd[7];
413  ezradioReply->GET_PROPERTY.DATA[8] = ezradioCmd[8];
414  ezradioReply->GET_PROPERTY.DATA[9] = ezradioCmd[9];
415  ezradioReply->GET_PROPERTY.DATA[10] = ezradioCmd[10];
416  ezradioReply->GET_PROPERTY.DATA[11] = ezradioCmd[11];
417  ezradioReply->GET_PROPERTY.DATA[12] = ezradioCmd[12];
418  ezradioReply->GET_PROPERTY.DATA[13] = ezradioCmd[13];
419  ezradioReply->GET_PROPERTY.DATA[14] = ezradioCmd[14];
420  ezradioReply->GET_PROPERTY.DATA[15] = ezradioCmd[15];
421  }
422 }
423 
424 #ifdef EZRADIO_DRIVER_FULL_SUPPORT
425 /* Full driver support functions */
426 
432 void ezradio_func_info(ezradio_cmd_reply_t *ezradioReply)
433 {
434  /* EZRadio command buffer */
435  uint8_t ezradioCmd[EZRADIO_CMD_REPLY_COUNT_FUNC_INFO];
436 
437  ezradioCmd[0] = EZRADIO_CMD_ID_FUNC_INFO;
438 
439  ezradio_comm_SendCmdGetResp( EZRADIO_CMD_ARG_COUNT_FUNC_INFO,
440  ezradioCmd,
441  EZRADIO_CMD_REPLY_COUNT_FUNC_INFO,
442  ezradioCmd );
443 
444  if (ezradioReply != NULL)
445  {
446  ezradioReply->FUNC_INFO.REVEXT = ezradioCmd[0];
447  ezradioReply->FUNC_INFO.REVBRANCH = ezradioCmd[1];
448  ezradioReply->FUNC_INFO.REVINT = ezradioCmd[2];
449  ezradioReply->FUNC_INFO.FUNC = ezradioCmd[5];
450  }
451 }
452 
459 void ezradio_frr_a_read(uint8_t respByteCount, ezradio_cmd_reply_t *ezradioReply)
460 {
461  /* EZRadio command buffer */
462  uint8_t ezradioCmd[4u];
463 
464  ezradio_comm_ReadData(EZRADIO_CMD_ID_FRR_A_READ,
465  0,
466  respByteCount,
467  ezradioCmd);
468 
469  if (ezradioReply != NULL)
470  {
471  ezradioReply->FRR_A_READ.FRR_A_VALUE = ezradioCmd[0];
472  ezradioReply->FRR_A_READ.FRR_B_VALUE = ezradioCmd[1];
473  ezradioReply->FRR_A_READ.FRR_C_VALUE = ezradioCmd[2];
474  ezradioReply->FRR_A_READ.FRR_D_VALUE = ezradioCmd[3];
475  }
476 }
477 
484 void ezradio_frr_b_read(uint8_t respByteCount, ezradio_cmd_reply_t *ezradioReply)
485 {
486  /* EZRadio command buffer */
487  uint8_t ezradioCmd[4u];
488 
489  ezradio_comm_ReadData(EZRADIO_CMD_ID_FRR_B_READ,
490  0,
491  respByteCount,
492  ezradioCmd);
493 
494  if (ezradioReply != NULL)
495  {
496  ezradioReply->FRR_B_READ.FRR_B_VALUE = ezradioCmd[0];
497  ezradioReply->FRR_B_READ.FRR_C_VALUE = ezradioCmd[1];
498  ezradioReply->FRR_B_READ.FRR_D_VALUE = ezradioCmd[2];
499  ezradioReply->FRR_B_READ.FRR_A_VALUE = ezradioCmd[3];
500  }
501 }
502 
509 void ezradio_frr_c_read(uint8_t respByteCount, ezradio_cmd_reply_t *ezradioReply)
510 {
511  /* EZRadio command buffer */
512  uint8_t ezradioCmd[4u];
513 
514  ezradio_comm_ReadData(EZRADIO_CMD_ID_FRR_C_READ,
515  0,
516  respByteCount,
517  ezradioCmd);
518 
519  if (ezradioReply != NULL)
520  {
521  ezradioReply->FRR_C_READ.FRR_C_VALUE = ezradioCmd[0];
522  ezradioReply->FRR_C_READ.FRR_D_VALUE = ezradioCmd[1];
523  ezradioReply->FRR_C_READ.FRR_A_VALUE = ezradioCmd[2];
524  ezradioReply->FRR_C_READ.FRR_B_VALUE = ezradioCmd[3];
525  }
526 }
527 
534 void ezradio_frr_d_read(uint8_t respByteCount, ezradio_cmd_reply_t *ezradioReply)
535 {
536  /* EZRadio command buffer */
537  uint8_t ezradioCmd[4u];
538 
539  ezradio_comm_ReadData(EZRADIO_CMD_ID_FRR_D_READ,
540  0,
541  respByteCount,
542  ezradioCmd);
543 
544  if (ezradioReply != NULL)
545  {
546  ezradioReply->FRR_D_READ.FRR_D_VALUE = ezradioCmd[0];
547  ezradioReply->FRR_D_READ.FRR_A_VALUE = ezradioCmd[1];
548  ezradioReply->FRR_D_READ.FRR_B_VALUE = ezradioCmd[2];
549  ezradioReply->FRR_D_READ.FRR_C_VALUE = ezradioCmd[3];
550  }
551 }
552 
558 void ezradio_request_device_state(ezradio_cmd_reply_t *ezradioReply)
559 {
560  /* EZRadio command buffer */
561  uint8_t ezradioCmd[EZRADIO_CMD_REPLY_COUNT_REQUEST_DEVICE_STATE];
562 
563  ezradioCmd[0] = EZRADIO_CMD_ID_REQUEST_DEVICE_STATE;
564 
565  ezradio_comm_SendCmdGetResp( EZRADIO_CMD_ARG_COUNT_REQUEST_DEVICE_STATE,
566  ezradioCmd,
567  EZRADIO_CMD_REPLY_COUNT_REQUEST_DEVICE_STATE,
568  ezradioCmd );
569 
570  if (ezradioReply != NULL)
571  {
572  ezradioReply->REQUEST_DEVICE_STATE.CURR_STATE = ezradioCmd[0];
573  ezradioReply->REQUEST_DEVICE_STATE.CURRENT_CHANNEL = ezradioCmd[1];
574  }
575 }
576 
582 void ezradio_read_cmd_buff(ezradio_cmd_reply_t *ezradioReply)
583 {
584  /* EZRadio command buffer */
585  uint8_t ezradioCmd[EZRADIO_CMD_REPLY_COUNT_READ_CMD_BUFF];
586 
587  ezradioCmd[0] = EZRADIO_CMD_ID_READ_CMD_BUFF;
588 
589  ezradio_comm_SendCmdGetResp( EZRADIO_CMD_ARG_COUNT_READ_CMD_BUFF,
590  ezradioCmd,
591  EZRADIO_CMD_REPLY_COUNT_READ_CMD_BUFF,
592  ezradioCmd );
593 
594  if (ezradioReply != NULL)
595  {
596  ezradioReply->READ_CMD_BUFF.BYTE[0] = ezradioCmd[0];
597  ezradioReply->READ_CMD_BUFF.BYTE[1] = ezradioCmd[1];
598  ezradioReply->READ_CMD_BUFF.BYTE[2] = ezradioCmd[2];
599  ezradioReply->READ_CMD_BUFF.BYTE[3] = ezradioCmd[3];
600  ezradioReply->READ_CMD_BUFF.BYTE[4] = ezradioCmd[4];
601  ezradioReply->READ_CMD_BUFF.BYTE[5] = ezradioCmd[5];
602  ezradioReply->READ_CMD_BUFF.BYTE[6] = ezradioCmd[6];
603  ezradioReply->READ_CMD_BUFF.BYTE[7] = ezradioCmd[7];
604  ezradioReply->READ_CMD_BUFF.BYTE[8] = ezradioCmd[8];
605  ezradioReply->READ_CMD_BUFF.BYTE[9] = ezradioCmd[9];
606  ezradioReply->READ_CMD_BUFF.BYTE[10] = ezradioCmd[10];
607  ezradioReply->READ_CMD_BUFF.BYTE[11] = ezradioCmd[11];
608  ezradioReply->READ_CMD_BUFF.BYTE[12] = ezradioCmd[12];
609  ezradioReply->READ_CMD_BUFF.BYTE[13] = ezradioCmd[13];
610  ezradioReply->READ_CMD_BUFF.BYTE[14] = ezradioCmd[14];
611  ezradioReply->READ_CMD_BUFF.BYTE[15] = ezradioCmd[15];
612  }
613 }
614 
621 void ezradio_get_ph_status(uint8_t ph_clr_pend, ezradio_cmd_reply_t *ezradioReply)
622 {
623  /* EZRadio command buffer */
624  uint8_t ezradioCmd[EZRADIO_CMD_REPLY_COUNT_GET_PH_STATUS];
625 
626  ezradioCmd[0] = EZRADIO_CMD_ID_GET_PH_STATUS;
627  ezradioCmd[1] = ph_clr_pend;
628 
629  ezradio_comm_SendCmdGetResp( EZRADIO_CMD_ARG_COUNT_GET_PH_STATUS,
630  ezradioCmd,
631  EZRADIO_CMD_REPLY_COUNT_GET_PH_STATUS,
632  ezradioCmd );
633 
634  if (ezradioReply != NULL)
635  {
636  ezradioReply->GET_PH_STATUS.PH_PEND = ezradioCmd[0];
637  ezradioReply->GET_PH_STATUS.PH_STATUS = ezradioCmd[1];
638  }
639 }
640 
647 void ezradio_get_modem_status( uint8_t modem_clr_pend, ezradio_cmd_reply_t *ezradioReply)
648 {
649  /* EZRadio command buffer */
650  uint8_t ezradioCmd[EZRADIO_CMD_REPLY_COUNT_GET_MODEM_STATUS];
651 
652  ezradioCmd[0] = EZRADIO_CMD_ID_GET_MODEM_STATUS;
653  ezradioCmd[1] = modem_clr_pend;
654 
655  ezradio_comm_SendCmdGetResp( EZRADIO_CMD_ARG_COUNT_GET_MODEM_STATUS,
656  ezradioCmd,
657  EZRADIO_CMD_REPLY_COUNT_GET_MODEM_STATUS,
658  ezradioCmd );
659 
660  if (ezradioReply != NULL)
661  {
662  ezradioReply->GET_MODEM_STATUS.MODEM_PEND = ezradioCmd[0];
663  ezradioReply->GET_MODEM_STATUS.MODEM_STATUS = ezradioCmd[1];
664  ezradioReply->GET_MODEM_STATUS.CURR_RSSI = ezradioCmd[2];
665  ezradioReply->GET_MODEM_STATUS.LATCH_RSSI = ezradioCmd[3];
666  ezradioReply->GET_MODEM_STATUS.ANT1_RSSI = ezradioCmd[4];
667  ezradioReply->GET_MODEM_STATUS.ANT2_RSSI = ezradioCmd[5];
668  ezradioReply->GET_MODEM_STATUS.AFC_FREQ_OFFSET = ((uint16_t)ezradioCmd[6] << 8) & 0xFF00;
669  ezradioReply->GET_MODEM_STATUS.AFC_FREQ_OFFSET |= (uint16_t)ezradioCmd[7] & 0x00FF;
670  }
671 }
672 
679 void ezradio_get_chip_status( uint8_t chip_clr_pend, ezradio_cmd_reply_t *ezradioReply)
680 {
681  /* EZRadio command buffer */
682  uint8_t ezradioCmd[EZRADIO_CMD_REPLY_COUNT_GET_CHIP_STATUS];
683 
684  ezradioCmd[0] = EZRADIO_CMD_ID_GET_CHIP_STATUS;
685  ezradioCmd[1] = chip_clr_pend;
686 
687  ezradio_comm_SendCmdGetResp( EZRADIO_CMD_ARG_COUNT_GET_CHIP_STATUS,
688  ezradioCmd,
689  EZRADIO_CMD_REPLY_COUNT_GET_CHIP_STATUS,
690  ezradioCmd );
691 
692  if (ezradioReply != NULL)
693  {
694  ezradioReply->GET_CHIP_STATUS.CHIP_PEND = ezradioCmd[0];
695  ezradioReply->GET_CHIP_STATUS.CHIP_STATUS = ezradioCmd[1];
696  ezradioReply->GET_CHIP_STATUS.CMD_ERR_STATUS = ezradioCmd[2];
697  }
698 }
699 
700 
710 void ezradio_get_packet_info(uint8_t field_number_mask, uint16_t len, int16_t diff_len, ezradio_cmd_reply_t *ezradioReply)
711 {
712  /* EZRadio command buffer */
713  uint8_t ezradioCmd[EZRADIO_CMD_ARG_COUNT_PACKET_INFO];
714 
715  ezradioCmd[0] = EZRADIO_CMD_ID_PACKET_INFO;
716  ezradioCmd[1] = field_number_mask;
717  ezradioCmd[2] = (uint8_t)(len >> 8);
718  ezradioCmd[3] = (uint8_t)(len);
719  // the different of the byte, althrough it is signed, but to command hander
720  // it can treat it as unsigned
721  ezradioCmd[4] = (uint8_t)((uint16_t)diff_len >> 8);
722  ezradioCmd[5] = (uint8_t)(diff_len);
723 
724  ezradio_comm_SendCmdGetResp( EZRADIO_CMD_ARG_COUNT_PACKET_INFO,
725  ezradioCmd,
726  EZRADIO_CMD_REPLY_COUNT_PACKET_INFO,
727  ezradioCmd );
728 
729  if (ezradioReply != NULL)
730  {
731  ezradioReply->PACKET_INFO.LENGTH = ((uint16_t)ezradioCmd[0] << 8) & 0xFF00;
732  ezradioReply->PACKET_INFO.LENGTH |= (uint16_t)ezradioCmd[1] & 0x00FF;
733  }
734 }
735 
736 
737 /*
738  * Faster versions of the above commands.
739  */
740 
745 {
746  /* EZRadio command buffer */
747  uint8_t ezradioCmd[1u];
748 
749  ezradioCmd[0] = EZRADIO_CMD_ID_START_TX;
750 
751  ezradio_comm_SendCmd( 1u, ezradioCmd );
752 }
753 
759 {
760  /* EZRadio command buffer */
761  uint8_t ezradioCmd[1u];
762 
763  ezradioCmd[0] = EZRADIO_CMD_ID_START_RX;
764 
765  ezradio_comm_SendCmd( 1u, ezradioCmd );
766 }
767 
773 {
774  /* EZRadio command buffer */
775  uint8_t ezradioCmd[1u];
776 
777  ezradioCmd[0] = EZRADIO_CMD_ID_GET_INT_STATUS;
778 
779  ezradio_comm_SendCmd( 1u, ezradioCmd );
780 }
781 
787 void ezradio_get_int_status_fast_clear_read(ezradio_cmd_reply_t *ezradioReply)
788 {
789  /* EZRadio command buffer */
790  uint8_t ezradioCmd[EZRADIO_CMD_REPLY_COUNT_GET_INT_STATUS];
791 
792  ezradioCmd[0] = EZRADIO_CMD_ID_GET_INT_STATUS;
793 
795  ezradioCmd,
796  EZRADIO_CMD_REPLY_COUNT_GET_INT_STATUS,
797  ezradioCmd );
798 
799  if (ezradioReply != NULL)
800  {
801  ezradioReply->GET_INT_STATUS.INT_PEND = ezradioCmd[0];
802  ezradioReply->GET_INT_STATUS.INT_STATUS = ezradioCmd[1];
803  ezradioReply->GET_INT_STATUS.PH_PEND = ezradioCmd[2];
804  ezradioReply->GET_INT_STATUS.PH_STATUS = ezradioCmd[3];
805  ezradioReply->GET_INT_STATUS.MODEM_PEND = ezradioCmd[4];
806  ezradioReply->GET_INT_STATUS.MODEM_STATUS = ezradioCmd[5];
807  ezradioReply->GET_INT_STATUS.CHIP_PEND = ezradioCmd[6];
808  ezradioReply->GET_INT_STATUS.CHIP_STATUS = ezradioCmd[7];
809  }
810 }
811 
817 void ezradio_gpio_pin_cfg_fast(ezradio_cmd_reply_t *ezradioReply)
818 {
819  /* EZRadio command buffer */
820  uint8_t ezradioCmd[EZRADIO_CMD_REPLY_COUNT_GPIO_PIN_CFG];
821 
822  ezradioCmd[0] = EZRADIO_CMD_ID_GPIO_PIN_CFG;
823 
825  ezradioCmd,
826  EZRADIO_CMD_REPLY_COUNT_GPIO_PIN_CFG,
827  ezradioCmd );
828 
829  if (ezradioReply != NULL)
830  {
831  ezradioReply->GPIO_PIN_CFG.gpIO[0] = ezradioCmd[0];
832  ezradioReply->GPIO_PIN_CFG.gpIO[1] = ezradioCmd[1];
833  ezradioReply->GPIO_PIN_CFG.gpIO[2] = ezradioCmd[2];
834  ezradioReply->GPIO_PIN_CFG.gpIO[3] = ezradioCmd[3];
835  ezradioReply->GPIO_PIN_CFG.NIRQ = ezradioCmd[4];
836  ezradioReply->GPIO_PIN_CFG.SDO = ezradioCmd[5];
837  ezradioReply->GPIO_PIN_CFG.GEN_CONFIG = ezradioCmd[6];
838  }
839 }
840 
841 
847 {
848  /* EZRadio command buffer */
849  uint8_t ezradioCmd[2u];
850 
851  ezradioCmd[0] = EZRADIO_CMD_ID_GET_PH_STATUS;
852  ezradioCmd[1] = 0;
853 
854  ezradio_comm_SendCmd( 2u, ezradioCmd );
855 }
856 
862 void ezradio_get_ph_status_fast_clear_read(ezradio_cmd_reply_t *ezradioReply)
863 {
864  /* EZRadio command buffer */
865  uint8_t ezradioCmd[EZRADIO_CMD_REPLY_COUNT_GET_PH_STATUS];
866 
867  ezradioCmd[0] = EZRADIO_CMD_ID_GET_PH_STATUS;
868 
870  ezradioCmd,
871  EZRADIO_CMD_REPLY_COUNT_GET_PH_STATUS,
872  ezradioCmd );
873 
874  if (ezradioReply != NULL)
875  {
876  ezradioReply->GET_PH_STATUS.PH_PEND = ezradioCmd[0];
877  ezradioReply->GET_PH_STATUS.PH_STATUS = ezradioCmd[1];
878  }
879 }
880 
886 {
887  /* EZRadio command buffer */
888  uint8_t ezradioCmd[2u];
889 
890  ezradioCmd[0] = EZRADIO_CMD_ID_GET_MODEM_STATUS;
891  ezradioCmd[1] = 0;
892 
893  ezradio_comm_SendCmd( 2u, ezradioCmd );
894 }
895 
901 void ezradio_get_modem_status_fast_clear_read(ezradio_cmd_reply_t *ezradioReply)
902 {
903  /* EZRadio command buffer */
904  uint8_t ezradioCmd[EZRADIO_CMD_REPLY_COUNT_GET_MODEM_STATUS];
905 
906  ezradioCmd[0] = EZRADIO_CMD_ID_GET_MODEM_STATUS;
907 
909  ezradioCmd,
910  EZRADIO_CMD_REPLY_COUNT_GET_MODEM_STATUS,
911  ezradioCmd );
912 
913  if (ezradioReply != NULL)
914  {
915  ezradioReply->GET_MODEM_STATUS.MODEM_PEND = ezradioCmd[0];
916  ezradioReply->GET_MODEM_STATUS.MODEM_STATUS = ezradioCmd[1];
917  ezradioReply->GET_MODEM_STATUS.CURR_RSSI = ezradioCmd[2];
918  ezradioReply->GET_MODEM_STATUS.LATCH_RSSI = ezradioCmd[3];
919  ezradioReply->GET_MODEM_STATUS.ANT1_RSSI = ezradioCmd[4];
920  ezradioReply->GET_MODEM_STATUS.ANT2_RSSI = ezradioCmd[5];
921  ezradioReply->GET_MODEM_STATUS.AFC_FREQ_OFFSET = ((uint16_t)ezradioCmd[6] << 8) & 0xFF00;
922  ezradioReply->GET_MODEM_STATUS.AFC_FREQ_OFFSET |= (uint16_t)ezradioCmd[7] & 0x00FF;
923  }
924 }
925 
931 {
932  /* EZRadio command buffer */
933  uint8_t ezradioCmd[2u];
934 
935  ezradioCmd[0] = EZRADIO_CMD_ID_GET_CHIP_STATUS;
936  ezradioCmd[1] = 0;
937 
938  ezradio_comm_SendCmd( 2u, ezradioCmd );
939 }
940 
946 void ezradio_get_chip_status_fast_clear_read(ezradio_cmd_reply_t *ezradioReply)
947 {
948  /* EZRadio command buffer */
949  uint8_t ezradioCmd[EZRADIO_CMD_REPLY_COUNT_GET_CHIP_STATUS];
950 
951  ezradioCmd[0] = EZRADIO_CMD_ID_GET_CHIP_STATUS;
952 
954  ezradioCmd,
955  EZRADIO_CMD_REPLY_COUNT_GET_CHIP_STATUS,
956  ezradioCmd );
957 
958  if (ezradioReply != NULL)
959  {
960  ezradioReply->GET_CHIP_STATUS.CHIP_PEND = ezradioCmd[0];
961  ezradioReply->GET_CHIP_STATUS.CHIP_STATUS = ezradioCmd[1];
962  ezradioReply->GET_CHIP_STATUS.CMD_ERR_STATUS = ezradioCmd[2];
963  }
964 }
965 
972 {
973  /* EZRadio command buffer */
974  uint8_t ezradioCmd[2u];
975 
976  ezradioCmd[0] = EZRADIO_CMD_ID_FIFO_INFO;
977  ezradioCmd[1] = fifo;
978 
979  ezradio_comm_SendCmd( 2u, ezradioCmd );
980 }
981 
987 void ezradio_fifo_info_fast_read(ezradio_cmd_reply_t *ezradioReply)
988 {
989  /* EZRadio command buffer */
990  uint8_t ezradioCmd[EZRADIO_CMD_REPLY_COUNT_FIFO_INFO];
991 
992  ezradioCmd[0] = EZRADIO_CMD_ID_FIFO_INFO;
993 
995  ezradioCmd,
996  EZRADIO_CMD_REPLY_COUNT_FIFO_INFO,
997  ezradioCmd );
998 
999  if (ezradioReply != NULL)
1000  {
1001  ezradioReply->FIFO_INFO.RX_FIFO_COUNT = ezradioCmd[0];
1002  ezradioReply->FIFO_INFO.TX_FIFO_SPACE = ezradioCmd[1];
1003  }
1004 }
1005 
1006 #endif /* EZRADIO_DRIVER_FULL_SUPPORT */
1007 
1008 #endif /* EZRADIO_DRIVER_EXTENDED_SUPPORT */
void ezradio_get_modem_status_fast_clear_read(ezradio_cmd_reply_t *ezradioReply)
void ezradio_get_ph_status_fast_clear_read(ezradio_cmd_reply_t *ezradioReply)
void ezradio_get_property(uint8_t group, uint8_t num_props, uint8_t start_prop, ezradio_cmd_reply_t *ezradioReply)
void ezradio_write_tx_fifo(uint8_t numBytes, uint8_t *pTxData)
void ezradio_get_modem_status_fast_clear(void)
void ezradio_comm_ClearCTS(void)
Definition: ezradio_comm.c:278
void ezradio_fifo_info_fast_reset(uint8_t fifo)
void ezradio_change_state(uint8_t next_state1)
void ezradio_fifo_info_fast_read(ezradio_cmd_reply_t *ezradioReply)
void ezradio_hal_AssertShutdown(void)
Definition: ezradio_hal.c:141
void ezradio_frr_d_read(uint8_t respByteCount, ezradio_cmd_reply_t *ezradioReply)
void ezradio_get_ph_status(uint8_t ph_clr_pend, ezradio_cmd_reply_t *ezradioReply)
This file contains the common API library of the EZRadio and EZRadioPRO families. ...
void ezradio_start_tx(uint8_t channel, uint8_t condition, uint16_t tx_len)
void ezradio_get_int_status(uint8_t ph_clr_pend, uint8_t modem_clr_pend, uint8_t chip_clr_pend, ezradio_cmd_reply_t *ezradioReply)
void ezradio_get_ph_status_fast_clear(void)
void ezradio_frr_b_read(uint8_t respByteCount, ezradio_cmd_reply_t *ezradioReply)
void ezradio_get_chip_status(uint8_t chip_clr_pend, ezradio_cmd_reply_t *ezradioReply)
Ecode_t USTIMER_Init(void)
Activate and initialize the hardware timer used to pace the 1 microsecond delay functions.
Definition: ustimer.c:139
void ezradio_part_info(ezradio_cmd_reply_t *ezradioReply)
void ezradio_get_modem_status(uint8_t modem_clr_pend, ezradio_cmd_reply_t *ezradioReply)
This file contains EZRadio HAL.
void ezradio_start_tx_fast(void)
void ezradio_frr_c_read(uint8_t respByteCount, ezradio_cmd_reply_t *ezradioReply)
void ezradio_fifo_info(uint8_t fifo, ezradio_cmd_reply_t *ezradioReply)
void ezradio_read_rx_fifo(uint8_t numBytes, uint8_t *pRxData)
void ezradio_get_int_status_fast_clear_read(ezradio_cmd_reply_t *ezradioReply)
void ezradio_get_chip_status_fast_clear_read(ezradio_cmd_reply_t *ezradioReply)
General Purpose IO (GPIO) peripheral API.
void ezradio_start_rx(uint8_t channel, uint8_t condition, uint16_t rx_len, uint8_t next_state1, uint8_t next_state2, uint8_t next_state3)
void ezradio_get_packet_info(uint8_t field_number_mask, uint16_t len, int16_t diff_len, ezradio_cmd_reply_t *ezradioReply)
void ezradio_set_property(uint8_t group, uint8_t num_props, uint8_t start_prop,...)
void ezradio_get_chip_status_fast_clear(void)
uint8_t ezradio_comm_SendCmdGetResp(uint8_t cmdByteCount, uint8_t *pCmdData, uint8_t respByteCount, uint8_t *pRespData)
Definition: ezradio_comm.c:293
Ecode_t USTIMER_DeInit(void)
Deinitialize USTIMER driver.
Definition: ustimer.c:190
void ezradio_frr_a_read(uint8_t respByteCount, ezradio_cmd_reply_t *ezradioReply)
void ezradio_power_up(uint8_t boot_options, uint8_t xtal_options, uint32_t xo_freq)
void ezradio_gpio_pin_cfg_fast(ezradio_cmd_reply_t *ezradioReply)
void ezradio_get_int_status_fast_clear(void)
void ezradio_start_rx_fast(void)
void ezradio_nop(void)
void ezradio_comm_WriteData(uint8_t cmd, uint8_t pollCts, uint8_t byteCount, uint8_t *pData)
Definition: ezradio_comm.c:207
GPIOINT API definition.
void ezradio_gpio_pin_cfg(uint8_t gpio0, uint8_t gpio1, uint8_t gpio2, uint8_t gpio3, uint8_t nirq, uint8_t sdo, uint8_t gen_config, ezradio_cmd_reply_t *ezradioReply)
Microsecond delay function API definition.
void ezradio_reset(void)
Ecode_t USTIMER_Delay(uint32_t usec)
Delay a given number of microseconds.
Definition: ustimer.c:221
void ezradio_request_device_state(ezradio_cmd_reply_t *ezradioReply)
void ezradio_comm_ReadData(uint8_t cmd, uint8_t pollCts, uint8_t byteCount, uint8_t *pData)
Definition: ezradio_comm.c:164
This file contains the EZRadio communication layer.
void ezradio_func_info(ezradio_cmd_reply_t *ezradioReply)
void ezradio_comm_SendCmd(uint8_t byteCount, uint8_t *pData)
Definition: ezradio_comm.c:140
void ezradio_hal_DeassertShutdown(void)
Definition: ezradio_hal.c:149
void ezradio_read_cmd_buff(ezradio_cmd_reply_t *ezradioReply)