28 #include "S2LP_SDK_Util.h" 80 EXTENDED_LENGTH_FIELD,
113 uint8_t
vectcTxBuff[20]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
118 #define IRQ_PREEMPTION_PRIORITY 0x03 136 static uint16_t M2S_GPIO_PIN_IRQ;
138 void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
140 if(GPIO_Pin==M2S_GPIO_PIN_IRQ)
158 #ifdef USE_STM32L0XX_NUCLEO 164 static void SystemClock_Config(
void)
166 RCC_ClkInitTypeDef RCC_ClkInitStruct;
167 RCC_OscInitTypeDef RCC_OscInitStruct;
175 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
178 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
179 RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
180 RCC_OscInitStruct.HSIState = RCC_HSI_ON;
181 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
182 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
183 RCC_OscInitStruct.PLL.PLLMUL = RCC_PLLMUL_4;
184 RCC_OscInitStruct.PLL.PLLDIV = RCC_PLLDIV_2;
185 RCC_OscInitStruct.HSICalibrationValue = 0x10;
186 HAL_RCC_OscConfig(&RCC_OscInitStruct);
190 RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
191 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
192 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
193 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
194 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
195 HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1);
198 static void SystemClock_Config(
void)
201 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
202 RCC_OscInitTypeDef RCC_OscInitStruct = {0};
205 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
206 RCC_OscInitStruct.HSIState = RCC_HSI_ON;
207 RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
208 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
209 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
210 RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
211 RCC_OscInitStruct.PLL.PLLDIV = RCC_PLL_DIV3;
212 HAL_RCC_OscConfig(&RCC_OscInitStruct);
215 __HAL_RCC_PWR_CLK_ENABLE();
216 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
219 while (__HAL_PWR_GET_FLAG(PWR_FLAG_VOS) != RESET) {};
223 RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
224 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
225 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
226 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
227 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
228 HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1);
242 SystemClock_Config();
266 S2LPManagementIdentificationRFBoard();
275 S2LPManagementRangeExtInit();
278 S2LPManagementTcxoInit();
298 if(!S2LPManagementGetRangeExtender())
308 uint8_t paLevelValue=0x25;
329 printf(
"A data to transmit: [");
331 for(uint8_t i=0 ; i<20 ; i++)
337 S2LPCmdStrobeFlushTxFifo();
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...
void S2LPGpioIrqDeInit(S2LPIrqs *pxIrqInit)
Deinit the S2LPIrqs structure setting all the bitfield to 0. Moreover, it sets the IRQ mask registers...
SFlagStatus IRQ_TX_DATA_SENT
void S2LPGpioInit(SGpioInit *pxGpioInitStruct)
Initialize the S2LP GPIOx according to the specified parameters in the pxGpioInitStruct.
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...
int main(void)
System main function.
uint8_t vectcTxBuff[20]
Tx buffer declaration: data to transmit.
Common configuration header file.
void SdkEvalLedToggle(SdkEvalLed xLed)
Toggles the selected LED.
This file contains SDK EVAL configuration and useful defines.
SGpioInit xGpioIRQ
GPIO 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.
#define PA_POWER8_ADDR
PA_POWER8 register.
uint16_t SdkEvalGpioGetPin(M2SGpioPin xGpio)
Gets the GPIO_PIN of the M2SGpioPin.
S2LP Radio Init structure definition.
volatile FlagStatus xTxDoneFlag
Declare the Tx done flag.
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.
void S2LPRadioSetPALeveldBm(uint8_t cIndex, int32_t wPowerdBm)
Sets a specific PA_LEVEL register, with a value given in dBm.
void S2LPRadioSetPALevelMaxIndex(uint8_t cIndex)
Sets a specific PA_LEVEL_MAX_INDEX.
S2LP Configuration and useful defines .
#define IRQ_PREEMPTION_PRIORITY
Preemption priority IRQ.
S2LPIrqs xIrqStatus
IRQ status struct declaration.
#define S2LPCmdStrobeTx()
Sends the TX command to S2-LP. Start to transmit.
SRadioInit xRadioInit
Radio structure fitting.
void SdkEvalM2SGpioInit(M2SGpioPin xGpio, M2SGpioMode xGpioMode)
Configures MCU GPIO and EXTI Line for GPIOs.
void S2LPRadioSetMaxPALevel(SFunctionalState xNewState)
Set the MAX_DBM bit. This will allow to transmit at the maximum power.
void SdkEvalIdentification(void)
Identifies the current motherboard.
PktBasicInit xBasicInit
Packet Basic structure fitting.
void SdkEvalLedInit(SdkEvalLed xLed)
Configures LED GPIO.
S2LP GPIO Init structure definition.
void S2LPGpioIrqGetStatus(S2LPIrqs *pxIrqStatus)
Fill a pointer to a structure of S2LPIrqs type reading the IRQ_STATUS registers.