|
STM32G474xx HAL用户手册
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32g4xx_hal_tim_ex.h 00004 * @author MCD Application Team 00005 * @brief TIM HAL扩展模块头文件。 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * Copyright (c) 2019 STMicroelectronics. 00010 * All rights reserved. 00011 * 00012 * This software is licensed under terms that can be found in the LICENSE file 00013 * in the root directory of this software component. 00014 * If no LICENSE file comes with this software, it is provided AS-IS. 00015 * 00016 ****************************************************************************** 00017 */ 00018 00019 /* Define to prevent recursive inclusion -------------------------------------*/ 00020 #ifndef STM32G4xx_HAL_TIM_EX_H 00021 #define STM32G4xx_HAL_TIM_EX_H 00022 00023 #ifdef __cplusplus 00024 extern "C" { 00025 #endif 00026 00027 /* Includes ------------------------------------------------------------------*/ 00028 #include "stm32g4xx_hal_def.h" 00029 00030 /** @addtogroup STM32G4xx_HAL_Driver 00031 * @{ 00032 */ 00033 00034 /** @addtogroup TIMEx 00035 * @{ 00036 */ 00037 00038 /* Exported types ------------------------------------------------------------*/ 00039 /** @defgroup TIMEx_Exported_Types TIM扩展导出类型 00040 * @{ 00041 */ 00042 00043 /** 00044 * @brief TIM霍尔传感器配置结构体定义 00045 */ 00046 00047 typedef struct 00048 { 00049 uint32_t IC1Polarity; /*!< 指定输入信号的有效边沿。 00050 此参数可以是@ref TIM_Input_Capture_Polarity的值 */ 00051 00052 uint32_t IC1Prescaler; /*!< 指定输入捕获预分频器。 00053 此参数可以是@ref TIM_Input_Capture_Prescaler的值 */ 00054 00055 uint32_t IC1Filter; /*!< 指定输入捕获滤波器。 00056 此参数可以是Min_Data = 0x0到Max_Data = 0xF之间的数值 */ 00057 00058 uint32_t Commutation_Delay; /*!< 指定要加载到捕获比较寄存器的脉冲值。 00059 此参数可以是Min_Data = 0x0000到Max_Data = 0xFFFF之间的数值 */ 00060 } TIM_HallSensor_InitTypeDef; 00061 00062 /** 00063 * @brief TIM断路/断路2输入配置 00064 */ 00065 typedef struct 00066 { 00067 uint32_t Source; /*!< 指定定时器断路输入的来源。 00068 此参数可以是@ref TIMEx_Break_Input_Source的值 */ 00069 uint32_t Enable; /*!< 指定是否启用断路输入源。 00070 此参数可以是@ref TIMEx_Break_Input_Source_Enable的值 */ 00071 uint32_t Polarity; /*!< 指定断路输入源的极性。 00072 此参数可以是@ref TIMEx_Break_Input_Source_Polarity的值 */ 00073 } TIMEx_BreakInputConfigTypeDef; 00074 00075 /** 00076 * @brief TIM编码器索引配置 00077 */ 00078 typedef struct 00079 { 00080 uint32_t Polarity; /*!< TIM编码器索引极性。此参数可以是@ref TIMEx_Encoder_Index_Polarity的值 */ 00081 00082 uint32_t Prescaler; /*!< TIM编码器索引预分频器。此参数可以是@ref TIMEx_Encoder_Index_Prescaler的值 */ 00083 00084 uint32_t Filter; /*!< TIM编码器索引滤波器。此参数可以是Min_Data = 0x0到Max_Data = 0xF之间的数值 */ 00085 00086 FunctionalState FirstIndexEnable; /*!< 指定是否启用编码器第一个索引。此参数值可以是ENABLE或DISABLE。 */ 00087 00088 uint32_t Position; /*!< 指定在哪个AB输入配置下索引事件复位计数器。此参数可以是@ref TIMEx_Encoder_Index_Position的值 */ 00089 00090 uint32_t Direction; /*!< 指定在哪个计数器方向下索引事件复位计数器。此参数可以是@ref TIMEx_Encoder_Index_Direction的值 */ 00091 00092 } TIMEx_EncoderIndexConfigTypeDef; 00093 00094 /** 00095 * @} 00096 */ 00097 /* End of exported types -----------------------------------------------------*/ 00098 00099 /* Exported constants --------------------------------------------------------*/ 00100 /** @defgroup TIMEx_Exported_Constants TIM扩展导出常量 00101 * @{ 00102 */ 00103 00104 /** @defgroup TIMEx_Remap TIM扩展重映射 00105 * @{ 00106 */ 00107 #define TIM_TIM1_ETR_GPIO 0x00000000U /*!< ETR输入连接到GPIO */ 00108 #define TIM_TIM1_ETR_COMP1 TIM1_AF1_ETRSEL_0 /*!< ETR输入连接到COMP1_OUT */ 00109 #define TIM_TIM1_ETR_COMP2 TIM1_AF1_ETRSEL_1 /*!< ETR输入连接到COMP2_OUT */ 00110 #define TIM_TIM1_ETR_COMP3 (TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ETR输入连接到COMP3_OUT */ 00111 #define TIM_TIM1_ETR_COMP4 TIM1_AF1_ETRSEL_2 /*!< ETR输入连接到COMP4_OUT */ 00112 #if defined(COMP5) 00113 #define TIM_TIM1_ETR_COMP5 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< ETR输入连接到COMP5_OUT */ 00114 #endif /* COMP5 */ 00115 #if defined(COMP6) 00116 #define TIM_TIM1_ETR_COMP6 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1) /*!< ETR输入连接到COMP6_OUT */ 00117 #endif /* COMP6 */ 00118 #if defined(COMP7) 00119 #define TIM_TIM1_ETR_COMP7 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ETR输入连接到COMP7_OUT */ 00120 #endif /* COMP7 */ 00121 #define TIM_TIM1_ETR_ADC1_AWD1 TIM1_AF1_ETRSEL_3 /*!< ADC1模拟看门狗1 */ 00122 #define TIM_TIM1_ETR_ADC1_AWD2 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_0) /*!< ADC1模拟看门狗2 */ 00123 #define TIM_TIM1_ETR_ADC1_AWD3 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_1) /*!< ADC1模拟看门狗3 */ 00124 #if defined (ADC4) 00125 #define TIM_TIM1_ETR_ADC4_AWD1 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ADC4模拟看门狗1 */ 00126 #define TIM_TIM1_ETR_ADC4_AWD2 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_2) /*!< ADC4模拟看门狗2 */ 00127 #define TIM_TIM1_ETR_ADC4_AWD3 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< ADC4模拟看门狗3 */ 00128 #endif /* ADC4 */ 00129 00130 #define TIM_TIM2_ETR_GPIO 0x00000000U /*!< ETR输入连接到GPIO */ 00131 #define TIM_TIM2_ETR_COMP1 TIM1_AF1_ETRSEL_0 /*!< ETR输入连接到COMP1_OUT */ 00132 #define TIM_TIM2_ETR_COMP2 TIM1_AF1_ETRSEL_1 /*!< ETR输入连接到COMP2_OUT */ 00133 #define TIM_TIM2_ETR_COMP3 (TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ETR输入连接到COMP3_OUT */ 00134 #define TIM_TIM2_ETR_COMP4 TIM1_AF1_ETRSEL_2 /*!< ETR输入连接到COMP4_OUT */ 00135 #if defined(COMP5) 00136 #define TIM_TIM2_ETR_COMP5 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< ETR输入连接到COMP5_OUT */ 00137 #endif /* COMP5 */ 00138 #if defined(COMP6) 00139 #define TIM_TIM2_ETR_COMP6 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1) /*!< ETR输入连接到COMP6_OUT */ 00140 #endif /* COMP6 */ 00141 #if defined(COMP7) 00142 #define TIM_TIM2_ETR_COMP7 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0)/*!< ETR输入连接到COMP7_OUT */ 00143 #endif /* COMP7 */ 00144 #define TIM_TIM2_ETR_TIM3_ETR TIM1_AF1_ETRSEL_3 /*!< ETR输入连接到TIM3 ETR */ 00145 #define TIM_TIM2_ETR_TIM4_ETR (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_0) /*!< ETR输入连接到TIM4 ETR */ 00146 #if defined (TIM5) 00147 #define TIM_TIM2_ETR_TIM5_ETR (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_1)