EFR32 Mighty Gecko 1 Software Documentation  efr32mg1-doc-5.1.2
ezradio_api_lib_add.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 
40 #include "ezradio_cmd.h"
41 #include "ezradio_prop.h"
42 #include "ezradio_comm.h"
43 #include "ezradio_hal.h"
44 #include "ezradio_api_lib.h"
45 #include "ezradio_api_lib_add.h"
46 
54 {
55  /* EZRadio command buffer */
56  uint8_t ezradioCmd[16u];
57  ezradio_cmd_reply_t ezradioReply;
58 
59  uint8_t col;
60  uint8_t response;
61  uint8_t numOfBytes;
62 
63  /* While cycle as far as the pointer points to a command */
64  while (*pSetPropCmd != 0x00)
65  {
66  /* Commands structure in the array:
67  * --------------------------------
68  * LEN | <LEN length of data>
69  */
70 
71  numOfBytes = *pSetPropCmd++;
72 
73  if (numOfBytes > 16u)
74  {
75  /* Number of command bytes exceeds maximal allowable length */
77  }
78 
79  for (col = 0u; col < numOfBytes; col++)
80  {
81  ezradioCmd[col] = *pSetPropCmd;
82  pSetPropCmd++;
83  }
84 
85  if (ezradio_comm_SendCmdGetResp(numOfBytes, ezradioCmd, 1, &response) != 0xFF)
86  {
87  /* Timeout occured */
89  }
90 
91  if (ezradio_hal_NirqLevel() == 0)
92  {
93  /* Get and clear all interrupts. An error has occured... */
94  ezradio_get_int_status(0, 0, 0, &ezradioReply);
95  if (ezradioReply.GET_INT_STATUS.CHIP_PEND & EZRADIO_CMD_GET_CHIP_STATUS_REP_CHIP_PEND_CMD_ERROR_PEND_MASK)
96  {
98  }
99  }
100  }
101 
102  return EZRADIO_CONFIG_SUCCESS;
103 }
104 
105 #ifdef EZRADIO_DRIVER_EXTENDED_SUPPORT
106 /* Extended driver support functions */
107 
108 #ifdef EZRADIO_DRIVER_FULL_SUPPORT
109 /* Full driver support functions */
110 
118 void ezradio_get_adc_reading( uint8_t adc_en, uint8_t adc_cfg, ezradio_cmd_reply_t *ezradioReply )
119 {
120  /* EZRadio command buffer */
121  uint8_t ezradioCmd[EZRADIO_CMD_REPLY_COUNT_GET_ADC_READING];
122 
123  ezradioCmd[0] = EZRADIO_CMD_ID_GET_ADC_READING;
124  ezradioCmd[1] = adc_en;
125  ezradioCmd[2] = adc_cfg;
126 
127  ezradio_comm_SendCmdGetResp( EZRADIO_CMD_ARG_COUNT_GET_ADC_READING,
128  ezradioCmd,
129  EZRADIO_CMD_REPLY_COUNT_GET_ADC_READING,
130  ezradioCmd );
131 
132  if (ezradioReply != NULL)
133  {
134  ezradioReply->GET_ADC_READING.GPIO_ADC = ((uint16_t)ezradioCmd[0] << 8) & 0xFF00;
135  ezradioReply->GET_ADC_READING.GPIO_ADC |= (uint16_t)ezradioCmd[1] & 0x00FF;
136  ezradioReply->GET_ADC_READING.BATTERY_ADC = ((uint16_t)ezradioCmd[2] << 8) & 0xFF00;
137  ezradioReply->GET_ADC_READING.BATTERY_ADC |= (uint16_t)ezradioCmd[3] & 0x00FF;
138  ezradioReply->GET_ADC_READING.TEMP_ADC = ((uint16_t)ezradioCmd[4] << 8) & 0xFF00;
139  ezradioReply->GET_ADC_READING.TEMP_ADC |= (uint16_t)ezradioCmd[5] & 0x00FF;
140  }
141 }
142 
151 void ezradio_ircal(uint8_t searching_step_size, uint8_t searching_rssi_avg, uint8_t rx_chain_setting1, uint8_t rx_chain_setting2)
152 {
153  /* EZRadio command buffer */
154  uint8_t ezradioCmd[5u];
155 
156  ezradioCmd[0] = EZRADIO_CMD_ID_IRCAL;
157  ezradioCmd[1] = searching_step_size;
158  ezradioCmd[2] = searching_rssi_avg;
159  ezradioCmd[3] = rx_chain_setting1;
160  ezradioCmd[4] = rx_chain_setting2;
161 
162  ezradio_comm_SendCmd( EZRADIO_CMD_ARG_COUNT_IRCAL, ezradioCmd);
163 }
164 
172 void ezradio_ircal_manual(uint8_t ircal_amp, uint8_t ircal_ph, ezradio_cmd_reply_t *ezradioReply )
173 {
174  /* EZRadio command buffer */
175  uint8_t ezradioCmd[EZRADIO_CMD_ARG_COUNT_IRCAL_MANUAL];
176 
177  ezradioCmd[0] = EZRADIO_CMD_ID_IRCAL_MANUAL;
178  ezradioCmd[1] = ircal_amp;
179  ezradioCmd[2] = ircal_ph;
180 
181  ezradio_comm_SendCmdGetResp( EZRADIO_CMD_ARG_COUNT_IRCAL_MANUAL,
182  ezradioCmd,
183  EZRADIO_CMD_REPLY_COUNT_IRCAL_MANUAL,
184  ezradioCmd );
185 
186  if (ezradioReply != NULL)
187  {
188  ezradioReply->IRCAL_MANUAL.IRCAL_AMP_REPLY = ezradioCmd[0];
189  ezradioReply->IRCAL_MANUAL.IRCAL_PH_REPLY = ezradioCmd[1];
190  }
191 }
192 
205 void ezradio_tx_hop(uint8_t inte, uint8_t frac2, uint8_t frac1, uint8_t frac0, uint8_t vco_cnt1, uint8_t vco_cnt0, uint8_t pll_settle_time1, uint8_t pll_settle_time0)
206 {
207  /* EZRadio command buffer */
208  uint8_t ezradioCmd[9u];
209 
210  ezradioCmd[0] = EZRADIO_CMD_ID_TX_HOP;
211  ezradioCmd[1] = inte;
212  ezradioCmd[2] = frac2;
213  ezradioCmd[3] = frac1;
214  ezradioCmd[4] = frac0;
215  ezradioCmd[5] = vco_cnt1;
216  ezradioCmd[6] = vco_cnt0;
217  ezradioCmd[7] = pll_settle_time1;
218  ezradioCmd[8] = pll_settle_time0;
219 
220  ezradio_comm_SendCmd( EZRADIO_CMD_ARG_COUNT_TX_HOP, ezradioCmd );
221 }
222 
233 void ezradio_rx_hop(uint8_t inte, uint8_t frac2, uint8_t frac1, uint8_t frac0, uint8_t vco_cnt1, uint8_t vco_cnt0)
234 {
235  /* EZRadio command buffer */
236  uint8_t ezradioCmd[7u];
237 
238  ezradioCmd[0] = EZRADIO_CMD_ID_RX_HOP;
239  ezradioCmd[1] = inte;
240  ezradioCmd[2] = frac2;
241  ezradioCmd[3] = frac1;
242  ezradioCmd[4] = frac0;
243  ezradioCmd[5] = vco_cnt1;
244  ezradioCmd[6] = vco_cnt0;
245 
246  ezradio_comm_SendCmd( EZRADIO_CMD_ARG_COUNT_RX_HOP, ezradioCmd );
247 }
248 
249 #endif /* EZRADIO_DRIVER_FULL_SUPPORT */
250 
251 #endif /* EZRADIO_DRIVER_EXTENDED_SUPPORT */
This file contains the common API library of the EZRadio and EZRadioPRO families. ...
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_ircal_manual(uint8_t ircal_amp, uint8_t ircal_ph, ezradio_cmd_reply_t *ezradioReply)
This file contains EZRadio HAL.
General Purpose IO (GPIO) peripheral API.
void ezradio_tx_hop(uint8_t inte, uint8_t frac2, uint8_t frac1, uint8_t frac0, uint8_t vco_cnt1, uint8_t vco_cnt0, uint8_t pll_settle_time1, uint8_t pll_settle_time0)
EZRADIO_ConfigRet_t ezradio_configuration_init(const uint8_t *pSetPropCmd)
uint8_t ezradio_comm_SendCmdGetResp(uint8_t cmdByteCount, uint8_t *pCmdData, uint8_t respByteCount, uint8_t *pRespData)
Definition: ezradio_comm.c:293
void ezradio_ircal(uint8_t searching_step_size, uint8_t searching_rssi_avg, uint8_t rx_chain_setting1, uint8_t rx_chain_setting2)
void ezradio_rx_hop(uint8_t inte, uint8_t frac2, uint8_t frac1, uint8_t frac0, uint8_t vco_cnt1, uint8_t vco_cnt0)
GPIOINT API definition.
uint8_t ezradio_hal_NirqLevel(void)
Definition: ezradio_hal.c:175
void ezradio_get_adc_reading(uint8_t adc_en, uint8_t adc_cfg, ezradio_cmd_reply_t *ezradioReply)
This file contains the EZRadio communication layer.
EZRADIO_ConfigRet_t
void ezradio_comm_SendCmd(uint8_t byteCount, uint8_t *pData)
Definition: ezradio_comm.c:140