This commit is contained in:
2025-03-19 11:06:57 +08:00
commit 49f5db3a10
1343 changed files with 599230 additions and 0 deletions

View File

@ -0,0 +1,72 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file mw_log_conf.h
* @author MCD Application Team
* @brief Configure (enable/disable) traces for CM0
*******************************************************************************
* @attention
*
* Copyright (c) 2022 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 ------------------------------------------------------------------*/
#include "stm32_adv_trace.h"
/* 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
#define MW_LOG(TS,VL, ...) do{ {UTIL_ADV_TRACE_COND_FSend(VL, T_REG_OFF, TS, __VA_ARGS__);} }while(0)
#else /* MW_LOG_ENABLED */
#define MW_LOG(TS,VL, ...)
#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__ */

View File

@ -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) 2022 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 */

View File

@ -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) 2022 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 */

View File

@ -0,0 +1,151 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file radio_conf.h
* @author MCD Application Team
* @brief Header of Radio configuration
******************************************************************************
* @attention
*
* Copyright (c) 2022 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) */
#include "sys_debug.h"
/* 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__*/

117
SubGHz_Phy/Target/timer.h Normal file
View File

@ -0,0 +1,117 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file timer.h
* @author MCD Application Team
* @brief Wrapper to timer server
******************************************************************************
* @attention
*
* Copyright (c) 2022 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__*/