28 #include "S2LP_SDK_Util.h" 84 EXTENDED_LENGTH_FIELD,
117 #define IRQ_PREEMPTION_PRIORITY 0x03 135 static uint16_t M2S_GPIO_PIN_IRQ;
137 void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
139 if(GPIO_Pin==M2S_GPIO_PIN_IRQ)
151 printf(
"DATA DISCARDED\n\r");
167 S2LPCmdStrobeFlushRxFifo();
171 SBool xCorrect=S_TRUE;
173 for(uint8_t i=0 ; i<cRxData ; i++)
190 printf(
"B data received: [");
191 for(uint8_t i=0 ; i<cRxData ; i++)
202 #ifdef USE_STM32L0XX_NUCLEO 208 static void SystemClock_Config(
void)
210 RCC_ClkInitTypeDef RCC_ClkInitStruct;
211 RCC_OscInitTypeDef RCC_OscInitStruct;
219 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
222 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
223 RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
224 RCC_OscInitStruct.HSIState = RCC_HSI_ON;
225 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
226 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
227 RCC_OscInitStruct.PLL.PLLMUL = RCC_PLLMUL_4;
228 RCC_OscInitStruct.PLL.PLLDIV = RCC_PLLDIV_2;
229 RCC_OscInitStruct.HSICalibrationValue = 0x10;
230 HAL_RCC_OscConfig(&RCC_OscInitStruct);
234 RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
235 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
236 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
237 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
238 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
239 HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1);
242 static void SystemClock_Config(
void)
245 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
246 RCC_OscInitTypeDef RCC_OscInitStruct = {0};
249 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
250 RCC_OscInitStruct.HSIState = RCC_HSI_ON;
251 RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
252 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
253 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
254 RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
255 RCC_OscInitStruct.PLL.PLLDIV = RCC_PLL_DIV3;
256 HAL_RCC_OscConfig(&RCC_OscInitStruct);
259 __HAL_RCC_PWR_CLK_ENABLE();
260 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
263 while (__HAL_PWR_GET_FLAG(PWR_FLAG_VOS) != RESET) {};
267 RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
268 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
269 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
270 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
271 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
272 HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1);
286 SystemClock_Config();
302 S2LPManagementIdentificationRFBoard();
309 S2LPManagementRangeExtInit();
312 S2LPManagementTcxoInit();
356 #ifdef USE_FULL_ASSERT 364 void assert_failed(uint8_t* file, uint32_t line)
367 printf(
"Wrong parameters value: file %s on line %d\r\n", file, line);
void S2LPPktBasicSetPayloadLength(uint16_t nPayloadLength)
Set the payload length for S2LP Basic packets. Since the packet length depends from the address and t...
SBool
boolean type enumeration.
void S2LPGpioIrqDeInit(S2LPIrqs *pxIrqInit)
Deinit the S2LPIrqs structure setting all the bitfield to 0. Moreover, it sets the IRQ mask registers...
void S2LPGpioInit(SGpioInit *pxGpioInitStruct)
Initialize the S2LP GPIOx according to the specified parameters in the pxGpioInitStruct.
SFlagStatus IRQ_RX_DATA_DISC
void SdkEvalM2SGpioInterruptCmd(M2SGpioPin xGpio, uint8_t nPreemption, uint8_t nSubpriority, FunctionalState xNewState)
Enables or disables the interrupt on GPIO .
uint8_t S2LPRadioInit(SRadioInit *pxSRadioInitStruct)
Initializes the S2LP analog and digital radio part according to the specified parameters in the pxSRa...
SRadioInit xRadioInit
Radio structure fitting.
Common configuration header file.
void SdkEvalLedToggle(SdkEvalLed xLed)
Toggles the selected LED.
This file contains SDK EVAL configuration and useful defines.
PktBasicInit xBasicInit
Packet Basic structure fitting.
void S2LPPktBasicInit(PktBasicInit *pxPktBasicInit)
Initialize the S2LP Basic packet according to the specified parameters in the PktBasicInit struct....
S2LP Basic Packet Init structure definition.
void S2LPGpioIrqConfig(IrqList xIrq, SFunctionalState xNewState)
Enable or disables a specific IRQ.
void S2LPGpioIrqClearStatus(void)
Clear the IRQ status registers.
uint16_t SdkEvalGpioGetPin(M2SGpioPin xGpio)
Gets the GPIO_PIN of the M2SGpioPin.
S2LP Radio Init structure definition.
SFlagStatus IRQ_RX_DATA_READY
IRQ bitfield structure for S2LP. This structure is used to read or write the single IRQ bit....
void SdkEvalComInit(void)
Configures UART port in DMA mode for both RX and TX.
S2LPIrqs xIrqStatus
IRQ status struct declaration.
int main(void)
System main function.
uint8_t S2LPFifoReadNumberBytesRxFifo(void)
Return the number of elements in the Rx FIFO.
int32_t S2LPRadioGetRssidBm(void)
Returns the RSSI value.
uint8_t vectcRxBuff[128]
Rx buffer declaration: how to store the received data.
S2LP Configuration and useful defines .
#define S2LPCmdStrobeRx()
Sends the RX command to S2-LP. Start to receive.
void SdkEvalM2SGpioInit(M2SGpioPin xGpio, M2SGpioMode xGpioMode)
Configures MCU GPIO and EXTI Line for GPIOs.
void SdkEvalIdentification(void)
Identifies the current motherboard.
SGpioInit xGpioIRQ
GPIO IRQ structure fitting.
void SdkEvalLedInit(SdkEvalLed xLed)
Configures LED GPIO.
S2LP GPIO Init structure definition.
#define IRQ_PREEMPTION_PRIORITY
Preemption priority IRQ.
void S2LPGpioIrqGetStatus(S2LPIrqs *pxIrqStatus)
Fill a pointer to a structure of S2LPIrqs type reading the IRQ_STATUS registers.
void S2LPTimerSetRxTimerUs(uint32_t lDesiredUsec)
Set the RX timeout timer counter and prescaler from the desired value in ms. it is possible to fix th...