[bsp/stm32g491] add tim and iwdog
This commit is contained in:
parent
f4b2035c03
commit
32342c6995
|
@ -6,6 +6,7 @@
|
|||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2018-12-11 zylx first version
|
||||
* 2023-12-7 supperthomas add timer
|
||||
*/
|
||||
|
||||
#ifndef __TIM_CONFIG_H__
|
||||
|
@ -27,6 +28,83 @@ extern "C" {
|
|||
}
|
||||
#endif /* TIM_DEV_INFO_CONFIG */
|
||||
|
||||
#ifdef BSP_USING_TIM1
|
||||
#ifndef TIM1_CONFIG
|
||||
#define TIM1_CONFIG \
|
||||
{ \
|
||||
.tim_handle.Instance = TIM1, \
|
||||
.tim_irqn = TIM1_UP_TIM16_IRQn, \
|
||||
.name = "timer1", \
|
||||
}
|
||||
#endif /* TIM1_CONFIG */
|
||||
#endif /* BSP_USING_TIM1 */
|
||||
|
||||
#ifdef BSP_USING_TIM2
|
||||
#ifndef TIM2_CONFIG
|
||||
#define TIM2_CONFIG \
|
||||
{ \
|
||||
.tim_handle.Instance = TIM2, \
|
||||
.tim_irqn = TIM2_IRQn, \
|
||||
.name = "timer2", \
|
||||
}
|
||||
#endif /* TIM2_CONFIG */
|
||||
#endif /* BSP_USING_TIM2 */
|
||||
|
||||
#ifdef BSP_USING_TIM3
|
||||
#ifndef TIM3_CONFIG
|
||||
#define TIM3_CONFIG \
|
||||
{ \
|
||||
.tim_handle.Instance = TIM3, \
|
||||
.tim_irqn = TIM3_IRQn, \
|
||||
.name = "timer3", \
|
||||
}
|
||||
#endif /* TIM3_CONFIG */
|
||||
#endif /* BSP_USING_TIM3 */
|
||||
|
||||
#ifdef BSP_USING_TIM4
|
||||
#ifndef TIM4_CONFIG
|
||||
#define TIM4_CONFIG \
|
||||
{ \
|
||||
.tim_handle.Instance = TIM4, \
|
||||
.tim_irqn = TIM4_IRQn, \
|
||||
.name = "timer4", \
|
||||
}
|
||||
#endif /* TIM4_CONFIG */
|
||||
#endif /* BSP_USING_TIM4 */
|
||||
|
||||
#ifdef BSP_USING_TIM6
|
||||
#ifndef TIM6_CONFIG
|
||||
#define TIM6_CONFIG \
|
||||
{ \
|
||||
.tim_handle.Instance = TIM6, \
|
||||
.tim_irqn = TIM6_IRQn, \
|
||||
.name = "timer6", \
|
||||
}
|
||||
#endif /* TIM7_CONFIG */
|
||||
#endif /* BSP_USING_TIM7 */
|
||||
|
||||
#ifdef BSP_USING_TIM7
|
||||
#ifndef TIM7_CONFIG
|
||||
#define TIM7_CONFIG \
|
||||
{ \
|
||||
.tim_handle.Instance = TIM7, \
|
||||
.tim_irqn = TIM7_IRQn, \
|
||||
.name = "timer7", \
|
||||
}
|
||||
#endif /* TIM7_CONFIG */
|
||||
#endif /* BSP_USING_TIM7 */
|
||||
|
||||
#ifdef BSP_USING_TIM8
|
||||
#ifndef TIM8_CONFIG
|
||||
#define TIM8_CONFIG \
|
||||
{ \
|
||||
.tim_handle.Instance = TIM8, \
|
||||
.tim_irqn = TIM8_UP_IRQn, \
|
||||
.name = "timer8", \
|
||||
}
|
||||
#endif /* TIM8_CONFIG */
|
||||
#endif /* BSP_USING_TIM8 */
|
||||
|
||||
#ifdef BSP_USING_TIM11
|
||||
#ifndef TIM11_CONFIG
|
||||
#define TIM11_CONFIG \
|
||||
|
@ -60,6 +138,39 @@ extern "C" {
|
|||
#endif /* TIM14_CONFIG */
|
||||
#endif /* BSP_USING_TIM14 */
|
||||
|
||||
#ifdef BSP_USING_TIM15
|
||||
#ifndef TIM15_CONFIG
|
||||
#define TIM15_CONFIG \
|
||||
{ \
|
||||
.tim_handle.Instance = TIM15, \
|
||||
.tim_irqn = TIM1_BRK_TIM15_IRQn, \
|
||||
.name = "timer15", \
|
||||
}
|
||||
#endif /* TIM16_CONFIG */
|
||||
#endif /* BSP_USING_TIM16 */
|
||||
|
||||
#ifdef BSP_USING_TIM16
|
||||
#ifndef TIM16_CONFIG
|
||||
#define TIM16_CONFIG \
|
||||
{ \
|
||||
.tim_handle.Instance = TIM16, \
|
||||
.tim_irqn = TIM1_UP_TIM16_IRQn, \
|
||||
.name = "timer16", \
|
||||
}
|
||||
#endif /* TIM16_CONFIG */
|
||||
#endif /* BSP_USING_TIM16 */
|
||||
|
||||
#ifdef BSP_USING_TIM17
|
||||
#ifndef TIM17_CONFIG
|
||||
#define TIM17_CONFIG \
|
||||
{ \
|
||||
.tim_handle.Instance = TIM17, \
|
||||
.tim_irqn = TIM1_TRG_COM_TIM17_IRQn, \
|
||||
.name = "timer17", \
|
||||
}
|
||||
#endif /* TIM17_CONFIG */
|
||||
#endif /* BSP_USING_TIM17 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -359,7 +359,7 @@ static void timer_init(struct rt_hwtimer_device *timer, rt_uint32_t state)
|
|||
tim->Init.CounterMode = TIM_COUNTERMODE_DOWN;
|
||||
}
|
||||
tim->Init.RepetitionCounter = 0;
|
||||
#if defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F0) || defined(SOC_SERIES_STM32G0) || defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32WB)
|
||||
#if defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32G4) || defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F0) || defined(SOC_SERIES_STM32G0) || defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32WB)
|
||||
tim->Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||
#endif
|
||||
if (HAL_TIM_Base_Init(tim) != HAL_OK)
|
||||
|
@ -442,7 +442,7 @@ static rt_err_t timer_ctrl(rt_hwtimer_t *timer, rt_uint32_t cmd, void *arg)
|
|||
case HWTIMER_CTRL_FREQ_SET:
|
||||
{
|
||||
rt_uint32_t freq;
|
||||
rt_uint16_t val;
|
||||
rt_uint16_t val=0;
|
||||
|
||||
/* set timer frequence */
|
||||
freq = *((rt_uint32_t *)arg);
|
||||
|
@ -451,7 +451,7 @@ static rt_err_t timer_ctrl(rt_hwtimer_t *timer, rt_uint32_t cmd, void *arg)
|
|||
|
||||
#if defined(SOC_SERIES_STM32F2) || defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32F7)
|
||||
if (tim->Instance == TIM1 || tim->Instance == TIM8 || tim->Instance == TIM9 || tim->Instance == TIM10 || tim->Instance == TIM11)
|
||||
#elif defined(SOC_SERIES_STM32L4)
|
||||
#elif defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32G4)
|
||||
if (tim->Instance == TIM15 || tim->Instance == TIM16 || tim->Instance == TIM17)
|
||||
#elif defined(SOC_SERIES_STM32WB)
|
||||
if (tim->Instance == TIM16 || tim->Instance == TIM17)
|
||||
|
@ -616,7 +616,7 @@ void TIM1_BRK_TIM15_IRQHandler(void)
|
|||
}
|
||||
#endif
|
||||
#ifdef BSP_USING_TIM16
|
||||
#if defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32WB)
|
||||
#if defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32WB)|| defined(SOC_SERIES_STM32G4)
|
||||
void TIM1_UP_TIM16_IRQHandler(void)
|
||||
#elif defined(SOC_SERIES_STM32F0) || defined(SOC_SERIES_STM32MP1)
|
||||
void TIM16_IRQHandler(void)
|
||||
|
@ -630,7 +630,7 @@ void TIM1_BRK_TIM15_IRQHandler(void)
|
|||
}
|
||||
#endif
|
||||
#ifdef BSP_USING_TIM17
|
||||
#if defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32WB)
|
||||
#if defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32WB) || defined(SOC_SERIES_STM32G4)
|
||||
void TIM1_TRG_COM_TIM17_IRQHandler(void)
|
||||
#elif defined(SOC_SERIES_STM32F0) || defined(SOC_SERIES_STM32MP1)
|
||||
void TIM17_IRQHandler(void)
|
||||
|
|
|
@ -108,7 +108,7 @@ int rt_wdt_init(void)
|
|||
stm32_wdt.hiwdg.Init.Prescaler = IWDG_PRESCALER_256;
|
||||
|
||||
stm32_wdt.hiwdg.Init.Reload = 0x00000FFF;
|
||||
#if defined(SOC_SERIES_STM32F0) || defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F7) \
|
||||
#if defined(SOC_SERIES_STM32F0) || defined(SOC_SERIES_STM32G4)|| defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F7) \
|
||||
|| defined(SOC_SERIES_STM32H7) || defined(SOC_SERIES_STM32L0) || defined(SOC_SERIES_STM32G0)
|
||||
stm32_wdt.hiwdg.Init.Window = 0x00000FFF;
|
||||
#endif
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -53,7 +53,7 @@ extern "C" {
|
|||
void Error_Handler(void);
|
||||
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
#include <drv_common.h>
|
||||
/* USER CODE END EFP */
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
/*#define HAL_FMAC_MODULE_ENABLED */
|
||||
/*#define HAL_HRTIM_MODULE_ENABLED */
|
||||
/*#define HAL_IRDA_MODULE_ENABLED */
|
||||
/*#define HAL_IWDG_MODULE_ENABLED */
|
||||
#define HAL_IWDG_MODULE_ENABLED
|
||||
/*#define HAL_I2C_MODULE_ENABLED */
|
||||
/*#define HAL_I2S_MODULE_ENABLED */
|
||||
/*#define HAL_LPTIM_MODULE_ENABLED */
|
||||
|
@ -62,7 +62,7 @@
|
|||
/*#define HAL_SMBUS_MODULE_ENABLED */
|
||||
/*#define HAL_SPI_MODULE_ENABLED */
|
||||
/*#define HAL_SRAM_MODULE_ENABLED */
|
||||
/*#define HAL_TIM_MODULE_ENABLED */
|
||||
#define HAL_TIM_MODULE_ENABLED
|
||||
#define HAL_UART_MODULE_ENABLED
|
||||
/*#define HAL_USART_MODULE_ENABLED */
|
||||
/*#define HAL_WWDG_MODULE_ENABLED */
|
||||
|
|
|
@ -40,8 +40,15 @@
|
|||
/* USER CODE END PM */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
IWDG_HandleTypeDef hiwdg;
|
||||
|
||||
UART_HandleTypeDef hlpuart1;
|
||||
|
||||
TIM_HandleTypeDef htim7;
|
||||
TIM_HandleTypeDef htim15;
|
||||
TIM_HandleTypeDef htim16;
|
||||
TIM_HandleTypeDef htim17;
|
||||
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
@ -50,6 +57,11 @@ UART_HandleTypeDef hlpuart1;
|
|||
void SystemClock_Config(void);
|
||||
static void MX_GPIO_Init(void);
|
||||
static void MX_LPUART1_UART_Init(void);
|
||||
static void MX_IWDG_Init(void);
|
||||
static void MX_TIM15_Init(void);
|
||||
static void MX_TIM16_Init(void);
|
||||
static void MX_TIM17_Init(void);
|
||||
static void MX_TIM7_Init(void);
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
@ -88,6 +100,11 @@ int main(void)
|
|||
/* Initialize all configured peripherals */
|
||||
MX_GPIO_Init();
|
||||
MX_LPUART1_UART_Init();
|
||||
MX_IWDG_Init();
|
||||
MX_TIM15_Init();
|
||||
MX_TIM16_Init();
|
||||
MX_TIM17_Init();
|
||||
MX_TIM7_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
@ -119,9 +136,10 @@ void SystemClock_Config(void)
|
|||
/** Initializes the RCC Oscillators according to the specified parameters
|
||||
* in the RCC_OscInitTypeDef structure.
|
||||
*/
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSI;
|
||||
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
|
||||
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
|
||||
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV4;
|
||||
|
@ -149,6 +167,35 @@ void SystemClock_Config(void)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief IWDG Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_IWDG_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN IWDG_Init 0 */
|
||||
|
||||
/* USER CODE END IWDG_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN IWDG_Init 1 */
|
||||
|
||||
/* USER CODE END IWDG_Init 1 */
|
||||
hiwdg.Instance = IWDG;
|
||||
hiwdg.Init.Prescaler = IWDG_PRESCALER_4;
|
||||
hiwdg.Init.Window = 4095;
|
||||
hiwdg.Init.Reload = 4095;
|
||||
if (HAL_IWDG_Init(&hiwdg) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN IWDG_Init 2 */
|
||||
|
||||
/* USER CODE END IWDG_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief LPUART1 Initialization Function
|
||||
* @param None
|
||||
|
@ -196,6 +243,154 @@ static void MX_LPUART1_UART_Init(void)
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TIM7 Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_TIM7_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN TIM7_Init 0 */
|
||||
|
||||
/* USER CODE END TIM7_Init 0 */
|
||||
|
||||
TIM_MasterConfigTypeDef sMasterConfig = {0};
|
||||
|
||||
/* USER CODE BEGIN TIM7_Init 1 */
|
||||
|
||||
/* USER CODE END TIM7_Init 1 */
|
||||
htim7.Instance = TIM7;
|
||||
htim7.Init.Prescaler = 0;
|
||||
htim7.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim7.Init.Period = 65535;
|
||||
htim7.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||
if (HAL_TIM_Base_Init(&htim7) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim7, &sMasterConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN TIM7_Init 2 */
|
||||
|
||||
/* USER CODE END TIM7_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TIM15 Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_TIM15_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN TIM15_Init 0 */
|
||||
|
||||
/* USER CODE END TIM15_Init 0 */
|
||||
|
||||
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
|
||||
TIM_MasterConfigTypeDef sMasterConfig = {0};
|
||||
|
||||
/* USER CODE BEGIN TIM15_Init 1 */
|
||||
|
||||
/* USER CODE END TIM15_Init 1 */
|
||||
htim15.Instance = TIM15;
|
||||
htim15.Init.Prescaler = 0;
|
||||
htim15.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim15.Init.Period = 65535;
|
||||
htim15.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
htim15.Init.RepetitionCounter = 0;
|
||||
htim15.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||
if (HAL_TIM_Base_Init(&htim15) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
||||
if (HAL_TIM_ConfigClockSource(&htim15, &sClockSourceConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim15, &sMasterConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN TIM15_Init 2 */
|
||||
|
||||
/* USER CODE END TIM15_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TIM16 Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_TIM16_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN TIM16_Init 0 */
|
||||
|
||||
/* USER CODE END TIM16_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN TIM16_Init 1 */
|
||||
|
||||
/* USER CODE END TIM16_Init 1 */
|
||||
htim16.Instance = TIM16;
|
||||
htim16.Init.Prescaler = 0;
|
||||
htim16.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim16.Init.Period = 65535;
|
||||
htim16.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
htim16.Init.RepetitionCounter = 0;
|
||||
htim16.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||
if (HAL_TIM_Base_Init(&htim16) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN TIM16_Init 2 */
|
||||
|
||||
/* USER CODE END TIM16_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TIM17 Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_TIM17_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN TIM17_Init 0 */
|
||||
|
||||
/* USER CODE END TIM17_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN TIM17_Init 1 */
|
||||
|
||||
/* USER CODE END TIM17_Init 1 */
|
||||
htim17.Instance = TIM17;
|
||||
htim17.Init.Prescaler = 0;
|
||||
htim17.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim17.Init.Period = 65535;
|
||||
htim17.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
htim17.Init.RepetitionCounter = 0;
|
||||
htim17.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||
if (HAL_TIM_Base_Init(&htim17) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN TIM17_Init 2 */
|
||||
|
||||
/* USER CODE END TIM17_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief GPIO Initialization Function
|
||||
* @param None
|
||||
|
|
|
@ -103,7 +103,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
|
|||
PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PCLK1;
|
||||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
|
||||
{
|
||||
// Error_Handler();
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/* Peripheral clock enable */
|
||||
|
@ -157,6 +157,116 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TIM_Base MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
* @param htim_base: TIM_Base handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
|
||||
{
|
||||
if(htim_base->Instance==TIM7)
|
||||
{
|
||||
/* USER CODE BEGIN TIM7_MspInit 0 */
|
||||
|
||||
/* USER CODE END TIM7_MspInit 0 */
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_TIM7_CLK_ENABLE();
|
||||
/* USER CODE BEGIN TIM7_MspInit 1 */
|
||||
|
||||
/* USER CODE END TIM7_MspInit 1 */
|
||||
}
|
||||
else if(htim_base->Instance==TIM15)
|
||||
{
|
||||
/* USER CODE BEGIN TIM15_MspInit 0 */
|
||||
|
||||
/* USER CODE END TIM15_MspInit 0 */
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_TIM15_CLK_ENABLE();
|
||||
/* USER CODE BEGIN TIM15_MspInit 1 */
|
||||
|
||||
/* USER CODE END TIM15_MspInit 1 */
|
||||
}
|
||||
else if(htim_base->Instance==TIM16)
|
||||
{
|
||||
/* USER CODE BEGIN TIM16_MspInit 0 */
|
||||
|
||||
/* USER CODE END TIM16_MspInit 0 */
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_TIM16_CLK_ENABLE();
|
||||
/* USER CODE BEGIN TIM16_MspInit 1 */
|
||||
|
||||
/* USER CODE END TIM16_MspInit 1 */
|
||||
}
|
||||
else if(htim_base->Instance==TIM17)
|
||||
{
|
||||
/* USER CODE BEGIN TIM17_MspInit 0 */
|
||||
|
||||
/* USER CODE END TIM17_MspInit 0 */
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_TIM17_CLK_ENABLE();
|
||||
/* USER CODE BEGIN TIM17_MspInit 1 */
|
||||
|
||||
/* USER CODE END TIM17_MspInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TIM_Base MSP De-Initialization
|
||||
* This function freeze the hardware resources used in this example
|
||||
* @param htim_base: TIM_Base handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
|
||||
{
|
||||
if(htim_base->Instance==TIM7)
|
||||
{
|
||||
/* USER CODE BEGIN TIM7_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END TIM7_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_TIM7_CLK_DISABLE();
|
||||
/* USER CODE BEGIN TIM7_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END TIM7_MspDeInit 1 */
|
||||
}
|
||||
else if(htim_base->Instance==TIM15)
|
||||
{
|
||||
/* USER CODE BEGIN TIM15_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END TIM15_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_TIM15_CLK_DISABLE();
|
||||
/* USER CODE BEGIN TIM15_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END TIM15_MspDeInit 1 */
|
||||
}
|
||||
else if(htim_base->Instance==TIM16)
|
||||
{
|
||||
/* USER CODE BEGIN TIM16_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END TIM16_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_TIM16_CLK_DISABLE();
|
||||
/* USER CODE BEGIN TIM16_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END TIM16_MspDeInit 1 */
|
||||
}
|
||||
else if(htim_base->Instance==TIM17)
|
||||
{
|
||||
/* USER CODE BEGIN TIM17_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END TIM17_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_TIM17_CLK_DISABLE();
|
||||
/* USER CODE BEGIN TIM17_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END TIM17_MspDeInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
|
|
@ -9,18 +9,28 @@ LPUART1.IPParameters=BaudRate,WordLength
|
|||
LPUART1.WordLength=UART_WORDLENGTH_8B
|
||||
Mcu.CPN=STM32G491RET6
|
||||
Mcu.Family=STM32G4
|
||||
Mcu.IP0=LPUART1
|
||||
Mcu.IP1=NVIC
|
||||
Mcu.IP2=RCC
|
||||
Mcu.IP3=SYS
|
||||
Mcu.IPNb=4
|
||||
Mcu.IP0=IWDG
|
||||
Mcu.IP1=LPUART1
|
||||
Mcu.IP2=NVIC
|
||||
Mcu.IP3=RCC
|
||||
Mcu.IP4=SYS
|
||||
Mcu.IP5=TIM7
|
||||
Mcu.IP6=TIM15
|
||||
Mcu.IP7=TIM16
|
||||
Mcu.IP8=TIM17
|
||||
Mcu.IPNb=9
|
||||
Mcu.Name=STM32G491R(C-E)Tx
|
||||
Mcu.Package=LQFP64
|
||||
Mcu.Pin0=PC13
|
||||
Mcu.Pin1=PC14-OSC32_IN
|
||||
Mcu.Pin10=PB3
|
||||
Mcu.Pin11=VP_SYS_VS_Systick
|
||||
Mcu.Pin12=VP_SYS_VS_DBSignals
|
||||
Mcu.Pin11=VP_IWDG_VS_IWDG
|
||||
Mcu.Pin12=VP_SYS_VS_Systick
|
||||
Mcu.Pin13=VP_SYS_VS_DBSignals
|
||||
Mcu.Pin14=VP_TIM7_VS_ClockSourceINT
|
||||
Mcu.Pin15=VP_TIM15_VS_ClockSourceINT
|
||||
Mcu.Pin16=VP_TIM16_VS_ClockSourceINT
|
||||
Mcu.Pin17=VP_TIM17_VS_ClockSourceINT
|
||||
Mcu.Pin2=PC15-OSC32_OUT
|
||||
Mcu.Pin3=PF0-OSC_IN
|
||||
Mcu.Pin4=PF1-OSC_OUT
|
||||
|
@ -29,7 +39,7 @@ Mcu.Pin6=PA3
|
|||
Mcu.Pin7=PA5
|
||||
Mcu.Pin8=PA13
|
||||
Mcu.Pin9=PA14
|
||||
Mcu.PinsNb=13
|
||||
Mcu.PinsNb=18
|
||||
Mcu.ThirdPartyNb=0
|
||||
Mcu.UserConstants=
|
||||
Mcu.UserName=STM32G491RETx
|
||||
|
@ -122,7 +132,7 @@ ProjectManager.ToolChainLocation=
|
|||
ProjectManager.UAScriptAfterPath=
|
||||
ProjectManager.UAScriptBeforePath=
|
||||
ProjectManager.UnderRoot=false
|
||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_LPUART1_UART_Init-LPUART1-false-HAL-true
|
||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_LPUART1_UART_Init-LPUART1-false-HAL-true,4-MX_IWDG_Init-IWDG-false-HAL-true,5-MX_TIM15_Init-TIM15-false-HAL-true,6-MX_TIM16_Init-TIM16-false-HAL-true,7-MX_TIM17_Init-TIM17-false-HAL-true
|
||||
RCC.ADC12Freq_Value=170000000
|
||||
RCC.ADC345Freq_Value=170000000
|
||||
RCC.AHBFreq_Value=170000000
|
||||
|
@ -175,9 +185,19 @@ RCC.VCOInputFreq_Value=4000000
|
|||
RCC.VCOOutputFreq_Value=340000000
|
||||
SH.GPXTI13.0=GPIO_EXTI13
|
||||
SH.GPXTI13.ConfNb=1
|
||||
VP_IWDG_VS_IWDG.Mode=IWDG_Activate
|
||||
VP_IWDG_VS_IWDG.Signal=IWDG_VS_IWDG
|
||||
VP_SYS_VS_DBSignals.Mode=DisableDeadBatterySignals
|
||||
VP_SYS_VS_DBSignals.Signal=SYS_VS_DBSignals
|
||||
VP_SYS_VS_Systick.Mode=SysTick
|
||||
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
|
||||
VP_TIM15_VS_ClockSourceINT.Mode=Internal
|
||||
VP_TIM15_VS_ClockSourceINT.Signal=TIM15_VS_ClockSourceINT
|
||||
VP_TIM16_VS_ClockSourceINT.Mode=Enable_Timer
|
||||
VP_TIM16_VS_ClockSourceINT.Signal=TIM16_VS_ClockSourceINT
|
||||
VP_TIM17_VS_ClockSourceINT.Mode=Enable_Timer
|
||||
VP_TIM17_VS_ClockSourceINT.Signal=TIM17_VS_ClockSourceINT
|
||||
VP_TIM7_VS_ClockSourceINT.Mode=Enable_Timer
|
||||
VP_TIM7_VS_ClockSourceINT.Signal=TIM7_VS_ClockSourceINT
|
||||
board=NUCLEO-G491RE
|
||||
boardIOC=true
|
||||
|
|
|
@ -52,6 +52,221 @@ menu "On-chip Peripheral Drivers"
|
|||
depends on BSP_USING_UART4 && RT_SERIAL_USING_DMA
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_SPI
|
||||
bool "Enable SPI Bus"
|
||||
default n
|
||||
select RT_USING_SPI
|
||||
if BSP_USING_SPI
|
||||
config BSP_USING_SPI1
|
||||
bool "Enable SPI1 Bus"
|
||||
default n
|
||||
|
||||
config BSP_SPI1_TX_USING_DMA
|
||||
bool "Enable SPI1 TX DMA"
|
||||
depends on BSP_USING_SPI1
|
||||
default n
|
||||
|
||||
config BSP_SPI1_RX_USING_DMA
|
||||
bool "Enable SPI1 RX DMA"
|
||||
depends on BSP_USING_SPI1
|
||||
select BSP_SPI1_TX_USING_DMA
|
||||
default n
|
||||
|
||||
config BSP_USING_SPI2
|
||||
bool "Enable SPI2 Bus"
|
||||
default n
|
||||
|
||||
config BSP_SPI2_TX_USING_DMA
|
||||
bool "Enable SPI2 TX DMA"
|
||||
depends on BSP_USING_SPI2
|
||||
default n
|
||||
|
||||
config BSP_SPI2_RX_USING_DMA
|
||||
bool "Enable SPI2 RX DMA"
|
||||
depends on BSP_USING_SPI2
|
||||
select BSP_SPI2_TX_USING_DMA
|
||||
default n
|
||||
|
||||
config BSP_USING_SPI3
|
||||
bool "Enable SPI3 Bus"
|
||||
default n
|
||||
|
||||
config BSP_SPI3_TX_USING_DMA
|
||||
bool "Enable SPI3 TX DMA"
|
||||
depends on BSP_USING_SPI3
|
||||
default n
|
||||
|
||||
config BSP_SPI3_RX_USING_DMA
|
||||
bool "Enable SPI3 RX DMA"
|
||||
depends on BSP_USING_SPI3
|
||||
select BSP_SPI3_TX_USING_DMA
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_I2C
|
||||
bool "Enable I2C Bus"
|
||||
default n
|
||||
select RT_USING_I2C
|
||||
select RT_USING_I2C_BITOPS
|
||||
select RT_USING_PIN
|
||||
if BSP_USING_I2C
|
||||
config BSP_USING_I2C1
|
||||
bool "Enable I2C1 Bus (User I2C)"
|
||||
default n
|
||||
if BSP_USING_I2C1
|
||||
comment "Notice: PC7 --> 39; PC6 --> 38"
|
||||
config BSP_I2C1_SCL_PIN
|
||||
int "i2c1 SCL pin number"
|
||||
range 1 176
|
||||
default 38
|
||||
config BSP_I2C1_SDA_PIN
|
||||
int "i2c1 SDA pin number"
|
||||
range 1 176
|
||||
default 39
|
||||
endif
|
||||
|
||||
config BSP_USING_I2C3
|
||||
bool "Enable I2C3 Bus (AP3216C/ICM20608/ES8388)"
|
||||
default n
|
||||
|
||||
if BSP_USING_I2C3
|
||||
# Notice: PC0 --> 32; PC1 --> 33
|
||||
config BSP_I2C3_SCL_PIN
|
||||
int
|
||||
default 32
|
||||
config BSP_I2C3_SDA_PIN
|
||||
int
|
||||
default 33
|
||||
endif
|
||||
|
||||
config BSP_USING_I2C4
|
||||
bool "Enable I2C4 Bus (AHT10)"
|
||||
default n
|
||||
|
||||
if BSP_USING_I2C4
|
||||
# Notice: PC1 --> 33; PD6 --> 54
|
||||
config BSP_I2C4_SCL_PIN
|
||||
int
|
||||
default 54
|
||||
config BSP_I2C4_SDA_PIN
|
||||
int
|
||||
default 33
|
||||
endif
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_TIM
|
||||
bool "Enable timer"
|
||||
default n
|
||||
select RT_USING_HWTIMER
|
||||
if BSP_USING_TIM
|
||||
config BSP_USING_TIM7
|
||||
bool "Enable TIM7"
|
||||
default n
|
||||
|
||||
config BSP_USING_TIM15
|
||||
bool "Enable TIM15"
|
||||
default n
|
||||
|
||||
config BSP_USING_TIM16
|
||||
bool "Enable TIM16"
|
||||
default n
|
||||
|
||||
config BSP_USING_TIM17
|
||||
bool "Enable TIM17"
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_PWM
|
||||
bool "Enable PWM"
|
||||
default n
|
||||
select RT_USING_PWM
|
||||
if BSP_USING_PWM
|
||||
menuconfig BSP_USING_PWM1
|
||||
bool "Enable timer1 output PWM"
|
||||
default n
|
||||
if BSP_USING_PWM1
|
||||
config BSP_USING_PWM1_CH1
|
||||
bool "Enable PWM1 channel1"
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_PWM2
|
||||
bool "Enable timer2 output PWM"
|
||||
default n
|
||||
if BSP_USING_PWM2
|
||||
config BSP_USING_PWM2_CH3
|
||||
bool "Enable PWM2 channel3"
|
||||
default n
|
||||
|
||||
config BSP_USING_PWM2_CH4
|
||||
bool "Enable PWM2 channel4"
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_PWM4
|
||||
bool "Enable timer4 output PWM"
|
||||
default n
|
||||
if BSP_USING_PWM4
|
||||
config BSP_USING_PWM4_CH1
|
||||
bool "Enable PWM4 channel1"
|
||||
default n
|
||||
|
||||
config BSP_USING_PWM4_CH2
|
||||
bool "Enable PWM4 channel2"
|
||||
default n
|
||||
|
||||
config BSP_USING_PWM4_CH3
|
||||
bool "Enable PWM4 channel3"
|
||||
default n
|
||||
|
||||
config BSP_USING_PWM4_CH4
|
||||
bool "Enable PWM4 channel4"
|
||||
default n
|
||||
endif
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_ADC
|
||||
bool "Enable ADC"
|
||||
default n
|
||||
select RT_USING_ADC
|
||||
if BSP_USING_ADC
|
||||
config BSP_USING_ADC1
|
||||
bool "Enable ADC1"
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_DAC
|
||||
bool "Enable DAC"
|
||||
default n
|
||||
select RT_USING_DAC
|
||||
if BSP_USING_DAC
|
||||
config BSP_USING_DAC1
|
||||
bool "Enable DAC1"
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_ONCHIP_RTC
|
||||
bool "Enable RTC"
|
||||
select RT_USING_RTC
|
||||
default n
|
||||
if BSP_USING_ONCHIP_RTC
|
||||
choice
|
||||
prompt "Select clock source"
|
||||
default BSP_RTC_USING_LSE
|
||||
|
||||
config BSP_RTC_USING_LSE
|
||||
bool "RTC USING LSE"
|
||||
|
||||
config BSP_RTC_USING_LSI
|
||||
bool "RTC USING LSI"
|
||||
endchoice
|
||||
endif
|
||||
|
||||
config BSP_USING_WDT
|
||||
bool "Enable Watchdog Timer"
|
||||
select RT_USING_WDT
|
||||
default n
|
||||
source "$BSP_DIR/../libraries/HAL_Drivers/drivers/Kconfig"
|
||||
|
||||
endmenu
|
||||
|
|
|
@ -23,9 +23,10 @@ void SystemClock_Config(void)
|
|||
/** Initializes the RCC Oscillators according to the specified parameters
|
||||
* in the RCC_OscInitTypeDef structure.
|
||||
*/
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSI;
|
||||
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
|
||||
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
|
||||
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV4;
|
||||
|
@ -52,4 +53,3 @@ void SystemClock_Config(void)
|
|||
Error_Handler();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
|
||||
<uAC6>0</uAC6>
|
||||
<uAC6>1</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>STM32G491RETx</Device>
|
||||
|
@ -54,7 +54,7 @@
|
|||
<CreateLib>0</CreateLib>
|
||||
<CreateHexFile>0</CreateHexFile>
|
||||
<DebugInformation>1</DebugInformation>
|
||||
<BrowseInformation>0</BrowseInformation>
|
||||
<BrowseInformation>1</BrowseInformation>
|
||||
<ListingPath>.\build\keil\List\</ListingPath>
|
||||
<HexFormatSelection>1</HexFormatSelection>
|
||||
<Merge32K>0</Merge32K>
|
||||
|
@ -313,7 +313,7 @@
|
|||
</ArmAdsMisc>
|
||||
<Cads>
|
||||
<interw>1</interw>
|
||||
<Optim>1</Optim>
|
||||
<Optim>2</Optim>
|
||||
<oTime>0</oTime>
|
||||
<SplitLS>0</SplitLS>
|
||||
<OneElfS>1</OneElfS>
|
||||
|
@ -322,14 +322,14 @@
|
|||
<PlainCh>0</PlainCh>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<wLevel>2</wLevel>
|
||||
<wLevel>3</wLevel>
|
||||
<uThumb>0</uThumb>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<uC99>1</uC99>
|
||||
<uGnu>0</uGnu>
|
||||
<useXO>0</useXO>
|
||||
<v6Lang>1</v6Lang>
|
||||
<v6LangP>1</v6LangP>
|
||||
<v6Lang>3</v6Lang>
|
||||
<v6LangP>3</v6LangP>
|
||||
<vShortEn>1</vShortEn>
|
||||
<vShortWch>1</vShortWch>
|
||||
<v6Lto>0</v6Lto>
|
||||
|
|
Loading…
Reference in New Issue