Appiko
S2LP_SDK_Util.c
1 
24 /* Includes ------------------------------------------------------------------*/
25 #include "S2LP_SDK_Util.h"
26 #include "MCU_Interface.h"
27 
28 
46 static volatile FlagStatus s_xTIMChCompareModeRaised = RESET;
47 
51 static volatile uint8_t s_RfModuleBand = 0, s_Tcxo=0;
52 static volatile int32_t s_RfModuleOffset=0;
53 static volatile RangeExtType s_RangeExtType = RANGE_EXT_NONE;
54 static volatile uint32_t s_XtalFrequency=50000000;
55 static volatile S2LPCutType s_S2LPCut = S2LP_CUT_2_1;
56 static TIM_HandleTypeDef TimHandle;
57 
58 
68 void S2LPRadioSetXtalFrequency(uint32_t lXtalFrequency);
69 
75 void TIM3_IRQHandler(void)
76 {
77  HAL_TIM_IRQHandler(&TimHandle);
78 }
79 
80 void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
81 {
82  s_xTIMChCompareModeRaised = SET;
83 }
84 
85 
87 {
88  __GPIOC_CLK_ENABLE();
89  HAL_GPIO_Init(GPIOC, &(GPIO_InitTypeDef){GPIO_PIN_7, GPIO_MODE_OUTPUT_PP, GPIO_NOPULL, GPIO_SPEED_HIGH });
90  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_7, GPIO_PIN_SET);
91 }
92 
93 void S2LPManagementRangeExtInit(void)
94 {
95 
96  if(s_RangeExtType==RANGE_EXT_SKYWORKS_868)
97  {
98  uint8_t tmp[3]={0x92,0x52,0x2A};
99  SdkEvalSpiWriteRegisters(0x00, 3, tmp);
100  }
101 }
102 
103 RangeExtType S2LPManagementGetRangeExtender(void)
104 {
105  return s_RangeExtType;
106 }
107 
108 S2LPCutType S2LPManagementGetCut(void)
109 {
110  return s_S2LPCut;
111 }
112 
113 static void S2LPManagementSetRangeExtender(RangeExtType xRangeType)
114 {
115  s_RangeExtType = xRangeType;
116 }
117 
118 static void S2LPManagementSetTcxo(uint8_t tcxo)
119 {
120  s_Tcxo = tcxo;
121 }
122 
123 uint8_t S2LPManagementGetTcxo(void)
124 {
125  return s_Tcxo;
126 }
127 
128 void S2LPManagementTcxoInit(void)
129 {
130  if(s_Tcxo)
131  {
133 
134  uint8_t tmp;
135  SdkEvalSpiReadRegisters(0x6D, 1, &tmp);
136  tmp|=0x80;
137  SdkEvalSpiWriteRegisters(0x6D, 1, &tmp);
138  }
139 }
140 
148 {
149  uint32_t lMeasuredXtalFrequency;
150 
151 
152 #if defined(USE_STM32L0XX_NUCLEO) || defined(USE_STM32F0XX_NUCLEO)
153  lMeasuredXtalFrequency=50000000;
154 #else
155  uint8_t tmp;
156 
157 #define N_SAMPLES 20
158 #define SETTLING_PERIODS 40
159 
160  GPIO_TypeDef *pGpioPeriph;
161  GPIO_InitTypeDef GPIO_InitStructure;
162  TIM_IC_InitTypeDef sICConfig;
163 
164 
165  TimHandle.Instance = TIM3;
166  pGpioPeriph=GPIOB;
167  /* TIM3 clock enable */
168  __HAL_RCC_TIM3_CLK_ENABLE();
169  /* GPIOC clock enable */
170  __GPIOB_CLK_ENABLE();
171 
172  /* Instance the variables used to compute the XTAL frequency */
173  uint8_t CaptureNumber=0;
174  uint16_t IC3ReadValue1=0,IC3ReadValue2=0,Capture=0;
175  volatile uint16_t cWtchdg = 0;
176  uint32_t TIMFreq=0,lXoFreq=0,lXoFreqRounded,j=0;
177 
178  /* TIM3 channel 2 pin (PC.07) configuration */
179  GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
180  GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
181  GPIO_InitStructure.Pull = GPIO_PULLUP;
182  GPIO_InitStructure.Pin = GPIO_PIN_0;
183 
184  GPIO_InitStructure.Alternate = GPIO_AF2_TIM3;
185 
186  HAL_GPIO_Init(pGpioPeriph, &GPIO_InitStructure);
187 
188  /* Configure the timer IRQ to be raised on the rising fronts */
189  sICConfig.ICPolarity = TIM_ICPOLARITY_RISING;
190 
191  /* Input capture selection setting */
192  sICConfig.ICSelection = TIM_ICSELECTION_DIRECTTI;
193 
194  /* Input capture prescaler setting. Setting it to TIM_ICPSC_DIV8 makes the IRQ are raised every 8 rising fronts detected by hardware. */
195  sICConfig.ICPrescaler = TIM_ICPSC_DIV8;
196 
197  /* Disable every kind of capture filter */
198  sICConfig.ICFilter = 0x0;
199 
200  /* Timer initialization */
201  HAL_TIM_IC_ConfigChannel(&TimHandle, &sICConfig, TIM_CHANNEL_3);
202 
203  /* TIM enable counter */
204  HAL_TIM_IC_Start_IT(&TimHandle, TIM_CHANNEL_3);
205 
206  HAL_NVIC_SetPriority(TIM3_IRQn, 0x0F, 0x0F);
207  HAL_NVIC_EnableIRQ(TIM3_IRQn);
208 
209 
210  /* Disable the clock divider to measure the max frequency of the clock. */
211  //S2LPRadioSetDigDiv(S_DISABLE);
212  tmp=0x55;
213  SdkEvalSpiWriteRegisters(0x6C, 1, &tmp);
214 
215  /* GPIO2 to the clock output */
216  //S2LPGpioInit(&(SGpioInit){S2LP_GPIO_2, S2LP_GPIO_MODE_DIGITAL_OUTPUT_LP, S2LP_GPIO_DIG_OUT_MCU_CLOCK});
217  tmp=0x88|0x02;
218  SdkEvalSpiWriteRegisters(0x02, 1, &tmp);
219 
220  SdkEvalSpiReadRegisters(0xF1, 1, &tmp);
221  if((tmp&0x80)==0)
222  {/* CUT 1.x */
223  tmp=0x9E;
224  }
225  else
226  {
227  tmp=0x90;
228  }
229  SdkEvalSpiWriteRegisters(0x04, 1, &tmp);
230 
231  //S2LPGpioClockOutput(S_ENABLE);
232 
233 
234  /* measure the frequency and average it on N_SAMPLES. Moreover cycle to wait for same SETTLING_PERIODS */
235  for(uint32_t i=0;i<2*(N_SAMPLES+SETTLING_PERIODS);i++) {
236  /* block the routine until the TIM CCP2 IRQ is raised */
237  while(!s_xTIMChCompareModeRaised && (cWtchdg!=0xFFFF)) {
238  cWtchdg++;
239  }
240 
241  if(cWtchdg==0xFFFF) {
242  break;
243  }
244  else {
245  cWtchdg=0;
246  }
247 
248  /* reset the IRQ raised flag */
249  s_xTIMChCompareModeRaised = RESET;
250 
251  /* if the SETTLING PERIODS expired */
252  if(i>=SETTLING_PERIODS*2) {
253  /* First TIMER capture */
254  if(CaptureNumber == 0)
255  {
256  /* Get the Input Capture value */
257  IC3ReadValue1 = HAL_TIM_ReadCapturedValue(&TimHandle, TIM_CHANNEL_3);
258  CaptureNumber = 1;
259  }
260  /* Second TIMER capture */
261  else if(CaptureNumber == 1)
262  {
263  /* Get the Input Capture value */
264  IC3ReadValue2 = HAL_TIM_ReadCapturedValue(&TimHandle, TIM_CHANNEL_3);
265 
266  /* Capture computation */
267  if (IC3ReadValue2 > IC3ReadValue1)
268  {
269  /* If the TIMER didn't overflow between the first and the second capture. Compute it as the difference between the second and the first capture values. */
270  Capture = (IC3ReadValue2 - IC3ReadValue1) - 1;
271  }
272  else
273  {
274  /* .. else, if overflowed 'roll' the first measure to be complementar of 0xFFFF */
275  Capture = ((0xFFFF - IC3ReadValue1) + IC3ReadValue2) - 1;
276  }
277 
278  /* Punctual frequency computation */
279  TIMFreq = (uint32_t) SystemCoreClock / Capture;
280 
281  /* Averaged frequency computation */
282  //lXoFreq =(uint32_t)(A*(float)lXoFreq+((float)1-A)*(float)TIMFreq);
283  lXoFreq += TIMFreq;
284  j++;
285 
286  CaptureNumber = 0;
287  }
288  }
289  }
290  lXoFreq /= j;
291 
292  /* Compute the real frequency in Hertz tanking in account the MCU and Spirit divisions */
293 
294  SdkEvalSpiReadRegisters(0xF1, 1, &tmp);
295  /* cut 1.1 */
296  if((tmp&0x80)==0)
297  {
298  lXoFreq *=(192*8);
299  }
300  /* cut 2.0 */
301  else
302  {
303  lXoFreq *=(256*8);
304  }
305 
306  /* Disable the output clock */
307  tmp=0x00;
308  SdkEvalSpiWriteRegisters(0x04, 1, &tmp);
309  //S2LPGpioClockOutput(S_DISABLE);
310 
311  /* TIM disable counter */
312  HAL_TIM_IC_Stop(&TimHandle, TIM_CHANNEL_3);
313 
315 
316  /* S2LP GPIO 0 to the default configuration */
317  tmp=0xA2;
318  SdkEvalSpiWriteRegisters(0x02, 1, &tmp);
319  //S2LPGpioSetLevel(S2LP_GPIO_2, LOW);
320 
321  //S2LPRadioSetDigDiv(S_ENABLE);
322  tmp=0x45;
323  SdkEvalSpiWriteRegisters(0x6C, 1, &tmp);
324 
325  lXoFreqRounded=(lXoFreq/1000000)*1000000;
326 
327  lMeasuredXtalFrequency=lXoFreqRounded;
328  if(lXoFreq-lXoFreqRounded > (lXoFreqRounded+1000000)-lXoFreq)
329  {
330  lMeasuredXtalFrequency+=1000000;
331  }
332 
333 
334 #endif
335 
336  S2LPRadioSetXtalFrequency(lMeasuredXtalFrequency);
337  s_XtalFrequency=lMeasuredXtalFrequency;
338 
339  return lMeasuredXtalFrequency;
340 }
341 
342 uint32_t S2LPManagementGetXtalFrequency(void)
343 {
344  return s_XtalFrequency;
345 }
346 
347 
348 uint32_t S2LPManagementComputeXtalFrequencyGpio2(void)
349 {
351 }
352 
353 
354 
355 
356 uint32_t S2LPManagementComputeRcoFrequency(void)
357 {
358  uint32_t lMeasuredRcoFrequency;
359 
360 #if defined(USE_STM32L0XX_NUCLEO) || defined(USE_STM32F0XX_NUCLEO)
361  lMeasuredRcoFrequency=33330;
362 #else
363  uint8_t tmp;
364 
365 #define RCO_SETTLING_PERIODS 4000
366 #define RCO_N_SAMPLES 10000
367 
368  HAL_NVIC_DisableIRQ(TIM2_IRQn);
369 
370  GPIO_TypeDef *pGpioPeriph;
371  GPIO_InitTypeDef GPIO_InitStructure;
372  TIM_IC_InitTypeDef sICConfig;
373 
374 
375  TimHandle.Instance = TIM3;
376  pGpioPeriph=GPIOB;
377  __HAL_RCC_TIM3_CLK_ENABLE();
378  __GPIOB_CLK_ENABLE();
379 
380 
381  /* Instance the variables used to compute the XTAL frequency */
382  uint8_t CaptureNumber=0;
383  uint16_t IC3ReadValue1=0,IC3ReadValue2=0,Capture=0;
384  volatile uint16_t cWtchdg = 0;
385  uint32_t TIMFreq=0,lXoFreq=0;
386 
387 
388 
389  GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
390  GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
391  GPIO_InitStructure.Pull = GPIO_PULLUP;
392  GPIO_InitStructure.Pin = GPIO_PIN_0;
393 
394  GPIO_InitStructure.Alternate = GPIO_AF2_TIM3;
395 
396  HAL_GPIO_Init(pGpioPeriph, &GPIO_InitStructure);
397 
398  /* Configure the timer IRQ to be raised on the rising fronts */
399  sICConfig.ICPolarity = TIM_ICPOLARITY_RISING;
400 
401  /* Input capture selection setting */
402  sICConfig.ICSelection = TIM_ICSELECTION_DIRECTTI;
403 
404  /* Input capture prescaler setting. Setting it to TIM_ICPSC_DIV8 makes the IRQ are raised every 8 rising fronts detected by hardware. */
405  sICConfig.ICPrescaler = TIM_ICPSC_DIV1;
406 
407  /* Disable every kind of capture filter */
408  sICConfig.ICFilter = 0x0;
409 
410  /* Timer initialization */
411  HAL_TIM_IC_ConfigChannel(&TimHandle, &sICConfig, TIM_CHANNEL_3);
412 
413  /* TIM enable counter */
414  HAL_TIM_IC_Start_IT(&TimHandle, TIM_CHANNEL_3);
415 
416 
417  HAL_NVIC_SetPriority(TIM3_IRQn, 0x0F, 0x0F);
418  HAL_NVIC_EnableIRQ(TIM3_IRQn);
419 
420 
421  /* Disable the clock divider to measure the max frequency of the clock. */
422  //S2LPRadioSetDigDiv(S_DISABLE);
423  tmp=0x55;
424  SdkEvalSpiWriteRegisters(0x6C, 1, &tmp);
425 
426  SdkEvalSpiReadRegisters(0xF1, 1, &tmp);
427  tmp=0x88|0x02;
428  SdkEvalSpiWriteRegisters(0x02, 1, &tmp);
429 
430  SdkEvalSpiReadRegisters(0xF1, 1, &tmp);
431  if((tmp&0x80)==0)
432  {/* CUT 1.x */
433  tmp=0x9E;
434  }
435  else
436  {
437  tmp=0x90;
438  }
439  SdkEvalSpiWriteRegisters(0x04, 1, &tmp);
440 
441  // go to SLEEP
443 
444 
445  uint32_t n=0;
446 
447  /* measure the frequency and average it on N_SAMPLES. Moreover cycle to wait for same SETTLING_PERIODS */
448  for(uint32_t i=0;i<2*(RCO_N_SAMPLES+RCO_SETTLING_PERIODS);i++) {
449  /* block the routine until the TIM CCP2 IRQ is raised */
450  while(!s_xTIMChCompareModeRaised && (cWtchdg!=0xFFFF)) {
451  cWtchdg++;
452  }
453  HAL_TIM_IRQHandler(&TimHandle);
454 
455  if(cWtchdg==0xFFFF) {
456  break;
457  }
458  else {
459  cWtchdg=0;
460  }
461 
462  /* reset the IRQ raised flag */
463  s_xTIMChCompareModeRaised = RESET;
464 
465  /* if the SETTLING PERIODS expired */
466  if(i>=RCO_SETTLING_PERIODS*2) {
467  /* First TIMER capture */
468  if(CaptureNumber == 0)
469  {
470  /* Get the Input Capture value */
471  IC3ReadValue1 = HAL_TIM_ReadCapturedValue(&TimHandle, TIM_CHANNEL_3);
472  CaptureNumber = 1;
473  }
474  /* Second TIMER capture */
475  else if(CaptureNumber == 1)
476  {
477  /* Get the Input Capture value */
478  IC3ReadValue2 = HAL_TIM_ReadCapturedValue(&TimHandle, TIM_CHANNEL_3);
479 
480  /* Capture computation */
481  if (IC3ReadValue2 > IC3ReadValue1)
482  {
483  /* If the TIMER didn't overflow between the first and the second capture. Compute it as the difference between the second and the first capture values. */
484  Capture = (IC3ReadValue2 - IC3ReadValue1) - 1;
485  }
486  else
487  {
488  /* .. else, if overflowed 'roll' the first measure to be complementar of 0xFFFF */
489  Capture = ((0xFFFF - IC3ReadValue1) + IC3ReadValue2) - 1;
490  }
491 
492  /* Punctual frequency computation */
493  TIMFreq = (uint32_t) SystemCoreClock / Capture;
494 
495  lXoFreq+=TIMFreq;
496  n++;
497 
498  CaptureNumber = 0;
499  }
500  }
501  }
502 
503  /* Compute the real frequency in Hertz tanking in account the MCU and Spirit divisions */
504 
505  lXoFreq/=n;
506 
507 
508  /* Disable the output clock */
509  tmp=0x00;
510  SdkEvalSpiWriteRegisters(0x04, 1, &tmp);
511  //S2LPGpioClockOutput(S_DISABLE);
512 
513 
514  /* TIM disable counter */
515  HAL_TIM_IC_Stop(&TimHandle, TIM_CHANNEL_3);
516 
518 
519  /* S2LP GPIO2 to the default configuration */
520  //S2LPGpioSetLevel(S2LP_GPIO_2, LOW);
521  tmp=0xA2;
522  SdkEvalSpiWriteRegisters(0x02, 1, &tmp);
523 
524  //S2LPRadioSetDigDiv(S_ENABLE);
525  tmp=0x45;
526  SdkEvalSpiWriteRegisters(0x6C, 1, &tmp);
527 
528  //uint8_t tmp= 0x21; S2LPSpiWriteRegisters(0xB4, 1, &tmp);
529 
530  lMeasuredRcoFrequency=lXoFreq;
531 
532  HAL_NVIC_EnableIRQ(TIM2_IRQn);
533  //S2LPCmdStrobeReady();
535 
536 #endif
537 
538  return lMeasuredRcoFrequency;
539 }
540 
541 
547 uint8_t EepromIdentification(void)
548 {
549  uint8_t status=0;
550 
551  /*Configure EEPROM SPI with default configuration*/
553 
554  /* Try this procedure for both FKIxxx and XNUCLEO -S2868 boards */
555  for (int i=0; i<2; i++)
556  {
557  /*Switch to new CS configuration only if previoisly conf failed */
558  if (i==1 && status==0)
560 
561  /* try to get the status of the EEPROM */
562  status = EepromStatus();
563  if((status&0xF0) == EEPROM_STATUS_SRWD) {
564  /* if it is EEPROM_STATUS_SRWD, ok the EEPROM is present and ready to work */
565  status=1;
566  }
567  else
568  {
570  SdkDelayMs(10);
571  /* else the bit may be not set (first time we see this EEPROM), try to set it*/
572  status = EepromSetSrwd();
573  SdkDelayMs(10);
574  /*check again*/
575  status = EepromStatus();
576 
577  if((status&0xF0) == EEPROM_STATUS_SRWD) { // 0xF0 mask [SRWD 0 0 0]
578  /* if it is EEPROM_STATUS_SRWD, ok the EEPROM is present and ready to work */
579  status=1;
580  }
581  else
582  {
583  /* else no EEPROM is present */
584  status = 0;
585  }
586  }
587  }
588 
589  return status;
590 }
591 
592 
593 void S2LPManagementSetBand(uint8_t value)
594 {
595  s_RfModuleBand = value;
596 }
597 
598 uint8_t S2LPManagementGetBand(void)
599 {
600  return s_RfModuleBand;
601 }
602 
603 void S2LPManagementSetOffset(int32_t value)
604 {
605  s_RfModuleOffset=value;
606 }
607 
608 int32_t S2LPManagementGetOffset(void)
609 {
610  return s_RfModuleOffset;
611 }
612 
613 void S2LPManagementIdentificationRFBoard(void)
614 {
615  uint8_t tmp;
616  StatusBytes status;
617 
618  do{
619  /* Delay for state transition */
620  for(volatile uint8_t i=0; i!=0xFF; i++);
621 
622  /* Reads the MC_STATUS register */
623  status = SdkEvalSpiReadRegisters(0x8E, 1, &tmp);
624  }while(status.MC_STATE!=MC_STATE_READY);
625 
626  SdkEvalSpiReadRegisters(0xF1, 1, &tmp);
627 
628 
629  s_S2LPCut=(S2LPCutType)tmp;
630 
631  if((s_S2LPCut==S2LP_CUT_2_0) || (s_S2LPCut==S2LP_CUT_2_1))
632  {
634  }
635 
637 
638  if(!SdkEvalGetHasEeprom()) // EEPROM is not present
639  {
642  {
643  /* if it fails force it to 50MHz */
644  S2LPRadioSetXtalFrequency(50000000);
645  }
646  }
647  else // EEPROM found
648  {
649  //read the memory and set the variable
650  uint8_t tmpBuffer[32];
651  EepromRead(0x0000, 32, tmpBuffer);
652  uint32_t xtal;
653  float foffset=0;
654  if(tmpBuffer[0]==0 || tmpBuffer[0]==0xFF) {
655  /* this one happens in production where the E2PROM is here but blank */
657  if((s_S2LPCut==S2LP_CUT_2_0) || (s_S2LPCut==S2LP_CUT_2_1))
658  {
660  }
662  return;
663  }
664  switch(tmpBuffer[1]) {
665  case 0:
666  xtal = 24000000;
668  break;
669  case 1:
670  xtal = 25000000;
672  break;
673  case 2:
674  xtal = 26000000;
676  break;
677  case 3:
678  xtal = 48000000;
680  break;
681  case 4:
682  xtal = 50000000;
684  break;
685  case 5:
686  xtal = 52000000;
688  break;
689  case 0xff:
690  /* XTAL freqeuncy is custom */
691  for(uint8_t i=0;i<4;i++)
692  {
693  ((uint8_t*)&xtal)[i]=tmpBuffer[30-i];
694  }
696  break;
697  default:
699  break;
700  }
701 
702  /* TCXO field */
703  if(tmpBuffer[31]==1)
704  {
705  S2LPManagementSetTcxo(1);
706  }
707 
708  S2LPManagementSetBand(tmpBuffer[3]);
709 
710  RangeExtType range=RANGE_EXT_NONE;
711  if(tmpBuffer[5]==2)
712  {
713  range = RANGE_EXT_SKYWORKS_868;
714  }
715  S2LPManagementSetRangeExtender(range);
716 
717  EepromRead(0x0021,4,tmpBuffer);
718 
719  if(*(uint32_t*)tmpBuffer != 0xffffffff)
720  {
721  for(uint8_t i=0;i<4;i++)
722  {
723  ((uint8_t*)&foffset)[i]=tmpBuffer[3-i];
724  }
725 
726  if(foffset<-100000 || foffset>100000)
727  {
728  foffset=0;
729  }
730  }
731  S2LPManagementSetOffset((int32_t)foffset);
732  }
733 
734  if((s_S2LPCut==S2LP_CUT_2_0) || (s_S2LPCut==S2LP_CUT_2_1))
735  {
737  }
738 
739 
740 
741 
742 }
743 
744 void S2LPManagementRcoCalibration(void)
745 {
746  uint8_t tmp[2],tmp2;
747 
748  //S2LPTimerCalibrationRco(S_ENABLE);
749  SdkEvalSpiReadRegisters(0x6D, 1, &tmp2);
750  tmp2 |= 0x01;
751  SdkEvalSpiWriteRegisters(0x6D, 1, &tmp2);
752 
753  //S2LPCmdStrobeStandby();
755  SdkDelayMs(100);
756  //S2LPCmdStrobeReady();
758 
759  do
760  {
761  SdkEvalSpiReadRegisters(0x8D, 1, tmp);
762  }
763  while((tmp[0]&0x10)==0);
764 
765 
766 
767  SdkEvalSpiReadRegisters(0x94, 2, tmp);
768  SdkEvalSpiReadRegisters(0x6F, 1, &tmp2);
769  tmp[1]=(tmp[1]&0x80)|(tmp2&0x7F);
770 
771  SdkEvalSpiWriteRegisters(0x6E, 2, tmp);
772 
773 
774  //S2LPTimerCalibrationRco(S_DISABLE);
775  SdkEvalSpiReadRegisters(0x6D, 1, &tmp2);
776  tmp2 &= 0xFE;
777  SdkEvalSpiWriteRegisters(0x6D, 1, &tmp2);
778 
779 }
780 
781 
782 
803 /******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/
void S2LPManagementEnableTcxo(void)
Definition: S2LP_SDK_Util.c:86
void EepromSpiInitialization(void)
Initializes the SPI for the EEPROM. SPI, MISO, MOSI and SCLK are the same used for the SPIRIT1....
S2LPState MC_STATE
Definition: S2LP_Types.h:119
StatusBytes SdkEvalSpiReadRegisters(uint8_t cRegAddress, uint8_t cNbBytes, uint8_t *pcBuffer)
Read single or multiple registers.
uint32_t S2LPManagementComputeXtalFrequency(void)
This function can be used to automatically measure the XTAL frequency making use of the Spirit clock ...
S2LP Status. This definition represents the single field of the S2LP status returned on each SPI tran...
Definition: S2LP_Types.h:117
void S2LPRadioSetXtalFrequency(uint32_t lXtalFrequency)
Set the XTAL frequency.
Definition: S2LP_Radio.c:1162
void TIM3_IRQHandler(void)
This function handles TIM3 global interrupt.
Definition: S2LP_SDK_Util.c:75
uint8_t SdkEvalGetHasEeprom(void)
This function is to query if EEPROM is present or not.
StatusBytes SdkEvalSpiWriteRegisters(uint8_t cRegAddress, uint8_t cNbBytes, uint8_t *pcBuffer)
Write single or multiple registers.
void SdkEvalSetHasEeprom(uint8_t eeprom)
This function is to set if EEPROM is present or not.
void EepromRead(uint16_t nAddress, uint8_t cNbBytes, uint8_t *pcBuffer)
Read a page of the EEPROM. A page size is 32 bytes. The pages are 256. Page 0 address: 0x0000 Page 1 ...
void SdkEvalEnterShutdown(void)
Puts at logic 1 the SDN pin.
uint8_t EepromStatus(void)
Read the status register.
void SdkEvalExitShutdown(void)
Put at logic 0 the SDN pin.
void SdkEvalM2SGpioInit(M2SGpioPin xGpio, M2SGpioMode xGpioMode)
Configures MCU GPIO and EXTI Line for GPIOs.
void EepromCsXnucleoPinInitialization(void)
Initialization of the CSn pin of the EEPROM for XNUCLEO boards.
Header file for low level S2LP SPI driver.
uint8_t EepromSetSrwd(void)
Set the ERSR status bit.
StatusBytes SdkEvalSpiCommandStrobes(uint8_t cCommandCode)
Send a command.
void EepromWriteEnable(void)
Set the internal WEL flag to allow write operation.
uint8_t EepromIdentification(void)
Read the status register.