generated from Embedded_Projects/YZL_WLE5CB_Template
Basic MX Project.
Signed-off-by: Yilin Sun <imi415@imi.moe>
This commit is contained in:
parent
747d6f9edb
commit
a728969791
|
@ -14,4 +14,4 @@ steps:
|
|||
commands:
|
||||
- mkdir build && cd build
|
||||
- cmake -DCMAKE_TOOLCHAIN_FILE=arm-none-eabi.cmake ..
|
||||
- make yzl_wle5_template_FLASH.elf
|
||||
- make yzl_wle5_lorawan_node_FLASH.elf
|
||||
|
|
|
@ -0,0 +1,678 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file stm32wlxx_nucleo.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides set of firmware functions to manage:
|
||||
* - LEDs and push-buttons available on STM32WLXX-Nucleo
|
||||
* Kit from STMicroelectronics
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2020(-2021) STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32wlxx_nucleo.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32WLXX_NUCLEO
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32WLXX_NUCLEO_LOW_LEVEL
|
||||
* @brief This file provides set of firmware functions to manage LEDs and push-buttons
|
||||
* on STM32WLXX-Nucleo Kit from STMicroelectronics.
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_Exported_Variables LOW LEVEL Exported Variables
|
||||
* @{
|
||||
*/
|
||||
EXTI_HandleTypeDef hpb_exti[BUTTONn];
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
UART_HandleTypeDef hcom_uart[COMn];
|
||||
#endif /* (USE_BSP_COM_FEATURE > 0) */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_Private_Defines LOW LEVEL Private Defines
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_Private_TypesDefinitions LOW LEVEL Private Typedef
|
||||
* @{
|
||||
*/
|
||||
typedef void (* BSP_EXTI_LineCallback) (void);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_Private_Variables LOW LEVEL Private Variables
|
||||
* @{
|
||||
*/
|
||||
static GPIO_TypeDef* LED_PORT[LEDn] = {LED1_GPIO_PORT, LED2_GPIO_PORT, LED3_GPIO_PORT};
|
||||
|
||||
static const uint16_t LED_PIN[LEDn] = {LED1_PIN, LED2_PIN, LED3_PIN};
|
||||
|
||||
static GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {BUTTON_SW1_GPIO_PORT, BUTTON_SW2_GPIO_PORT, BUTTON_SW3_GPIO_PORT};
|
||||
|
||||
static const uint16_t BUTTON_PIN[BUTTONn] = {BUTTON_SW1_PIN, BUTTON_SW2_PIN, BUTTON_SW3_PIN};
|
||||
|
||||
static const IRQn_Type BUTTON_IRQn[BUTTONn] = {BUTTON_SW1_EXTI_IRQn, BUTTON_SW2_EXTI_IRQn, BUTTON_SW3_EXTI_IRQn};
|
||||
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
static USART_TypeDef* COM_USART[COMn] = {COM1_UART};
|
||||
|
||||
#if (USE_COM_LOG > 0)
|
||||
static COM_TypeDef COM_ActiveLogPort = COM1;
|
||||
#endif
|
||||
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
||||
static uint32_t IsComMspCbValid[COMn] = {0};
|
||||
#endif
|
||||
#endif /* (USE_BSP_COM_FEATURE > 0) */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_Private_Functions LOW LEVEL Private Functions
|
||||
* @{
|
||||
*/
|
||||
static void BUTTON_SW1_EXTI_Callback(void);
|
||||
static void BUTTON_SW2_EXTI_Callback(void);
|
||||
static void BUTTON_SW3_EXTI_Callback(void);
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
static void COM1_MspInit(UART_HandleTypeDef *huart);
|
||||
static void COM1_MspDeInit(UART_HandleTypeDef *huart);
|
||||
#endif /* (USE_BSP_COM_FEATURE > 0) */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @addtogroup STM32WLXX_NUCLEO_LOW_LEVEL_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief This method returns the STM32WLXX NUCLEO BSP Driver revision
|
||||
* @retval version: 0xXYZR (8bits for each decimal, R for RC)
|
||||
*/
|
||||
uint32_t BSP_GetVersion(void)
|
||||
{
|
||||
return (int32_t)__STM32WLXX_NUCLEO_BSP_VERSION;
|
||||
}
|
||||
|
||||
/** @addtogroup STM32WLXX_NUCLEO_LOW_LEVEL_LED_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Configures LED GPIO.
|
||||
* @param Led: LED to be configured.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED1
|
||||
* @arg LED2
|
||||
* @arg LED3
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_LED_Init(Led_TypeDef Led)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure = {0};
|
||||
|
||||
/* Enable the GPIO_LED Clock */
|
||||
LEDx_GPIO_CLK_ENABLE(Led);
|
||||
|
||||
/* Configure the GPIO_LED pin */
|
||||
gpio_init_structure.Pin = LED_PIN[Led];
|
||||
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
gpio_init_structure.Pull = GPIO_NOPULL;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
|
||||
HAL_GPIO_Init(LED_PORT[Led], &gpio_init_structure);
|
||||
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_RESET);
|
||||
|
||||
return BSP_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInit LEDs.
|
||||
* @param Led: LED to be de-init.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED1
|
||||
* @arg LED2
|
||||
* @arg LED3
|
||||
* @note Led DeInit does not disable the GPIO clock nor disable the Mfx
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_LED_DeInit(Led_TypeDef Led)
|
||||
{
|
||||
/* Turn off LED */
|
||||
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_RESET);
|
||||
|
||||
/* DeInit the GPIO_LED pin */
|
||||
HAL_GPIO_DeInit(LED_PORT[Led], LED_PIN[Led]);
|
||||
|
||||
return BSP_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Turns selected LED On.
|
||||
* @param Led: Specifies the Led to be set on.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED1
|
||||
* @arg LED2
|
||||
* @arg LED3
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_LED_On(Led_TypeDef Led)
|
||||
{
|
||||
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_SET);
|
||||
|
||||
return BSP_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Turns selected LED Off.
|
||||
* @param Led: Specifies the Led to be set off.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED1
|
||||
* @arg LED2
|
||||
* @arg LED3
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_LED_Off(Led_TypeDef Led)
|
||||
{
|
||||
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_RESET);
|
||||
|
||||
return BSP_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggles the selected LED.
|
||||
* @param Led: Specifies the Led to be toggled.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED1
|
||||
* @arg LED2
|
||||
* @arg LED3
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_LED_Toggle(Led_TypeDef Led)
|
||||
{
|
||||
HAL_GPIO_TogglePin(LED_PORT[Led], LED_PIN[Led]);
|
||||
|
||||
return BSP_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the status of the selected LED.
|
||||
* @param Led Specifies the Led to get its state.
|
||||
* This parameter can be one of following parameters:
|
||||
* @arg LED1
|
||||
* @arg LED2
|
||||
* @arg LED3
|
||||
* @retval LED status
|
||||
*/
|
||||
int32_t BSP_LED_GetState(Led_TypeDef Led)
|
||||
{
|
||||
return (int32_t)HAL_GPIO_ReadPin(LED_PORT[Led], LED_PIN[Led]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32WLXX_NUCLEO_LOW_LEVEL_BUTTON_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Configures Button GPIO and EXTI Line.
|
||||
* @param Button: Specifies the Button to be configured.
|
||||
* This parameter can be one of following parameters:
|
||||
* @arg BUTTON_SW1
|
||||
* @arg BUTTON_SW2
|
||||
* @arg BUTTON_SW3
|
||||
* @param ButtonMode: Specifies Button mode.
|
||||
* This parameter can be one of following parameters:
|
||||
* @arg BUTTON_MODE_GPIO: Button will be used as simple IO
|
||||
* @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line with interrupt
|
||||
* generation capability
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure = {0};
|
||||
static BSP_EXTI_LineCallback button_callback[BUTTONn] = {BUTTON_SW1_EXTI_Callback, BUTTON_SW2_EXTI_Callback, BUTTON_SW3_EXTI_Callback};
|
||||
static uint32_t button_interrupt_priority[BUTTONn] = {BSP_BUTTON_USER_IT_PRIORITY, BSP_BUTTON_USER_IT_PRIORITY, BSP_BUTTON_USER_IT_PRIORITY};
|
||||
static const uint32_t button_exti_line[BUTTONn] = {BUTTON_SW1_EXTI_LINE, BUTTON_SW2_EXTI_LINE, BUTTON_SW3_EXTI_LINE};
|
||||
|
||||
/* Enable the BUTTON Clock */
|
||||
BUTTONx_GPIO_CLK_ENABLE(Button);
|
||||
|
||||
gpio_init_structure.Pin = BUTTON_PIN[Button];
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
|
||||
if(ButtonMode == BUTTON_MODE_GPIO)
|
||||
{
|
||||
/* Configure Button pin as input */
|
||||
gpio_init_structure.Mode = GPIO_MODE_INPUT;
|
||||
HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
|
||||
}
|
||||
else /* (ButtonMode == BUTTON_MODE_EXTI) */
|
||||
{
|
||||
/* Configure Button pin as input with External interrupt */
|
||||
gpio_init_structure.Mode = GPIO_MODE_IT_FALLING;
|
||||
|
||||
HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
|
||||
|
||||
(void)HAL_EXTI_GetHandle(&hpb_exti[Button], button_exti_line[Button]);
|
||||
(void)HAL_EXTI_RegisterCallback(&hpb_exti[Button], HAL_EXTI_COMMON_CB_ID, button_callback[Button]);
|
||||
|
||||
/* Enable and set Button EXTI Interrupt to the lowest priority */
|
||||
HAL_NVIC_SetPriority((BUTTON_IRQn[Button]), button_interrupt_priority[Button], 0x00);
|
||||
HAL_NVIC_EnableIRQ((BUTTON_IRQn[Button]));
|
||||
}
|
||||
|
||||
return BSP_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Push Button DeInit.
|
||||
* @param Button: Button to be configured
|
||||
* This parameter can be one of following parameters:
|
||||
* @arg BUTTON_SW1
|
||||
* @arg BUTTON_SW2
|
||||
* @arg BUTTON_SW3
|
||||
* @note PB DeInit does not disable the GPIO clock
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_PB_DeInit(Button_TypeDef Button)
|
||||
{
|
||||
HAL_NVIC_DisableIRQ((BUTTON_IRQn[Button]));
|
||||
HAL_GPIO_DeInit(BUTTON_PORT[Button], BUTTON_PIN[Button]);
|
||||
|
||||
return BSP_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the selected Button state.
|
||||
* @param Button: Specifies the Button to be checked.
|
||||
* This parameter can be one of following parameters:
|
||||
* @arg BUTTON_SW1
|
||||
* @arg BUTTON_SW2
|
||||
* @arg BUTTON_SW3
|
||||
* @retval The Button GPIO pin value.
|
||||
*/
|
||||
int32_t BSP_PB_GetState(Button_TypeDef Button)
|
||||
{
|
||||
return (int32_t)HAL_GPIO_ReadPin(BUTTON_PORT[Button], BUTTON_PIN[Button]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Push-Button interrupt requests.
|
||||
* @param Button Specifies the pin connected EXTI line
|
||||
* @retval None
|
||||
*/
|
||||
void BSP_PB_IRQHandler(Button_TypeDef Button)
|
||||
{
|
||||
HAL_EXTI_IRQHandler(&hpb_exti[Button]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief BSP Push Button callback
|
||||
* @param Button: Specifies the Button to be checked.
|
||||
* This parameter can be one of following parameters:
|
||||
* @arg BUTTON_SW1
|
||||
* @arg BUTTON_SW2
|
||||
* @arg BUTTON_SW3
|
||||
* @retval None.
|
||||
*/
|
||||
__weak void BSP_PB_Callback(Button_TypeDef Button)
|
||||
{
|
||||
/* Prevent unused argument(s) compilation warning */
|
||||
UNUSED(Button);
|
||||
|
||||
/* This function should be implemented by the user application.
|
||||
It is called into this driver when an event on Button is triggered. */
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
/** @addtogroup STM32WLXX_NUCLEO_LOW_LEVEL_COM_Functions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Configures COM port.
|
||||
* @param COM COM port to be configured.
|
||||
* This parameter can be COM1
|
||||
* @param COM_Init Pointer to a UART_HandleTypeDef structure that contains the
|
||||
* configuration information for the specified USART peripheral.
|
||||
* @retval BSP error code
|
||||
*/
|
||||
int32_t BSP_COM_Init(COM_TypeDef COM, COM_InitTypeDef *COM_Init)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if(COM > COMn)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 0)
|
||||
/* Init the UART Msp */
|
||||
COM1_MspInit(&hcom_uart[COM]);
|
||||
#else
|
||||
if(IsComMspCbValid == 0U)
|
||||
{
|
||||
if(BSP_COM_RegisterDefaultMspCallbacks(COM) != BSP_ERROR_NONE)
|
||||
{
|
||||
return BSP_ERROR_MSP_FAILURE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if(MX_LPUART1_Init(&hcom_uart[COM], COM_Init) != HAL_OK)
|
||||
{
|
||||
return BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInit COM port.
|
||||
* @param COM COM port to be configured.
|
||||
* This parameter can be COM1
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_COM_DeInit(COM_TypeDef COM)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if(COM >= COMn)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* USART configuration */
|
||||
hcom_uart[COM].Instance = COM_USART[COM];
|
||||
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 0)
|
||||
COM1_MspDeInit(&hcom_uart[COM]);
|
||||
#endif /* (USE_HAL_UART_REGISTER_CALLBACKS == 0) */
|
||||
|
||||
if(HAL_UART_DeInit(&hcom_uart[COM]) != HAL_OK)
|
||||
{
|
||||
return BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures COM port.
|
||||
* @param huart USART handle
|
||||
* @param COM_Init Pointer to a UART_HandleTypeDef structure that contains the
|
||||
* configuration information for the specified USART peripheral.
|
||||
* @retval HAL error code
|
||||
*/
|
||||
__weak HAL_StatusTypeDef MX_LPUART1_Init(UART_HandleTypeDef *huart, MX_UART_InitTypeDef *COM_Init)
|
||||
{
|
||||
/* USART configuration */
|
||||
huart->Instance = COM_USART[COM1];
|
||||
huart->Init.BaudRate = COM_Init->BaudRate;
|
||||
huart->Init.Mode = UART_MODE_TX_RX;
|
||||
huart->Init.Parity = (uint32_t)COM_Init->Parity;
|
||||
huart->Init.WordLength = COM_Init->WordLength;
|
||||
huart->Init.StopBits = (uint32_t)COM_Init->StopBits;
|
||||
huart->Init.HwFlowCtl = (uint32_t)COM_Init->HwFlowCtl;
|
||||
huart->Init.OverSampling = UART_OVERSAMPLING_8;
|
||||
|
||||
return HAL_UART_Init(huart);
|
||||
}
|
||||
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
||||
/**
|
||||
* @brief Register Default COM Msp Callbacks
|
||||
* @param COM COM port to be configured.
|
||||
* This parameter can be COM1
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_COM_RegisterDefaultMspCallbacks(COM_TypeDef COM)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if(COM >= COMn)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
__HAL_UART_RESET_HANDLE_STATE(&hcom_uart[COM]);
|
||||
|
||||
/* Register default MspInit/MspDeInit Callback */
|
||||
if(HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPINIT_CB_ID, COM1_MspInit) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else if(HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPDEINIT_CB_ID, COM1_MspDeInit) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsComMspCbValid[COM] = 1U;
|
||||
}
|
||||
}
|
||||
|
||||
/* BSP status */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Register COM Msp Callback registering
|
||||
* @param COM COM port to be configured.
|
||||
* This parameter can be COM1
|
||||
* @param Callbacks pointer to COM1 MspInit/MspDeInit callback functions
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_COM_RegisterMspCallbacks(COM_TypeDef COM , BSP_COM_Cb_t *Callback)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if(COM >= COMn)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
__HAL_UART_RESET_HANDLE_STATE(&hcom_uart[COM]);
|
||||
|
||||
/* Register MspInit/MspDeInit Callbacks */
|
||||
if(HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPINIT_CB_ID, Callback->pMspInitCb) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else if(HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPDEINIT_CB_ID, Callback->pMspDeInitCb) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsComMspCbValid[COM] = 1U;
|
||||
}
|
||||
}
|
||||
/* BSP status */
|
||||
return ret;
|
||||
}
|
||||
#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
|
||||
|
||||
#if (USE_COM_LOG > 0)
|
||||
/**
|
||||
* @brief Select the active COM port.
|
||||
* @param COM COM port to be activated.
|
||||
* This parameter can be COM1
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_COM_SelectLogPort(COM_TypeDef COM)
|
||||
{
|
||||
if(COM_ActiveLogPort != COM)
|
||||
{
|
||||
COM_ActiveLogPort = COM;
|
||||
}
|
||||
return BSP_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Redirect console output to COM
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
int __io_putchar (int ch)
|
||||
#else
|
||||
int fputc (int ch, FILE *f)
|
||||
#endif /* __GNUC__ */
|
||||
{
|
||||
(void) HAL_UART_Transmit(&hcom_uart [COM_ActiveLogPort], (uint8_t *) &ch, 1, COM_POLL_TIMEOUT);
|
||||
return ch;
|
||||
}
|
||||
#endif /* USE_COM_LOG */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* (USE_BSP_COM_FEATURE > 0) */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32WLXX_NUCLEO_LOW_LEVEL_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Button SW1 EXTI line detection callback.
|
||||
* @retval None
|
||||
*/
|
||||
static void BUTTON_SW1_EXTI_Callback(void)
|
||||
{
|
||||
BSP_PB_Callback(BUTTON_SW1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Button SW2 EXTI line detection callback.
|
||||
* @retval None
|
||||
*/
|
||||
static void BUTTON_SW2_EXTI_Callback(void)
|
||||
{
|
||||
BSP_PB_Callback(BUTTON_SW2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Button SW3 EXTI line detection callback.
|
||||
* @retval None
|
||||
*/
|
||||
static void BUTTON_SW3_EXTI_Callback(void)
|
||||
{
|
||||
BSP_PB_Callback(BUTTON_SW3);
|
||||
}
|
||||
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
/**
|
||||
* @brief Initializes COM1 MSP.
|
||||
* @param huart UART handle
|
||||
* @retval BSP status
|
||||
*/
|
||||
static void COM1_MspInit(UART_HandleTypeDef *huart)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/* Prevent unused argument(s) compilation warning */
|
||||
UNUSED(huart);
|
||||
|
||||
/* Enable GPIO clock */
|
||||
COM1_TX_GPIO_CLK_ENABLE();
|
||||
COM1_RX_GPIO_CLK_ENABLE();
|
||||
|
||||
/* Enable USART clock */
|
||||
COM1_CLK_ENABLE();
|
||||
|
||||
/* Configure USART Tx as alternate function */
|
||||
gpio_init_structure.Pin = COM1_TX_PIN;
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Alternate = COM1_TX_AF;
|
||||
HAL_GPIO_Init(COM1_TX_GPIO_PORT, &gpio_init_structure);
|
||||
|
||||
/* Configure USART Rx as alternate function */
|
||||
gpio_init_structure.Pin = COM1_RX_PIN;
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Alternate = COM1_RX_AF;
|
||||
HAL_GPIO_Init(COM1_RX_GPIO_PORT, &gpio_init_structure);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitialize COM1 MSP part
|
||||
* @param huart UART handle
|
||||
* @retval BSP status
|
||||
*/
|
||||
static void COM1_MspDeInit(UART_HandleTypeDef *huart)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/* Prevent unused argument(s) compilation warning */
|
||||
UNUSED(huart);
|
||||
|
||||
/* COM GPIO pin configuration */
|
||||
gpio_init_structure.Pin = COM1_TX_PIN;
|
||||
HAL_GPIO_DeInit(COM1_TX_GPIO_PORT, gpio_init_structure.Pin);
|
||||
|
||||
gpio_init_structure.Pin = COM1_RX_PIN;
|
||||
HAL_GPIO_DeInit(COM1_RX_GPIO_PORT, gpio_init_structure.Pin);
|
||||
|
||||
/* Disable USART clock */
|
||||
COM1_CLK_DISABLE();
|
||||
}
|
||||
#endif /* (USE_BSP_COM_FEATURE > 0) */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -0,0 +1,355 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file stm32wlxx_nucleo.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for stm32wlxx_nucleo.c
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2020(-2021) STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef STM32WLXX_NUCLEO_H
|
||||
#define STM32WLXX_NUCLEO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32wlxx_nucleo_errno.h"
|
||||
#include "stm32wlxx_nucleo_conf.h"
|
||||
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
#if (USE_COM_LOG > 0)
|
||||
#ifndef __GNUC__
|
||||
#include "stdio.h"
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO STM32WLXX-NUCLEO
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL LOW LEVEL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_Exported_Types LOW LEVEL Exported Types
|
||||
* @{
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
LED1 = 0,
|
||||
LED2 = 1,
|
||||
LED3 = 2,
|
||||
/* Color led aliases */
|
||||
LED_BLUE = LED1,
|
||||
LED_GREEN = LED2,
|
||||
LED_RED = LED3
|
||||
}Led_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BUTTON_SW1 = 0,
|
||||
BUTTON_SW2 = 1,
|
||||
BUTTON_SW3 = 2,
|
||||
}Button_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BUTTON_MODE_GPIO = 0,
|
||||
BUTTON_MODE_EXTI = 1
|
||||
}ButtonMode_TypeDef;
|
||||
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
typedef enum
|
||||
{
|
||||
COM1 = 0U,
|
||||
COMn
|
||||
}COM_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COM_STOPBITS_1 = UART_STOPBITS_1,
|
||||
COM_STOPBITS_2 = UART_STOPBITS_2,
|
||||
}COM_StopBitsTypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COM_PARITY_NONE = UART_PARITY_NONE,
|
||||
COM_PARITY_EVEN = UART_PARITY_EVEN,
|
||||
COM_PARITY_ODD = UART_PARITY_ODD,
|
||||
}COM_ParityTypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COM_HWCONTROL_NONE = UART_HWCONTROL_NONE,
|
||||
COM_HWCONTROL_RTS = UART_HWCONTROL_RTS,
|
||||
COM_HWCONTROL_CTS = UART_HWCONTROL_CTS,
|
||||
COM_HWCONTROL_RTS_CTS = UART_HWCONTROL_RTS_CTS,
|
||||
}COM_HwFlowCtlTypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COM_WORDLENGTH_7B = UART_WORDLENGTH_7B,
|
||||
COM_WORDLENGTH_8B = UART_WORDLENGTH_8B,
|
||||
COM_WORDLENGTH_9B = UART_WORDLENGTH_9B,
|
||||
}COM_WordLengthTypeDef;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t BaudRate;
|
||||
COM_WordLengthTypeDef WordLength;
|
||||
COM_StopBitsTypeDef StopBits;
|
||||
COM_ParityTypeDef Parity;
|
||||
COM_HwFlowCtlTypeDef HwFlowCtl;
|
||||
}COM_InitTypeDef;
|
||||
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
||||
typedef struct
|
||||
{
|
||||
pUART_CallbackTypeDef pMspInitCb;
|
||||
pUART_CallbackTypeDef pMspDeInitCb;
|
||||
}BSP_COM_Cb_t;
|
||||
#endif /* (USE_HAL_UART_REGISTER_CALLBACKS == 1) */
|
||||
#endif /* (USE_BSP_COM_FEATURE > 0) */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ABSENT = 0,
|
||||
PRESENT = 1,
|
||||
}Presence_TypeDef;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_Exported_Constants LOW LEVEL Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief STM32WLXX NUCLEO BSP Driver version number
|
||||
*/
|
||||
#define __STM32WLXX_NUCLEO_BSP_VERSION_MAIN (0x01U) /*!< [31:24] main version */
|
||||
#define __STM32WLXX_NUCLEO_BSP_VERSION_SUB1 (0x01U) /*!< [23:16] sub1 version */
|
||||
#define __STM32WLXX_NUCLEO_BSP_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */
|
||||
#define __STM32WLXX_NUCLEO_BSP_VERSION_RC (0x00U) /*!< [7:0] release candidate */
|
||||
#define __STM32WLXX_NUCLEO_BSP_VERSION ((__STM32WLXX_NUCLEO_BSP_VERSION_MAIN << 24)\
|
||||
|(__STM32WLXX_NUCLEO_BSP_VERSION_SUB1 << 16)\
|
||||
|(__STM32WLXX_NUCLEO_BSP_VERSION_SUB2 << 8 )\
|
||||
|(__STM32WLXX_NUCLEO_BSP_VERSION_RC))
|
||||
|
||||
/**
|
||||
* @brief Define for STM32WLXX_NUCLEO board
|
||||
*/
|
||||
#if !defined (USE_STM32WLXX_NUCLEO)
|
||||
#define USE_STM32WLXX_NUCLEO
|
||||
#endif
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_LED LOW LEVEL LED Constants
|
||||
* @{
|
||||
*/
|
||||
#define LEDn 3
|
||||
|
||||
#define LED1_PIN GPIO_PIN_5
|
||||
#define LED1_GPIO_PORT GPIOB
|
||||
#define LED1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
#define LED1_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
|
||||
|
||||
#define LED2_PIN GPIO_PIN_4
|
||||
#define LED2_GPIO_PORT GPIOB
|
||||
#define LED2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
#define LED2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
|
||||
|
||||
#define LED3_PIN GPIO_PIN_3
|
||||
#define LED3_GPIO_PORT GPIOB
|
||||
#define LED3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
#define LED3_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
|
||||
|
||||
#define LEDx_GPIO_CLK_ENABLE(__INDEX__) __HAL_RCC_GPIOB_CLK_ENABLE() /* All Led on same port */
|
||||
#define LEDx_GPIO_CLK_DISABLE(__INDEX__) __HAL_RCC_GPIOB_CLK_DISABLE() /* All Led on same port */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_BUTTON LOW LEVEL BUTTON Constants
|
||||
* @{
|
||||
*/
|
||||
#define BUTTONn 3
|
||||
|
||||
/**
|
||||
* @brief Key push-buttons
|
||||
*/
|
||||
#define BUTTON_SW1_PIN GPIO_PIN_0
|
||||
#define BUTTON_SW1_GPIO_PORT GPIOA
|
||||
#define BUTTON_SW1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
|
||||
#define BUTTON_SW1_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
|
||||
#define BUTTON_SW1_EXTI_LINE EXTI_LINE_0
|
||||
#ifdef CORE_CM0PLUS
|
||||
#define BUTTON_SW1_EXTI_IRQn EXTI1_0_IRQn
|
||||
#else
|
||||
#define BUTTON_SW1_EXTI_IRQn EXTI0_IRQn
|
||||
#endif
|
||||
#define H_EXTI_0 hpb_exti[BUTTON_SW1]
|
||||
|
||||
#define BUTTON_SW2_PIN GPIO_PIN_1
|
||||
#define BUTTON_SW2_GPIO_PORT GPIOA
|
||||
#define BUTTON_SW2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
|
||||
#define BUTTON_SW2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
|
||||
#define BUTTON_SW2_EXTI_LINE EXTI_LINE_1
|
||||
|
||||
#define BUTTON_SW2_EXTI_IRQn EXTI1_IRQn
|
||||
|
||||
#define H_EXTI_1 hpb_exti[BUTTON_SW2]
|
||||
|
||||
#define BUTTON_SW3_PIN GPIO_PIN_4
|
||||
#define BUTTON_SW3_GPIO_PORT GPIOA
|
||||
#define BUTTON_SW3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
|
||||
#define BUTTON_SW3_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
|
||||
|
||||
#define BUTTON_SW3_EXTI_LINE EXTI_LINE_4
|
||||
#define BUTTON_SW3_EXTI_IRQn EXTI4_IRQn
|
||||
|
||||
#define H_EXTI_4 hpb_exti[BUTTON_SW3]
|
||||
|
||||
#define BUTTONx_GPIO_CLK_ENABLE(__INDEX__) do { if ((__INDEX__) == BUTTON_SW1) BUTTON_SW1_GPIO_CLK_ENABLE(); else \
|
||||
if ((__INDEX__) == BUTTON_SW2) BUTTON_SW2_GPIO_CLK_ENABLE(); else \
|
||||
if ((__INDEX__) == BUTTON_SW3) BUTTON_SW3_GPIO_CLK_ENABLE();} while(0)
|
||||
|
||||
#define BUTTONx_GPIO_CLK_DISABLE(__INDEX__) do { if ((__INDEX__) == BUTTON_SW1) BUTTON_SW1_GPIO_CLK_DISABLE(); else \
|
||||
if ((__INDEX__) == BUTTON_SW2) BUTTON_SW2_GPIO_CLK_DISABLE(); else \
|
||||
if ((__INDEX__) == BUTTON_SW3) BUTTON_SW3_GPIO_CLK_DISABLE();} while(0)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_COM LOW LEVEL COM Port Constants
|
||||
* @{
|
||||
*/
|
||||
#define COM1_UART LPUART1
|
||||
#define COM1_CLK_ENABLE() __HAL_RCC_LPUART1_CLK_ENABLE()
|
||||
#define COM1_CLK_DISABLE() __HAL_RCC_LPUART1_CLK_DISABLE()
|
||||
|
||||
#define COM1_TX_PIN GPIO_PIN_2
|
||||
#define COM1_TX_GPIO_PORT GPIOA
|
||||
#define COM1_TX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
|
||||
#define COM1_TX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
|
||||
#define COM1_TX_AF GPIO_AF8_LPUART1
|
||||
|
||||
#define COM1_RX_PIN GPIO_PIN_3
|
||||
#define COM1_RX_GPIO_PORT GPIOA
|
||||
#define COM1_RX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
|
||||
#define COM1_RX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
|
||||
#define COM1_RX_AF GPIO_AF8_LPUART1
|
||||
#define COM_POLL_TIMEOUT 1000
|
||||
|
||||
#define MX_UART_InitTypeDef COM_InitTypeDef
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* (USE_BSP_COM_FEATURE > 0)*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32WLXX_NUCLEO_LOW_LEVEL_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
extern EXTI_HandleTypeDef hpb_exti[];
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
extern UART_HandleTypeDef hcom_uart[];
|
||||
#endif /* (USE_BSP_COM_FEATURE > 0) */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_Exported_Functions LOW LEVEL Exported Functions
|
||||
* @{
|
||||
*/
|
||||
uint32_t BSP_GetVersion(void);
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_LED_Functions LOW LEVEL LED Functions
|
||||
* @{
|
||||
*/
|
||||
int32_t BSP_LED_Init(Led_TypeDef Led);
|
||||
int32_t BSP_LED_DeInit(Led_TypeDef Led);
|
||||
int32_t BSP_LED_On(Led_TypeDef Led);
|
||||
int32_t BSP_LED_Off(Led_TypeDef Led);
|
||||
int32_t BSP_LED_Toggle(Led_TypeDef Led);
|
||||
int32_t BSP_LED_GetState(Led_TypeDef Led);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_BUTTON_Functions LOW LEVEL BUTTON Functions
|
||||
* @{
|
||||
*/
|
||||
int32_t BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode);
|
||||
int32_t BSP_PB_DeInit(Button_TypeDef Button);
|
||||
int32_t BSP_PB_GetState(Button_TypeDef Button);
|
||||
void BSP_PB_Callback(Button_TypeDef Button);
|
||||
void BSP_PB_IRQHandler(Button_TypeDef Button);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_COM_Functions LOW LEVEL COM Port Functions
|
||||
* @{
|
||||
*/
|
||||
int32_t BSP_COM_Init(COM_TypeDef COM, COM_InitTypeDef *COM_Init);
|
||||
int32_t BSP_COM_DeInit(COM_TypeDef COM);
|
||||
#if (USE_COM_LOG > 0)
|
||||
int32_t BSP_COM_SelectLogPort (COM_TypeDef COM);
|
||||
#endif
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
||||
int32_t BSP_COM_RegisterDefaultMspCallbacks(COM_TypeDef COM);
|
||||
int32_t BSP_COM_RegisterMspCallbacks(COM_TypeDef COM , BSP_COM_Cb_t *Callback);
|
||||
#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
|
||||
HAL_StatusTypeDef MX_LPUART1_Init(UART_HandleTypeDef *huart, MX_UART_InitTypeDef *COM_Init);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* (USE_BSP_COM_FEATURE > 0) */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* STM32WLXX_NUCLEO_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file stm32wlxx_nucleo_errno.h
|
||||
* @author MCD Application Team
|
||||
* @brief Error Code.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2020(-2021) STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef STM32WLXX_NUCLEO_ERRNO_H
|
||||
#define STM32WLXX_NUCLEO_ERRNO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Common Error codes */
|
||||
#define BSP_ERROR_NONE 0
|
||||
#define BSP_ERROR_NO_INIT -1
|
||||
#define BSP_ERROR_WRONG_PARAM -2
|
||||
#define BSP_ERROR_BUSY -3
|
||||
#define BSP_ERROR_PERIPH_FAILURE -4
|
||||
#define BSP_ERROR_COMPONENT_FAILURE -5
|
||||
#define BSP_ERROR_UNKNOWN_FAILURE -6
|
||||
#define BSP_ERROR_UNKNOWN_COMPONENT -7
|
||||
#define BSP_ERROR_BUS_FAILURE -8
|
||||
#define BSP_ERROR_CLOCK_FAILURE -9
|
||||
#define BSP_ERROR_MSP_FAILURE -10
|
||||
#define BSP_ERROR_FEATURE_NOT_SUPPORTED -11
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* STM32WLXX_NUCLEO_ERRNO_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -0,0 +1,221 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file stm32wlxx_nucleo_radio.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides set of firmware functions to manage:
|
||||
* - RF circuitry available on STM32WLXX-Nucleo
|
||||
* Kit from STMicroelectronics
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2020-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32wlxx_nucleo_radio.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32WLXX_NUCLEO
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL
|
||||
* @brief This file provides set of firmware functions to Radio switch
|
||||
* available on STM32WLXX-Nucleo Kit from STMicroelectronics.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Init Radio Switch
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_RADIO_Init(void)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure = {0};
|
||||
|
||||
/* Enable the Radio Switch Clock */
|
||||
RF_SW_CTRL3_GPIO_CLK_ENABLE();
|
||||
RF_SW_CTRL2_GPIO_CLK_ENABLE();
|
||||
RF_SW_CTRL1_GPIO_CLK_ENABLE();
|
||||
/* Configure the Radio Switch pin */
|
||||
gpio_init_structure.Pin = RF_SW_CTRL1_PIN;
|
||||
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
gpio_init_structure.Pull = GPIO_NOPULL;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
|
||||
HAL_GPIO_Init(RF_SW_CTRL1_GPIO_PORT, &gpio_init_structure);
|
||||
|
||||
gpio_init_structure.Pin = RF_SW_CTRL2_PIN;
|
||||
HAL_GPIO_Init(RF_SW_CTRL2_GPIO_PORT, &gpio_init_structure);
|
||||
|
||||
gpio_init_structure.Pin = RF_SW_CTRL3_PIN;
|
||||
HAL_GPIO_Init(RF_SW_CTRL3_GPIO_PORT, &gpio_init_structure);
|
||||
|
||||
HAL_GPIO_WritePin(RF_SW_CTRL2_GPIO_PORT, RF_SW_CTRL2_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(RF_SW_CTRL1_GPIO_PORT, RF_SW_CTRL1_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(RF_SW_CTRL3_GPIO_PORT, RF_SW_CTRL3_PIN, GPIO_PIN_RESET);
|
||||
|
||||
return BSP_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInit Radio Switch
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_RADIO_DeInit(void)
|
||||
{
|
||||
RF_SW_CTRL3_GPIO_CLK_ENABLE();
|
||||
|
||||
/* Turn off switch */
|
||||
HAL_GPIO_WritePin(RF_SW_CTRL1_GPIO_PORT, RF_SW_CTRL1_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(RF_SW_CTRL2_GPIO_PORT, RF_SW_CTRL2_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(RF_SW_CTRL3_GPIO_PORT, RF_SW_CTRL3_PIN, GPIO_PIN_RESET);
|
||||
|
||||
/* DeInit the Radio Switch pin */
|
||||
HAL_GPIO_DeInit(RF_SW_CTRL1_GPIO_PORT, RF_SW_CTRL1_PIN);
|
||||
HAL_GPIO_DeInit(RF_SW_CTRL2_GPIO_PORT, RF_SW_CTRL2_PIN);
|
||||
HAL_GPIO_DeInit(RF_SW_CTRL3_GPIO_PORT, RF_SW_CTRL3_PIN);
|
||||
|
||||
return BSP_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure Radio Switch.
|
||||
* @param Config: Specifies the Radio RF switch path to be set.
|
||||
* This parameter can be one of following parameters:
|
||||
* @arg RADIO_SWITCH_OFF
|
||||
* @arg RADIO_SWITCH_RX
|
||||
* @arg RADIO_SWITCH_RFO_LP
|
||||
* @arg RADIO_SWITCH_RFO_HP
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_RADIO_ConfigRFSwitch(BSP_RADIO_Switch_TypeDef Config)
|
||||
{
|
||||
switch (Config)
|
||||
{
|
||||
case RADIO_SWITCH_OFF:
|
||||
{
|
||||
/* Turn off switch */
|
||||
HAL_GPIO_WritePin(RF_SW_CTRL3_GPIO_PORT, RF_SW_CTRL3_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(RF_SW_CTRL1_GPIO_PORT, RF_SW_CTRL1_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(RF_SW_CTRL2_GPIO_PORT, RF_SW_CTRL2_PIN, GPIO_PIN_RESET);
|
||||
break;
|
||||
}
|
||||
case RADIO_SWITCH_RX:
|
||||
{
|
||||
/*Turns On in Rx Mode the RF Switch */
|
||||
HAL_GPIO_WritePin(RF_SW_CTRL3_GPIO_PORT, RF_SW_CTRL3_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(RF_SW_CTRL1_GPIO_PORT, RF_SW_CTRL1_PIN, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(RF_SW_CTRL2_GPIO_PORT, RF_SW_CTRL2_PIN, GPIO_PIN_RESET);
|
||||
break;
|
||||
}
|
||||
case RADIO_SWITCH_RFO_LP:
|
||||
{
|
||||
/*Turns On in Tx Low Power the RF Switch */
|
||||
HAL_GPIO_WritePin(RF_SW_CTRL3_GPIO_PORT, RF_SW_CTRL3_PIN, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(RF_SW_CTRL1_GPIO_PORT, RF_SW_CTRL1_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(RF_SW_CTRL2_GPIO_PORT, RF_SW_CTRL2_PIN, GPIO_PIN_RESET);
|
||||
break;
|
||||
}
|
||||
case RADIO_SWITCH_RFO_HP:
|
||||
{
|
||||
/*Turns On in Tx High Power the RF Switch */
|
||||
HAL_GPIO_WritePin(RF_SW_CTRL3_GPIO_PORT, RF_SW_CTRL3_PIN, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(RF_SW_CTRL1_GPIO_PORT, RF_SW_CTRL1_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(RF_SW_CTRL2_GPIO_PORT, RF_SW_CTRL2_PIN, GPIO_PIN_RESET);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return BSP_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return Board Configuration
|
||||
* @retval
|
||||
* RADIO_CONF_RFO_LP_HP
|
||||
* RADIO_CONF_RFO_LP
|
||||
* RADIO_CONF_RFO_HP
|
||||
*/
|
||||
int32_t BSP_RADIO_GetTxConfig(void)
|
||||
{
|
||||
return RADIO_CONF_RFO_HP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get If TCXO is to be present on board
|
||||
* @note never remove called by MW,
|
||||
* @retval
|
||||
* RADIO_CONF_TCXO_NOT_SUPPORTED
|
||||
* RADIO_CONF_TCXO_SUPPORTED
|
||||
*/
|
||||
int32_t BSP_RADIO_IsTCXO(void)
|
||||
{
|
||||
return RADIO_CONF_TCXO_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get If DCDC is to be present on board
|
||||
* @note never remove called by MW,
|
||||
* @retval
|
||||
* RADIO_CONF_DCDC_NOT_SUPPORTED
|
||||
* RADIO_CONF_DCDC_SUPPORTED
|
||||
*/
|
||||
int32_t BSP_RADIO_IsDCDC(void)
|
||||
{
|
||||
return RADIO_CONF_DCDC_SUPPORTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return RF Output Max Power Configuration
|
||||
* @retval
|
||||
* RADIO_CONF_RFO_LP_MAX_15_dBm for LP mode
|
||||
* RADIO_CONF_RFO_HP_MAX_22_dBm for HP mode
|
||||
*/
|
||||
int32_t BSP_RADIO_GetRFOMaxPowerConfig(BSP_RADIO_RFOMaxPowerConfig_TypeDef Config)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
if(Config == RADIO_RFO_LP_MAXPOWER)
|
||||
{
|
||||
ret = RADIO_CONF_RFO_LP_MAX_15_dBm;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = RADIO_CONF_RFO_HP_MAX_22_dBm;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
|
@ -0,0 +1,160 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file stm32wlxx_nucleo_radio.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for stm32wlxx_nucleo_radio.c
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2020(-2021) STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef STM32WLXX_NUCLEO_RADIO_H
|
||||
#define STM32WLXX_NUCLEO_RADIO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32wlxx_nucleo_errno.h"
|
||||
#include "stm32wlxx_nucleo_conf.h"
|
||||
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32WLXX_NUCLEO STM32WLXX-NUCLEO
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL RADIO LOW LEVEL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL_Exported_Types RADIO LOW LEVEL Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
RADIO_SWITCH_OFF = 0,
|
||||
RADIO_SWITCH_RX = 1,
|
||||
RADIO_SWITCH_RFO_LP = 2,
|
||||
RADIO_SWITCH_RFO_HP = 3,
|
||||
}BSP_RADIO_Switch_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
RADIO_RFO_LP_MAXPOWER = 0,
|
||||
RADIO_RFO_HP_MAXPOWER,
|
||||
} BSP_RADIO_RFOMaxPowerConfig_TypeDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL_Exported_Constants RADIO LOW LEVEL Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL_RADIOCONFIG RADIO LOW LEVEL RADIO CONFIG Constants
|
||||
* @{
|
||||
*/
|
||||
#define RADIO_CONF_RFO_LP_HP 0U
|
||||
#define RADIO_CONF_RFO_LP 1U
|
||||
#define RADIO_CONF_RFO_HP 2U
|
||||
|
||||
#define RADIO_CONF_TCXO_NOT_SUPPORTED 0U
|
||||
#define RADIO_CONF_TCXO_SUPPORTED 1U
|
||||
|
||||
#define RADIO_CONF_DCDC_NOT_SUPPORTED 0U
|
||||
#define RADIO_CONF_DCDC_SUPPORTED 1U
|
||||
|
||||
#define RADIO_CONF_RFO_HP_MAX_22_dBm ((int32_t) 22)
|
||||
#define RADIO_CONF_RFO_HP_MAX_20_dBm ((int32_t) 20)
|
||||
#define RADIO_CONF_RFO_HP_MAX_17_dBm ((int32_t) 17)
|
||||
#define RADIO_CONF_RFO_HP_MAX_14_dBm ((int32_t) 14)
|
||||
#define RADIO_CONF_RFO_LP_MAX_15_dBm ((int32_t) 15)
|
||||
#define RADIO_CONF_RFO_LP_MAX_14_dBm ((int32_t) 14)
|
||||
#define RADIO_CONF_RFO_LP_MAX_10_dBm ((int32_t) 10)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL_RFSWITCH RADIO LOW LEVEL RF SWITCH Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define RF_SW_CTRL3_PIN GPIO_PIN_8
|
||||
#define RF_SW_CTRL3_GPIO_PORT GPIOA
|
||||
#define RF_SW_CTRL3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
|
||||
#define RF_SW_CTRL3_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
|
||||
|
||||
#define RF_SW_CTRL1_PIN GPIO_PIN_0
|
||||
#define RF_SW_CTRL1_GPIO_PORT GPIOB
|
||||
#define RF_SW_CTRL1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
#define RF_SW_RX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
|
||||
|
||||
#define RF_SW_CTRL2_PIN GPIO_PIN_15
|
||||
#define RF_SW_CTRL2_GPIO_PORT GPIOA
|
||||
#define RF_SW_CTRL2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
|
||||
#define RF_SW_CTRL2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
|
||||
//未使用
|
||||
#define RF_TCXO_VCC_PIN
|
||||
#define RF_TCXO_VCC_GPIO_PORT
|
||||
#define RF_TCXO_VCC_CLK_ENABLE()
|
||||
#define RF_TCXO_VCC_CLK_DISABLE()
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL_Exported_Functions RADIO LOW LEVEL Exported Functions
|
||||
* @{
|
||||
*/
|
||||
int32_t BSP_RADIO_Init(void);
|
||||
int32_t BSP_RADIO_DeInit(void);
|
||||
int32_t BSP_RADIO_ConfigRFSwitch(BSP_RADIO_Switch_TypeDef Config);
|
||||
int32_t BSP_RADIO_GetTxConfig(void);
|
||||
int32_t BSP_RADIO_IsTCXO(void);
|
||||
int32_t BSP_RADIO_IsDCDC(void);
|
||||
int32_t BSP_RADIO_GetRFOMaxPowerConfig(BSP_RADIO_RFOMaxPowerConfig_TypeDef Config);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* STM32WLXX_NUCLEO_RADIO_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
project(yzl_wle5_template)
|
||||
project(yzl_wle5_lorawan_node)
|
||||
|
||||
enable_language(CXX)
|
||||
enable_language(ASM)
|
||||
|
@ -9,21 +9,85 @@ enable_language(ASM)
|
|||
set(TARGET_LDSCRIPT_FLASH "${CMAKE_SOURCE_DIR}/MX_Generated/STM32WLE5XX_FLASH.ld")
|
||||
|
||||
set(TARGET_SOURCES
|
||||
"BSP/stm32wlxx_nucleo_radio.c"
|
||||
"BSP/stm32wlxx_nucleo.c"
|
||||
"MX_Generated/startup_stm32wle5xx.s"
|
||||
"MX_Generated/Core/Src/adc.c"
|
||||
"MX_Generated/Core/Src/adc_if.c"
|
||||
"MX_Generated/Core/Src/dma.c"
|
||||
"MX_Generated/Core/Src/gpio.c"
|
||||
"MX_Generated/Core/Src/main.c"
|
||||
"MX_Generated/Core/Src/rtc.c"
|
||||
"MX_Generated/Core/Src/stm32_lpm_if.c"
|
||||
"MX_Generated/Core/Src/stm32wlxx_hal_msp.c"
|
||||
"MX_Generated/Core/Src/stm32wlxx_it.c"
|
||||
"MX_Generated/Core/Src/sys_app.c"
|
||||
"MX_Generated/Core/Src/system_stm32wlxx.c"
|
||||
"MX_Generated/Core/Src/timer_if.c"
|
||||
"MX_Generated/Core/Src/usart.c"
|
||||
"MX_Generated/Core/Src/usart_if.c"
|
||||
"MX_Generated/Core/Src/rtc.c"
|
||||
"MX_Generated/Core/Src/subghz.c"
|
||||
"MX_Generated/LoRaWAN/App/app_lorawan.c"
|
||||
"MX_Generated/LoRaWAN/App/lora_app.c"
|
||||
"MX_Generated/LoRaWAN/App/lora_info.c"
|
||||
"MX_Generated/LoRaWAN/Target/radio_board_if.c"
|
||||
"SDK/Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal.c"
|
||||
"SDK/Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_cortex.c"
|
||||
"SDK/Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_dma.c"
|
||||
"SDK/Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_dma_ex.c"
|
||||
"SDK/Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_pwr.c"
|
||||
"SDK/Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_pwr_ex.c"
|
||||
"SDK/Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_gpio.c"
|
||||
"SDK/Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_rcc.c"
|
||||
"SDK/Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_rcc_ex.c"
|
||||
"SDK/Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_rtc.c"
|
||||
"SDK/Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_rtc_ex.c"
|
||||
"SDK/Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_subghz.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Crypto/lorawan_aes.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Crypto/cmac.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Crypto/soft-se.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/LmHandler/Packages/LmhpCompliance.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/LmHandler/Packages/LmhpPackagesRegistration.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/Region/Region.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/Region/RegionAS923.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/Region/RegionAU915.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/Region/RegionBaseUS.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/Region/RegionCommon.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/Region/RegionCN470.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/Region/RegionCN470A20.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/Region/RegionCN470A26.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/Region/RegionCN470B20.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/Region/RegionCN470B26.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/Region/RegionCN779.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/Region/RegionEU433.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/Region/RegionEU868.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/Region/RegionIN865.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/Region/RegionKR920.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/Region/RegionRU864.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/Region/RegionUS915.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/LoRaMacAdr.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/LoRaMacCommands.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/LoRaMacParser.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/LoRaMacConfirmQueue.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/LoRaMacSerializer.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/LoRaMacClassB.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/LoRaMac.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/LoRaMacCrypto.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/LmHandler/NvmDataMgmt.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/LmHandler/LmHandler.c"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Utilities/utilities.c"
|
||||
"SDK/Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver/radio.c"
|
||||
"SDK/Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver/radio_driver.c"
|
||||
"SDK/Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver/radio_fw.c"
|
||||
"SDK/Utilities/trace/adv_trace/stm32_adv_trace.c"
|
||||
"SDK/Utilities/misc/stm32_mem.c"
|
||||
"SDK/Utilities/misc/stm32_systime.c"
|
||||
"SDK/Utilities/misc/stm32_tiny_sscanf.c"
|
||||
"SDK/Utilities/misc/stm32_tiny_vsnprintf.c"
|
||||
"SDK/Utilities/sequencer/stm32_seq.c"
|
||||
"SDK/Utilities/timer/stm32_timer.c"
|
||||
"SDK/Utilities/lpm/tiny_lpm/stm32_lpm.c"
|
||||
"src/main.c"
|
||||
)
|
||||
|
||||
|
@ -34,10 +98,26 @@ set(TARGET_C_DEFINES
|
|||
)
|
||||
|
||||
set(TARGET_C_INCLUDES
|
||||
"BSP"
|
||||
"SDK/Drivers/CMSIS/Core/Include"
|
||||
"SDK/Drivers/CMSIS/Device/ST/STM32WLxx/Include"
|
||||
"SDK/Drivers/STM32WLxx_HAL_Driver/Inc"
|
||||
"MX_Generated/Core/Inc"
|
||||
"MX_Generated/LoRaWAN/App"
|
||||
"MX_Generated/LoRaWAN/Target"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Crypto"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/LmHandler"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/LmHandler/Packages"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac/Region"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Mac"
|
||||
"SDK/Middlewares/Third_Party/LoRaWAN/Utilities"
|
||||
"SDK/Middlewares/Third_Party/SubGHz_Phy"
|
||||
"SDK/Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver"
|
||||
"SDK/Utilities/lpm/tiny_lpm"
|
||||
"SDK/Utilities/misc"
|
||||
"SDK/Utilities/sequencer"
|
||||
"SDK/Utilities/timer"
|
||||
"SDK/Utilities/trace/adv_trace"
|
||||
"include"
|
||||
)
|
||||
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file adc.h
|
||||
* @brief This file contains all the function prototypes for
|
||||
* the adc.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __ADC_H__
|
||||
#define __ADC_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
extern ADC_HandleTypeDef hadc;
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
void MX_ADC_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
|
||||
/* USER CODE END Prototypes */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ADC_H__ */
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file adc_if.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for ADC interface configuration
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __ADC_IF_H__
|
||||
#define __ADC_IF_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "adc.h"
|
||||
#include "platform.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Battery level in mV
|
||||
*/
|
||||
#define BAT_CR2032 ((uint32_t) 3000)
|
||||
/**
|
||||
* @brief Maximum battery level in mV
|
||||
*/
|
||||
#define VDD_BAT BAT_CR2032
|
||||
/**
|
||||
* @brief Minimum battery level in mV
|
||||
*/
|
||||
#define VDD_MIN 1800
|
||||
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Initializes the ADC input
|
||||
*/
|
||||
void SYS_InitMeasurement(void);
|
||||
|
||||
/**
|
||||
* @brief DeInitializes the ADC
|
||||
*/
|
||||
void SYS_DeInitMeasurement(void);
|
||||
|
||||
/**
|
||||
* @brief Get the current temperature
|
||||
* @return value temperature in degree Celsius( q7.8 )
|
||||
*/
|
||||
int16_t SYS_GetTemperatureLevel(void);
|
||||
|
||||
/**
|
||||
* @brief Get the current battery level
|
||||
* @return value battery level in linear scale
|
||||
*/
|
||||
uint16_t SYS_GetBatteryLevel(void);
|
||||
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ADC_IF_H__ */
|
|
@ -0,0 +1,52 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file dma.h
|
||||
* @brief This file contains all the function prototypes for
|
||||
* the dma.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __DMA_H__
|
||||
#define __DMA_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
|
||||
/* DMA memory to memory transfer handles -------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
void MX_DMA_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
|
||||
/* USER CODE END Prototypes */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __DMA_H__ */
|
||||
|
|
@ -57,6 +57,9 @@ void Error_Handler(void);
|
|||
/* USER CODE END EFP */
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
#define RTC_PREDIV_A ((1<<(15-RTC_N_PREDIV_S))-1)
|
||||
#define RTC_N_PREDIV_S 10
|
||||
#define RTC_PREDIV_S ((1<<RTC_N_PREDIV_S)-1)
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file platform.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for General HW instances configuration
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PLATFORM_H__
|
||||
#define __PLATFORM_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
#define USE_BSP_DRIVER
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <stdbool.h>
|
||||
#include "stm32wlxx.h"
|
||||
#include "main.h"
|
||||
#include "stm32wlxx_ll_gpio.h"
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
/* code generated by STM32CubeMX does not support BSP. */
|
||||
/* In order to use BSP, users can add the BSP files in the IDE project space */
|
||||
/* and define USE_BSP_DRIVER in the preprocessor definitions */
|
||||
#include "stm32wlxx_nucleo_radio.h"
|
||||
#include "stm32wlxx_nucleo.h" /* not used by this project*/
|
||||
#endif /* defined(USE_BSP_DRIVER) */
|
||||
|
||||
/* USER CODE BEGIN include */
|
||||
|
||||
/* USER CODE END include */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PLATFORM_H__ */
|
|
@ -0,0 +1,99 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32_lpm_if.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for Low Power Manager interface configuration
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32_LPM_IF_H__
|
||||
#define __STM32_LPM_IF_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32_lpm.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/**
|
||||
* @brief Enters Low Power Off Mode
|
||||
*/
|
||||
void PWR_EnterOffMode(void);
|
||||
|
||||
/**
|
||||
* @brief Exits Low Power Off Mode
|
||||
*/
|
||||
void PWR_ExitOffMode(void);
|
||||
|
||||
/**
|
||||
* @brief Enters Low Power Stop Mode
|
||||
* @note ARM exists the function when waking up
|
||||
*/
|
||||
void PWR_EnterStopMode(void);
|
||||
|
||||
/**
|
||||
* @brief Exits Low Power Stop Mode
|
||||
* @note Enable the pll at 32MHz
|
||||
*/
|
||||
void PWR_ExitStopMode(void);
|
||||
|
||||
/**
|
||||
* @brief Enters Low Power Sleep Mode
|
||||
* @note ARM exits the function when waking up
|
||||
*/
|
||||
void PWR_EnterSleepMode(void);
|
||||
|
||||
/**
|
||||
* @brief Exits Low Power Sleep Mode
|
||||
* @note ARM exits the function when waking up
|
||||
*/
|
||||
void PWR_ExitSleepMode(void);
|
||||
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__STM32_LPM_IF_H__ */
|
|
@ -34,7 +34,7 @@
|
|||
* @brief This is the list of modules to be used in the HAL driver
|
||||
*/
|
||||
#define HAL_MODULE_ENABLED
|
||||
/*#define HAL_ADC_MODULE_ENABLED */
|
||||
#define HAL_ADC_MODULE_ENABLED
|
||||
/*#define HAL_COMP_MODULE_ENABLED */
|
||||
/*#define HAL_CRC_MODULE_ENABLED */
|
||||
/*#define HAL_CRYP_MODULE_ENABLED */
|
||||
|
@ -53,9 +53,9 @@
|
|||
/*#define HAL_SMARTCARD_MODULE_ENABLED */
|
||||
/*#define HAL_SMBUS_MODULE_ENABLED */
|
||||
/*#define HAL_SPI_MODULE_ENABLED */
|
||||
/*#define HAL_SUBGHZ_MODULE_ENABLED */
|
||||
#define HAL_SUBGHZ_MODULE_ENABLED
|
||||
/*#define HAL_TIM_MODULE_ENABLED */
|
||||
/*#define HAL_UART_MODULE_ENABLED */
|
||||
#define HAL_UART_MODULE_ENABLED
|
||||
/*#define HAL_USART_MODULE_ENABLED */
|
||||
/*#define HAL_WWDG_MODULE_ENABLED */
|
||||
#define HAL_EXTI_MODULE_ENABLED
|
||||
|
|
|
@ -55,6 +55,8 @@ void SVC_Handler(void);
|
|||
void DebugMon_Handler(void);
|
||||
void PendSV_Handler(void);
|
||||
void SysTick_Handler(void);
|
||||
void DMA1_Channel1_IRQHandler(void);
|
||||
void DMA1_Channel2_IRQHandler(void);
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32wlxx_nucleo_conf.h
|
||||
* @author MCD Application Team
|
||||
* @brief STM32WLxx_Nucleo board configuration file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef STM32WLXX_NUCLEO_CONF_H
|
||||
#define STM32WLXX_NUCLEO_CONF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32wlxx_hal.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32WLXX_NUCLEO
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO_CONFIG CONFIG
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32WLXX_NUCLEO_CONFIG_Exported_Constants Exported Constants
|
||||
* @{
|
||||
*/
|
||||
/* COM usage define */
|
||||
#define USE_BSP_COM_FEATURE 0U
|
||||
|
||||
/* COM log define */
|
||||
#define USE_COM_LOG 0U
|
||||
|
||||
/* IRQ priorities */
|
||||
#define BSP_BUTTON_USER_IT_PRIORITY 14U
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* STM32WLXX_NUCLEO_CONF_H */
|
|
@ -0,0 +1,52 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file subghz.h
|
||||
* @brief This file contains all the function prototypes for
|
||||
* the subghz.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __SUBGHZ_H__
|
||||
#define __SUBGHZ_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
extern SUBGHZ_HandleTypeDef hsubghz;
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
void MX_SUBGHZ_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
|
||||
/* USER CODE END Prototypes */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __SUBGHZ_H__ */
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file sys_app.h
|
||||
* @author MCD Application Team
|
||||
* @brief Function prototypes for sys_app.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __SYS_APP_H__
|
||||
#define __SYS_APP_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stdint.h"
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported defines ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ED */
|
||||
|
||||
/* USER CODE END ED */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN APP_PRINT */
|
||||
/* Map your own trace mechanism or to map UTIL_ADV_TRACE see examples from CubeFw, e.g.: */
|
||||
#define APP_PRINTF(...) /* do{ {UTIL_ADV_TRACE_COND_FSend(VLEVEL_ALWAYS, T_REG_OFF, TS_OFF, __VA_ARGS__);} }while(0); */
|
||||
#define APP_LOG(TS,VL,...) /* do{ {UTIL_ADV_TRACE_COND_FSend(VL, T_REG_OFF, TS, __VA_ARGS__);} }while(0); */
|
||||
/* USER CODE END APP_PRINT */
|
||||
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/**
|
||||
* @brief initialize the system (dbg pins, trace, mbmux, sys timer, LPM, ...)
|
||||
*/
|
||||
void SystemApp_Init(void);
|
||||
|
||||
/**
|
||||
* @brief callback to get the battery level in % of full charge (254 full charge, 0 no charge)
|
||||
* @retval battery level
|
||||
*/
|
||||
uint8_t GetBatteryLevel(void);
|
||||
|
||||
/**
|
||||
* @brief callback to get the current temperature in the MCU
|
||||
* @retval temperature level
|
||||
*/
|
||||
int16_t GetTemperatureLevel(void);
|
||||
|
||||
/**
|
||||
* @brief callback to get the board 64 bits unique ID
|
||||
* @param id unique ID
|
||||
*/
|
||||
void GetUniqueId(uint8_t *id);
|
||||
|
||||
/**
|
||||
* @brief callback to get the board 32 bits unique ID (LSB)
|
||||
* @param devAddr Device Address
|
||||
*/
|
||||
void GetDevAddr(uint32_t *devAddr);
|
||||
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __SYS_APP_H__ */
|
|
@ -0,0 +1,171 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file timer_if.h
|
||||
* @author MCD Application Team
|
||||
* @brief configuration of the timer_if.c instances
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TIMER_IF_H__
|
||||
#define __TIMER_IF_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32_timer.h"
|
||||
#include "stm32_systime.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/**
|
||||
* @brief Init RTC hardware
|
||||
* @return Status based on @ref UTIL_TIMER_Status_t
|
||||
*/
|
||||
UTIL_TIMER_Status_t TIMER_IF_Init(void);
|
||||
|
||||
/**
|
||||
* @brief Set the alarm
|
||||
* @note The alarm is set at timeout from timer Reference (TimerContext)
|
||||
* @param timeout Duration of the Timer in ticks
|
||||
* @return Status based on @ref UTIL_TIMER_Status_t
|
||||
*/
|
||||
UTIL_TIMER_Status_t TIMER_IF_StartTimer(uint32_t timeout);
|
||||
|
||||
/**
|
||||
* @brief Stop the Alarm
|
||||
* @return Status based on @ref UTIL_TIMER_Status_t
|
||||
*/
|
||||
UTIL_TIMER_Status_t TIMER_IF_StopTimer(void);
|
||||
|
||||
/**
|
||||
* @brief set timer Reference (TimerContext)
|
||||
* @return Timer Reference Value in Ticks
|
||||
*/
|
||||
uint32_t TIMER_IF_SetTimerContext(void);
|
||||
|
||||
/**
|
||||
* @brief Get the RTC timer Reference
|
||||
* @return Timer Value in Ticks
|
||||
*/
|
||||
uint32_t TIMER_IF_GetTimerContext(void);
|
||||
|
||||
/**
|
||||
* @brief Get the timer elapsed time since timer Reference (TimerContext) was set
|
||||
* @return RTC Elapsed time in ticks
|
||||
*/
|
||||
uint32_t TIMER_IF_GetTimerElapsedTime(void);
|
||||
|
||||
/**
|
||||
* @brief Get the timer value
|
||||
* @return RTC Timer value in ticks
|
||||
*/
|
||||
uint32_t TIMER_IF_GetTimerValue(void);
|
||||
|
||||
/**
|
||||
* @brief Return the minimum timeout in ticks the RTC is able to handle
|
||||
* @return minimum value for a timeout in ticks
|
||||
*/
|
||||
uint32_t TIMER_IF_GetMinimumTimeout(void);
|
||||
|
||||
/**
|
||||
* @brief a delay of delay ms by polling RTC
|
||||
* @param delay in ms
|
||||
*/
|
||||
void TIMER_IF_DelayMs(uint32_t delay);
|
||||
|
||||
/**
|
||||
* @brief converts time in ms to time in ticks
|
||||
* @param[in] timeMilliSec time in milliseconds
|
||||
* @return time in timer ticks
|
||||
*/
|
||||
uint32_t TIMER_IF_Convert_ms2Tick(uint32_t timeMilliSec);
|
||||
|
||||
/**
|
||||
* @brief converts time in ticks to time in ms
|
||||
* @param[in] tick time in timer ticks
|
||||
* @return time in timer milliseconds
|
||||
*/
|
||||
uint32_t TIMER_IF_Convert_Tick2ms(uint32_t tick);
|
||||
|
||||
/**
|
||||
* @brief Get rtc time
|
||||
* @param[out] subSeconds in ticks
|
||||
* @return time seconds
|
||||
*/
|
||||
uint32_t TIMER_IF_GetTime(uint16_t *subSeconds);
|
||||
|
||||
/**
|
||||
* @brief write seconds in backUp register
|
||||
* @note Used to store seconds difference between RTC time and Unix time
|
||||
* @param[in] Seconds time in seconds
|
||||
*/
|
||||
void TIMER_IF_BkUp_Write_Seconds(uint32_t Seconds);
|
||||
|
||||
/**
|
||||
* @brief reads seconds from backUp register
|
||||
* @note Used to store seconds difference between RTC time and Unix time
|
||||
* @return Time in seconds
|
||||
*/
|
||||
uint32_t TIMER_IF_BkUp_Read_Seconds(void);
|
||||
|
||||
/**
|
||||
* @brief writes SubSeconds in backUp register
|
||||
* @note Used to store SubSeconds difference between RTC time and Unix time
|
||||
* @param[in] SubSeconds time in SubSeconds
|
||||
*/
|
||||
void TIMER_IF_BkUp_Write_SubSeconds(uint32_t SubSeconds);
|
||||
|
||||
/**
|
||||
* @brief reads SubSeconds from backUp register
|
||||
* @note Used to store SubSeconds difference between RTC time and Unix time
|
||||
* @return Time in SubSeconds
|
||||
*/
|
||||
uint32_t TIMER_IF_BkUp_Read_SubSeconds(void);
|
||||
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __TIMER_IF_H__ */
|
|
@ -0,0 +1,52 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usart.h
|
||||
* @brief This file contains all the function prototypes for
|
||||
* the usart.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __USART_H__
|
||||
#define __USART_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
extern UART_HandleTypeDef hlpuart1;
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
void MX_LPUART1_UART_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
|
||||
/* USER CODE END Prototypes */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __USART_H__ */
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usart_if.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for USART interface configuration
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
#include "stm32_adv_trace.h"
|
||||
#include "usart.h"
|
||||
#include "dma.h"
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __USART_IF_H__
|
||||
#define __USART_IF_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/**
|
||||
* @brief Init the UART and associated DMA.
|
||||
* @param cb TxCpltCallback
|
||||
* @return @ref UTIL_ADV_TRACE_Status_t
|
||||
*/
|
||||
UTIL_ADV_TRACE_Status_t vcom_Init(void (*cb)(void *));
|
||||
|
||||
/**
|
||||
* @brief init receiver of vcom
|
||||
* @param RxCb callback when Rx char is received
|
||||
* @return @ref UTIL_ADV_TRACE_Status_t
|
||||
*/
|
||||
UTIL_ADV_TRACE_Status_t vcom_ReceiveInit(void (*RxCb)(uint8_t *rxChar, uint16_t size, uint8_t error));
|
||||
|
||||
/**
|
||||
* @brief DeInit the UART and associated DMA.
|
||||
* @return @ref UTIL_ADV_TRACE_Status_t
|
||||
*/
|
||||
UTIL_ADV_TRACE_Status_t vcom_DeInit(void);
|
||||
|
||||
/**
|
||||
* @brief send buffer \p p_data of size \p size to vcom in polling mode
|
||||
* @param p_data data to be sent
|
||||
* @param size of buffer p_data to be sent
|
||||
*/
|
||||
void vcom_Trace(uint8_t *p_data, uint16_t size);
|
||||
|
||||
/**
|
||||
* @brief send buffer \p p_data of size \p size to vcom using DMA
|
||||
* @param p_data data to be sent
|
||||
* @param size of buffer p_data to be sent
|
||||
* @return @ref UTIL_ADV_TRACE_Status_t
|
||||
*/
|
||||
UTIL_ADV_TRACE_Status_t vcom_Trace_DMA(uint8_t *p_data, uint16_t size);
|
||||
|
||||
/**
|
||||
* @brief last byte has been sent on the uart line
|
||||
*/
|
||||
void vcom_IRQHandler(void);
|
||||
|
||||
/**
|
||||
* @brief last byte has been sent from memory to uart data register
|
||||
*/
|
||||
void vcom_DMA_TX_IRQHandler(void);
|
||||
|
||||
/**
|
||||
* @brief Resume the UART and associated DMA (used by LPM)
|
||||
*/
|
||||
void vcom_Resume(void);
|
||||
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __USART_IF_H__ */
|
|
@ -0,0 +1,177 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file utilities_conf.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for configuration file to utilities
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __UTILITIES_CONF_H__
|
||||
#define __UTILITIES_CONF_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "cmsis_compiler.h"
|
||||
|
||||
/* definitions to be provided to "sequencer" utility */
|
||||
#include "stm32_mem.h"
|
||||
/* definition and callback for tiny_vsnprintf */
|
||||
#include "stm32_tiny_vsnprintf.h"
|
||||
|
||||
/* enum number of task and priority*/
|
||||
#include "utilities_def.h"
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define VLEVEL_OFF 0 /*!< used to set UTIL_ADV_TRACE_SetVerboseLevel() (not as message param) */
|
||||
#define VLEVEL_ALWAYS 0 /*!< used as message params, if this level is given
|
||||
trace will be printed even when UTIL_ADV_TRACE_SetVerboseLevel(OFF) */
|
||||
#define VLEVEL_L 1 /*!< just essential traces */
|
||||
#define VLEVEL_M 2 /*!< functional traces */
|
||||
#define VLEVEL_H 3 /*!< all traces */
|
||||
|
||||
#define TS_OFF 0 /*!< Log without TimeStamp */
|
||||
#define TS_ON 1 /*!< Log with TimeStamp */
|
||||
|
||||
#define T_REG_OFF 0 /*!< Log without bitmask */
|
||||
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/******************************************************************************
|
||||
* common
|
||||
******************************************************************************/
|
||||
/**
|
||||
* @brief Memory placement macro
|
||||
*/
|
||||
#if defined(__CC_ARM)
|
||||
#define UTIL_PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__), zero_init))
|
||||
#elif defined(__ICCARM__)
|
||||
#define UTIL_PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__)))
|
||||
#else /* __GNUC__ */
|
||||
#define UTIL_PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__)))
|
||||
#endif /* __CC_ARM | __ICCARM__ | __GNUC__ */
|
||||
|
||||
/**
|
||||
* @brief Memory alignment macro
|
||||
*/
|
||||
#undef ALIGN
|
||||
#ifdef WIN32
|
||||
#define ALIGN(n)
|
||||
#else
|
||||
#define ALIGN(n) __attribute__((aligned(n)))
|
||||
#endif /* WIN32 */
|
||||
|
||||
/**
|
||||
* @brief macro used to initialize the critical section
|
||||
*/
|
||||
#define UTILS_INIT_CRITICAL_SECTION()
|
||||
|
||||
/**
|
||||
* @brief macro used to enter the critical section
|
||||
*/
|
||||
#define UTILS_ENTER_CRITICAL_SECTION() uint32_t primask_bit= __get_PRIMASK();\
|
||||
__disable_irq()
|
||||
|
||||
/**
|
||||
* @brief macro used to exit the critical section
|
||||
*/
|
||||
#define UTILS_EXIT_CRITICAL_SECTION() __set_PRIMASK(primask_bit)
|
||||
/******************************************************************************
|
||||
* sequencer
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief default number of tasks configured in sequencer
|
||||
*/
|
||||
#define UTIL_SEQ_CONF_TASK_NBR CFG_SEQ_Task_NBR
|
||||
|
||||
/**
|
||||
* @brief default value of priority task
|
||||
*/
|
||||
|
||||
#define UTIL_SEQ_CONF_PRIO_NBR CFG_SEQ_Prio_NBR
|
||||
|
||||
/**
|
||||
* @brief macro used to initialize the critical section
|
||||
*/
|
||||
#define UTIL_SEQ_INIT_CRITICAL_SECTION( ) UTILS_INIT_CRITICAL_SECTION()
|
||||
|
||||
/**
|
||||
* @brief macro used to enter the critical section
|
||||
*/
|
||||
#define UTIL_SEQ_ENTER_CRITICAL_SECTION( ) UTILS_ENTER_CRITICAL_SECTION()
|
||||
|
||||
/**
|
||||
* @brief macro used to exit the critical section
|
||||
*/
|
||||
#define UTIL_SEQ_EXIT_CRITICAL_SECTION( ) UTILS_EXIT_CRITICAL_SECTION()
|
||||
|
||||
/**
|
||||
* @brief Memset utilities interface to application
|
||||
*/
|
||||
#define UTIL_SEQ_MEMSET8( dest, value, size ) UTIL_MEM_set_8( dest, value, size )
|
||||
|
||||
/******************************************************************************
|
||||
* trace\advanced
|
||||
* the define option
|
||||
* UTIL_ADV_TRACE_CONDITIONNAL shall be defined if you want use conditional function
|
||||
* UTIL_ADV_TRACE_UNCHUNK_MODE shall be defined if you want use the unchunk mode
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#define UTIL_ADV_TRACE_CONDITIONNAL /*!< not used */
|
||||
#define UTIL_ADV_TRACE_UNCHUNK_MODE /*!< not used */
|
||||
#define UTIL_ADV_TRACE_DEBUG(...) /*!< not used */
|
||||
#define UTIL_ADV_TRACE_INIT_CRITICAL_SECTION( ) UTILS_INIT_CRITICAL_SECTION() /*!< init the critical section in trace feature */
|
||||
#define UTIL_ADV_TRACE_ENTER_CRITICAL_SECTION( ) UTILS_ENTER_CRITICAL_SECTION() /*!< enter the critical section in trace feature */
|
||||
#define UTIL_ADV_TRACE_EXIT_CRITICAL_SECTION( ) UTILS_EXIT_CRITICAL_SECTION() /*!< exit the critical section in trace feature */
|
||||
#define UTIL_ADV_TRACE_TMP_BUF_SIZE (256U) /*!< default trace buffer size */
|
||||
#define UTIL_ADV_TRACE_TMP_MAX_TIMESTMAP_SIZE (15U) /*!< default trace timestamp size */
|
||||
#define UTIL_ADV_TRACE_FIFO_SIZE (512U) /*!< default trace fifo size */
|
||||
#define UTIL_ADV_TRACE_MEMSET8( dest, value, size) UTIL_MEM_set_8((dest),(value),(size)) /*!< memset utilities interface to trace feature */
|
||||
#define UTIL_ADV_TRACE_VSNPRINTF(...) tiny_vsnprintf_like(__VA_ARGS__) /*!< vsnprintf utilities interface to trace feature */
|
||||
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__UTILITIES_CONF_H__ */
|
|
@ -0,0 +1,112 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file utilities_def.h
|
||||
* @author MCD Application Team
|
||||
* @brief Definitions for modules requiring utilities
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __UTILITIES_DEF_H__
|
||||
#define __UTILITIES_DEF_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <stddef.h>
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/******************************************************************************
|
||||
* LOW POWER MANAGER
|
||||
******************************************************************************/
|
||||
/**
|
||||
* Supported requester to the MCU Low Power Manager - can be increased up to 32
|
||||
* It lists a bit mapping of all user of the Low Power Manager
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/* USER CODE BEGIN CFG_LPM_Id_t_0 */
|
||||
|
||||
/* USER CODE END CFG_LPM_Id_t_0 */
|
||||
CFG_LPM_DUMMY_Id,
|
||||
/* USER CODE BEGIN CFG_LPM_Id_t */
|
||||
|
||||
/* USER CODE END CFG_LPM_Id_t */
|
||||
} CFG_LPM_Id_t;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* sequencer definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* This is the list of priority required by the application
|
||||
* Each Id shall be in the range 0..31
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
CFG_SEQ_Prio_0,
|
||||
/* USER CODE BEGIN CFG_SEQ_Prio_Id_t */
|
||||
|
||||
/* USER CODE END CFG_SEQ_Prio_Id_t */
|
||||
CFG_SEQ_Prio_NBR,
|
||||
} CFG_SEQ_Prio_Id_t;
|
||||
|
||||
/**
|
||||
* This is the list of task id required by the application
|
||||
* Each Id shall be in the range 0..31
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
CFG_SEQ_Task_Default,
|
||||
/* USER CODE BEGIN CFG_SEQ_Task_Id_t */
|
||||
|
||||
/* USER CODE END CFG_SEQ_Task_Id_t */
|
||||
CFG_SEQ_Task_NBR
|
||||
} CFG_SEQ_Task_Id_t;
|
||||
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __UTILITIES_DEF_H__ */
|
|
@ -0,0 +1,106 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file adc.c
|
||||
* @brief This file provides code for the configuration
|
||||
* of the ADC instances.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "adc.h"
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
ADC_HandleTypeDef hadc;
|
||||
|
||||
/* ADC init function */
|
||||
void MX_ADC_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN ADC_Init 0 */
|
||||
|
||||
/* USER CODE END ADC_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN ADC_Init 1 */
|
||||
|
||||
/* USER CODE END ADC_Init 1 */
|
||||
|
||||
/** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
|
||||
*/
|
||||
hadc.Instance = ADC;
|
||||
hadc.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2;
|
||||
hadc.Init.Resolution = ADC_RESOLUTION_12B;
|
||||
hadc.Init.DataAlign = ADC_DATAALIGN_RIGHT;
|
||||
hadc.Init.ScanConvMode = ADC_SCAN_DISABLE;
|
||||
hadc.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
|
||||
hadc.Init.LowPowerAutoWait = DISABLE;
|
||||
hadc.Init.LowPowerAutoPowerOff = DISABLE;
|
||||
hadc.Init.ContinuousConvMode = DISABLE;
|
||||
hadc.Init.NbrOfConversion = 1;
|
||||
hadc.Init.DiscontinuousConvMode = DISABLE;
|
||||
hadc.Init.ExternalTrigConv = ADC_SOFTWARE_START;
|
||||
hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
|
||||
hadc.Init.DMAContinuousRequests = DISABLE;
|
||||
hadc.Init.Overrun = ADC_OVR_DATA_PRESERVED;
|
||||
hadc.Init.SamplingTimeCommon1 = ADC_SAMPLETIME_1CYCLE_5;
|
||||
hadc.Init.SamplingTimeCommon2 = ADC_SAMPLETIME_1CYCLE_5;
|
||||
hadc.Init.OversamplingMode = DISABLE;
|
||||
hadc.Init.TriggerFrequencyMode = ADC_TRIGGER_FREQ_HIGH;
|
||||
if (HAL_ADC_Init(&hadc) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN ADC_Init 2 */
|
||||
|
||||
/* USER CODE END ADC_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
void HAL_ADC_MspInit(ADC_HandleTypeDef* adcHandle)
|
||||
{
|
||||
|
||||
if(adcHandle->Instance==ADC)
|
||||
{
|
||||
/* USER CODE BEGIN ADC_MspInit 0 */
|
||||
|
||||
/* USER CODE END ADC_MspInit 0 */
|
||||
/* ADC clock enable */
|
||||
__HAL_RCC_ADC_CLK_ENABLE();
|
||||
/* USER CODE BEGIN ADC_MspInit 1 */
|
||||
|
||||
/* USER CODE END ADC_MspInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_ADC_MspDeInit(ADC_HandleTypeDef* adcHandle)
|
||||
{
|
||||
|
||||
if(adcHandle->Instance==ADC)
|
||||
{
|
||||
/* USER CODE BEGIN ADC_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END ADC_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_ADC_CLK_DISABLE();
|
||||
/* USER CODE BEGIN ADC_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END ADC_MspDeInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
|
@ -0,0 +1,225 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file adc_if.c
|
||||
* @author MCD Application Team
|
||||
* @brief Read status related to the chip (battery level, VREF, chip temperature)
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "adc_if.h"
|
||||
#include "sys_app.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* External variables ---------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ADC handle
|
||||
*/
|
||||
extern ADC_HandleTypeDef hadc;
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PTD */
|
||||
|
||||
/* USER CODE END PTD */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
#define TEMPSENSOR_TYP_CAL1_V (( int32_t) 760) /*!< Internal temperature sensor, parameter V30 (unit: mV). Refer to device datasheet for min/typ/max values. */
|
||||
#define TEMPSENSOR_TYP_AVGSLOPE (( int32_t) 2500) /*!< Internal temperature sensor, parameter Avg_Slope (unit: uV/DegCelsius). Refer to device datasheet for min/typ/max values. */
|
||||
|
||||
/* USER CODE BEGIN PD */
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PM */
|
||||
|
||||
/* USER CODE END PM */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/**
|
||||
* @brief This function reads the ADC channel
|
||||
* @param channel channel number to read
|
||||
* @return adc measured level value
|
||||
*/
|
||||
static uint32_t ADC_ReadChannels(uint32_t channel);
|
||||
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EF */
|
||||
|
||||
/* USER CODE END EF */
|
||||
|
||||
void SYS_InitMeasurement(void)
|
||||
{
|
||||
/* USER CODE BEGIN SYS_InitMeasurement_1 */
|
||||
|
||||
/* USER CODE END SYS_InitMeasurement_1 */
|
||||
hadc.Instance = ADC;
|
||||
/* USER CODE BEGIN SYS_InitMeasurement_2 */
|
||||
|
||||
/* USER CODE END SYS_InitMeasurement_2 */
|
||||
}
|
||||
|
||||
void SYS_DeInitMeasurement(void)
|
||||
{
|
||||
/* USER CODE BEGIN SYS_DeInitMeasurement_1 */
|
||||
|
||||
/* USER CODE END SYS_DeInitMeasurement_1 */
|
||||
}
|
||||
|
||||
int16_t SYS_GetTemperatureLevel(void)
|
||||
{
|
||||
/* USER CODE BEGIN SYS_GetTemperatureLevel_1 */
|
||||
|
||||
/* USER CODE END SYS_GetTemperatureLevel_1 */
|
||||
__IO int16_t temperatureDegreeC = 0;
|
||||
uint32_t measuredLevel = 0;
|
||||
uint16_t batteryLevelmV = SYS_GetBatteryLevel();
|
||||
|
||||
measuredLevel = ADC_ReadChannels(ADC_CHANNEL_TEMPSENSOR);
|
||||
|
||||
/* convert ADC level to temperature */
|
||||
/* check whether device has temperature sensor calibrated in production */
|
||||
if (((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR) != 0)
|
||||
{
|
||||
/* Device with temperature sensor calibrated in production:
|
||||
use device optimized parameters */
|
||||
temperatureDegreeC = __LL_ADC_CALC_TEMPERATURE(batteryLevelmV,
|
||||
measuredLevel,
|
||||
LL_ADC_RESOLUTION_12B);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Device with temperature sensor not calibrated in production:
|
||||
use generic parameters */
|
||||
temperatureDegreeC = __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(TEMPSENSOR_TYP_AVGSLOPE,
|
||||
TEMPSENSOR_TYP_CAL1_V,
|
||||
TEMPSENSOR_CAL1_TEMP,
|
||||
batteryLevelmV,
|
||||
measuredLevel,
|
||||
LL_ADC_RESOLUTION_12B);
|
||||
}
|
||||
|
||||
/* from int16 to q8.7*/
|
||||
temperatureDegreeC <<= 8;
|
||||
|
||||
return (int16_t) temperatureDegreeC;
|
||||
/* USER CODE BEGIN SYS_GetTemperatureLevel_2 */
|
||||
|
||||
/* USER CODE END SYS_GetTemperatureLevel_2 */
|
||||
}
|
||||
|
||||
uint16_t SYS_GetBatteryLevel(void)
|
||||
{
|
||||
/* USER CODE BEGIN SYS_GetBatteryLevel_1 */
|
||||
|
||||
/* USER CODE END SYS_GetBatteryLevel_1 */
|
||||
uint16_t batteryLevelmV = 0;
|
||||
uint32_t measuredLevel = 0;
|
||||
|
||||
measuredLevel = ADC_ReadChannels(ADC_CHANNEL_VREFINT);
|
||||
|
||||
if (measuredLevel == 0)
|
||||
{
|
||||
batteryLevelmV = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((uint32_t)*VREFINT_CAL_ADDR != (uint32_t)0xFFFFU)
|
||||
{
|
||||
/* Device with Reference voltage calibrated in production:
|
||||
use device optimized parameters */
|
||||
batteryLevelmV = __LL_ADC_CALC_VREFANALOG_VOLTAGE(measuredLevel,
|
||||
ADC_RESOLUTION_12B);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Device with Reference voltage not calibrated in production:
|
||||
use generic parameters */
|
||||
batteryLevelmV = (VREFINT_CAL_VREF * 1510) / measuredLevel;
|
||||
}
|
||||
}
|
||||
|
||||
return batteryLevelmV;
|
||||
/* USER CODE BEGIN SYS_GetBatteryLevel_2 */
|
||||
|
||||
/* USER CODE END SYS_GetBatteryLevel_2 */
|
||||
}
|
||||
|
||||
/* Private Functions Definition -----------------------------------------------*/
|
||||
/* USER CODE BEGIN PrFD */
|
||||
|
||||
/* USER CODE END PrFD */
|
||||
|
||||
static uint32_t ADC_ReadChannels(uint32_t channel)
|
||||
{
|
||||
/* USER CODE BEGIN ADC_ReadChannels_1 */
|
||||
|
||||
/* USER CODE END ADC_ReadChannels_1 */
|
||||
uint32_t ADCxConvertedValues = 0;
|
||||
ADC_ChannelConfTypeDef sConfig = {0};
|
||||
|
||||
MX_ADC_Init();
|
||||
|
||||
/* Start Calibration */
|
||||
if (HAL_ADCEx_Calibration_Start(&hadc) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/* Configure Regular Channel */
|
||||
sConfig.Channel = channel;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_1;
|
||||
sConfig.SamplingTime = ADC_SAMPLINGTIME_COMMON_1;
|
||||
if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
if (HAL_ADC_Start(&hadc) != HAL_OK)
|
||||
{
|
||||
/* Start Error */
|
||||
Error_Handler();
|
||||
}
|
||||
/** Wait for end of conversion */
|
||||
HAL_ADC_PollForConversion(&hadc, HAL_MAX_DELAY);
|
||||
|
||||
/** Wait for end of conversion */
|
||||
HAL_ADC_Stop(&hadc); /* it calls also ADC_Disable() */
|
||||
|
||||
ADCxConvertedValues = HAL_ADC_GetValue(&hadc);
|
||||
|
||||
HAL_ADC_DeInit(&hadc);
|
||||
|
||||
return ADCxConvertedValues;
|
||||
/* USER CODE BEGIN ADC_ReadChannels_2 */
|
||||
|
||||
/* USER CODE END ADC_ReadChannels_2 */
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file dma.c
|
||||
* @brief This file provides code for the configuration
|
||||
* of all the requested memory to memory DMA transfers.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dma.h"
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Configure DMA */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/**
|
||||
* Enable DMA controller clock
|
||||
*/
|
||||
void MX_DMA_Init(void)
|
||||
{
|
||||
|
||||
/* DMA controller clock enable */
|
||||
__HAL_RCC_DMAMUX1_CLK_ENABLE();
|
||||
__HAL_RCC_DMA1_CLK_ENABLE();
|
||||
|
||||
/* DMA interrupt init */
|
||||
/* DMA1_Channel1_IRQn interrupt configuration */
|
||||
HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
|
||||
/* DMA1_Channel2_IRQn interrupt configuration */
|
||||
HAL_NVIC_SetPriority(DMA1_Channel2_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(DMA1_Channel2_IRQn);
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
|
@ -18,6 +18,8 @@
|
|||
/* USER CODE END Header */
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
#include "dma.h"
|
||||
#include "app_lorawan.h"
|
||||
#include "rtc.h"
|
||||
#include "gpio.h"
|
||||
|
||||
|
|
|
@ -34,8 +34,7 @@ void MX_RTC_Init(void)
|
|||
|
||||
/* USER CODE END RTC_Init 0 */
|
||||
|
||||
RTC_TimeTypeDef sTime = {0};
|
||||
RTC_DateTypeDef sDate = {0};
|
||||
RTC_AlarmTypeDef sAlarm = {0};
|
||||
|
||||
/* USER CODE BEGIN RTC_Init 1 */
|
||||
|
||||
|
@ -44,15 +43,13 @@ void MX_RTC_Init(void)
|
|||
/** Initialize RTC Only
|
||||
*/
|
||||
hrtc.Instance = RTC;
|
||||
hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
|
||||
hrtc.Init.AsynchPrediv = 127;
|
||||
hrtc.Init.SynchPrediv = 255;
|
||||
hrtc.Init.AsynchPrediv = RTC_PREDIV_A;
|
||||
hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
|
||||
hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE;
|
||||
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
|
||||
hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
|
||||
hrtc.Init.OutPutPullUp = RTC_OUTPUT_PULLUP_NONE;
|
||||
hrtc.Init.BinMode = RTC_BINARY_NONE;
|
||||
hrtc.Init.BinMode = RTC_BINARY_ONLY;
|
||||
if (HAL_RTC_Init(&hrtc) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
|
@ -62,23 +59,14 @@ void MX_RTC_Init(void)
|
|||
|
||||
/* USER CODE END Check_RTC_BKUP */
|
||||
|
||||
/** Initialize RTC and set the Time and Date
|
||||
/** Enable the Alarm A
|
||||
*/
|
||||
sTime.Hours = 0x0;
|
||||
sTime.Minutes = 0x0;
|
||||
sTime.Seconds = 0x0;
|
||||
sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
|
||||
sTime.StoreOperation = RTC_STOREOPERATION_RESET;
|
||||
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sDate.WeekDay = RTC_WEEKDAY_MONDAY;
|
||||
sDate.Month = RTC_MONTH_JANUARY;
|
||||
sDate.Date = 0x1;
|
||||
sDate.Year = 0x0;
|
||||
|
||||
if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BCD) != HAL_OK)
|
||||
sAlarm.BinaryAutoClr = RTC_ALARMSUBSECONDBIN_AUTOCLR_NO;
|
||||
sAlarm.AlarmTime.SubSeconds = 0x0;
|
||||
sAlarm.AlarmMask = RTC_ALARMMASK_NONE;
|
||||
sAlarm.AlarmSubSecondMask = RTC_ALARMSUBSECONDBINMASK_NONE;
|
||||
sAlarm.Alarm = RTC_ALARM_A;
|
||||
if (HAL_RTC_SetAlarm(&hrtc, &sAlarm, 0) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,165 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32_lpm_if.c
|
||||
* @author MCD Application Team
|
||||
* @brief Low layer function to enter/exit low power modes (stop, sleep)
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "platform.h"
|
||||
#include "stm32_lpm.h"
|
||||
#include "stm32_lpm_if.h"
|
||||
#include "usart_if.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* External variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Power driver callbacks handler
|
||||
*/
|
||||
const struct UTIL_LPM_Driver_s UTIL_PowerDriver =
|
||||
{
|
||||
PWR_EnterSleepMode,
|
||||
PWR_ExitSleepMode,
|
||||
|
||||
PWR_EnterStopMode,
|
||||
PWR_ExitStopMode,
|
||||
|
||||
PWR_EnterOffMode,
|
||||
PWR_ExitOffMode,
|
||||
};
|
||||
|
||||
/* USER CODE BEGIN PTD */
|
||||
|
||||
/* USER CODE END PTD */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PD */
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PM */
|
||||
|
||||
/* USER CODE END PM */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
|
||||
void PWR_EnterOffMode(void)
|
||||
{
|
||||
/* USER CODE BEGIN EnterOffMode_1 */
|
||||
|
||||
/* USER CODE END EnterOffMode_1 */
|
||||
}
|
||||
|
||||
void PWR_ExitOffMode(void)
|
||||
{
|
||||
/* USER CODE BEGIN ExitOffMode_1 */
|
||||
|
||||
/* USER CODE END ExitOffMode_1 */
|
||||
}
|
||||
|
||||
void PWR_EnterStopMode(void)
|
||||
{
|
||||
/* USER CODE BEGIN EnterStopMode_1 */
|
||||
|
||||
/* USER CODE END EnterStopMode_1 */
|
||||
HAL_SuspendTick();
|
||||
/* Clear Status Flag before entering STOP/STANDBY Mode */
|
||||
LL_PWR_ClearFlag_C1STOP_C1STB();
|
||||
|
||||
/* USER CODE BEGIN EnterStopMode_2 */
|
||||
|
||||
/* USER CODE END EnterStopMode_2 */
|
||||
HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
|
||||
/* USER CODE BEGIN EnterStopMode_3 */
|
||||
|
||||
/* USER CODE END EnterStopMode_3 */
|
||||
}
|
||||
|
||||
void PWR_ExitStopMode(void)
|
||||
{
|
||||
/* USER CODE BEGIN ExitStopMode_1 */
|
||||
|
||||
/* USER CODE END ExitStopMode_1 */
|
||||
/* Resume sysTick : work around for debugger problem in dual core */
|
||||
HAL_ResumeTick();
|
||||
/*Not retained periph:
|
||||
ADC interface
|
||||
DAC interface USARTx, TIMx, i2Cx, SPIx
|
||||
SRAM ctrls, DMAx, DMAMux, AES, RNG, HSEM */
|
||||
|
||||
/* Resume not retained USARTx and DMA */
|
||||
vcom_Resume();
|
||||
/* USER CODE BEGIN ExitStopMode_2 */
|
||||
|
||||
/* USER CODE END ExitStopMode_2 */
|
||||
}
|
||||
|
||||
void PWR_EnterSleepMode(void)
|
||||
{
|
||||
/* USER CODE BEGIN EnterSleepMode_1 */
|
||||
|
||||
/* USER CODE END EnterSleepMode_1 */
|
||||
/* Suspend sysTick */
|
||||
HAL_SuspendTick();
|
||||
/* USER CODE BEGIN EnterSleepMode_2 */
|
||||
|
||||
/* USER CODE END EnterSleepMode_2 */
|
||||
HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);
|
||||
/* USER CODE BEGIN EnterSleepMode_3 */
|
||||
|
||||
/* USER CODE END EnterSleepMode_3 */
|
||||
}
|
||||
|
||||
void PWR_ExitSleepMode(void)
|
||||
{
|
||||
/* USER CODE BEGIN ExitSleepMode_1 */
|
||||
|
||||
/* USER CODE END ExitSleepMode_1 */
|
||||
/* Resume sysTick */
|
||||
HAL_ResumeTick();
|
||||
|
||||
/* USER CODE BEGIN ExitSleepMode_2 */
|
||||
|
||||
/* USER CODE END ExitSleepMode_2 */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN EF */
|
||||
|
||||
/* USER CODE END EF */
|
||||
|
||||
/* Private Functions Definition -----------------------------------------------*/
|
||||
/* USER CODE BEGIN PrFD */
|
||||
|
||||
/* USER CODE END PrFD */
|
|
@ -55,7 +55,8 @@
|
|||
/* USER CODE END 0 */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
|
||||
extern DMA_HandleTypeDef hdma_lpuart1_rx;
|
||||
extern DMA_HandleTypeDef hdma_lpuart1_tx;
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
@ -199,6 +200,34 @@ void SysTick_Handler(void)
|
|||
/* please refer to the startup file (startup_stm32wlxx.s). */
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief This function handles DMA1 Channel 1 Interrupt.
|
||||
*/
|
||||
void DMA1_Channel1_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN DMA1_Channel1_IRQn 0 */
|
||||
|
||||
/* USER CODE END DMA1_Channel1_IRQn 0 */
|
||||
HAL_DMA_IRQHandler(&hdma_lpuart1_rx);
|
||||
/* USER CODE BEGIN DMA1_Channel1_IRQn 1 */
|
||||
|
||||
/* USER CODE END DMA1_Channel1_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles DMA1 Channel 2 Interrupt.
|
||||
*/
|
||||
void DMA1_Channel2_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN DMA1_Channel2_IRQn 0 */
|
||||
|
||||
/* USER CODE END DMA1_Channel2_IRQn 0 */
|
||||
HAL_DMA_IRQHandler(&hdma_lpuart1_tx);
|
||||
/* USER CODE BEGIN DMA1_Channel2_IRQn 1 */
|
||||
|
||||
/* USER CODE END DMA1_Channel2_IRQn 1 */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file subghz.c
|
||||
* @brief This file provides code for the configuration
|
||||
* of the SUBGHZ instances.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "subghz.h"
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
SUBGHZ_HandleTypeDef hsubghz;
|
||||
|
||||
/* SUBGHZ init function */
|
||||
void MX_SUBGHZ_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN SUBGHZ_Init 0 */
|
||||
|
||||
/* USER CODE END SUBGHZ_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN SUBGHZ_Init 1 */
|
||||
|
||||
/* USER CODE END SUBGHZ_Init 1 */
|
||||
hsubghz.Init.BaudratePrescaler = SUBGHZSPI_BAUDRATEPRESCALER_8;
|
||||
if (HAL_SUBGHZ_Init(&hsubghz) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN SUBGHZ_Init 2 */
|
||||
|
||||
/* USER CODE END SUBGHZ_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
void HAL_SUBGHZ_MspInit(SUBGHZ_HandleTypeDef* subghzHandle)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN SUBGHZ_MspInit 0 */
|
||||
|
||||
/* USER CODE END SUBGHZ_MspInit 0 */
|
||||
/* SUBGHZ clock enable */
|
||||
__HAL_RCC_SUBGHZSPI_CLK_ENABLE();
|
||||
/* USER CODE BEGIN SUBGHZ_MspInit 1 */
|
||||
|
||||
/* USER CODE END SUBGHZ_MspInit 1 */
|
||||
}
|
||||
|
||||
void HAL_SUBGHZ_MspDeInit(SUBGHZ_HandleTypeDef* subghzHandle)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN SUBGHZ_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END SUBGHZ_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_SUBGHZSPI_CLK_DISABLE();
|
||||
/* USER CODE BEGIN SUBGHZ_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END SUBGHZ_MspDeInit 1 */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
|
@ -0,0 +1,231 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file sys_app.c
|
||||
* @author MCD Application Team
|
||||
* @brief Initializes HW and SW system entities (not related to the radio)
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include "platform.h"
|
||||
#include "sys_app.h"
|
||||
#include "stm32_systime.h"
|
||||
#include "stm32_lpm.h"
|
||||
#include "timer_if.h"
|
||||
#include "utilities_def.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* External variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PTD */
|
||||
|
||||
/* USER CODE END PTD */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
#define MAX_TS_SIZE (int) 16
|
||||
|
||||
/**
|
||||
* Defines the maximum battery level
|
||||
*/
|
||||
#define LORAWAN_MAX_BAT 254
|
||||
|
||||
/* USER CODE BEGIN PD */
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PM */
|
||||
|
||||
/* USER CODE END PM */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
static uint8_t SYS_TimerInitialisedFlag = 0;
|
||||
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Exported functions ---------------------------------------------------------*/
|
||||
void SystemApp_Init(void)
|
||||
{
|
||||
/* USER CODE BEGIN SystemApp_Init_1 */
|
||||
|
||||
/* USER CODE END SystemApp_Init_1 */
|
||||
|
||||
}
|
||||
|
||||
uint8_t GetBatteryLevel(void)
|
||||
{
|
||||
uint8_t batteryLevel = 0;
|
||||
|
||||
/* USER CODE BEGIN GetBatteryLevel_0 */
|
||||
|
||||
/* USER CODE END GetBatteryLevel_0 */
|
||||
|
||||
return batteryLevel; /* 1 (very low) to 254 (fully charged) */
|
||||
}
|
||||
|
||||
int16_t GetTemperatureLevel(void)
|
||||
{
|
||||
int16_t temperatureLevel = 0;
|
||||
|
||||
/* USER CODE BEGIN GetTemperatureLevel */
|
||||
|
||||
/* USER CODE END GetTemperatureLevel */
|
||||
return temperatureLevel;
|
||||
}
|
||||
|
||||
void GetUniqueId(uint8_t *id)
|
||||
{
|
||||
/* USER CODE BEGIN GetUniqueId_1 */
|
||||
|
||||
/* USER CODE END GetUniqueId_1 */
|
||||
uint32_t val = 0;
|
||||
val = LL_FLASH_GetUDN();
|
||||
if (val == 0xFFFFFFFF) /* Normally this should not happen */
|
||||
{
|
||||
uint32_t ID_1_3_val = HAL_GetUIDw0() + HAL_GetUIDw2();
|
||||
uint32_t ID_2_val = HAL_GetUIDw1();
|
||||
|
||||
id[7] = (ID_1_3_val) >> 24;
|
||||
id[6] = (ID_1_3_val) >> 16;
|
||||
id[5] = (ID_1_3_val) >> 8;
|
||||
id[4] = (ID_1_3_val);
|
||||
id[3] = (ID_2_val) >> 24;
|
||||
id[2] = (ID_2_val) >> 16;
|
||||
id[1] = (ID_2_val) >> 8;
|
||||
id[0] = (ID_2_val);
|
||||
}
|
||||
else /* Typical use case */
|
||||
{
|
||||
id[7] = val & 0xFF;
|
||||
id[6] = (val >> 8) & 0xFF;
|
||||
id[5] = (val >> 16) & 0xFF;
|
||||
id[4] = (val >> 24) & 0xFF;
|
||||
val = LL_FLASH_GetDeviceID();
|
||||
id[3] = val & 0xFF;
|
||||
val = LL_FLASH_GetSTCompanyID();
|
||||
id[2] = val & 0xFF;
|
||||
id[1] = (val >> 8) & 0xFF;
|
||||
id[0] = (val >> 16) & 0xFF;
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN GetUniqueId_2 */
|
||||
|
||||
/* USER CODE END GetUniqueId_2 */
|
||||
}
|
||||
|
||||
void GetDevAddr(uint32_t *devAddr)
|
||||
{
|
||||
/* USER CODE BEGIN GetDevAddr_1 */
|
||||
|
||||
/* USER CODE END GetDevAddr_1 */
|
||||
|
||||
*devAddr = LL_FLASH_GetUDN();
|
||||
if (*devAddr == 0xFFFFFFFF)
|
||||
{
|
||||
*devAddr = ((HAL_GetUIDw0()) ^ (HAL_GetUIDw1()) ^ (HAL_GetUIDw2()));
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN GetDevAddr_2 */
|
||||
|
||||
/* USER CODE END GetDevAddr_2 */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN EF */
|
||||
|
||||
/* USER CODE END EF */
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PrFD */
|
||||
|
||||
/* USER CODE END PrFD */
|
||||
|
||||
/* HAL overload functions ---------------------------------------------------------*/
|
||||
|
||||
/* Set #if 0 if you want to keep the default HAL instead overcharge them*/
|
||||
/* USER CODE BEGIN Overload_HAL_weaks_1 */
|
||||
#if 1
|
||||
/* USER CODE END Overload_HAL_weaks_1 */
|
||||
|
||||
/* USER CODE BEGIN Overload_HAL_weaks_1a */
|
||||
|
||||
/* USER CODE END Overload_HAL_weaks_1a */
|
||||
|
||||
/**
|
||||
* @note This function overwrites the __weak one from HAL
|
||||
*/
|
||||
uint32_t HAL_GetTick(void)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
/* TIMER_IF can be based on other counter the SysTick e.g. RTC */
|
||||
/* USER CODE BEGIN HAL_GetTick_1 */
|
||||
|
||||
/* USER CODE END HAL_GetTick_1 */
|
||||
if (SYS_TimerInitialisedFlag == 0)
|
||||
{
|
||||
/* TIMER_IF_GetTimerValue should be used only once UTIL_TIMER_Init() is initialized */
|
||||
/* If HAL_Delay or a TIMEOUT countdown is necessary during initialization phase */
|
||||
/* please use temporarily another timebase source (SysTick or TIMx), which implies also */
|
||||
/* to rework the above function HAL_InitTick() and to call HAL_IncTick() on the timebase IRQ */
|
||||
/* Note: when TIMER_IF is based on RTC, stm32wlxx_hal_rtc.c calls this function before TimeServer is functional */
|
||||
/* RTC TIMEOUT will not expire, i.e. if RTC has an hw problem it will keep looping in the RTC_Init function */
|
||||
/* USER CODE BEGIN HAL_GetTick_EarlyCall */
|
||||
|
||||
/* USER CODE END HAL_GetTick_EarlyCall */
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = TIMER_IF_GetTimerValue();
|
||||
}
|
||||
/* USER CODE BEGIN HAL_GetTick_2 */
|
||||
|
||||
/* USER CODE END HAL_GetTick_2 */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @note This function overwrites the __weak one from HAL
|
||||
*/
|
||||
void HAL_Delay(__IO uint32_t Delay)
|
||||
{
|
||||
/* TIMER_IF can be based on other counter the SysTick e.g. RTC */
|
||||
/* USER CODE BEGIN HAL_Delay_1 */
|
||||
|
||||
/* USER CODE END HAL_Delay_1 */
|
||||
TIMER_IF_DelayMs(Delay);
|
||||
/* USER CODE BEGIN HAL_Delay_2 */
|
||||
|
||||
/* USER CODE END HAL_Delay_2 */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN Overload_HAL_weaks_2 */
|
||||
#endif /* 1 default HAL overcharge */
|
||||
/* if needed set #if 0 and redefine here your own "Tick" functions*/
|
||||
|
||||
/* USER CODE END Overload_HAL_weaks_2 */
|
|
@ -0,0 +1,521 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file timer_if.c
|
||||
* @author MCD Application Team
|
||||
* @brief Configure RTC Alarm, Tick and Calendar manager
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <math.h>
|
||||
#include "timer_if.h"
|
||||
#include "main.h" /*for STM32CubeMX generated RTC_N_PREDIV_S and RTC_N_PREDIV_A*/
|
||||
#include "rtc.h"
|
||||
#include "utilities_def.h"
|
||||
#include "stm32wlxx_ll_rtc.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* External variables ---------------------------------------------------------*/
|
||||
/**
|
||||
* @brief RTC handle
|
||||
*/
|
||||
extern RTC_HandleTypeDef hrtc;
|
||||
|
||||
/**
|
||||
* @brief Timer driver callbacks handler
|
||||
*/
|
||||
const UTIL_TIMER_Driver_s UTIL_TimerDriver =
|
||||
{
|
||||
TIMER_IF_Init,
|
||||
NULL,
|
||||
|
||||
TIMER_IF_StartTimer,
|
||||
TIMER_IF_StopTimer,
|
||||
|
||||
TIMER_IF_SetTimerContext,
|
||||
TIMER_IF_GetTimerContext,
|
||||
|
||||
TIMER_IF_GetTimerElapsedTime,
|
||||
TIMER_IF_GetTimerValue,
|
||||
TIMER_IF_GetMinimumTimeout,
|
||||
|
||||
TIMER_IF_Convert_ms2Tick,
|
||||
TIMER_IF_Convert_Tick2ms,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief SysTime driver callbacks handler
|
||||
*/
|
||||
const UTIL_SYSTIM_Driver_s UTIL_SYSTIMDriver =
|
||||
{
|
||||
TIMER_IF_BkUp_Write_Seconds,
|
||||
TIMER_IF_BkUp_Read_Seconds,
|
||||
TIMER_IF_BkUp_Write_SubSeconds,
|
||||
TIMER_IF_BkUp_Read_SubSeconds,
|
||||
TIMER_IF_GetTime,
|
||||
};
|
||||
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PTD */
|
||||
|
||||
/* USER CODE END PTD */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Minimum timeout delay of Alarm in ticks
|
||||
*/
|
||||
#define MIN_ALARM_DELAY 3
|
||||
|
||||
/**
|
||||
* @brief Backup seconds register
|
||||
*/
|
||||
#define RTC_BKP_SECONDS RTC_BKP_DR0
|
||||
|
||||
/**
|
||||
* @brief Backup subseconds register
|
||||
*/
|
||||
#define RTC_BKP_SUBSECONDS RTC_BKP_DR1
|
||||
|
||||
/**
|
||||
* @brief Backup msbticks register
|
||||
*/
|
||||
#define RTC_BKP_MSBTICKS RTC_BKP_DR2
|
||||
|
||||
/* #define RTIF_DEBUG */
|
||||
|
||||
/**
|
||||
* @brief Map UTIL_TIMER_IRQ can be overridden in utilities_conf.h to Map on Task rather then Isr
|
||||
*/
|
||||
#ifndef UTIL_TIMER_IRQ_MAP_INIT
|
||||
#define UTIL_TIMER_IRQ_MAP_INIT()
|
||||
#endif /* UTIL_TIMER_IRQ_MAP_INIT */
|
||||
|
||||
#ifndef UTIL_TIMER_IRQ_MAP_PROCESS
|
||||
#define UTIL_TIMER_IRQ_MAP_PROCESS() UTIL_TIMER_IRQ_Handler()
|
||||
#endif /* UTIL_TIMER_IRQ_MAP_PROCESS */
|
||||
|
||||
/* USER CODE BEGIN PD */
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
#ifdef RTIF_DEBUG
|
||||
#include "sys_app.h" /*for app_log*/
|
||||
/**
|
||||
* @brief Post the RTC log string format to the circular queue for printing in using the polling mode
|
||||
*/
|
||||
#define TIMER_IF_DBG_PRINTF(...) do{ {UTIL_ADV_TRACE_COND_FSend(VLEVEL_ALWAYS, T_REG_OFF, TS_OFF, __VA_ARGS__);} }while(0);
|
||||
#else
|
||||
/**
|
||||
* @brief not used
|
||||
*/
|
||||
#define TIMER_IF_DBG_PRINTF(...)
|
||||
#endif /* RTIF_DEBUG */
|
||||
|
||||
/* USER CODE BEGIN PM */
|
||||
|
||||
/* USER CODE END PM */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Indicates if the RTC is already Initialized or not
|
||||
*/
|
||||
static bool RTC_Initialized = false;
|
||||
|
||||
/**
|
||||
* @brief RtcTimerContext
|
||||
*/
|
||||
static uint32_t RtcTimerContext = 0;
|
||||
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/**
|
||||
* @brief Get rtc timer Value in rtc tick
|
||||
* @return val the rtc timer value (upcounting)
|
||||
*/
|
||||
static inline uint32_t GetTimerTicks(void);
|
||||
|
||||
/**
|
||||
* @brief Writes MSBticks to backup register
|
||||
* Absolute RTC time in tick is (MSBticks)<<32 + (32bits binary counter)
|
||||
* @note MSBticks incremented every time the 32bits RTC timer wraps around (~44days)
|
||||
* @param[in] MSBticks
|
||||
*/
|
||||
static void TIMER_IF_BkUp_Write_MSBticks(uint32_t MSBticks);
|
||||
|
||||
/**
|
||||
* @brief Reads MSBticks from backup register
|
||||
* Absolute RTC time in tick is (MSBticks)<<32 + (32bits binary counter)
|
||||
* @note MSBticks incremented every time the 32bits RTC timer wraps around (~44days)
|
||||
* @retval MSBticks
|
||||
*/
|
||||
static uint32_t TIMER_IF_BkUp_Read_MSBticks(void);
|
||||
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Exported functions ---------------------------------------------------------*/
|
||||
UTIL_TIMER_Status_t TIMER_IF_Init(void)
|
||||
{
|
||||
UTIL_TIMER_Status_t ret = UTIL_TIMER_OK;
|
||||
/* USER CODE BEGIN TIMER_IF_Init */
|
||||
|
||||
/* USER CODE END TIMER_IF_Init */
|
||||
if (RTC_Initialized == false)
|
||||
{
|
||||
hrtc.IsEnabled.RtcFeatures = UINT32_MAX;
|
||||
/*Init RTC*/
|
||||
MX_RTC_Init();
|
||||
/*Stop Timer */
|
||||
TIMER_IF_StopTimer();
|
||||
/** DeActivate the Alarm A enabled by STM32CubeMX during MX_RTC_Init() */
|
||||
HAL_RTC_DeactivateAlarm(&hrtc, RTC_ALARM_A);
|
||||
/*overload RTC feature enable*/
|
||||
hrtc.IsEnabled.RtcFeatures = UINT32_MAX;
|
||||
|
||||
/*Enable Direct Read of the calendar registers (not through Shadow) */
|
||||
HAL_RTCEx_EnableBypassShadow(&hrtc);
|
||||
/*Initialize MSB ticks*/
|
||||
TIMER_IF_BkUp_Write_MSBticks(0);
|
||||
|
||||
TIMER_IF_SetTimerContext();
|
||||
|
||||
/* Register a task to associate to UTIL_TIMER_Irq() interrupt */
|
||||
UTIL_TIMER_IRQ_MAP_INIT();
|
||||
|
||||
RTC_Initialized = true;
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN TIMER_IF_Init_Last */
|
||||
|
||||
/* USER CODE END TIMER_IF_Init_Last */
|
||||
return ret;
|
||||
}
|
||||
|
||||
UTIL_TIMER_Status_t TIMER_IF_StartTimer(uint32_t timeout)
|
||||
{
|
||||
UTIL_TIMER_Status_t ret = UTIL_TIMER_OK;
|
||||
/* USER CODE BEGIN TIMER_IF_StartTimer */
|
||||
|
||||
/* USER CODE END TIMER_IF_StartTimer */
|
||||
RTC_AlarmTypeDef sAlarm = {0};
|
||||
/*Stop timer if one is already started*/
|
||||
TIMER_IF_StopTimer();
|
||||
timeout += RtcTimerContext;
|
||||
|
||||
TIMER_IF_DBG_PRINTF("Start timer: time=%d, alarm=%d\n\r", GetTimerTicks(), timeout);
|
||||
/* starts timer*/
|
||||
sAlarm.BinaryAutoClr = RTC_ALARMSUBSECONDBIN_AUTOCLR_NO;
|
||||
sAlarm.AlarmTime.SubSeconds = UINT32_MAX - timeout;
|
||||
sAlarm.AlarmMask = RTC_ALARMMASK_NONE;
|
||||
sAlarm.AlarmSubSecondMask = RTC_ALARMSUBSECONDBINMASK_NONE;
|
||||
sAlarm.Alarm = RTC_ALARM_A;
|
||||
if (HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, RTC_FORMAT_BCD) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN TIMER_IF_StartTimer_Last */
|
||||
|
||||
/* USER CODE END TIMER_IF_StartTimer_Last */
|
||||
return ret;
|
||||
}
|
||||
|
||||
UTIL_TIMER_Status_t TIMER_IF_StopTimer(void)
|
||||
{
|
||||
UTIL_TIMER_Status_t ret = UTIL_TIMER_OK;
|
||||
/* USER CODE BEGIN TIMER_IF_StopTimer */
|
||||
|
||||
/* USER CODE END TIMER_IF_StopTimer */
|
||||
/* Clear RTC Alarm Flag */
|
||||
__HAL_RTC_ALARM_CLEAR_FLAG(&hrtc, RTC_FLAG_ALRAF);
|
||||
/* Disable the Alarm A interrupt */
|
||||
HAL_RTC_DeactivateAlarm(&hrtc, RTC_ALARM_A);
|
||||
/*overload RTC feature enable*/
|
||||
hrtc.IsEnabled.RtcFeatures = UINT32_MAX;
|
||||
/* USER CODE BEGIN TIMER_IF_StopTimer_Last */
|
||||
|
||||
/* USER CODE END TIMER_IF_StopTimer_Last */
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t TIMER_IF_SetTimerContext(void)
|
||||
{
|
||||
/*store time context*/
|
||||
RtcTimerContext = GetTimerTicks();
|
||||
|
||||
/* USER CODE BEGIN TIMER_IF_SetTimerContext */
|
||||
|
||||
/* USER CODE END TIMER_IF_SetTimerContext */
|
||||
|
||||
TIMER_IF_DBG_PRINTF("TIMER_IF_SetTimerContext=%d\n\r", RtcTimerContext);
|
||||
/*return time context*/
|
||||
return RtcTimerContext;
|
||||
}
|
||||
|
||||
uint32_t TIMER_IF_GetTimerContext(void)
|
||||
{
|
||||
/* USER CODE BEGIN TIMER_IF_GetTimerContext */
|
||||
|
||||
/* USER CODE END TIMER_IF_GetTimerContext */
|
||||
|
||||
TIMER_IF_DBG_PRINTF("TIMER_IF_GetTimerContext=%d\n\r", RtcTimerContext);
|
||||
/*return time context*/
|
||||
return RtcTimerContext;
|
||||
}
|
||||
|
||||
uint32_t TIMER_IF_GetTimerElapsedTime(void)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
/* USER CODE BEGIN TIMER_IF_GetTimerElapsedTime */
|
||||
|
||||
/* USER CODE END TIMER_IF_GetTimerElapsedTime */
|
||||
ret = ((uint32_t)(GetTimerTicks() - RtcTimerContext));
|
||||
/* USER CODE BEGIN TIMER_IF_GetTimerElapsedTime_Last */
|
||||
|
||||
/* USER CODE END TIMER_IF_GetTimerElapsedTime_Last */
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t TIMER_IF_GetTimerValue(void)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
/* USER CODE BEGIN TIMER_IF_GetTimerValue */
|
||||
|
||||
/* USER CODE END TIMER_IF_GetTimerValue */
|
||||
if (RTC_Initialized == true)
|
||||
{
|
||||
ret = GetTimerTicks();
|
||||
}
|
||||
/* USER CODE BEGIN TIMER_IF_GetTimerValue_Last */
|
||||
|
||||
/* USER CODE END TIMER_IF_GetTimerValue_Last */
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t TIMER_IF_GetMinimumTimeout(void)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
/* USER CODE BEGIN TIMER_IF_GetMinimumTimeout */
|
||||
|
||||
/* USER CODE END TIMER_IF_GetMinimumTimeout */
|
||||
ret = (MIN_ALARM_DELAY);
|
||||
/* USER CODE BEGIN TIMER_IF_GetMinimumTimeout_Last */
|
||||
|
||||
/* USER CODE END TIMER_IF_GetMinimumTimeout_Last */
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t TIMER_IF_Convert_ms2Tick(uint32_t timeMilliSec)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
/* USER CODE BEGIN TIMER_IF_Convert_ms2Tick */
|
||||
|
||||
/* USER CODE END TIMER_IF_Convert_ms2Tick */
|
||||
ret = ((uint32_t)((((uint64_t) timeMilliSec) << RTC_N_PREDIV_S) / 1000));
|
||||
/* USER CODE BEGIN TIMER_IF_Convert_ms2Tick_Last */
|
||||
|
||||
/* USER CODE END TIMER_IF_Convert_ms2Tick_Last */
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t TIMER_IF_Convert_Tick2ms(uint32_t tick)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
/* USER CODE BEGIN TIMER_IF_Convert_Tick2ms */
|
||||
|
||||
/* USER CODE END TIMER_IF_Convert_Tick2ms */
|
||||
ret = ((uint32_t)((((uint64_t)(tick)) * 1000) >> RTC_N_PREDIV_S));
|
||||
/* USER CODE BEGIN TIMER_IF_Convert_Tick2ms_Last */
|
||||
|
||||
/* USER CODE END TIMER_IF_Convert_Tick2ms_Last */
|
||||
return ret;
|
||||
}
|
||||
|
||||
void TIMER_IF_DelayMs(uint32_t delay)
|
||||
{
|
||||
/* USER CODE BEGIN TIMER_IF_DelayMs */
|
||||
|
||||
/* USER CODE END TIMER_IF_DelayMs */
|
||||
uint32_t delayTicks = TIMER_IF_Convert_ms2Tick(delay);
|
||||
uint32_t timeout = GetTimerTicks();
|
||||
|
||||
/* Wait delay ms */
|
||||
while (((GetTimerTicks() - timeout)) < delayTicks)
|
||||
{
|
||||
__NOP();
|
||||
}
|
||||
/* USER CODE BEGIN TIMER_IF_DelayMs_Last */
|
||||
|
||||
/* USER CODE END TIMER_IF_DelayMs_Last */
|
||||
}
|
||||
|
||||
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc)
|
||||
{
|
||||
/* USER CODE BEGIN HAL_RTC_AlarmAEventCallback */
|
||||
|
||||
/* USER CODE END HAL_RTC_AlarmAEventCallback */
|
||||
UTIL_TIMER_IRQ_MAP_PROCESS();
|
||||
/* USER CODE BEGIN HAL_RTC_AlarmAEventCallback_Last */
|
||||
|
||||
/* USER CODE END HAL_RTC_AlarmAEventCallback_Last */
|
||||
}
|
||||
|
||||
void HAL_RTCEx_SSRUEventCallback(RTC_HandleTypeDef *hrtc)
|
||||
{
|
||||
/* USER CODE BEGIN HAL_RTCEx_SSRUEventCallback */
|
||||
|
||||
/* USER CODE END HAL_RTCEx_SSRUEventCallback */
|
||||
/*called every 48 days with 1024 ticks per seconds*/
|
||||
TIMER_IF_DBG_PRINTF(">>Handler SSRUnderflow at %d\n\r", GetTimerTicks());
|
||||
/*Increment MSBticks*/
|
||||
uint32_t MSB_ticks = TIMER_IF_BkUp_Read_MSBticks();
|
||||
TIMER_IF_BkUp_Write_MSBticks(MSB_ticks + 1);
|
||||
/* USER CODE BEGIN HAL_RTCEx_SSRUEventCallback_Last */
|
||||
|
||||
/* USER CODE END HAL_RTCEx_SSRUEventCallback_Last */
|
||||
}
|
||||
|
||||
uint32_t TIMER_IF_GetTime(uint16_t *mSeconds)
|
||||
{
|
||||
uint32_t seconds = 0;
|
||||
/* USER CODE BEGIN TIMER_IF_GetTime */
|
||||
|
||||
/* USER CODE END TIMER_IF_GetTime */
|
||||
uint64_t ticks;
|
||||
uint32_t timerValueLsb = GetTimerTicks();
|
||||
uint32_t timerValueMSB = TIMER_IF_BkUp_Read_MSBticks();
|
||||
|
||||
ticks = (((uint64_t) timerValueMSB) << 32) + timerValueLsb;
|
||||
|
||||
seconds = (uint32_t)(ticks >> RTC_N_PREDIV_S);
|
||||
|
||||
ticks = (uint32_t) ticks & RTC_PREDIV_S;
|
||||
|
||||
*mSeconds = TIMER_IF_Convert_Tick2ms(ticks);
|
||||
|
||||
/* USER CODE BEGIN TIMER_IF_GetTime_Last */
|
||||
|
||||
/* USER CODE END TIMER_IF_GetTime_Last */
|
||||
return seconds;
|
||||
}
|
||||
|
||||
void TIMER_IF_BkUp_Write_Seconds(uint32_t Seconds)
|
||||
{
|
||||
/* USER CODE BEGIN TIMER_IF_BkUp_Write_Seconds */
|
||||
|
||||
/* USER CODE END TIMER_IF_BkUp_Write_Seconds */
|
||||
HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_SECONDS, Seconds);
|
||||
/* USER CODE BEGIN TIMER_IF_BkUp_Write_Seconds_Last */
|
||||
|
||||
/* USER CODE END TIMER_IF_BkUp_Write_Seconds_Last */
|
||||
}
|
||||
|
||||
void TIMER_IF_BkUp_Write_SubSeconds(uint32_t SubSeconds)
|
||||
{
|
||||
/* USER CODE BEGIN TIMER_IF_BkUp_Write_SubSeconds */
|
||||
|
||||
/* USER CODE END TIMER_IF_BkUp_Write_SubSeconds */
|
||||
HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_SUBSECONDS, SubSeconds);
|
||||
/* USER CODE BEGIN TIMER_IF_BkUp_Write_SubSeconds_Last */
|
||||
|
||||
/* USER CODE END TIMER_IF_BkUp_Write_SubSeconds_Last */
|
||||
}
|
||||
|
||||
uint32_t TIMER_IF_BkUp_Read_Seconds(void)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
/* USER CODE BEGIN TIMER_IF_BkUp_Read_Seconds */
|
||||
|
||||
/* USER CODE END TIMER_IF_BkUp_Read_Seconds */
|
||||
ret = HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_SECONDS);
|
||||
/* USER CODE BEGIN TIMER_IF_BkUp_Read_Seconds_Last */
|
||||
|
||||
/* USER CODE END TIMER_IF_BkUp_Read_Seconds_Last */
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t TIMER_IF_BkUp_Read_SubSeconds(void)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
/* USER CODE BEGIN TIMER_IF_BkUp_Read_SubSeconds */
|
||||
|
||||
/* USER CODE END TIMER_IF_BkUp_Read_SubSeconds */
|
||||
ret = HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_SUBSECONDS);
|
||||
/* USER CODE BEGIN TIMER_IF_BkUp_Read_SubSeconds_Last */
|
||||
|
||||
/* USER CODE END TIMER_IF_BkUp_Read_SubSeconds_Last */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN EF */
|
||||
|
||||
/* USER CODE END EF */
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
static void TIMER_IF_BkUp_Write_MSBticks(uint32_t MSBticks)
|
||||
{
|
||||
/* USER CODE BEGIN TIMER_IF_BkUp_Write_MSBticks */
|
||||
|
||||
/* USER CODE END TIMER_IF_BkUp_Write_MSBticks */
|
||||
HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_MSBTICKS, MSBticks);
|
||||
/* USER CODE BEGIN TIMER_IF_BkUp_Write_MSBticks_Last */
|
||||
|
||||
/* USER CODE END TIMER_IF_BkUp_Write_MSBticks_Last */
|
||||
}
|
||||
|
||||
static uint32_t TIMER_IF_BkUp_Read_MSBticks(void)
|
||||
{
|
||||
/* USER CODE BEGIN TIMER_IF_BkUp_Read_MSBticks */
|
||||
|
||||
/* USER CODE END TIMER_IF_BkUp_Read_MSBticks */
|
||||
uint32_t MSBticks;
|
||||
MSBticks = HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_MSBTICKS);
|
||||
return MSBticks;
|
||||
/* USER CODE BEGIN TIMER_IF_BkUp_Read_MSBticks_Last */
|
||||
|
||||
/* USER CODE END TIMER_IF_BkUp_Read_MSBticks_Last */
|
||||
}
|
||||
|
||||
static inline uint32_t GetTimerTicks(void)
|
||||
{
|
||||
/* USER CODE BEGIN GetTimerTicks */
|
||||
|
||||
/* USER CODE END GetTimerTicks */
|
||||
uint32_t ssr = LL_RTC_TIME_GetSubSecond(RTC);
|
||||
/* read twice to make sure value it valid*/
|
||||
while (ssr != LL_RTC_TIME_GetSubSecond(RTC))
|
||||
{
|
||||
ssr = LL_RTC_TIME_GetSubSecond(RTC);
|
||||
}
|
||||
return UINT32_MAX - ssr;
|
||||
/* USER CODE BEGIN GetTimerTicks_Last */
|
||||
|
||||
/* USER CODE END GetTimerTicks_Last */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN PrFD */
|
||||
|
||||
/* USER CODE END PrFD */
|
|
@ -0,0 +1,180 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usart.c
|
||||
* @brief This file provides code for the configuration
|
||||
* of the USART instances.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usart.h"
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
UART_HandleTypeDef hlpuart1;
|
||||
DMA_HandleTypeDef hdma_lpuart1_rx;
|
||||
DMA_HandleTypeDef hdma_lpuart1_tx;
|
||||
|
||||
/* LPUART1 init function */
|
||||
|
||||
void MX_LPUART1_UART_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN LPUART1_Init 0 */
|
||||
|
||||
/* USER CODE END LPUART1_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN LPUART1_Init 1 */
|
||||
|
||||
/* USER CODE END LPUART1_Init 1 */
|
||||
hlpuart1.Instance = LPUART1;
|
||||
hlpuart1.Init.BaudRate = 115200;
|
||||
hlpuart1.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
hlpuart1.Init.StopBits = UART_STOPBITS_1;
|
||||
hlpuart1.Init.Parity = UART_PARITY_NONE;
|
||||
hlpuart1.Init.Mode = UART_MODE_TX_RX;
|
||||
hlpuart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||
hlpuart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
|
||||
hlpuart1.Init.ClockPrescaler = UART_PRESCALER_DIV1;
|
||||
hlpuart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
|
||||
hlpuart1.FifoMode = UART_FIFOMODE_ENABLE;
|
||||
if (HAL_UART_Init(&hlpuart1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_UARTEx_SetTxFifoThreshold(&hlpuart1, UART_TXFIFO_THRESHOLD_1_4) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_UARTEx_SetRxFifoThreshold(&hlpuart1, UART_RXFIFO_THRESHOLD_1_4) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_UARTEx_EnableFifoMode(&hlpuart1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN LPUART1_Init 2 */
|
||||
|
||||
/* USER CODE END LPUART1_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
||||
{
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
|
||||
if(uartHandle->Instance==LPUART1)
|
||||
{
|
||||
/* USER CODE BEGIN LPUART1_MspInit 0 */
|
||||
|
||||
/* USER CODE END LPUART1_MspInit 0 */
|
||||
|
||||
/** Initializes the peripherals clocks
|
||||
*/
|
||||
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPUART1;
|
||||
PeriphClkInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PCLK1;
|
||||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/* LPUART1 clock enable */
|
||||
__HAL_RCC_LPUART1_CLK_ENABLE();
|
||||
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
/**LPUART1 GPIO Configuration
|
||||
PA2 ------> LPUART1_TX
|
||||
PA3 ------> LPUART1_RX
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF8_LPUART1;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/* LPUART1 DMA Init */
|
||||
/* LPUART1_RX Init */
|
||||
hdma_lpuart1_rx.Instance = DMA1_Channel1;
|
||||
hdma_lpuart1_rx.Init.Request = DMA_REQUEST_LPUART1_RX;
|
||||
hdma_lpuart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
||||
hdma_lpuart1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
hdma_lpuart1_rx.Init.MemInc = DMA_MINC_ENABLE;
|
||||
hdma_lpuart1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||
hdma_lpuart1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||
hdma_lpuart1_rx.Init.Mode = DMA_NORMAL;
|
||||
hdma_lpuart1_rx.Init.Priority = DMA_PRIORITY_LOW;
|
||||
if (HAL_DMA_Init(&hdma_lpuart1_rx) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
__HAL_LINKDMA(uartHandle,hdmarx,hdma_lpuart1_rx);
|
||||
|
||||
/* LPUART1_TX Init */
|
||||
hdma_lpuart1_tx.Instance = DMA1_Channel2;
|
||||
hdma_lpuart1_tx.Init.Request = DMA_REQUEST_LPUART1_TX;
|
||||
hdma_lpuart1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
|
||||
hdma_lpuart1_tx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
hdma_lpuart1_tx.Init.MemInc = DMA_MINC_ENABLE;
|
||||
hdma_lpuart1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||
hdma_lpuart1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||
hdma_lpuart1_tx.Init.Mode = DMA_NORMAL;
|
||||
hdma_lpuart1_tx.Init.Priority = DMA_PRIORITY_LOW;
|
||||
if (HAL_DMA_Init(&hdma_lpuart1_tx) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
__HAL_LINKDMA(uartHandle,hdmatx,hdma_lpuart1_tx);
|
||||
|
||||
/* USER CODE BEGIN LPUART1_MspInit 1 */
|
||||
|
||||
/* USER CODE END LPUART1_MspInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
|
||||
{
|
||||
|
||||
if(uartHandle->Instance==LPUART1)
|
||||
{
|
||||
/* USER CODE BEGIN LPUART1_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END LPUART1_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_LPUART1_CLK_DISABLE();
|
||||
|
||||
/**LPUART1 GPIO Configuration
|
||||
PA2 ------> LPUART1_TX
|
||||
PA3 ------> LPUART1_RX
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);
|
||||
|
||||
/* LPUART1 DMA DeInit */
|
||||
HAL_DMA_DeInit(uartHandle->hdmarx);
|
||||
HAL_DMA_DeInit(uartHandle->hdmatx);
|
||||
/* USER CODE BEGIN LPUART1_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END LPUART1_MspDeInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
|
@ -0,0 +1,254 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usart_if.c
|
||||
* @author MCD Application Team
|
||||
* @brief Configuration of UART driver interface for hyperterminal communication
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usart_if.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* External variables ---------------------------------------------------------*/
|
||||
/**
|
||||
* @brief DMA handle
|
||||
*/
|
||||
extern DMA_HandleTypeDef hdma_lpuart1_tx;
|
||||
|
||||
/**
|
||||
* @brief UART handle
|
||||
*/
|
||||
extern UART_HandleTypeDef hlpuart1;
|
||||
|
||||
/**
|
||||
* @brief buffer to receive 1 character
|
||||
*/
|
||||
uint8_t charRx;
|
||||
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Trace driver callbacks handler
|
||||
*/
|
||||
const UTIL_ADV_TRACE_Driver_s UTIL_TraceDriver =
|
||||
{
|
||||
vcom_Init,
|
||||
vcom_DeInit,
|
||||
vcom_ReceiveInit,
|
||||
vcom_Trace_DMA,
|
||||
};
|
||||
|
||||
/* USER CODE BEGIN PTD */
|
||||
|
||||
/* USER CODE END PTD */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PD */
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PM */
|
||||
|
||||
/* USER CODE END PM */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/**
|
||||
* @brief TX complete callback
|
||||
* @return none
|
||||
*/
|
||||
static void (*TxCpltCallback)(void *);
|
||||
/**
|
||||
* @brief RX complete callback
|
||||
* @param rxChar ptr of chars buffer sent by user
|
||||
* @param size buffer size
|
||||
* @param error errorcode
|
||||
* @return none
|
||||
*/
|
||||
static void (*RxCpltCallback)(uint8_t *rxChar, uint16_t size, uint8_t error);
|
||||
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
|
||||
UTIL_ADV_TRACE_Status_t vcom_Init(void (*cb)(void *))
|
||||
{
|
||||
/* USER CODE BEGIN vcom_Init_1 */
|
||||
|
||||
/* USER CODE END vcom_Init_1 */
|
||||
TxCpltCallback = cb;
|
||||
MX_DMA_Init();
|
||||
MX_LPUART1_UART_Init();
|
||||
LL_EXTI_EnableIT_0_31(LL_EXTI_LINE_28);
|
||||
return UTIL_ADV_TRACE_OK;
|
||||
/* USER CODE BEGIN vcom_Init_2 */
|
||||
|
||||
/* USER CODE END vcom_Init_2 */
|
||||
}
|
||||
|
||||
UTIL_ADV_TRACE_Status_t vcom_DeInit(void)
|
||||
{
|
||||
/* USER CODE BEGIN vcom_DeInit_1 */
|
||||
|
||||
/* USER CODE END vcom_DeInit_1 */
|
||||
/* ##-1- Reset peripherals ################################################## */
|
||||
__HAL_RCC_LPUART1_FORCE_RESET();
|
||||
__HAL_RCC_LPUART1_RELEASE_RESET();
|
||||
|
||||
/* ##-2- MspDeInit ################################################## */
|
||||
HAL_UART_MspDeInit(&hlpuart1);
|
||||
|
||||
/* ##-3- Disable the NVIC for DMA ########################################### */
|
||||
/* USER CODE BEGIN 1 */
|
||||
HAL_NVIC_DisableIRQ(DMA1_Channel5_IRQn);
|
||||
|
||||
return UTIL_ADV_TRACE_OK;
|
||||
/* USER CODE END 1 */
|
||||
/* USER CODE BEGIN vcom_DeInit_2 */
|
||||
|
||||
/* USER CODE END vcom_DeInit_2 */
|
||||
}
|
||||
|
||||
void vcom_Trace(uint8_t *p_data, uint16_t size)
|
||||
{
|
||||
/* USER CODE BEGIN vcom_Trace_1 */
|
||||
|
||||
/* USER CODE END vcom_Trace_1 */
|
||||
HAL_UART_Transmit(&hlpuart1, p_data, size, 1000);
|
||||
/* USER CODE BEGIN vcom_Trace_2 */
|
||||
|
||||
/* USER CODE END vcom_Trace_2 */
|
||||
}
|
||||
|
||||
UTIL_ADV_TRACE_Status_t vcom_Trace_DMA(uint8_t *p_data, uint16_t size)
|
||||
{
|
||||
/* USER CODE BEGIN vcom_Trace_DMA_1 */
|
||||
|
||||
/* USER CODE END vcom_Trace_DMA_1 */
|
||||
HAL_UART_Transmit_DMA(&hlpuart1, p_data, size);
|
||||
return UTIL_ADV_TRACE_OK;
|
||||
/* USER CODE BEGIN vcom_Trace_DMA_2 */
|
||||
|
||||
/* USER CODE END vcom_Trace_DMA_2 */
|
||||
}
|
||||
|
||||
UTIL_ADV_TRACE_Status_t vcom_ReceiveInit(void (*RxCb)(uint8_t *rxChar, uint16_t size, uint8_t error))
|
||||
{
|
||||
/* USER CODE BEGIN vcom_ReceiveInit_1 */
|
||||
|
||||
/* USER CODE END vcom_ReceiveInit_1 */
|
||||
UART_WakeUpTypeDef WakeUpSelection;
|
||||
|
||||
/*record call back*/
|
||||
RxCpltCallback = RxCb;
|
||||
|
||||
/*Set wakeUp event on start bit*/
|
||||
WakeUpSelection.WakeUpEvent = UART_WAKEUP_ON_STARTBIT;
|
||||
|
||||
HAL_UARTEx_StopModeWakeUpSourceConfig(&hlpuart1, WakeUpSelection);
|
||||
|
||||
/* Make sure that no UART transfer is on-going */
|
||||
while (__HAL_UART_GET_FLAG(&hlpuart1, USART_ISR_BUSY) == SET);
|
||||
|
||||
/* Make sure that UART is ready to receive) */
|
||||
while (__HAL_UART_GET_FLAG(&hlpuart1, USART_ISR_REACK) == RESET);
|
||||
|
||||
/* Enable USART interrupt */
|
||||
__HAL_UART_ENABLE_IT(&hlpuart1, UART_IT_WUF);
|
||||
|
||||
/*Enable wakeup from stop mode*/
|
||||
HAL_UARTEx_EnableStopMode(&hlpuart1);
|
||||
|
||||
/*Start LPUART receive on IT*/
|
||||
HAL_UART_Receive_IT(&hlpuart1, &charRx, 1);
|
||||
|
||||
return UTIL_ADV_TRACE_OK;
|
||||
/* USER CODE BEGIN vcom_ReceiveInit_2 */
|
||||
|
||||
/* USER CODE END vcom_ReceiveInit_2 */
|
||||
}
|
||||
|
||||
void vcom_Resume(void)
|
||||
{
|
||||
/* USER CODE BEGIN vcom_Resume_1 */
|
||||
|
||||
/* USER CODE END vcom_Resume_1 */
|
||||
/*to re-enable lost DMA settings*/
|
||||
if (HAL_DMA_Init(&hdma_lpuart1_tx) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN vcom_Resume_2 */
|
||||
|
||||
/* USER CODE END vcom_Resume_2 */
|
||||
}
|
||||
|
||||
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
|
||||
{
|
||||
/* USER CODE BEGIN HAL_UART_TxCpltCallback_1 */
|
||||
|
||||
/* USER CODE END HAL_UART_TxCpltCallback_1 */
|
||||
/* buffer transmission complete*/
|
||||
if (huart->Instance == LPUART1)
|
||||
{
|
||||
TxCpltCallback(NULL);
|
||||
}
|
||||
/* USER CODE BEGIN HAL_UART_TxCpltCallback_2 */
|
||||
|
||||
/* USER CODE END HAL_UART_TxCpltCallback_2 */
|
||||
}
|
||||
|
||||
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
|
||||
{
|
||||
/* USER CODE BEGIN HAL_UART_RxCpltCallback_1 */
|
||||
|
||||
/* USER CODE END HAL_UART_RxCpltCallback_1 */
|
||||
if (huart->Instance == LPUART1)
|
||||
{
|
||||
if ((NULL != RxCpltCallback) && (HAL_UART_ERROR_NONE == huart->ErrorCode))
|
||||
{
|
||||
RxCpltCallback(&charRx, 1, 0);
|
||||
}
|
||||
HAL_UART_Receive_IT(huart, &charRx, 1);
|
||||
}
|
||||
/* USER CODE BEGIN HAL_UART_RxCpltCallback_2 */
|
||||
|
||||
/* USER CODE END HAL_UART_RxCpltCallback_2 */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN EF */
|
||||
|
||||
/* USER CODE END EF */
|
||||
|
||||
/* Private Functions Definition -----------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN PrFD */
|
||||
|
||||
/* USER CODE END PrFD */
|
|
@ -0,0 +1,81 @@
|
|||
/*!
|
||||
* \file Commissioning.h
|
||||
*
|
||||
* \brief End-device commissioning parameters
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
* ______ _
|
||||
* / _____) _ | |
|
||||
* ( (____ _____ ____ _| |_ _____ ____| |__
|
||||
* \____ \| ___ | (_ _) ___ |/ ___) _ \
|
||||
* _____) ) ____| | | || |_| ____( (___| | | |
|
||||
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
|
||||
* (C)2013-2020 Semtech
|
||||
*
|
||||
* \endcode
|
||||
*/
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* Portions COPYRIGHT 2020 STMicroelectronics
|
||||
*
|
||||
* @file Commissioning.h
|
||||
* @author MCD Application Team
|
||||
* @brief End-device commissioning parameters
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __COMMISSIONING_H__
|
||||
#define __COMMISSIONING_H__
|
||||
|
||||
/*!
|
||||
******************************************************************************
|
||||
********************************** WARNING ***********************************
|
||||
******************************************************************************
|
||||
|
||||
The LoRaWAN AES128 keys are stored and provisioned on secure-elements.
|
||||
|
||||
This project provides a software emulated secure-element.
|
||||
The LoRaWAN AES128 keys SHALL be updated under
|
||||
src/peripherals/<secure-element name>-se\se-identity.h file.
|
||||
|
||||
******************************************************************************
|
||||
******************************************************************************
|
||||
******************************************************************************
|
||||
*/
|
||||
#include "se-identity.h"
|
||||
#include "LoRaMacVersion.h"
|
||||
|
||||
/* USER CODE BEGIN EC1 */
|
||||
|
||||
/* USER CODE END EC1 */
|
||||
|
||||
/*!
|
||||
* When using ABP activation the MAC layer must know in advance to which server
|
||||
* version it will be connected.
|
||||
*/
|
||||
#define ABP_ACTIVATION_LRWAN_VERSION LORAMAC_VERSION
|
||||
|
||||
/*!
|
||||
* Indicates if the end-device support the operation with repeaters
|
||||
*/
|
||||
#define LORAWAN_REPEATER_SUPPORT false
|
||||
|
||||
/*!
|
||||
* Indicates if the end-device is to be connected to a private or public network
|
||||
*/
|
||||
#define LORAWAN_PUBLIC_NETWORK false
|
||||
|
||||
/*!
|
||||
* Current network ID
|
||||
*/
|
||||
#define LORAWAN_NETWORK_ID ( uint32_t )0
|
||||
|
||||
/* USER CODE BEGIN EC2 */
|
||||
|
||||
/* USER CODE END EC2 */
|
||||
|
||||
#endif /* __COMMISSIONING_H__ */
|
|
@ -0,0 +1,100 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file app_lorawan.c
|
||||
* @author MCD Application Team
|
||||
* @brief Application of the LRWAN Middleware
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "app_lorawan.h"
|
||||
#include "lora_app.h"
|
||||
#include "sys_app.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
#include "stm32_seq.h"
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* External variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PTD */
|
||||
|
||||
/* USER CODE END PTD */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PD */
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PM */
|
||||
|
||||
/* USER CODE END PM */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
|
||||
void MX_LoRaWAN_Init(void)
|
||||
{
|
||||
/* USER CODE BEGIN MX_LoRaWAN_Init_1 */
|
||||
|
||||
/* USER CODE END MX_LoRaWAN_Init_1 */
|
||||
SystemApp_Init();
|
||||
/* USER CODE BEGIN MX_LoRaWAN_Init_2 */
|
||||
|
||||
/* USER CODE END MX_LoRaWAN_Init_2 */
|
||||
LoRaWAN_Init();
|
||||
/* USER CODE BEGIN MX_LoRaWAN_Init_3 */
|
||||
|
||||
/* USER CODE END MX_LoRaWAN_Init_3 */
|
||||
}
|
||||
|
||||
void MX_LoRaWAN_Process(void)
|
||||
{
|
||||
/* USER CODE BEGIN MX_LoRaWAN_Process_1 */
|
||||
|
||||
UTIL_SEQ_Run(UTIL_SEQ_DEFAULT);
|
||||
|
||||
/* USER CODE END MX_LoRaWAN_Process_1 */
|
||||
/* USER CODE BEGIN MX_LoRaWAN_Process_OS */
|
||||
|
||||
/* USER CODE END MX_LoRaWAN_Process_OS */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN EF */
|
||||
|
||||
/* USER CODE END EF */
|
||||
|
||||
/* Private Functions Definition -----------------------------------------------*/
|
||||
/* USER CODE BEGIN PrFD */
|
||||
|
||||
/* USER CODE END PrFD */
|
|
@ -0,0 +1,73 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file app_lorawan.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header of application of the LRWAN Middleware
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __APP_LORAWAN_H__
|
||||
#define __APP_LORAWAN_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported Functions Prototypes ---------------------------------------------*/
|
||||
/**
|
||||
* @brief Init Lora Application
|
||||
*/
|
||||
void MX_LoRaWAN_Init(void);
|
||||
|
||||
/**
|
||||
* @brief Entry Lora Process or scheduling
|
||||
*/
|
||||
void MX_LoRaWAN_Process(void);
|
||||
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__APP_LORAWAN_H__*/
|
|
@ -0,0 +1,82 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file app_version.h
|
||||
* @author MCD Application Team
|
||||
* @brief Definition the version of the application
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __APP_VERSION_H__
|
||||
#define __APP_VERSION_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define APP_VERSION_MAIN (0x01U) /*!< [31:24] main version */
|
||||
#define APP_VERSION_SUB1 (0x03U) /*!< [23:16] sub1 version */
|
||||
#define APP_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */
|
||||
#define APP_VERSION_RC (0x00U) /*!< [7:0] release candidate */
|
||||
|
||||
#define APP_VERSION_MAIN_SHIFT 24 /*!< main byte shift */
|
||||
#define APP_VERSION_SUB1_SHIFT 16 /*!< sub1 byte shift */
|
||||
#define APP_VERSION_SUB2_SHIFT 8 /*!< sub2 byte shift */
|
||||
#define APP_VERSION_RC_SHIFT 0 /*!< release candidate byte shift */
|
||||
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Application version
|
||||
*/
|
||||
#define APP_VERSION ((APP_VERSION_MAIN << APP_VERSION_MAIN_SHIFT)\
|
||||
|(APP_VERSION_SUB1 << APP_VERSION_SUB1_SHIFT)\
|
||||
|(APP_VERSION_SUB2 << APP_VERSION_SUB2_SHIFT)\
|
||||
|(APP_VERSION_RC << APP_VERSION_RC_SHIFT))
|
||||
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__APP_VERSION_H__*/
|
|
@ -0,0 +1,265 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file lora_app.c
|
||||
* @author MCD Application Team
|
||||
* @brief Application of the LRWAN Middleware
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "platform.h"
|
||||
#include "sys_app.h"
|
||||
#include "lora_app.h"
|
||||
#include "app_version.h"
|
||||
#include "LmHandler.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* External variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PTD */
|
||||
|
||||
/* USER CODE END PTD */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/**
|
||||
* LEDs period value of the timer in ms
|
||||
*/
|
||||
#define LED_PERIOD_TIME 500
|
||||
|
||||
/* USER CODE BEGIN PD */
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PM */
|
||||
|
||||
/* USER CODE END PM */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/**
|
||||
* @brief join event callback function
|
||||
* @param joinParams status of join
|
||||
*/
|
||||
static void OnJoinRequest(LmHandlerJoinParams_t *joinParams);
|
||||
|
||||
/**
|
||||
* @brief callback when LoRaWAN application has sent a frame
|
||||
* @brief tx event callback function
|
||||
* @param params status of last Tx
|
||||
*/
|
||||
static void OnTxData(LmHandlerTxParams_t *params);
|
||||
|
||||
/**
|
||||
* @brief callback when LoRaWAN application has received a frame
|
||||
* @param appData data received in the last Rx
|
||||
* @param params status of last Rx
|
||||
*/
|
||||
static void OnRxData(LmHandlerAppData_t *appData, LmHandlerRxParams_t *params);
|
||||
|
||||
/**
|
||||
* @brief callback when LoRaWAN Beacon status is updated
|
||||
* @param params status of Last Beacon
|
||||
*/
|
||||
static void OnBeaconStatusChange(LmHandlerBeaconParams_t *params);
|
||||
|
||||
/**
|
||||
* @brief callback when system time has been updated
|
||||
*/
|
||||
static void OnSysTimeUpdate(void);
|
||||
|
||||
/**
|
||||
* @brief callback when LoRaWAN application Class is changed
|
||||
* @param deviceClass new class
|
||||
*/
|
||||
static void OnClassChange(DeviceClass_t deviceClass);
|
||||
|
||||
/**
|
||||
* Will be called each time a Radio IRQ is handled by the MAC layer
|
||||
*
|
||||
*/
|
||||
static void OnMacProcessNotify(void);
|
||||
|
||||
/**
|
||||
* @brief Change the periodicity of the uplink frames
|
||||
* @param periodicity uplink frames period in ms
|
||||
* @note Compliance test protocol callbacks
|
||||
*/
|
||||
static void OnTxPeriodicityChanged(uint32_t periodicity);
|
||||
|
||||
/**
|
||||
* @brief Change the confirmation control of the uplink frames
|
||||
* @param isTxConfirmed Indicates if the uplink requires an acknowledgement
|
||||
* @note Compliance test protocol callbacks
|
||||
*/
|
||||
static void OnTxFrameCtrlChanged(LmHandlerMsgTypes_t isTxConfirmed);
|
||||
|
||||
/**
|
||||
* @brief Change the periodicity of the ping slot frames
|
||||
* @param pingSlotPeriodicity ping slot frames period in ms
|
||||
* @note Compliance test protocol callbacks
|
||||
*/
|
||||
static void OnPingSlotPeriodicityChanged(uint8_t pingSlotPeriodicity);
|
||||
|
||||
/**
|
||||
* @brief Will be called to reset the system
|
||||
* @note Compliance test protocol callbacks
|
||||
*/
|
||||
static void OnSystemReset(void);
|
||||
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/**
|
||||
* @brief LoRaWAN handler Callbacks
|
||||
*/
|
||||
static LmHandlerCallbacks_t LmHandlerCallbacks =
|
||||
{
|
||||
.GetBatteryLevel = GetBatteryLevel,
|
||||
.GetTemperature = GetTemperatureLevel,
|
||||
.GetUniqueId = GetUniqueId,
|
||||
.GetDevAddr = GetDevAddr,
|
||||
.OnMacProcess = OnMacProcessNotify,
|
||||
.OnJoinRequest = OnJoinRequest,
|
||||
.OnTxData = OnTxData,
|
||||
.OnRxData = OnRxData,
|
||||
.OnBeaconStatusChange = OnBeaconStatusChange,
|
||||
.OnSysTimeUpdate = OnSysTimeUpdate,
|
||||
.OnClassChange = OnClassChange,
|
||||
.OnTxPeriodicityChanged = OnTxPeriodicityChanged,
|
||||
.OnTxFrameCtrlChanged = OnTxFrameCtrlChanged,
|
||||
.OnPingSlotPeriodicityChanged = OnPingSlotPeriodicityChanged,
|
||||
.OnSystemReset = OnSystemReset,
|
||||
};
|
||||
|
||||
/* USER CODE BEGIN PV */
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Exported functions ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EF */
|
||||
|
||||
/* USER CODE END EF */
|
||||
|
||||
void LoRaWAN_Init(void)
|
||||
{
|
||||
/* USER CODE BEGIN LoRaWAN_Init_LV */
|
||||
|
||||
/* USER CODE END LoRaWAN_Init_LV */
|
||||
|
||||
/* USER CODE BEGIN LoRaWAN_Init_1 */
|
||||
|
||||
/* USER CODE END LoRaWAN_Init_1 */
|
||||
|
||||
/* Init the Lora Stack*/
|
||||
LmHandlerInit(&LmHandlerCallbacks, APP_VERSION);
|
||||
|
||||
/* USER CODE BEGIN LoRaWAN_Init_Last */
|
||||
|
||||
/* USER CODE END LoRaWAN_Init_Last */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN PB_Callbacks */
|
||||
|
||||
/* USER CODE END PB_Callbacks */
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PrFD */
|
||||
|
||||
/* USER CODE END PrFD */
|
||||
|
||||
static void OnRxData(LmHandlerAppData_t *appData, LmHandlerRxParams_t *params)
|
||||
{
|
||||
/* USER CODE BEGIN OnRxData_1 */
|
||||
/* USER CODE END OnRxData_1 */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN PrFD_LedEvents */
|
||||
|
||||
/* USER CODE END PrFD_LedEvents */
|
||||
|
||||
static void OnTxData(LmHandlerTxParams_t *params)
|
||||
{
|
||||
/* USER CODE BEGIN OnTxData_1 */
|
||||
/* USER CODE END OnTxData_1 */
|
||||
}
|
||||
|
||||
static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
|
||||
{
|
||||
/* USER CODE BEGIN OnJoinRequest_1 */
|
||||
/* USER CODE END OnJoinRequest_1 */
|
||||
}
|
||||
|
||||
static void OnBeaconStatusChange(LmHandlerBeaconParams_t *params)
|
||||
{
|
||||
/* USER CODE BEGIN OnBeaconStatusChange_1 */
|
||||
/* USER CODE END OnBeaconStatusChange_1 */
|
||||
}
|
||||
|
||||
static void OnSysTimeUpdate(void)
|
||||
{
|
||||
/* USER CODE BEGIN OnSysTimeUpdate_1 */
|
||||
|
||||
/* USER CODE END OnSysTimeUpdate_1 */
|
||||
}
|
||||
|
||||
static void OnClassChange(DeviceClass_t deviceClass)
|
||||
{
|
||||
/* USER CODE BEGIN OnClassChange_1 */
|
||||
/* USER CODE END OnClassChange_1 */
|
||||
}
|
||||
|
||||
static void OnMacProcessNotify(void)
|
||||
{
|
||||
/* USER CODE BEGIN OnMacProcessNotify_1 */
|
||||
|
||||
/* USER CODE END OnMacProcessNotify_1 */
|
||||
}
|
||||
|
||||
static void OnTxPeriodicityChanged(uint32_t periodicity)
|
||||
{
|
||||
/* USER CODE BEGIN OnTxPeriodicityChanged_1 */
|
||||
|
||||
/* USER CODE END OnTxPeriodicityChanged_1 */
|
||||
}
|
||||
|
||||
static void OnTxFrameCtrlChanged(LmHandlerMsgTypes_t isTxConfirmed)
|
||||
{
|
||||
/* USER CODE BEGIN OnTxFrameCtrlChanged_1 */
|
||||
|
||||
/* USER CODE END OnTxFrameCtrlChanged_1 */
|
||||
}
|
||||
|
||||
static void OnPingSlotPeriodicityChanged(uint8_t pingSlotPeriodicity)
|
||||
{
|
||||
/* USER CODE BEGIN OnPingSlotPeriodicityChanged_1 */
|
||||
|
||||
/* USER CODE END OnPingSlotPeriodicityChanged_1 */
|
||||
}
|
||||
|
||||
static void OnSystemReset(void)
|
||||
{
|
||||
/* USER CODE BEGIN OnSystemReset_1 */
|
||||
|
||||
/* USER CODE END OnSystemReset_1 */
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file lora_app.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header of application of the LRWAN Middleware
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __LORA_APP_H__
|
||||
#define __LORA_APP_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/**
|
||||
* @brief Init Lora Application
|
||||
*/
|
||||
void LoRaWAN_Init(void);
|
||||
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__LORA_APP_H__*/
|
|
@ -0,0 +1,157 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file lora_info.c
|
||||
* @author MCD Application Team
|
||||
* @brief To give info to the application about LoRaWAN configuration
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "LoRaMac.h"
|
||||
#include "lora_info.h"
|
||||
#include "lorawan_conf.h"
|
||||
#include "sys_app.h" /* APP_PRINTF */
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN PTD */
|
||||
|
||||
/* USER CODE END PTD */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN PD */
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN PM */
|
||||
|
||||
/* USER CODE END PM */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
static LoraInfo_t loraInfo = {0, 0};
|
||||
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Exported variables --------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
void LoraInfo_Init(void)
|
||||
{
|
||||
loraInfo.ContextManagement = 0;
|
||||
loraInfo.Region = 0;
|
||||
loraInfo.ClassB = 0;
|
||||
loraInfo.Kms = 0;
|
||||
/* USER CODE BEGIN LoraInfo_Init_1 */
|
||||
|
||||
/* USER CODE END LoraInfo_Init_1 */
|
||||
|
||||
#ifdef REGION_AS923
|
||||
loraInfo.Region |= (1 << LORAMAC_REGION_AS923);
|
||||
#endif /* REGION_AS923 */
|
||||
#ifdef REGION_AU915
|
||||
loraInfo.Region |= (1 << LORAMAC_REGION_AU915);
|
||||
#endif /* REGION_AU915 */
|
||||
#ifdef REGION_CN470
|
||||
loraInfo.Region |= (1 << LORAMAC_REGION_CN470);
|
||||
#endif /* REGION_CN470 */
|
||||
#ifdef REGION_CN779
|
||||
loraInfo.Region |= (1 << LORAMAC_REGION_CN779);
|
||||
#endif /* REGION_CN779 */
|
||||
#ifdef REGION_EU433
|
||||
loraInfo.Region |= (1 << LORAMAC_REGION_EU433);
|
||||
#endif /* REGION_EU433 */
|
||||
#ifdef REGION_EU868
|
||||
loraInfo.Region |= (1 << LORAMAC_REGION_EU868);
|
||||
#endif /* REGION_EU868 */
|
||||
#ifdef REGION_KR920
|
||||
loraInfo.Region |= (1 << LORAMAC_REGION_KR920);
|
||||
#endif /* REGION_KR920 */
|
||||
#ifdef REGION_IN865
|
||||
loraInfo.Region |= (1 << LORAMAC_REGION_IN865);
|
||||
#endif /* REGION_IN865 */
|
||||
#ifdef REGION_US915
|
||||
loraInfo.Region |= (1 << LORAMAC_REGION_US915);
|
||||
#endif /* REGION_US915 */
|
||||
#ifdef REGION_RU864
|
||||
loraInfo.Region |= (1 << LORAMAC_REGION_RU864);
|
||||
#endif /* REGION_RU864 */
|
||||
|
||||
if (loraInfo.Region == 0)
|
||||
{
|
||||
/* USER CODE BEGIN LoraInfo_Init_NO_REGION */
|
||||
|
||||
/* USER CODE END LoraInfo_Init_NO_REGION */
|
||||
while (1) {} /* At least one region shall be defined */
|
||||
}
|
||||
|
||||
#if ( LORAMAC_CLASSB_ENABLED == 1 )
|
||||
loraInfo.ClassB = 1;
|
||||
#elif !defined (LORAMAC_CLASSB_ENABLED)
|
||||
#error LORAMAC_CLASSB_ENABLED not defined ( shall be <0 or 1> )
|
||||
#endif /* LORAMAC_CLASSB_ENABLED */
|
||||
|
||||
#if (!defined (LORAWAN_KMS) || (LORAWAN_KMS == 0))
|
||||
loraInfo.Kms = 0;
|
||||
#else /* LORAWAN_KMS == 1 */
|
||||
loraInfo.Kms = 1;
|
||||
#endif /* LORAWAN_KMS */
|
||||
|
||||
#if (!defined (CONTEXT_MANAGEMENT_ENABLED) || (CONTEXT_MANAGEMENT_ENABLED == 0))
|
||||
loraInfo.ContextManagement = 0;
|
||||
#else /* CONTEXT_MANAGEMENT_ENABLED == 1 */
|
||||
loraInfo.ContextManagement = 1;
|
||||
#endif /* CONTEXT_MANAGEMENT_ENABLED */
|
||||
|
||||
/* USER CODE BEGIN LoraInfo_Init_2 */
|
||||
|
||||
/* USER CODE END LoraInfo_Init_2 */
|
||||
}
|
||||
|
||||
LoraInfo_t *LoraInfo_GetPtr(void)
|
||||
{
|
||||
/* USER CODE BEGIN LoraInfo_GetPtr */
|
||||
|
||||
/* USER CODE END LoraInfo_GetPtr */
|
||||
return &loraInfo;
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN EF */
|
||||
|
||||
/* USER CODE END EF */
|
||||
|
||||
/* Private functions --------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN PF */
|
||||
|
||||
/* USER CODE END PF */
|
|
@ -0,0 +1,91 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file lora_info.h
|
||||
* @author MCD Application Team
|
||||
* @brief To give info to the application about LoRaWAN configuration
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
#ifndef __LORA_INFO_H__
|
||||
#define __LORA_INFO_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <stdint.h>
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/*!
|
||||
* To give info to the application about LoraWAN capability
|
||||
* it can depend how it has been compiled (e.g. compiled regions ...)
|
||||
* Params should be better uint32_t foe easier alignment with info_table concept
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t ContextManagement; /*!< 0: not compiled in Mw, 1 : compiled in MW */
|
||||
uint32_t Region; /*!< Combination of regions compiled on MW */
|
||||
uint32_t ClassB; /*!< 0: not compiled in Mw, 1 : compiled in MW */
|
||||
uint32_t Kms; /*!< 0: not compiled in Mw, 1 : compiled in MW */
|
||||
} LoraInfo_t;
|
||||
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
/**
|
||||
* @brief initialize the LoraInfo table
|
||||
*/
|
||||
void LoraInfo_Init(void);
|
||||
|
||||
/**
|
||||
* @brief returns the pointer to the LoraInfo capabilities table
|
||||
* @retval LoraInfo pointer
|
||||
*/
|
||||
LoraInfo_t *LoraInfo_GetPtr(void);
|
||||
|
||||
/* USER CODE BEGIN EF */
|
||||
|
||||
/* USER CODE END EF */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __LORA_INFO_H__ */
|
|
@ -0,0 +1,414 @@
|
|||
/*!
|
||||
* \file se-identity.h
|
||||
*
|
||||
* \brief Secure Element identity and keys
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
* ______ _
|
||||
* / _____) _ | |
|
||||
* ( (____ _____ ____ _| |_ _____ ____| |__
|
||||
* \____ \| ___ | (_ _) ___ |/ ___) _ \
|
||||
* _____) ) ____| | | || |_| ____( (___| | | |
|
||||
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
|
||||
* (C)2020 Semtech
|
||||
*
|
||||
* ___ _____ _ ___ _ _____ ___ ___ ___ ___
|
||||
* / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __|
|
||||
* \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _|
|
||||
* |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
|
||||
* embedded.connectivity.solutions===============
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
*/
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* Portions COPYRIGHT 2020 STMicroelectronics
|
||||
*
|
||||
* @file se-identity.h
|
||||
* @author MCD Application Team
|
||||
* @brief Secure Element identity and keys
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __SOFT_SE_IDENTITY_H__
|
||||
#define __SOFT_SE_IDENTITY_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported Includes --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/*!
|
||||
******************************************************************************
|
||||
********************************** WARNING ***********************************
|
||||
******************************************************************************
|
||||
The secure-element implementation supports both 1.0.x and 1.1.x LoRaWAN
|
||||
versions of the specification.
|
||||
Thus it has been decided to use the 1.1.x keys and EUI name definitions.
|
||||
The below table shows the names equivalence between versions:
|
||||
+---------------------+-------------------------+
|
||||
| 1.0.x | 1.1.x |
|
||||
+=====================+=========================+
|
||||
| LORAWAN_DEVICE_EUI | LORAWAN_DEVICE_EUI |
|
||||
+---------------------+-------------------------+
|
||||
| LORAWAN_APP_EUI | LORAWAN_JOIN_EUI |
|
||||
+---------------------+-------------------------+
|
||||
| LORAWAN_GEN_APP_KEY | LORAWAN_APP_KEY |
|
||||
+---------------------+-------------------------+
|
||||
| LORAWAN_APP_KEY | LORAWAN_NWK_KEY |
|
||||
+---------------------+-------------------------+
|
||||
| LORAWAN_NWK_S_KEY | LORAWAN_F_NWK_S_INT_KEY |
|
||||
+---------------------+-------------------------+
|
||||
| LORAWAN_NWK_S_KEY | LORAWAN_S_NWK_S_INT_KEY |
|
||||
+---------------------+-------------------------+
|
||||
| LORAWAN_NWK_S_KEY | LORAWAN_NWK_S_ENC_KEY |
|
||||
+---------------------+-------------------------+
|
||||
| LORAWAN_APP_S_KEY | LORAWAN_APP_S_KEY |
|
||||
+---------------------+-------------------------+
|
||||
******************************************************************************
|
||||
******************************************************************************
|
||||
******************************************************************************
|
||||
*/
|
||||
/*!
|
||||
* End-device IEEE EUI (big endian)
|
||||
* When set to 00,00,00,00,00,00,00,00 DevEui is automatically set with a value provided by MCU platform
|
||||
*/
|
||||
#define LORAWAN_DEVICE_EUI 00,00,00,00,00,00,00,00
|
||||
|
||||
/*!
|
||||
* App/Join server IEEE EUI (big endian)
|
||||
*/
|
||||
#define LORAWAN_JOIN_EUI 01,01,01,01,01,01,01,01
|
||||
|
||||
/*!
|
||||
* Device address on the network (big endian)
|
||||
* When set to 00,00,00,00 DevAddr is automatically set with a value provided by MCU platform
|
||||
*/
|
||||
#define LORAWAN_DEVICE_ADDRESS 00,00,00,00
|
||||
|
||||
/*!
|
||||
* Application root key
|
||||
*/
|
||||
#define LORAWAN_APP_KEY 2B,7E,15,16,28,AE,D2,A6,AB,F7,15,88,09,CF,4F,3C
|
||||
|
||||
/*!
|
||||
* Network root key
|
||||
*/
|
||||
#define LORAWAN_NWK_KEY 2B,7E,15,16,28,AE,D2,A6,AB,F7,15,88,09,CF,4F,3C
|
||||
|
||||
/*!
|
||||
* Forwarding Network session key
|
||||
*/
|
||||
#define LORAWAN_NWK_S_KEY 2B,7E,15,16,28,AE,D2,A6,AB,F7,15,88,09,CF,4F,3C
|
||||
|
||||
/*!
|
||||
* Application session key
|
||||
*/
|
||||
#define LORAWAN_APP_S_KEY 2B,7E,15,16,28,AE,D2,A6,AB,F7,15,88,09,CF,4F,3C
|
||||
|
||||
/*!
|
||||
* Format commissioning keys
|
||||
*/
|
||||
#define RAW_TO_INT8A(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) {0x##a,0x##b,0x##c,0x##d,\
|
||||
0x##e,0x##f,0x##g,0x##h,\
|
||||
0x##i,0x##j,0x##k,0x##l,\
|
||||
0x##m,0x##n,0x##o,0x##p}
|
||||
|
||||
#define RAW8_TO_INT8A(a,b,c,d) 0x##a##b##c##d
|
||||
#define RAW32_TO_INT8A(a,b,c,d,e,f,g,h) {0x##a,0x##b,0x##c,0x##d,\
|
||||
0x##e,0x##f,0x##g,0x##h}
|
||||
|
||||
#define FORMAT_KEY(...) RAW_TO_INT8A(__VA_ARGS__)
|
||||
#define FORMAT8_KEY(...) RAW8_TO_INT8A(__VA_ARGS__)
|
||||
#define FORMAT32_KEY(...) RAW32_TO_INT8A(__VA_ARGS__)
|
||||
|
||||
#if (defined( LORAMAC_VERSION ) && ( LORAMAC_VERSION == 0x01010100 ))
|
||||
#define SESSION_KEYS_LIST \
|
||||
{ \
|
||||
/*! \
|
||||
* Join session integrity key (Dynamically updated) \
|
||||
* WARNING: NOT USED FOR 1.0.x DEVICES \
|
||||
*/ \
|
||||
.KeyID = J_S_INT_KEY, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Join session encryption key (Dynamically updated) \
|
||||
* WARNING: NOT USED FOR 1.0.x DEVICES \
|
||||
*/ \
|
||||
.KeyID = J_S_ENC_KEY, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Forwarding Network session integrity key \
|
||||
* WARNING: NWK_S_KEY FOR 1.0.x DEVICES \
|
||||
*/ \
|
||||
.KeyID = F_NWK_S_INT_KEY, \
|
||||
.KeyValue = FORMAT_KEY(LORAWAN_NWK_S_KEY), \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Serving Network session integrity key \
|
||||
* WARNING: NOT USED FOR 1.0.x DEVICES. MUST BE THE SAME AS \ref LORAWAN_F_NWK_S_INT_KEY \
|
||||
*/ \
|
||||
.KeyID = S_NWK_S_INT_KEY, \
|
||||
.KeyValue = { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, \
|
||||
0x3C }, \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Network session encryption key \
|
||||
* WARNING: NOT USED FOR 1.0.x DEVICES. MUST BE THE SAME AS \ref LORAWAN_F_NWK_S_INT_KEY \
|
||||
*/ \
|
||||
.KeyID = NWK_S_ENC_KEY, \
|
||||
.KeyValue = { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, \
|
||||
0x3C }, \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Application session key \
|
||||
*/ \
|
||||
.KeyID = APP_S_KEY, \
|
||||
.KeyValue = FORMAT_KEY(LORAWAN_APP_S_KEY), \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Datablock MIC key \
|
||||
*/ \
|
||||
.KeyID = DATABLOCK_INT_KEY, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
},
|
||||
#else
|
||||
#define SESSION_KEYS_LIST \
|
||||
{ \
|
||||
/*! \
|
||||
* Network session key \
|
||||
*/ \
|
||||
.KeyID = NWK_S_KEY, \
|
||||
.KeyValue = FORMAT_KEY(LORAWAN_NWK_S_KEY), \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Application session key \
|
||||
*/ \
|
||||
.KeyID = APP_S_KEY, \
|
||||
.KeyValue = FORMAT_KEY(LORAWAN_APP_S_KEY), \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Datablock MIC key \
|
||||
*/ \
|
||||
.KeyID = DATABLOCK_INT_KEY, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
},
|
||||
#endif /* LORAMAC_VERSION */
|
||||
|
||||
#if (LORAMAC_MAX_MC_CTX == 1)
|
||||
#define SESSION_MC_KEYS_LIST \
|
||||
{ \
|
||||
/*! \
|
||||
* Multicast group #0 root key (Dynamically updated) \
|
||||
*/ \
|
||||
.KeyID = MC_KEY_0, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Multicast group #0 application session key (Dynamically updated) \
|
||||
*/ \
|
||||
.KeyID = MC_APP_S_KEY_0, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Multicast group #0 network session key (Dynamically updated) \
|
||||
*/ \
|
||||
.KeyID = MC_NWK_S_KEY_0, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
},
|
||||
#else /* LORAMAC_MAX_MC_CTX > 1 */
|
||||
#define SESSION_MC_KEYS_LIST \
|
||||
{ \
|
||||
/*! \
|
||||
* Multicast group #0 root key (Dynamically updated) \
|
||||
*/ \
|
||||
.KeyID = MC_KEY_0, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Multicast group #0 application session key (Dynamically updated) \
|
||||
*/ \
|
||||
.KeyID = MC_APP_S_KEY_0, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Multicast group #0 network session key (Dynamically updated) \
|
||||
*/ \
|
||||
.KeyID = MC_NWK_S_KEY_0, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Multicast group #1 root key (Dynamically updated) \
|
||||
*/ \
|
||||
.KeyID = MC_KEY_1, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Multicast group #1 application session key (Dynamically updated) \
|
||||
*/ \
|
||||
.KeyID = MC_APP_S_KEY_1, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Multicast group #1 network session key (Dynamically updated) \
|
||||
*/ \
|
||||
.KeyID = MC_NWK_S_KEY_1, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Multicast group #2 root key (Dynamically updated) \
|
||||
*/ \
|
||||
.KeyID = MC_KEY_2, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Multicast group #2 application session key (Dynamically updated) \
|
||||
*/ \
|
||||
.KeyID = MC_APP_S_KEY_2, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Multicast group #2 network session key (Dynamically updated) \
|
||||
*/ \
|
||||
.KeyID = MC_NWK_S_KEY_2, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Multicast group #3 root key (Dynamically updated) \
|
||||
*/ \
|
||||
.KeyID = MC_KEY_3, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Multicast group #3 application session key (Dynamically updated) \
|
||||
*/ \
|
||||
.KeyID = MC_APP_S_KEY_3, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Multicast group #3 network session key (Dynamically updated) \
|
||||
*/ \
|
||||
.KeyID = MC_NWK_S_KEY_3, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
},
|
||||
#endif /* LORAMAC_MAX_MC_CTX */
|
||||
|
||||
#define SOFT_SE_KEY_LIST \
|
||||
{ \
|
||||
{ \
|
||||
/*! \
|
||||
* Application root key \
|
||||
* WARNING: FOR 1.0.x DEVICES IT IS THE \ref LORAWAN_GEN_APP_KEY \
|
||||
*/ \
|
||||
.KeyID = APP_KEY, \
|
||||
.KeyValue = FORMAT_KEY(LORAWAN_APP_KEY), \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Network root key \
|
||||
* WARNING: FOR 1.0.x DEVICES IT IS THE \ref LORAWAN_APP_KEY \
|
||||
*/ \
|
||||
.KeyID = NWK_KEY, \
|
||||
.KeyValue = FORMAT_KEY(LORAWAN_NWK_KEY), \
|
||||
}, \
|
||||
SESSION_KEYS_LIST \
|
||||
{ \
|
||||
/*! \
|
||||
* Multicast root key (Dynamically updated) \
|
||||
*/ \
|
||||
.KeyID = MC_ROOT_KEY, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
}, \
|
||||
{ \
|
||||
/*! \
|
||||
* Multicast key encryption key (Dynamically updated) \
|
||||
*/ \
|
||||
.KeyID = MC_KE_KEY, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
}, \
|
||||
SESSION_MC_KEYS_LIST \
|
||||
{ \
|
||||
/*! \
|
||||
* All zeros key. (ClassB usage)(constant) \
|
||||
*/ \
|
||||
.KeyID = SLOT_RAND_ZERO_KEY, \
|
||||
.KeyValue = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00 }, \
|
||||
}, \
|
||||
}
|
||||
|
||||
#define SOFT_SE_ID_LIST \
|
||||
.SeNvmDevJoinKey.DevEui = FORMAT32_KEY(LORAWAN_DEVICE_EUI), \
|
||||
.SeNvmDevJoinKey.JoinEui = FORMAT32_KEY(LORAWAN_JOIN_EUI), \
|
||||
.SeNvmDevJoinKey.DevAddrOTAA = FORMAT8_KEY(LORAWAN_DEVICE_ADDRESS), \
|
||||
.SeNvmDevJoinKey.DevAddrABP = FORMAT8_KEY(LORAWAN_DEVICE_ADDRESS) \
|
||||
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __SOFT_SE_IDENTITY_H__ */
|
|
@ -0,0 +1,204 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file lorawan_conf.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for LoRaWAN middleware instances
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __LORAWAN_CONF_H__
|
||||
#define __LORAWAN_CONF_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#if defined(__ICCARM__)
|
||||
#define SOFT_SE_PLACE_IN_NVM_START _Pragma(" default_variable_attributes = @ \".USER_embedded_Keys\"")
|
||||
#elif defined(__CC_ARM)
|
||||
#define SOFT_SE_PLACE_IN_NVM_START _Pragma(" arm section rodata = \".USER_embedded_Keys\"")
|
||||
#elif defined(__GNUC__)
|
||||
#define SOFT_SE_PLACE_IN_NVM_START __attribute__((section(".USER_embedded_Keys")))
|
||||
#endif /* __ICCARM__ | __CC_ARM | __GNUC__ */
|
||||
|
||||
/* Stop placing data in specified section*/
|
||||
#if defined(__ICCARM__)
|
||||
#define SOFT_SE_PLACE_IN_NVM_STOP _Pragma("default_variable_attributes =")
|
||||
#elif defined(__CC_ARM)
|
||||
#define SOFT_SE_PLACE_IN_NVM_STOP _Pragma("arm section code")
|
||||
#endif /* __ICCARM__ | __CC_ARM | __GNUC__ */
|
||||
|
||||
/*!
|
||||
* @brief LoRaWAN version definition
|
||||
* @note possible values:
|
||||
* - 0x01000300: Link Layer(L2) v1.0.3 + Regional Parameters(RP) v1.0.3
|
||||
* - 0x01000400: Link Layer TS001-1.0.4 + Regional Parameters RP002-1.0.1
|
||||
* - 0x01010100: soon available ...
|
||||
*/
|
||||
#define LORAMAC_SPECIFICATION_VERSION 0x01000400
|
||||
|
||||
/*!
|
||||
* @brief Enable the additional LoRaWAN packages
|
||||
* @note LoRaWAN Packages available when enabled:
|
||||
* - Application Layer Clock Synchronization (Package ID: 1, Default Port: 202)
|
||||
* - Remote Multicast Setup (Package ID: 2, Default Port: 200)
|
||||
* - Fragmented Data Block Transport (Package ID: 3, Default Port: 201)
|
||||
* - Firmware Management Protocol (Package ID: 4, Default Port: 203)
|
||||
* The Certification Protocol is also defined as a mandatory package (Package ID: 0, Default Port: 224)
|
||||
*/
|
||||
#define LORAWAN_DATA_DISTRIB_MGT 0
|
||||
|
||||
/*!
|
||||
* @brief LoRaWAN packages version
|
||||
* @note When LORAWAN_DATA_DISTRIB_MGT is enabled, 2 possibles values:
|
||||
* - 1: v1.0.0 packages including:
|
||||
* - Application Layer Clock Synchronization v1.0.0
|
||||
* - Remote Multicast Setup v1.0.0
|
||||
* - Fragmented Data Block Transport v1.0.0
|
||||
* - 2: v2.0.0 packages including:
|
||||
* - Application Layer Clock Synchronization v2.0.0
|
||||
* - Remote Multicast Setup v2.0.0
|
||||
* - Fragmented Data Block Transport v2.0.0
|
||||
* - Firmware Management Protocol v1.0.0
|
||||
*/
|
||||
#define LORAWAN_PACKAGES_VERSION 1
|
||||
|
||||
/* Region ------------------------------------*/
|
||||
/* the region listed here will be linked in the MW code */
|
||||
/* the application (on sys_conf.h) shall just configure one region at the time */
|
||||
/*#define REGION_AS923*/
|
||||
/*#define REGION_AU915*/
|
||||
#define REGION_CN470
|
||||
/*#define REGION_CN779*/
|
||||
/*#define REGION_EU433*/
|
||||
/*#define REGION_EU868*/
|
||||
/*#define REGION_KR920*/
|
||||
/*#define REGION_IN865*/
|
||||
/*#define REGION_US915*/
|
||||
/*#define REGION_RU864*/
|
||||
|
||||
/*!
|
||||
* @brief Default channel plan for region AS923
|
||||
* @note Possible selections:
|
||||
* - CHANNEL_PLAN_GROUP_AS923_1 (Default configuration. Freq offset = 0.0 MHz / Freq range = 915-928MHz)
|
||||
* - CHANNEL_PLAN_GROUP_AS923_2 (Freq offset = -1.80 MHz / Freq range = 915-928MHz)
|
||||
* - CHANNEL_PLAN_GROUP_AS923_3 (Freq offset = -6.60 MHz / Freq range = 915-928MHz)
|
||||
* - CHANNEL_PLAN_GROUP_AS923_4 (Freq offset = -5.90 MHz / Freq range = 917-920MHz)
|
||||
* - CHANNEL_PLAN_GROUP_AS923_1_JP (Freq offset = 0.0 MHz / Freq range = 920.6-923.4MHz)
|
||||
*/
|
||||
#define REGION_AS923_DEFAULT_CHANNEL_PLAN CHANNEL_PLAN_GROUP_AS923_1
|
||||
|
||||
/*!
|
||||
* @brief Limits the number usable channels by default for AU915, CN470 and US915 regions
|
||||
* @note the default channel mask with this option activates the first 8 channels. \
|
||||
* this default mask can be modified in the RegionXXXXXInitDefaults function associated with the active region.
|
||||
*/
|
||||
#define HYBRID_ENABLED 0
|
||||
|
||||
/*!
|
||||
* @brief Define the read access of the keys in memory
|
||||
* @note this value should be disabled after the development process
|
||||
*/
|
||||
/* USER CODE BEGIN KEY_EXTRACTABLE */
|
||||
#define KEY_EXTRACTABLE 0
|
||||
/* USER CODE END KEY_EXTRACTABLE */
|
||||
|
||||
/*!
|
||||
* @brief Enables/Disables the context storage management storage
|
||||
* @note Must be enabled for LoRaWAN 1.0.4 or later.
|
||||
*/
|
||||
#define CONTEXT_MANAGEMENT_ENABLED 0
|
||||
|
||||
/* Class B ------------------------------------*/
|
||||
/*!
|
||||
* @brief Enables/Disables the LoRaWAN Class B (Periodic ping downlink slots + Beacon for synchronization)
|
||||
*/
|
||||
#define LORAMAC_CLASSB_ENABLED 0
|
||||
|
||||
#if ( LORAMAC_CLASSB_ENABLED == 1 )
|
||||
/* CLASS B LSE crystal calibration*/
|
||||
/*!
|
||||
* @brief Temperature coefficient of the clock source
|
||||
*/
|
||||
#define RTC_TEMP_COEFFICIENT ( -0.035 )
|
||||
|
||||
/*!
|
||||
* @brief Temperature coefficient deviation of the clock source
|
||||
*/
|
||||
#define RTC_TEMP_DEV_COEFFICIENT ( 0.0035 )
|
||||
|
||||
/*!
|
||||
* @brief Turnover temperature of the clock source
|
||||
*/
|
||||
#define RTC_TEMP_TURNOVER ( 25.0 )
|
||||
|
||||
/*!
|
||||
* @brief Turnover temperature deviation of the clock source
|
||||
*/
|
||||
#define RTC_TEMP_DEV_TURNOVER ( 5.0 )
|
||||
#endif /* LORAMAC_CLASSB_ENABLED == 1 */
|
||||
|
||||
/*!
|
||||
* @brief Disable the ClassA receive windows after Tx (after the Join Accept if OTAA mode defined)
|
||||
* @note Behavior to reduce power consumption but not compliant with LoRa Alliance recommendations.
|
||||
* All device parameters (Spreading Factor, channels selection, Tx Power, ...) should be fixed
|
||||
* and the adaptive datarate should be disabled.
|
||||
* @warning This limitation may have consequences for the proper functioning of the device,
|
||||
* if the LoRaMac ever generates MAC commands that require a response.
|
||||
*/
|
||||
#define DISABLE_LORAWAN_RX_WINDOW 0
|
||||
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
#ifndef CRITICAL_SECTION_BEGIN
|
||||
#define CRITICAL_SECTION_BEGIN( ) UTILS_ENTER_CRITICAL_SECTION( )
|
||||
#endif /* !CRITICAL_SECTION_BEGIN */
|
||||
#ifndef CRITICAL_SECTION_END
|
||||
#define CRITICAL_SECTION_END( ) UTILS_EXIT_CRITICAL_SECTION( )
|
||||
#endif /* !CRITICAL_SECTION_END */
|
||||
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __LORAWAN_CONF_H__ */
|
|
@ -0,0 +1,76 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file mw_log_conf.h
|
||||
* @author MCD Application Team
|
||||
* @brief Configure (enable/disable) traces
|
||||
*******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __MW_LOG_CONF_H__
|
||||
#define __MW_LOG_CONF_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define MW_LOG_ENABLED
|
||||
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
#ifdef MW_LOG_ENABLED
|
||||
/* USER CODE BEGIN Mw_Logs_En*/
|
||||
/* Map your own trace mechanism or to map UTIL_ADV_TRACE see examples from CubeFw, i.e.:
|
||||
do{ {UTIL_ADV_TRACE_COND_FSend(VL, T_REG_OFF, TS, __VA_ARGS__);} }while(0) */
|
||||
#define MW_LOG(TS,VL, ...)
|
||||
/* USER CODE END Mw_Logs_En */
|
||||
#else /* MW_LOG_ENABLED */
|
||||
/* USER CODE BEGIN Mw_Logs_Dis*/
|
||||
#define MW_LOG(TS,VL, ...)
|
||||
/* USER CODE END Mw_Logs_Dis */
|
||||
#endif /* MW_LOG_ENABLED */
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__MW_LOG_CONF_H__ */
|
|
@ -0,0 +1,256 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file radio_board_if.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides an interface layer between MW and Radio Board
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "radio_board_if.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* External variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PTD */
|
||||
|
||||
/* USER CODE END PTD */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PD */
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PM */
|
||||
|
||||
/* USER CODE END PM */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
int32_t RBI_Init(void)
|
||||
{
|
||||
/* USER CODE BEGIN RBI_Init_1 */
|
||||
|
||||
/* USER CODE END RBI_Init_1 */
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
/* Important note: BSP code is board dependent
|
||||
* STM32WL_Nucleo code can be found
|
||||
* either in STM32CubeWL package under Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* or at https://github.com/STMicroelectronics/STM32CubeWL/tree/main/Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* 1/ For User boards, the BSP/STM32WLxx_Nucleo/ directory can be copied and replaced in the project. The copy must then be updated depending:
|
||||
* on board RF switch configuration (pin control, number of port etc)
|
||||
* on TCXO configuration
|
||||
* on DC/DC configuration
|
||||
* on maximum output power that the board can deliver*/
|
||||
return BSP_RADIO_Init();
|
||||
#else
|
||||
/* 2/ Or implement RBI_Init here */
|
||||
int32_t retcode = 0;
|
||||
/* USER CODE BEGIN RBI_Init_2 */
|
||||
#warning user to provide its board code or to call his board driver functions
|
||||
/* USER CODE END RBI_Init_2 */
|
||||
return retcode;
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
}
|
||||
|
||||
int32_t RBI_DeInit(void)
|
||||
{
|
||||
/* USER CODE BEGIN RBI_DeInit_1 */
|
||||
|
||||
/* USER CODE END RBI_DeInit_1 */
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
/* Important note: BSP code is board dependent
|
||||
* STM32WL_Nucleo code can be found
|
||||
* either in STM32CubeWL package under Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* or at https://github.com/STMicroelectronics/STM32CubeWL/tree/main/Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* 1/ For User boards, the BSP/STM32WLxx_Nucleo/ directory can be copied and replaced in the project. The copy must then be updated depending:
|
||||
* on board RF switch configuration (pin control, number of port etc)
|
||||
* on TCXO configuration
|
||||
* on DC/DC configuration
|
||||
* on maximum output power that the board can deliver*/
|
||||
return BSP_RADIO_DeInit();
|
||||
#else
|
||||
/* 2/ Or implement RBI_DeInit here */
|
||||
int32_t retcode = 0;
|
||||
/* USER CODE BEGIN RBI_DeInit_2 */
|
||||
#warning user to provide its board code or to call his board driver functions
|
||||
/* USER CODE END RBI_DeInit_2 */
|
||||
return retcode;
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
}
|
||||
|
||||
int32_t RBI_ConfigRFSwitch(RBI_Switch_TypeDef Config)
|
||||
{
|
||||
/* USER CODE BEGIN RBI_ConfigRFSwitch_1 */
|
||||
|
||||
/* USER CODE END RBI_ConfigRFSwitch_1 */
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
|
||||
/* Important note: BSP code is board dependent
|
||||
* STM32WL_Nucleo code can be found
|
||||
* either in STM32CubeWL package under Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* or at https://github.com/STMicroelectronics/STM32CubeWL/tree/main/Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* 1/ For User boards, the BSP/STM32WLxx_Nucleo/ directory can be copied and replaced in the project. The copy must then be updated depending:
|
||||
* on board RF switch configuration (pin control, number of port etc)
|
||||
* on TCXO configuration
|
||||
* on DC/DC configuration
|
||||
* on maximum output power that the board can deliver*/
|
||||
return BSP_RADIO_ConfigRFSwitch((BSP_RADIO_Switch_TypeDef) Config);
|
||||
#else
|
||||
/* 2/ Or implement RBI_ConfigRFSwitch here */
|
||||
int32_t retcode = 0;
|
||||
/* USER CODE BEGIN RBI_ConfigRFSwitch_2 */
|
||||
#warning user to provide its board code or to call his board driver functions
|
||||
/* USER CODE END RBI_ConfigRFSwitch_2 */
|
||||
return retcode;
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
}
|
||||
|
||||
int32_t RBI_GetTxConfig(void)
|
||||
{
|
||||
/* USER CODE BEGIN RBI_GetTxConfig_1 */
|
||||
|
||||
/* USER CODE END RBI_GetTxConfig_1 */
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
/* Important note: BSP code is board dependent
|
||||
* STM32WL_Nucleo code can be found
|
||||
* either in STM32CubeWL package under Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* or at https://github.com/STMicroelectronics/STM32CubeWL/tree/main/Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* 1/ For User boards, the BSP/STM32WLxx_Nucleo/ directory can be copied and replaced in the project. The copy must then be updated depending:
|
||||
* on board RF switch configuration (pin control, number of port etc)
|
||||
* on TCXO configuration
|
||||
* on DC/DC configuration
|
||||
* on maximum output power that the board can deliver*/
|
||||
return BSP_RADIO_GetTxConfig();
|
||||
#else
|
||||
/* 2/ Or implement RBI_GetTxConfig here */
|
||||
int32_t retcode = RBI_CONF_RFO;
|
||||
/* USER CODE BEGIN RBI_GetTxConfig_2 */
|
||||
#warning user to provide its board code or to call his board driver functions
|
||||
/* USER CODE END RBI_GetTxConfig_2 */
|
||||
return retcode;
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
}
|
||||
|
||||
int32_t RBI_IsTCXO(void)
|
||||
{
|
||||
/* USER CODE BEGIN RBI_IsTCXO_1 */
|
||||
|
||||
/* USER CODE END RBI_IsTCXO_1 */
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
/* Important note: BSP code is board dependent
|
||||
* STM32WL_Nucleo code can be found
|
||||
* either in STM32CubeWL package under Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* or at https://github.com/STMicroelectronics/STM32CubeWL/tree/main/Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* 1/ For User boards, the BSP/STM32WLxx_Nucleo/ directory can be copied and replaced in the project. The copy must then be updated depending:
|
||||
* on board RF switch configuration (pin control, number of port etc)
|
||||
* on TCXO configuration
|
||||
* on DC/DC configuration
|
||||
* on maximum output power that the board can deliver*/
|
||||
return BSP_RADIO_IsTCXO();
|
||||
#else
|
||||
/* 2/ Or implement RBI_IsTCXO here */
|
||||
int32_t retcode = IS_TCXO_SUPPORTED;
|
||||
/* USER CODE BEGIN RBI_IsTCXO_2 */
|
||||
#warning user to provide its board code or to call his board driver functions
|
||||
/* USER CODE END RBI_IsTCXO_2 */
|
||||
return retcode;
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
}
|
||||
|
||||
int32_t RBI_IsDCDC(void)
|
||||
{
|
||||
/* USER CODE BEGIN RBI_IsDCDC_1 */
|
||||
|
||||
/* USER CODE END RBI_IsDCDC_1 */
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
/* Important note: BSP code is board dependent
|
||||
* STM32WL_Nucleo code can be found
|
||||
* either in STM32CubeWL package under Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* or at https://github.com/STMicroelectronics/STM32CubeWL/tree/main/Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* 1/ For User boards, the BSP/STM32WLxx_Nucleo/ directory can be copied and replaced in the project. The copy must then be updated depending:
|
||||
* on board RF switch configuration (pin control, number of port etc)
|
||||
* on TCXO configuration
|
||||
* on DC/DC configuration
|
||||
* on maximum output power that the board can deliver*/
|
||||
return BSP_RADIO_IsDCDC();
|
||||
#else
|
||||
/* 2/ Or implement RBI_IsDCDC here */
|
||||
int32_t retcode = IS_DCDC_SUPPORTED;
|
||||
/* USER CODE BEGIN RBI_IsDCDC_2 */
|
||||
#warning user to provide its board code or to call his board driver functions
|
||||
/* USER CODE END RBI_IsDCDC_2 */
|
||||
return retcode;
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
}
|
||||
|
||||
int32_t RBI_GetRFOMaxPowerConfig(RBI_RFOMaxPowerConfig_TypeDef Config)
|
||||
{
|
||||
/* USER CODE BEGIN RBI_GetRFOMaxPowerConfig_1 */
|
||||
|
||||
/* USER CODE END RBI_GetRFOMaxPowerConfig_1 */
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
/* Important note: BSP code is board dependent
|
||||
* STM32WL_Nucleo code can be found
|
||||
* either in STM32CubeWL package under Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* or at https://github.com/STMicroelectronics/STM32CubeWL/tree/main/Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* 1/ For User boards, the BSP/STM32WLxx_Nucleo/ directory can be copied and replaced in the project. The copy must then be updated depending:
|
||||
* on board RF switch configuration (pin control, number of port etc)
|
||||
* on TCXO configuration
|
||||
* on DC/DC configuration
|
||||
* on maximum output power that the board can deliver*/
|
||||
return BSP_RADIO_GetRFOMaxPowerConfig((BSP_RADIO_RFOMaxPowerConfig_TypeDef) Config);
|
||||
#else
|
||||
/* 2/ Or implement RBI_RBI_GetRFOMaxPowerConfig here */
|
||||
int32_t ret = 0;
|
||||
/* USER CODE BEGIN RBI_GetRFOMaxPowerConfig_2 */
|
||||
#warning user to provide its board code or to call his board driver functions
|
||||
if (Config == RBI_RFO_LP_MAXPOWER)
|
||||
{
|
||||
ret = 15; /*dBm*/
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = 22; /*dBm*/
|
||||
}
|
||||
/* USER CODE END RBI_GetRFOMaxPowerConfig_2 */
|
||||
return ret;
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
}
|
||||
/* USER CODE BEGIN EF */
|
||||
|
||||
/* USER CODE END EF */
|
||||
|
||||
/* Private Functions Definition -----------------------------------------------*/
|
||||
/* USER CODE BEGIN PrFD */
|
||||
|
||||
/* USER CODE END PrFD */
|
|
@ -0,0 +1,223 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file radio_board_if.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for Radio interface configuration
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef RADIO_BOARD_IF_H
|
||||
#define RADIO_BOARD_IF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "platform.h"
|
||||
/* USER CODE BEGIN include */
|
||||
|
||||
/* USER CODE END include */
|
||||
|
||||
/* Exported defines ----------------------------------------------------------*/
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
/* code generated by STM32CubeMX does not support BSP */
|
||||
/* In order to use BSP driver, add the correspondent files in the IDE workspace */
|
||||
/* and define USE_BSP_DRIVER in the preprocessor definitions or in platform.h */
|
||||
#define RBI_CONF_RFO_LP_HP RADIO_CONF_RFO_LP_HP
|
||||
#define RBI_CONF_RFO_LP RADIO_CONF_RFO_LP
|
||||
#define RBI_CONF_RFO_HP RADIO_CONF_RFO_HP
|
||||
#else
|
||||
/* USER CODE BEGIN Board Definition */
|
||||
|
||||
/* USER CODE END Board Definition */
|
||||
#define RBI_CONF_RFO_LP_HP 0
|
||||
#define RBI_CONF_RFO_LP 1
|
||||
#define RBI_CONF_RFO_HP 2
|
||||
/* USER CODE BEGIN Board Definition_2 */
|
||||
|
||||
/* USER CODE END Board Definition_2 */
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
/* code generated by STM32CubeMX does not support BSP */
|
||||
/* In order to use BSP driver, add the correspondent files in the IDE workspace */
|
||||
/* and define USE_BSP_DRIVER in the preprocessor definitions or in platform.h */
|
||||
|
||||
#else
|
||||
/* USER CODE BEGIN Exported Parameters */
|
||||
|
||||
/* USER CODE END Exported Parameters */
|
||||
/* Indicates the type of switch between the ones proposed by CONFIG Constants
|
||||
*/
|
||||
#define RBI_CONF_RFO RBI_CONF_RFO_LP_HP
|
||||
|
||||
/* Indicates whether or not TCXO is supported by the board
|
||||
* 0: TCXO not supported
|
||||
* 1: TCXO supported
|
||||
*/
|
||||
#define IS_TCXO_SUPPORTED 1U
|
||||
|
||||
/* Indicates whether or not DCDC is supported by the board
|
||||
* 0: DCDC not supported
|
||||
* 1: DCDC supported
|
||||
*/
|
||||
#define IS_DCDC_SUPPORTED 1U
|
||||
|
||||
/* USER CODE BEGIN Exported Parameters_2 */
|
||||
|
||||
/* USER CODE END Exported Parameters_2 */
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
/* code generated by STM32CubeMX does not support BSP */
|
||||
/* In order to use BSP driver, add the correspondent files in the IDE workspace */
|
||||
/* and define USE_BSP_DRIVER in the preprocessor definitions or in platform.h */
|
||||
|
||||
#else
|
||||
/* USER CODE BEGIN Exported PinMapping */
|
||||
#warning user to provide its board definitions pins
|
||||
/* USER CODE END Exported PinMapping */
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
|
||||
/* USER CODE BEGIN ED */
|
||||
|
||||
/* USER CODE END ED */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
/* code generated by STM32CubeMX does not support BSP */
|
||||
/* In order to use BSP driver, add the correspondent files in the IDE workspace */
|
||||
/* and define USE_BSP_DRIVER in the preprocessor definitions or in platform.h */
|
||||
typedef enum
|
||||
{
|
||||
RBI_SWITCH_OFF = RADIO_SWITCH_OFF,
|
||||
RBI_SWITCH_RX = RADIO_SWITCH_RX,
|
||||
RBI_SWITCH_RFO_LP = RADIO_SWITCH_RFO_LP,
|
||||
RBI_SWITCH_RFO_HP = RADIO_SWITCH_RFO_HP,
|
||||
} RBI_Switch_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
RBI_RFO_LP_MAXPOWER = RADIO_RFO_LP_MAXPOWER,
|
||||
RBI_RFO_HP_MAXPOWER = RADIO_RFO_HP_MAXPOWER,
|
||||
} RBI_RFOMaxPowerConfig_TypeDef;
|
||||
|
||||
#else
|
||||
/* USER CODE BEGIN Exported Types */
|
||||
|
||||
/* USER CODE END Exported Types */
|
||||
typedef enum
|
||||
{
|
||||
RBI_SWITCH_OFF = 0,
|
||||
RBI_SWITCH_RX = 1,
|
||||
RBI_SWITCH_RFO_LP = 2,
|
||||
RBI_SWITCH_RFO_HP = 3,
|
||||
} RBI_Switch_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
RBI_RFO_LP_MAXPOWER = 0,
|
||||
RBI_RFO_HP_MAXPOWER = 1,
|
||||
} RBI_RFOMaxPowerConfig_TypeDef;
|
||||
/* USER CODE BEGIN Exported Types_2 */
|
||||
|
||||
/* USER CODE END Exported Types_2 */
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
/**
|
||||
* @brief Init Radio Switch
|
||||
* @return BSP status
|
||||
*/
|
||||
int32_t RBI_Init(void);
|
||||
|
||||
/**
|
||||
* @brief DeInit Radio Switch
|
||||
* @return BSP status
|
||||
*/
|
||||
int32_t RBI_DeInit(void);
|
||||
|
||||
/**
|
||||
* @brief Configure Radio Switch.
|
||||
* @param Config: Specifies the Radio RF switch path to be set.
|
||||
* This parameter can be one of following parameters:
|
||||
* @arg RADIO_SWITCH_OFF
|
||||
* @arg RADIO_SWITCH_RX
|
||||
* @arg RADIO_SWITCH_RFO_LP
|
||||
* @arg RADIO_SWITCH_RFO_HP
|
||||
* @return BSP status
|
||||
*/
|
||||
int32_t RBI_ConfigRFSwitch(RBI_Switch_TypeDef Config);
|
||||
|
||||
/**
|
||||
* @brief Return Board Configuration
|
||||
* @retval RBI_CONF_RFO_LP_HP
|
||||
* @retval RBI_CONF_RFO_LP
|
||||
* @retval RBI_CONF_RFO_HP
|
||||
*/
|
||||
int32_t RBI_GetTxConfig(void);
|
||||
|
||||
/**
|
||||
* @brief Get If TCXO is to be present on board
|
||||
* @note never remove called by MW,
|
||||
* @retval return 1 if present, 0 if not present
|
||||
*/
|
||||
int32_t RBI_IsTCXO(void);
|
||||
|
||||
/**
|
||||
* @brief Get If DCDC is to be present on board
|
||||
* @note never remove called by MW,
|
||||
* @retval return 1 if present, 0 if not present
|
||||
*/
|
||||
int32_t RBI_IsDCDC(void);
|
||||
|
||||
/**
|
||||
* @brief Return RF Output Max Power Configuration of matching circuit
|
||||
* @note never remove called by MW,
|
||||
* @retval return Max Power configuration of matching circuit for Low Power or High Power mode in dBm
|
||||
*/
|
||||
int32_t RBI_GetRFOMaxPowerConfig(RBI_RFOMaxPowerConfig_TypeDef Config);
|
||||
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* RADIO_BOARD_IF_H */
|
|
@ -0,0 +1,150 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file radio_conf.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header of Radio configuration
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __RADIO_CONF_H__
|
||||
#define __RADIO_CONF_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "platform.h"
|
||||
#include "subghz.h"
|
||||
#include "stm32_mem.h" /* RADIO_MEMSET8 def in this file */
|
||||
#include "mw_log_conf.h" /* mw trace conf */
|
||||
#include "radio_board_if.h" /* low layer api (bsp) */
|
||||
#include "utilities_def.h" /* low layer api (bsp) */
|
||||
/* USER CODE BEGIN include */
|
||||
|
||||
/* USER CODE END include */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief drive value used anytime radio is NOT in TX low power mode
|
||||
* @note override the default configuration of radio_driver.c
|
||||
*/
|
||||
#define SMPS_DRIVE_SETTING_DEFAULT SMPS_DRV_40
|
||||
|
||||
/**
|
||||
* @brief drive value used anytime radio is in TX low power mode
|
||||
* TX low power mode is the worst case because the PA sinks from SMPS
|
||||
* while in high power mode, current is sunk directly from the battery
|
||||
* @note override the default configuration of radio_driver.c
|
||||
*/
|
||||
#define SMPS_DRIVE_SETTING_MAX SMPS_DRV_60
|
||||
|
||||
/**
|
||||
* @brief Provides the frequency of the chip running on the radio and the frequency step
|
||||
* @remark These defines are used for computing the frequency divider to set the RF frequency
|
||||
* @note override the default configuration of radio_driver.c
|
||||
*/
|
||||
#define XTAL_FREQ ( 32000000UL )
|
||||
|
||||
/**
|
||||
* @brief in XO mode, set internal capacitor (from 0x00 to 0x2F starting 11.2pF with 0.47pF steps)
|
||||
* @note override the default configuration of radio_driver.c
|
||||
*/
|
||||
#define XTAL_DEFAULT_CAP_VALUE ( 0x20UL )
|
||||
|
||||
/**
|
||||
* @brief voltage of vdd tcxo.
|
||||
* @note override the default configuration of radio_driver.c
|
||||
*/
|
||||
#define TCXO_CTRL_VOLTAGE TCXO_CTRL_1_7V
|
||||
|
||||
/**
|
||||
* @brief Radio maximum wakeup time (in ms)
|
||||
* @note override the default configuration of radio_driver.c
|
||||
*/
|
||||
#define RF_WAKEUP_TIME ( 1UL )
|
||||
|
||||
/**
|
||||
* @brief DCDC is enabled
|
||||
* @remark this define is only used if the DCDC is present on the board
|
||||
* @note override the default configuration of radio_driver.c
|
||||
*/
|
||||
#define DCDC_ENABLE ( 1UL )
|
||||
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
#ifndef CRITICAL_SECTION_BEGIN
|
||||
/**
|
||||
* @brief macro used to enter the critical section
|
||||
*/
|
||||
#define CRITICAL_SECTION_BEGIN( ) UTILS_ENTER_CRITICAL_SECTION( )
|
||||
#endif /* !CRITICAL_SECTION_BEGIN */
|
||||
#ifndef CRITICAL_SECTION_END
|
||||
/**
|
||||
* @brief macro used to exit the critical section
|
||||
*/
|
||||
#define CRITICAL_SECTION_END( ) UTILS_EXIT_CRITICAL_SECTION( )
|
||||
#endif /* !CRITICAL_SECTION_END */
|
||||
|
||||
/* Function mapping */
|
||||
/**
|
||||
* @brief SUBGHZ interface init to radio Middleware
|
||||
*/
|
||||
#define RADIO_INIT MX_SUBGHZ_Init
|
||||
|
||||
/**
|
||||
* @brief Delay interface to radio Middleware
|
||||
*/
|
||||
#define RADIO_DELAY_MS HAL_Delay
|
||||
|
||||
/**
|
||||
* @brief Memset utilities interface to radio Middleware
|
||||
*/
|
||||
#define RADIO_MEMSET8( dest, value, size ) UTIL_MEM_set_8( dest, value, size )
|
||||
|
||||
/**
|
||||
* @brief Memcpy utilities interface to radio Middleware
|
||||
*/
|
||||
#define RADIO_MEMCPY8( dest, src, size ) UTIL_MEM_cpy_8( dest, src, size )
|
||||
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __RADIO_CONF_H__*/
|
|
@ -0,0 +1,64 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file systime.h
|
||||
* @author MCD Application Team
|
||||
* @brief Map middleware systime
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __SYSTIME_H__
|
||||
#define __SYSTIME_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32_systime.h"
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__SYSTIME_H__*/
|
|
@ -0,0 +1,117 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file timer.h
|
||||
* @author MCD Application Team
|
||||
* @brief Wrapper to timer server
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TIMER_H__
|
||||
#define __TIMER_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32_timer.h"
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Max timer mask
|
||||
*/
|
||||
#define TIMERTIME_T_MAX ( ( uint32_t )~0 )
|
||||
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Timer value on 32 bits
|
||||
*/
|
||||
#define TimerTime_t UTIL_TIMER_Time_t
|
||||
|
||||
/**
|
||||
* @brief Timer object description
|
||||
*/
|
||||
#define TimerEvent_t UTIL_TIMER_Object_t
|
||||
|
||||
/**
|
||||
* @brief Create the timer object
|
||||
*/
|
||||
#define TimerInit(HANDLE, CB) do {\
|
||||
UTIL_TIMER_Create( HANDLE, TIMERTIME_T_MAX, UTIL_TIMER_ONESHOT, CB, NULL);\
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @brief update the period and start the timer
|
||||
*/
|
||||
#define TimerSetValue(HANDLE, TIMEOUT) do{ \
|
||||
UTIL_TIMER_SetPeriod(HANDLE, TIMEOUT);\
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @brief Start and adds the timer object to the list of timer events
|
||||
*/
|
||||
#define TimerStart(HANDLE) do {\
|
||||
UTIL_TIMER_Start(HANDLE);\
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @brief Stop and removes the timer object from the list of timer events
|
||||
*/
|
||||
#define TimerStop(HANDLE) do {\
|
||||
UTIL_TIMER_Stop(HANDLE);\
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @brief return the current time
|
||||
*/
|
||||
#define TimerGetCurrentTime UTIL_TIMER_GetCurrentTime
|
||||
|
||||
/**
|
||||
* @brief return the elapsed time
|
||||
*/
|
||||
#define TimerGetElapsedTime UTIL_TIMER_GetElapsedTime
|
||||
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __TIMER_H__*/
|
|
@ -1,36 +1,149 @@
|
|||
#MicroXplorer Configuration settings - do not modify
|
||||
ADC.IPParameters=NbrOfConversion,SelectedChannel
|
||||
ADC.NbrOfConversion=1
|
||||
ADC.SelectedChannel=ADC_CHANNEL_TEMPSENSOR|ADC_CHANNEL_VREFINT|ADC_CHANNEL_VBAT
|
||||
CAD.formats=
|
||||
CAD.pinconfig=
|
||||
CAD.provider=
|
||||
Dma.LPUART1_RX.0.Direction=DMA_PERIPH_TO_MEMORY
|
||||
Dma.LPUART1_RX.0.EventEnable=DISABLE
|
||||
Dma.LPUART1_RX.0.Instance=DMA1_Channel1
|
||||
Dma.LPUART1_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||
Dma.LPUART1_RX.0.MemInc=DMA_MINC_ENABLE
|
||||
Dma.LPUART1_RX.0.Mode=DMA_NORMAL
|
||||
Dma.LPUART1_RX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||
Dma.LPUART1_RX.0.PeriphInc=DMA_PINC_DISABLE
|
||||
Dma.LPUART1_RX.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING
|
||||
Dma.LPUART1_RX.0.Priority=DMA_PRIORITY_LOW
|
||||
Dma.LPUART1_RX.0.RequestNumber=1
|
||||
Dma.LPUART1_RX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber
|
||||
Dma.LPUART1_RX.0.SignalID=NONE
|
||||
Dma.LPUART1_RX.0.SyncEnable=DISABLE
|
||||
Dma.LPUART1_RX.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT
|
||||
Dma.LPUART1_RX.0.SyncRequestNumber=1
|
||||
Dma.LPUART1_RX.0.SyncSignalID=NONE
|
||||
Dma.LPUART1_TX.1.Direction=DMA_MEMORY_TO_PERIPH
|
||||
Dma.LPUART1_TX.1.EventEnable=DISABLE
|
||||
Dma.LPUART1_TX.1.Instance=DMA1_Channel2
|
||||
Dma.LPUART1_TX.1.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||
Dma.LPUART1_TX.1.MemInc=DMA_MINC_ENABLE
|
||||
Dma.LPUART1_TX.1.Mode=DMA_NORMAL
|
||||
Dma.LPUART1_TX.1.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||
Dma.LPUART1_TX.1.PeriphInc=DMA_PINC_DISABLE
|
||||
Dma.LPUART1_TX.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING
|
||||
Dma.LPUART1_TX.1.Priority=DMA_PRIORITY_LOW
|
||||
Dma.LPUART1_TX.1.RequestNumber=1
|
||||
Dma.LPUART1_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber
|
||||
Dma.LPUART1_TX.1.SignalID=NONE
|
||||
Dma.LPUART1_TX.1.SyncEnable=DISABLE
|
||||
Dma.LPUART1_TX.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT
|
||||
Dma.LPUART1_TX.1.SyncRequestNumber=1
|
||||
Dma.LPUART1_TX.1.SyncSignalID=NONE
|
||||
Dma.Request0=LPUART1_RX
|
||||
Dma.Request1=LPUART1_TX
|
||||
Dma.RequestsNb=2
|
||||
File.Version=6
|
||||
GPIO.groupedBy=Group By Peripherals
|
||||
KeepUserPlacement=false
|
||||
LORAWAN.Activate_RADIO_BOARD_INTERFACE=Bsp
|
||||
LORAWAN.IPParameters=SUBGHZ_APPLICATION,USE_RTC,USE_UART,USE_LPM,LORAWAN_PUBLIC_NETWORK,REGION_EU868,REGION_US915,REGION_CN470,LORAMAC_SPECIFICATION_VERSION,Activate_RADIO_BOARD_INTERFACE,USE_ADC
|
||||
LORAWAN.LORAMAC_SPECIFICATION_VERSION=0x01000400
|
||||
LORAWAN.LORAWAN_PUBLIC_NETWORK=false
|
||||
LORAWAN.REGION_CN470=true
|
||||
LORAWAN.REGION_EU868=false
|
||||
LORAWAN.REGION_US915=false
|
||||
LORAWAN.SUBGHZ_APPLICATION=LORA_USER_APPLICATION
|
||||
LORAWAN.USE_ADC=true
|
||||
LORAWAN.USE_LPM=true
|
||||
LORAWAN.USE_RTC=true
|
||||
LORAWAN.USE_UART=true
|
||||
LPUART1.BaudRate=115200
|
||||
LPUART1.FIFOMode=UART_FIFOMODE_ENABLE
|
||||
LPUART1.IPParameters=BaudRate,FIFOMode,TXFIFOThreshold,RXFIFOThreshold
|
||||
LPUART1.RXFIFOThreshold=UART_RXFIFO_THRESHOLD_1_4
|
||||
LPUART1.TXFIFOThreshold=UART_TXFIFO_THRESHOLD_1_4
|
||||
LoRaWAN.BSP.number=3
|
||||
LoRaWAN0.BSP.STBoard=false
|
||||
LoRaWAN0.BSP.api=Unknown
|
||||
LoRaWAN0.BSP.component=
|
||||
LoRaWAN0.BSP.condition=\!SEM_LORA_USER_APPLICATION | SEM_LORA_USE_ADC
|
||||
LoRaWAN0.BSP.instance=ADC
|
||||
LoRaWAN0.BSP.ip=ADC
|
||||
LoRaWAN0.BSP.mode=Vrefint Channel
|
||||
LoRaWAN0.BSP.name=ADC
|
||||
LoRaWAN0.BSP.semaphore=
|
||||
LoRaWAN0.BSP.solution=ADC
|
||||
LoRaWAN1.BSP.STBoard=false
|
||||
LoRaWAN1.BSP.api=Unknown
|
||||
LoRaWAN1.BSP.component=
|
||||
LoRaWAN1.BSP.condition=\!SEM_LORA_USER_APPLICATION | SEM_LORA_USE_RTC
|
||||
LoRaWAN1.BSP.instance=RTC
|
||||
LoRaWAN1.BSP.ip=RTC
|
||||
LoRaWAN1.BSP.mode=RTC Enabled
|
||||
LoRaWAN1.BSP.name=RTC
|
||||
LoRaWAN1.BSP.semaphore=
|
||||
LoRaWAN1.BSP.solution=RTC
|
||||
LoRaWAN2.BSP.STBoard=false
|
||||
LoRaWAN2.BSP.api=Unknown
|
||||
LoRaWAN2.BSP.component=
|
||||
LoRaWAN2.BSP.condition=SEM_LORA_END_NODE | SEM_LORA_USE_UART
|
||||
LoRaWAN2.BSP.instance=LPUART1
|
||||
LoRaWAN2.BSP.ip=(LPU|US)ART
|
||||
LoRaWAN2.BSP.mode=Asynchronous
|
||||
LoRaWAN2.BSP.name=USART
|
||||
LoRaWAN2.BSP.semaphore=
|
||||
LoRaWAN2.BSP.solution=LPUART1
|
||||
Mcu.CPN=STM32WLE5CBU6
|
||||
Mcu.Family=STM32WL
|
||||
Mcu.IP0=DEBUG
|
||||
Mcu.IP1=NVIC
|
||||
Mcu.IP2=RCC
|
||||
Mcu.IP3=RTC
|
||||
Mcu.IP4=SYS
|
||||
Mcu.IPNb=5
|
||||
Mcu.IP0=ADC
|
||||
Mcu.IP1=ADV_TRACE
|
||||
Mcu.IP10=SEQUENCER
|
||||
Mcu.IP11=SUBGHZ
|
||||
Mcu.IP12=SYS
|
||||
Mcu.IP13=TIMER
|
||||
Mcu.IP14=TINY_LPM
|
||||
Mcu.IP2=DEBUG
|
||||
Mcu.IP3=DMA
|
||||
Mcu.IP4=LORAWAN
|
||||
Mcu.IP5=LPUART1
|
||||
Mcu.IP6=MISC
|
||||
Mcu.IP7=NVIC
|
||||
Mcu.IP8=RCC
|
||||
Mcu.IP9=RTC
|
||||
Mcu.IPNb=15
|
||||
Mcu.Name=STM32WLE5CBUx
|
||||
Mcu.Package=UFQFPN48
|
||||
Mcu.Pin0=OSC_IN
|
||||
Mcu.Pin1=OSC_OUT
|
||||
Mcu.Pin2=PA13
|
||||
Mcu.Pin3=PC14-OSC32_IN
|
||||
Mcu.Pin4=PC15-OSC32_OUT
|
||||
Mcu.Pin5=PA14
|
||||
Mcu.Pin6=VP_RTC_VS_RTC_Activate
|
||||
Mcu.Pin7=VP_RTC_VS_RTC_Calendar
|
||||
Mcu.Pin8=VP_SYS_VS_Systick
|
||||
Mcu.PinsNb=9
|
||||
Mcu.Pin0=PA2
|
||||
Mcu.Pin1=PA3
|
||||
Mcu.Pin10=VP_ADC_Vbat_Input
|
||||
Mcu.Pin11=VP_ADV_TRACE_VS_ADV_TRACE
|
||||
Mcu.Pin12=VP_LORAWAN_VS_LoRaWAN
|
||||
Mcu.Pin13=VP_MISC_VS_MISC
|
||||
Mcu.Pin14=VP_RTC_VS_RTC_Activate
|
||||
Mcu.Pin15=VP_RTC_VS_RTC_Calendar
|
||||
Mcu.Pin16=VP_RTC_VS_RTC_Alarm_A_Intern
|
||||
Mcu.Pin17=VP_SEQUENCER_VS_SEQUENCER
|
||||
Mcu.Pin18=VP_SUBGHZ_VS_SUBGHZ
|
||||
Mcu.Pin19=VP_SYS_VS_Systick
|
||||
Mcu.Pin2=OSC_IN
|
||||
Mcu.Pin20=VP_TIMER_VS_TIMER
|
||||
Mcu.Pin21=VP_TINY_LPM_VS_TINY_LPM
|
||||
Mcu.Pin3=OSC_OUT
|
||||
Mcu.Pin4=PA13
|
||||
Mcu.Pin5=PC14-OSC32_IN
|
||||
Mcu.Pin6=PC15-OSC32_OUT
|
||||
Mcu.Pin7=PA14
|
||||
Mcu.Pin8=VP_ADC_TempSens_Input
|
||||
Mcu.Pin9=VP_ADC_Vref_Input
|
||||
Mcu.PinsNb=22
|
||||
Mcu.ThirdPartyNb=0
|
||||
Mcu.UserConstants=
|
||||
Mcu.UserConstants=RTC_PREDIV_A,((1<<(15-RTC_N_PREDIV_S))-1);RTC_N_PREDIV_S,10;RTC_PREDIV_S,((1<<RTC_N_PREDIV_S)-1)
|
||||
Mcu.UserName=STM32WLE5CBUx
|
||||
MxCube.Version=6.8.1
|
||||
MxDb.Version=DB.6.0.81
|
||||
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.DMA1_Channel1_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true
|
||||
NVIC.DMA1_Channel2_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true
|
||||
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.ForceEnableDMAVector=true
|
||||
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
|
@ -49,6 +162,12 @@ PA13.Mode=Serial_Wire
|
|||
PA13.Signal=DEBUG_JTMS-SWDIO
|
||||
PA14.Mode=Serial_Wire
|
||||
PA14.Signal=DEBUG_JTCK-SWCLK
|
||||
PA2.Locked=true
|
||||
PA2.Mode=Asynchronous
|
||||
PA2.Signal=LPUART1_TX
|
||||
PA3.Locked=true
|
||||
PA3.Mode=Asynchronous
|
||||
PA3.Signal=LPUART1_RX
|
||||
PC14-OSC32_IN.Mode=LSE-External-Oscillator
|
||||
PC14-OSC32_IN.Signal=RCC_OSC32_IN
|
||||
PC15-OSC32_OUT.Mode=LSE-External-Oscillator
|
||||
|
@ -89,7 +208,7 @@ ProjectManager.StackSize=0x400
|
|||
ProjectManager.TargetToolchain=Makefile
|
||||
ProjectManager.ToolChainLocation=
|
||||
ProjectManager.UnderRoot=false
|
||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_RTC_Init-RTC-false-HAL-true
|
||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_RTC_Init-RTC-false-HAL-true,5-MX_ADC_Init-ADC-true-HAL-false,6-MX_LPUART1_UART_Init-LPUART1-true-HAL-false,7-MX_SUBGHZ_Init-SUBGHZ-true-HAL-false,8-MX_LoRaWAN_Init-LORAWAN-false-HAL-false
|
||||
RCC.AHBFreq_Value=48000000
|
||||
RCC.APB1Freq_Value=48000000
|
||||
RCC.APB1TimFreq_Value=48000000
|
||||
|
@ -136,12 +255,37 @@ RCC.USART1Freq_Value=48000000
|
|||
RCC.USART2Freq_Value=48000000
|
||||
RCC.VCOInputFreq_Value=8000000
|
||||
RCC.VCOOutputFreq_Value=144000000
|
||||
RTC.BinMode=RTC_BINARY_NONE
|
||||
RTC.IPParameters=BinMode
|
||||
RTC.Alarm-Alarm\ A=RTC_ALARM_A
|
||||
RTC.AsynchPrediv=RTC_PREDIV_A
|
||||
RTC.BinMode=RTC_BINARY_ONLY
|
||||
RTC.BinaryAutoClr_A-Alarm\ A=RTC_ALARMSUBSECONDBIN_AUTOCLR_NO
|
||||
RTC.IPParameters=BinMode,AsynchPrediv,Alarm-Alarm A,BinaryAutoClr_A-Alarm A
|
||||
VP_ADC_TempSens_Input.Mode=IN-TempSens
|
||||
VP_ADC_TempSens_Input.Signal=ADC_TempSens_Input
|
||||
VP_ADC_Vbat_Input.Mode=IN-Vbat
|
||||
VP_ADC_Vbat_Input.Signal=ADC_Vbat_Input
|
||||
VP_ADC_Vref_Input.Mode=IN-Vrefint
|
||||
VP_ADC_Vref_Input.Signal=ADC_Vref_Input
|
||||
VP_ADV_TRACE_VS_ADV_TRACE.Mode=ADV_TRACE_Enabled
|
||||
VP_ADV_TRACE_VS_ADV_TRACE.Signal=ADV_TRACE_VS_ADV_TRACE
|
||||
VP_LORAWAN_VS_LoRaWAN.Mode=LoRaWAN_Enabled
|
||||
VP_LORAWAN_VS_LoRaWAN.Signal=LORAWAN_VS_LoRaWAN
|
||||
VP_MISC_VS_MISC.Mode=MISC_Enabled
|
||||
VP_MISC_VS_MISC.Signal=MISC_VS_MISC
|
||||
VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled
|
||||
VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate
|
||||
VP_RTC_VS_RTC_Alarm_A_Intern.Mode=Alarm A
|
||||
VP_RTC_VS_RTC_Alarm_A_Intern.Signal=RTC_VS_RTC_Alarm_A_Intern
|
||||
VP_RTC_VS_RTC_Calendar.Mode=RTC_Calendar
|
||||
VP_RTC_VS_RTC_Calendar.Signal=RTC_VS_RTC_Calendar
|
||||
VP_SEQUENCER_VS_SEQUENCER.Mode=SEQUENCER_Enabled
|
||||
VP_SEQUENCER_VS_SEQUENCER.Signal=SEQUENCER_VS_SEQUENCER
|
||||
VP_SUBGHZ_VS_SUBGHZ.Mode=SUBGHZ_Activate
|
||||
VP_SUBGHZ_VS_SUBGHZ.Signal=SUBGHZ_VS_SUBGHZ
|
||||
VP_SYS_VS_Systick.Mode=SysTick
|
||||
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
|
||||
VP_TIMER_VS_TIMER.Mode=TIMER_Enabled
|
||||
VP_TIMER_VS_TIMER.Signal=TIMER_VS_TIMER
|
||||
VP_TINY_LPM_VS_TINY_LPM.Mode=TINY_LPM_Enabled
|
||||
VP_TINY_LPM_VS_TINY_LPM.Signal=TINY_LPM_VS_TINY_LPM
|
||||
board=custom
|
||||
|
|
|
@ -1,424 +1,424 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file startup_stm32wle5xx.s
|
||||
* @author MCD Application Team
|
||||
* @brief STM32WLE5xx devices vector table for GCC toolchain.
|
||||
* This module performs:
|
||||
* - Set the initial SP
|
||||
* - Set the initial PC == Reset_Handler,
|
||||
* - Set the vector table entries with the exceptions ISR address,
|
||||
* - Branches to main in the C library (which eventually
|
||||
* calls main()).
|
||||
* After Reset the Cortex-M4 processor is in Thread mode,
|
||||
* priority is Privileged, and the Stack is set to Main.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2020-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
.syntax unified
|
||||
.cpu cortex-m4
|
||||
.fpu softvfp
|
||||
.thumb
|
||||
|
||||
.global g_pfnVectors
|
||||
.global Default_Handler
|
||||
|
||||
/* start address for the initialization values of the .data section.
|
||||
defined in linker script */
|
||||
.word _sidata
|
||||
/* start address for the .data section. defined in linker script */
|
||||
.word _sdata
|
||||
/* end address for the .data section. defined in linker script */
|
||||
.word _edata
|
||||
/* start address for the .bss section. defined in linker script */
|
||||
.word _sbss
|
||||
/* end address for the .bss section. defined in linker script */
|
||||
.word _ebss
|
||||
|
||||
/**
|
||||
* @brief This is the code that gets called when the processor first
|
||||
* starts execution following a reset event. Only the absolutely
|
||||
* necessary set is performed, after which the application
|
||||
* supplied main() routine is called.
|
||||
* @param None
|
||||
* @retval : None
|
||||
*/
|
||||
|
||||
.section .text.Reset_Handler
|
||||
.weak Reset_Handler
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
ldr r0, =_estack
|
||||
mov sp, r0 /* set stack pointer */
|
||||
|
||||
/* Call the clock system initialization function.*/
|
||||
bl SystemInit
|
||||
|
||||
/* Copy the data segment initializers from flash to SRAM */
|
||||
ldr r0, =_sdata
|
||||
ldr r1, =_edata
|
||||
ldr r2, =_sidata
|
||||
movs r3, #0
|
||||
b LoopCopyDataInit
|
||||
|
||||
CopyDataInit:
|
||||
ldr r4, [r2, r3]
|
||||
str r4, [r0, r3]
|
||||
adds r3, r3, #4
|
||||
|
||||
LoopCopyDataInit:
|
||||
adds r4, r0, r3
|
||||
cmp r4, r1
|
||||
bcc CopyDataInit
|
||||
|
||||
/* Zero fill the bss segment. */
|
||||
ldr r2, =_sbss
|
||||
ldr r4, =_ebss
|
||||
movs r3, #0
|
||||
b LoopFillZerobss
|
||||
|
||||
FillZerobss:
|
||||
str r3, [r2]
|
||||
adds r2, r2, #4
|
||||
|
||||
LoopFillZerobss:
|
||||
cmp r2, r4
|
||||
bcc FillZerobss
|
||||
|
||||
/* Call static constructors */
|
||||
bl __libc_init_array
|
||||
/* Call the application's entry point.*/
|
||||
bl main
|
||||
|
||||
LoopForever:
|
||||
b LoopForever
|
||||
|
||||
.size Reset_Handler, .-Reset_Handler
|
||||
|
||||
/**
|
||||
* @brief This is the code that gets called when the processor receives an
|
||||
* unexpected interrupt. This simply enters an infinite loop, preserving
|
||||
* the system state for examination by a debugger.
|
||||
*
|
||||
* @param None
|
||||
* @retval : None
|
||||
*/
|
||||
.section .text.Default_Handler,"ax",%progbits
|
||||
Default_Handler:
|
||||
Infinite_Loop:
|
||||
b Infinite_Loop
|
||||
.size Default_Handler, .-Default_Handler
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* The STM32WLE5xx vector table. Note that the proper constructs
|
||||
* must be placed on this to ensure that it ends up at physical address
|
||||
* 0x0000.0000.
|
||||
*
|
||||
******************************************************************************/
|
||||
.section .isr_vector,"a",%progbits
|
||||
.type g_pfnVectors, %object
|
||||
.size g_pfnVectors, .-g_pfnVectors
|
||||
|
||||
g_pfnVectors:
|
||||
.word _estack
|
||||
.word Reset_Handler
|
||||
.word NMI_Handler
|
||||
.word HardFault_Handler
|
||||
.word MemManage_Handler
|
||||
.word BusFault_Handler
|
||||
.word UsageFault_Handler
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word SVC_Handler
|
||||
.word DebugMon_Handler
|
||||
.word 0
|
||||
.word PendSV_Handler
|
||||
.word SysTick_Handler
|
||||
.word WWDG_IRQHandler /* Window Watchdog interrupt */
|
||||
.word PVD_PVM_IRQHandler /* PVD and PVM interrupt through EXTI */
|
||||
.word TAMP_STAMP_LSECSS_SSRU_IRQHandler /* RTC Tamper, RTC TimeStamp, LSECSS and RTC SSRU int.*/
|
||||
.word RTC_WKUP_IRQHandler /* RTC wakeup interrupt through EXTI[19] */
|
||||
.word FLASH_IRQHandler /* Flash memory global interrupt and Flash memory ECC */
|
||||
.word RCC_IRQHandler /* RCC global interrupt */
|
||||
.word EXTI0_IRQHandler /* EXTI line 0 interrupt */
|
||||
.word EXTI1_IRQHandler /* EXTI line 1 interrupt */
|
||||
.word EXTI2_IRQHandler /* EXTI line 2 interrupt */
|
||||
.word EXTI3_IRQHandler /* EXTI line 3 interrupt */
|
||||
.word EXTI4_IRQHandler /* EXTI line 4 interrupt */
|
||||
.word DMA1_Channel1_IRQHandler /* DMA1 channel 1 interrupt */
|
||||
.word DMA1_Channel2_IRQHandler /* DMA1 channel 2 interrupt */
|
||||
.word DMA1_Channel3_IRQHandler /* DMA1 channel 3 interrupt */
|
||||
.word DMA1_Channel4_IRQHandler /* DMA1 channel 4 interrupt */
|
||||
.word DMA1_Channel5_IRQHandler /* DMA1 channel 5 interrupt */
|
||||
.word DMA1_Channel6_IRQHandler /* DMA1 channel 6 interrupt */
|
||||
.word DMA1_Channel7_IRQHandler /* DMA1 channel 7 interrupt */
|
||||
.word ADC_IRQHandler /* ADC interrupt */
|
||||
.word DAC_IRQHandler /* DAC interrupt */
|
||||
.word 0 /* Reserved */
|
||||
.word COMP_IRQHandler /* COMP1 and COMP2 interrupt through EXTI */
|
||||
.word EXTI9_5_IRQHandler /* EXTI line 9_5 interrupt */
|
||||
.word TIM1_BRK_IRQHandler /* Timer 1 break interrupt */
|
||||
.word TIM1_UP_IRQHandler /* Timer 1 Update */
|
||||
.word TIM1_TRG_COM_IRQHandler /* Timer 1 trigger and communication */
|
||||
.word TIM1_CC_IRQHandler /* Timer 1 capture compare interrupt */
|
||||
.word TIM2_IRQHandler /* TIM2 global interrupt */
|
||||
.word TIM16_IRQHandler /* Timer 16 global interrupt */
|
||||
.word TIM17_IRQHandler /* Timer 17 global interrupt */
|
||||
.word I2C1_EV_IRQHandler /* I2C1 event interrupt */
|
||||
.word I2C1_ER_IRQHandler /* I2C1 event interrupt */
|
||||
.word I2C2_EV_IRQHandler /* I2C2 error interrupt */
|
||||
.word I2C2_ER_IRQHandler /* I2C2 error interrupt */
|
||||
.word SPI1_IRQHandler /* SPI1 global interrupt */
|
||||
.word SPI2_IRQHandler /* SPI2 global interrupt */
|
||||
.word USART1_IRQHandler /* USART1 global interrupt */
|
||||
.word USART2_IRQHandler /* USART2 global interrupt */
|
||||
.word LPUART1_IRQHandler /* LPUART1 global interrupt */
|
||||
.word LPTIM1_IRQHandler /* LPtimer 1 global interrupt */
|
||||
.word LPTIM2_IRQHandler /* LPtimer 2 global interrupt */
|
||||
.word EXTI15_10_IRQHandler /* EXTI line 15_10] interrupt through EXTI */
|
||||
.word RTC_Alarm_IRQHandler /* RTC Alarms A & B interrupt */
|
||||
.word LPTIM3_IRQHandler /* LPtimer 3 global interrupt */
|
||||
.word SUBGHZSPI_IRQHandler /* SUBGHZSPI global interrupt */
|
||||
.word 0 /* Reserved */
|
||||
.word 0 /* Reserved */
|
||||
.word HSEM_IRQHandler /* Semaphore interrupt 0 to CPU1 */
|
||||
.word I2C3_EV_IRQHandler /* I2C3 event interrupt */
|
||||
.word I2C3_ER_IRQHandler /* I2C3 error interrupt */
|
||||
.word SUBGHZ_Radio_IRQHandler /* Radio IRQs RFBUSY interrupt through EXTI */
|
||||
.word AES_IRQHandler /* AES global interrupt */
|
||||
.word RNG_IRQHandler /* RNG interrupt */
|
||||
.word PKA_IRQHandler /* PKA interrupt */
|
||||
.word DMA2_Channel1_IRQHandler /* DMA2 channel 1 interrupt */
|
||||
.word DMA2_Channel2_IRQHandler /* DMA2 channel 2 interrupt */
|
||||
.word DMA2_Channel3_IRQHandler /* DMA2 channel 3 interrupt */
|
||||
.word DMA2_Channel4_IRQHandler /* DMA2 channel 4 interrupt */
|
||||
.word DMA2_Channel5_IRQHandler /* DMA2 channel 5 interrupt */
|
||||
.word DMA2_Channel6_IRQHandler /* DMA2 channel 6 interrupt */
|
||||
.word DMA2_Channel7_IRQHandler /* DMA2 channel 7 interrupt */
|
||||
.word DMAMUX1_OVR_IRQHandler /* DMAMUX overrun interrupt */
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Provide weak aliases for each Exception handler to the Default_Handler.
|
||||
* As they are weak aliases, any function with the same name will override
|
||||
* this definition.
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
.weak NMI_Handler
|
||||
.thumb_set NMI_Handler,Default_Handler
|
||||
|
||||
.weak HardFault_Handler
|
||||
.thumb_set HardFault_Handler,Default_Handler
|
||||
|
||||
.weak MemManage_Handler
|
||||
.thumb_set MemManage_Handler,Default_Handler
|
||||
|
||||
.weak BusFault_Handler
|
||||
.thumb_set BusFault_Handler,Default_Handler
|
||||
|
||||
.weak UsageFault_Handler
|
||||
.thumb_set UsageFault_Handler,Default_Handler
|
||||
|
||||
.weak SVC_Handler
|
||||
.thumb_set SVC_Handler,Default_Handler
|
||||
|
||||
.weak DebugMon_Handler
|
||||
.thumb_set DebugMon_Handler,Default_Handler
|
||||
|
||||
.weak PendSV_Handler
|
||||
.thumb_set PendSV_Handler,Default_Handler
|
||||
|
||||
.weak SysTick_Handler
|
||||
.thumb_set SysTick_Handler,Default_Handler
|
||||
|
||||
.weak WWDG_IRQHandler
|
||||
.thumb_set WWDG_IRQHandler,Default_Handler
|
||||
|
||||
.weak PVD_PVM_IRQHandler
|
||||
.thumb_set PVD_PVM_IRQHandler,Default_Handler
|
||||
|
||||
.weak TAMP_STAMP_LSECSS_SSRU_IRQHandler
|
||||
.thumb_set TAMP_STAMP_LSECSS_SSRU_IRQHandler,Default_Handler
|
||||
|
||||
.weak RTC_WKUP_IRQHandler
|
||||
.thumb_set RTC_WKUP_IRQHandler,Default_Handler
|
||||
|
||||
.weak FLASH_IRQHandler
|
||||
.thumb_set FLASH_IRQHandler,Default_Handler
|
||||
|
||||
.weak RCC_IRQHandler
|
||||
.thumb_set RCC_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI0_IRQHandler
|
||||
.thumb_set EXTI0_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI1_IRQHandler
|
||||
.thumb_set EXTI1_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI2_IRQHandler
|
||||
.thumb_set EXTI2_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI3_IRQHandler
|
||||
.thumb_set EXTI3_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI4_IRQHandler
|
||||
.thumb_set EXTI4_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Channel1_IRQHandler
|
||||
.thumb_set DMA1_Channel1_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Channel2_IRQHandler
|
||||
.thumb_set DMA1_Channel2_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Channel3_IRQHandler
|
||||
.thumb_set DMA1_Channel3_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Channel4_IRQHandler
|
||||
.thumb_set DMA1_Channel4_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Channel5_IRQHandler
|
||||
.thumb_set DMA1_Channel5_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Channel6_IRQHandler
|
||||
.thumb_set DMA1_Channel6_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Channel7_IRQHandler
|
||||
.thumb_set DMA1_Channel7_IRQHandler,Default_Handler
|
||||
|
||||
.weak ADC_IRQHandler
|
||||
.thumb_set ADC_IRQHandler,Default_Handler
|
||||
|
||||
.weak DAC_IRQHandler
|
||||
.thumb_set DAC_IRQHandler,Default_Handler
|
||||
|
||||
.weak COMP_IRQHandler
|
||||
.thumb_set COMP_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI9_5_IRQHandler
|
||||
.thumb_set EXTI9_5_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM1_BRK_IRQHandler
|
||||
.thumb_set TIM1_BRK_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM1_UP_IRQHandler
|
||||
.thumb_set TIM1_UP_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM1_TRG_COM_IRQHandler
|
||||
.thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM1_CC_IRQHandler
|
||||
.thumb_set TIM1_CC_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM2_IRQHandler
|
||||
.thumb_set TIM2_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM16_IRQHandler
|
||||
.thumb_set TIM16_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM17_IRQHandler
|
||||
.thumb_set TIM17_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C1_EV_IRQHandler
|
||||
.thumb_set I2C1_EV_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C1_ER_IRQHandler
|
||||
.thumb_set I2C1_ER_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C2_EV_IRQHandler
|
||||
.thumb_set I2C2_EV_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C2_ER_IRQHandler
|
||||
.thumb_set I2C2_ER_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI1_IRQHandler
|
||||
.thumb_set SPI1_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI2_IRQHandler
|
||||
.thumb_set SPI2_IRQHandler,Default_Handler
|
||||
|
||||
.weak USART1_IRQHandler
|
||||
.thumb_set USART1_IRQHandler,Default_Handler
|
||||
|
||||
.weak USART2_IRQHandler
|
||||
.thumb_set USART2_IRQHandler,Default_Handler
|
||||
|
||||
.weak LPUART1_IRQHandler
|
||||
.thumb_set LPUART1_IRQHandler,Default_Handler
|
||||
|
||||
.weak LPTIM1_IRQHandler
|
||||
.thumb_set LPTIM1_IRQHandler,Default_Handler
|
||||
|
||||
.weak LPTIM2_IRQHandler
|
||||
.thumb_set LPTIM2_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI15_10_IRQHandler
|
||||
.thumb_set EXTI15_10_IRQHandler,Default_Handler
|
||||
|
||||
.weak RTC_Alarm_IRQHandler
|
||||
.thumb_set RTC_Alarm_IRQHandler,Default_Handler
|
||||
|
||||
.weak LPTIM3_IRQHandler
|
||||
.thumb_set LPTIM3_IRQHandler,Default_Handler
|
||||
|
||||
.weak SUBGHZSPI_IRQHandler
|
||||
.thumb_set SUBGHZSPI_IRQHandler,Default_Handler
|
||||
|
||||
.weak HSEM_IRQHandler
|
||||
.thumb_set HSEM_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C3_EV_IRQHandler
|
||||
.thumb_set I2C3_EV_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C3_ER_IRQHandler
|
||||
.thumb_set I2C3_ER_IRQHandler,Default_Handler
|
||||
|
||||
.weak SUBGHZ_Radio_IRQHandler
|
||||
.thumb_set SUBGHZ_Radio_IRQHandler,Default_Handler
|
||||
|
||||
.weak AES_IRQHandler
|
||||
.thumb_set AES_IRQHandler,Default_Handler
|
||||
|
||||
.weak RNG_IRQHandler
|
||||
.thumb_set RNG_IRQHandler,Default_Handler
|
||||
|
||||
.weak PKA_IRQHandler
|
||||
.thumb_set PKA_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Channel1_IRQHandler
|
||||
.thumb_set DMA2_Channel1_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Channel2_IRQHandler
|
||||
.thumb_set DMA2_Channel2_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Channel3_IRQHandler
|
||||
.thumb_set DMA2_Channel3_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Channel4_IRQHandler
|
||||
.thumb_set DMA2_Channel4_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Channel5_IRQHandler
|
||||
.thumb_set DMA2_Channel5_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Channel6_IRQHandler
|
||||
.thumb_set DMA2_Channel6_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Channel7_IRQHandler
|
||||
.thumb_set DMA2_Channel7_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMAMUX1_OVR_IRQHandler
|
||||
.thumb_set DMAMUX1_OVR_IRQHandler,Default_Handler
|
||||
|
||||
.weak SystemInit
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file startup_stm32wle5xx.s
|
||||
* @author MCD Application Team
|
||||
* @brief STM32WLE5xx devices vector table for GCC toolchain.
|
||||
* This module performs:
|
||||
* - Set the initial SP
|
||||
* - Set the initial PC == Reset_Handler,
|
||||
* - Set the vector table entries with the exceptions ISR address,
|
||||
* - Branches to main in the C library (which eventually
|
||||
* calls main()).
|
||||
* After Reset the Cortex-M4 processor is in Thread mode,
|
||||
* priority is Privileged, and the Stack is set to Main.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2020-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
.syntax unified
|
||||
.cpu cortex-m4
|
||||
.fpu softvfp
|
||||
.thumb
|
||||
|
||||
.global g_pfnVectors
|
||||
.global Default_Handler
|
||||
|
||||
/* start address for the initialization values of the .data section.
|
||||
defined in linker script */
|
||||
.word _sidata
|
||||
/* start address for the .data section. defined in linker script */
|
||||
.word _sdata
|
||||
/* end address for the .data section. defined in linker script */
|
||||
.word _edata
|
||||
/* start address for the .bss section. defined in linker script */
|
||||
.word _sbss
|
||||
/* end address for the .bss section. defined in linker script */
|
||||
.word _ebss
|
||||
|
||||
/**
|
||||
* @brief This is the code that gets called when the processor first
|
||||
* starts execution following a reset event. Only the absolutely
|
||||
* necessary set is performed, after which the application
|
||||
* supplied main() routine is called.
|
||||
* @param None
|
||||
* @retval : None
|
||||
*/
|
||||
|
||||
.section .text.Reset_Handler
|
||||
.weak Reset_Handler
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
ldr r0, =_estack
|
||||
mov sp, r0 /* set stack pointer */
|
||||
|
||||
/* Call the clock system initialization function.*/
|
||||
bl SystemInit
|
||||
|
||||
/* Copy the data segment initializers from flash to SRAM */
|
||||
ldr r0, =_sdata
|
||||
ldr r1, =_edata
|
||||
ldr r2, =_sidata
|
||||
movs r3, #0
|
||||
b LoopCopyDataInit
|
||||
|
||||
CopyDataInit:
|
||||
ldr r4, [r2, r3]
|
||||
str r4, [r0, r3]
|
||||
adds r3, r3, #4
|
||||
|
||||
LoopCopyDataInit:
|
||||
adds r4, r0, r3
|
||||
cmp r4, r1
|
||||
bcc CopyDataInit
|
||||
|
||||
/* Zero fill the bss segment. */
|
||||
ldr r2, =_sbss
|
||||
ldr r4, =_ebss
|
||||
movs r3, #0
|
||||
b LoopFillZerobss
|
||||
|
||||
FillZerobss:
|
||||
str r3, [r2]
|
||||
adds r2, r2, #4
|
||||
|
||||
LoopFillZerobss:
|
||||
cmp r2, r4
|
||||
bcc FillZerobss
|
||||
|
||||
/* Call static constructors */
|
||||
bl __libc_init_array
|
||||
/* Call the application's entry point.*/
|
||||
bl main
|
||||
|
||||
LoopForever:
|
||||
b LoopForever
|
||||
|
||||
.size Reset_Handler, .-Reset_Handler
|
||||
|
||||
/**
|
||||
* @brief This is the code that gets called when the processor receives an
|
||||
* unexpected interrupt. This simply enters an infinite loop, preserving
|
||||
* the system state for examination by a debugger.
|
||||
*
|
||||
* @param None
|
||||
* @retval : None
|
||||
*/
|
||||
.section .text.Default_Handler,"ax",%progbits
|
||||
Default_Handler:
|
||||
Infinite_Loop:
|
||||
b Infinite_Loop
|
||||
.size Default_Handler, .-Default_Handler
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* The STM32WLE5xx vector table. Note that the proper constructs
|
||||
* must be placed on this to ensure that it ends up at physical address
|
||||
* 0x0000.0000.
|
||||
*
|
||||
******************************************************************************/
|
||||
.section .isr_vector,"a",%progbits
|
||||
.type g_pfnVectors, %object
|
||||
.size g_pfnVectors, .-g_pfnVectors
|
||||
|
||||
g_pfnVectors:
|
||||
.word _estack
|
||||
.word Reset_Handler
|
||||
.word NMI_Handler
|
||||
.word HardFault_Handler
|
||||
.word MemManage_Handler
|
||||
.word BusFault_Handler
|
||||
.word UsageFault_Handler
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word SVC_Handler
|
||||
.word DebugMon_Handler
|
||||
.word 0
|
||||
.word PendSV_Handler
|
||||
.word SysTick_Handler
|
||||
.word WWDG_IRQHandler /* Window Watchdog interrupt */
|
||||
.word PVD_PVM_IRQHandler /* PVD and PVM interrupt through EXTI */
|
||||
.word TAMP_STAMP_LSECSS_SSRU_IRQHandler /* RTC Tamper, RTC TimeStamp, LSECSS and RTC SSRU int.*/
|
||||
.word RTC_WKUP_IRQHandler /* RTC wakeup interrupt through EXTI[19] */
|
||||
.word FLASH_IRQHandler /* Flash memory global interrupt and Flash memory ECC */
|
||||
.word RCC_IRQHandler /* RCC global interrupt */
|
||||
.word EXTI0_IRQHandler /* EXTI line 0 interrupt */
|
||||
.word EXTI1_IRQHandler /* EXTI line 1 interrupt */
|
||||
.word EXTI2_IRQHandler /* EXTI line 2 interrupt */
|
||||
.word EXTI3_IRQHandler /* EXTI line 3 interrupt */
|
||||
.word EXTI4_IRQHandler /* EXTI line 4 interrupt */
|
||||
.word DMA1_Channel1_IRQHandler /* DMA1 channel 1 interrupt */
|
||||
.word DMA1_Channel2_IRQHandler /* DMA1 channel 2 interrupt */
|
||||
.word DMA1_Channel3_IRQHandler /* DMA1 channel 3 interrupt */
|
||||
.word DMA1_Channel4_IRQHandler /* DMA1 channel 4 interrupt */
|
||||
.word DMA1_Channel5_IRQHandler /* DMA1 channel 5 interrupt */
|
||||
.word DMA1_Channel6_IRQHandler /* DMA1 channel 6 interrupt */
|
||||
.word DMA1_Channel7_IRQHandler /* DMA1 channel 7 interrupt */
|
||||
.word ADC_IRQHandler /* ADC interrupt */
|
||||
.word DAC_IRQHandler /* DAC interrupt */
|
||||
.word 0 /* Reserved */
|
||||
.word COMP_IRQHandler /* COMP1 and COMP2 interrupt through EXTI */
|
||||
.word EXTI9_5_IRQHandler /* EXTI line 9_5 interrupt */
|
||||
.word TIM1_BRK_IRQHandler /* Timer 1 break interrupt */
|
||||
.word TIM1_UP_IRQHandler /* Timer 1 Update */
|
||||
.word TIM1_TRG_COM_IRQHandler /* Timer 1 trigger and communication */
|
||||
.word TIM1_CC_IRQHandler /* Timer 1 capture compare interrupt */
|
||||
.word TIM2_IRQHandler /* TIM2 global interrupt */
|
||||
.word TIM16_IRQHandler /* Timer 16 global interrupt */
|
||||
.word TIM17_IRQHandler /* Timer 17 global interrupt */
|
||||
.word I2C1_EV_IRQHandler /* I2C1 event interrupt */
|
||||
.word I2C1_ER_IRQHandler /* I2C1 event interrupt */
|
||||
.word I2C2_EV_IRQHandler /* I2C2 error interrupt */
|
||||
.word I2C2_ER_IRQHandler /* I2C2 error interrupt */
|
||||
.word SPI1_IRQHandler /* SPI1 global interrupt */
|
||||
.word SPI2_IRQHandler /* SPI2 global interrupt */
|
||||
.word USART1_IRQHandler /* USART1 global interrupt */
|
||||
.word USART2_IRQHandler /* USART2 global interrupt */
|
||||
.word LPUART1_IRQHandler /* LPUART1 global interrupt */
|
||||
.word LPTIM1_IRQHandler /* LPtimer 1 global interrupt */
|
||||
.word LPTIM2_IRQHandler /* LPtimer 2 global interrupt */
|
||||
.word EXTI15_10_IRQHandler /* EXTI line 15_10] interrupt through EXTI */
|
||||
.word RTC_Alarm_IRQHandler /* RTC Alarms A & B interrupt */
|
||||
.word LPTIM3_IRQHandler /* LPtimer 3 global interrupt */
|
||||
.word SUBGHZSPI_IRQHandler /* SUBGHZSPI global interrupt */
|
||||
.word 0 /* Reserved */
|
||||
.word 0 /* Reserved */
|
||||
.word HSEM_IRQHandler /* Semaphore interrupt 0 to CPU1 */
|
||||
.word I2C3_EV_IRQHandler /* I2C3 event interrupt */
|
||||
.word I2C3_ER_IRQHandler /* I2C3 error interrupt */
|
||||
.word SUBGHZ_Radio_IRQHandler /* Radio IRQs RFBUSY interrupt through EXTI */
|
||||
.word AES_IRQHandler /* AES global interrupt */
|
||||
.word RNG_IRQHandler /* RNG interrupt */
|
||||
.word PKA_IRQHandler /* PKA interrupt */
|
||||
.word DMA2_Channel1_IRQHandler /* DMA2 channel 1 interrupt */
|
||||
.word DMA2_Channel2_IRQHandler /* DMA2 channel 2 interrupt */
|
||||
.word DMA2_Channel3_IRQHandler /* DMA2 channel 3 interrupt */
|
||||
.word DMA2_Channel4_IRQHandler /* DMA2 channel 4 interrupt */
|
||||
.word DMA2_Channel5_IRQHandler /* DMA2 channel 5 interrupt */
|
||||
.word DMA2_Channel6_IRQHandler /* DMA2 channel 6 interrupt */
|
||||
.word DMA2_Channel7_IRQHandler /* DMA2 channel 7 interrupt */
|
||||
.word DMAMUX1_OVR_IRQHandler /* DMAMUX overrun interrupt */
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Provide weak aliases for each Exception handler to the Default_Handler.
|
||||
* As they are weak aliases, any function with the same name will override
|
||||
* this definition.
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
.weak NMI_Handler
|
||||
.thumb_set NMI_Handler,Default_Handler
|
||||
|
||||
.weak HardFault_Handler
|
||||
.thumb_set HardFault_Handler,Default_Handler
|
||||
|
||||
.weak MemManage_Handler
|
||||
.thumb_set MemManage_Handler,Default_Handler
|
||||
|
||||
.weak BusFault_Handler
|
||||
.thumb_set BusFault_Handler,Default_Handler
|
||||
|
||||
.weak UsageFault_Handler
|
||||
.thumb_set UsageFault_Handler,Default_Handler
|
||||
|
||||
.weak SVC_Handler
|
||||
.thumb_set SVC_Handler,Default_Handler
|
||||
|
||||
.weak DebugMon_Handler
|
||||
.thumb_set DebugMon_Handler,Default_Handler
|
||||
|
||||
.weak PendSV_Handler
|
||||
.thumb_set PendSV_Handler,Default_Handler
|
||||
|
||||
.weak SysTick_Handler
|
||||
.thumb_set SysTick_Handler,Default_Handler
|
||||
|
||||
.weak WWDG_IRQHandler
|
||||
.thumb_set WWDG_IRQHandler,Default_Handler
|
||||
|
||||
.weak PVD_PVM_IRQHandler
|
||||
.thumb_set PVD_PVM_IRQHandler,Default_Handler
|
||||
|
||||
.weak TAMP_STAMP_LSECSS_SSRU_IRQHandler
|
||||
.thumb_set TAMP_STAMP_LSECSS_SSRU_IRQHandler,Default_Handler
|
||||
|
||||
.weak RTC_WKUP_IRQHandler
|
||||
.thumb_set RTC_WKUP_IRQHandler,Default_Handler
|
||||
|
||||
.weak FLASH_IRQHandler
|
||||
.thumb_set FLASH_IRQHandler,Default_Handler
|
||||
|
||||
.weak RCC_IRQHandler
|
||||
.thumb_set RCC_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI0_IRQHandler
|
||||
.thumb_set EXTI0_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI1_IRQHandler
|
||||
.thumb_set EXTI1_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI2_IRQHandler
|
||||
.thumb_set EXTI2_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI3_IRQHandler
|
||||
.thumb_set EXTI3_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI4_IRQHandler
|
||||
.thumb_set EXTI4_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Channel1_IRQHandler
|
||||
.thumb_set DMA1_Channel1_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Channel2_IRQHandler
|
||||
.thumb_set DMA1_Channel2_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Channel3_IRQHandler
|
||||
.thumb_set DMA1_Channel3_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Channel4_IRQHandler
|
||||
.thumb_set DMA1_Channel4_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Channel5_IRQHandler
|
||||
.thumb_set DMA1_Channel5_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Channel6_IRQHandler
|
||||
.thumb_set DMA1_Channel6_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Channel7_IRQHandler
|
||||
.thumb_set DMA1_Channel7_IRQHandler,Default_Handler
|
||||
|
||||
.weak ADC_IRQHandler
|
||||
.thumb_set ADC_IRQHandler,Default_Handler
|
||||
|
||||
.weak DAC_IRQHandler
|
||||
.thumb_set DAC_IRQHandler,Default_Handler
|
||||
|
||||
.weak COMP_IRQHandler
|
||||
.thumb_set COMP_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI9_5_IRQHandler
|
||||
.thumb_set EXTI9_5_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM1_BRK_IRQHandler
|
||||
.thumb_set TIM1_BRK_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM1_UP_IRQHandler
|
||||
.thumb_set TIM1_UP_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM1_TRG_COM_IRQHandler
|
||||
.thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM1_CC_IRQHandler
|
||||
.thumb_set TIM1_CC_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM2_IRQHandler
|
||||
.thumb_set TIM2_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM16_IRQHandler
|
||||
.thumb_set TIM16_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM17_IRQHandler
|
||||
.thumb_set TIM17_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C1_EV_IRQHandler
|
||||
.thumb_set I2C1_EV_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C1_ER_IRQHandler
|
||||
.thumb_set I2C1_ER_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C2_EV_IRQHandler
|
||||
.thumb_set I2C2_EV_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C2_ER_IRQHandler
|
||||
.thumb_set I2C2_ER_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI1_IRQHandler
|
||||
.thumb_set SPI1_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI2_IRQHandler
|
||||
.thumb_set SPI2_IRQHandler,Default_Handler
|
||||
|
||||
.weak USART1_IRQHandler
|
||||
.thumb_set USART1_IRQHandler,Default_Handler
|
||||
|
||||
.weak USART2_IRQHandler
|
||||
.thumb_set USART2_IRQHandler,Default_Handler
|
||||
|
||||
.weak LPUART1_IRQHandler
|
||||
.thumb_set LPUART1_IRQHandler,Default_Handler
|
||||
|
||||
.weak LPTIM1_IRQHandler
|
||||
.thumb_set LPTIM1_IRQHandler,Default_Handler
|
||||
|
||||
.weak LPTIM2_IRQHandler
|
||||
.thumb_set LPTIM2_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI15_10_IRQHandler
|
||||
.thumb_set EXTI15_10_IRQHandler,Default_Handler
|
||||
|
||||
.weak RTC_Alarm_IRQHandler
|
||||
.thumb_set RTC_Alarm_IRQHandler,Default_Handler
|
||||
|
||||
.weak LPTIM3_IRQHandler
|
||||
.thumb_set LPTIM3_IRQHandler,Default_Handler
|
||||
|
||||
.weak SUBGHZSPI_IRQHandler
|
||||
.thumb_set SUBGHZSPI_IRQHandler,Default_Handler
|
||||
|
||||
.weak HSEM_IRQHandler
|
||||
.thumb_set HSEM_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C3_EV_IRQHandler
|
||||
.thumb_set I2C3_EV_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C3_ER_IRQHandler
|
||||
.thumb_set I2C3_ER_IRQHandler,Default_Handler
|
||||
|
||||
.weak SUBGHZ_Radio_IRQHandler
|
||||
.thumb_set SUBGHZ_Radio_IRQHandler,Default_Handler
|
||||
|
||||
.weak AES_IRQHandler
|
||||
.thumb_set AES_IRQHandler,Default_Handler
|
||||
|
||||
.weak RNG_IRQHandler
|
||||
.thumb_set RNG_IRQHandler,Default_Handler
|
||||
|
||||
.weak PKA_IRQHandler
|
||||
.thumb_set PKA_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Channel1_IRQHandler
|
||||
.thumb_set DMA2_Channel1_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Channel2_IRQHandler
|
||||
.thumb_set DMA2_Channel2_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Channel3_IRQHandler
|
||||
.thumb_set DMA2_Channel3_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Channel4_IRQHandler
|
||||
.thumb_set DMA2_Channel4_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Channel5_IRQHandler
|
||||
.thumb_set DMA2_Channel5_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Channel6_IRQHandler
|
||||
.thumb_set DMA2_Channel6_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Channel7_IRQHandler
|
||||
.thumb_set DMA2_Channel7_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMAMUX1_OVR_IRQHandler
|
||||
.thumb_set DMAMUX1_OVR_IRQHandler,Default_Handler
|
||||
|
||||
.weak SystemInit
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 5b47f70ce5f9016b92a8bedb037d00d86b7c8080
|
|
@ -11,12 +11,13 @@ int main(void) {
|
|||
/* HAL */
|
||||
HAL_Init();
|
||||
|
||||
SystemClock_Config();
|
||||
|
||||
/* Hardware initialization */
|
||||
MX_GPIO_Init();
|
||||
SystemClock_Config();
|
||||
MX_RTC_Init();
|
||||
MX_LoRaWAN_Init();
|
||||
|
||||
for (;;) {
|
||||
/* -- */
|
||||
MX_LoRaWAN_Process();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue