Shota Asao
/
RobotEx_Test01
hoaaaaaaaaaaaaa
Diff: EncoderMspInitF7.cpp
- Revision:
- 0:1e31c3d92e90
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EncoderMspInitF7.cpp Thu Dec 21 04:16:17 2017 +0000 @@ -0,0 +1,30 @@ +#include "mbed.h" + +/* + TIM1_CH1: PA8 + TIM1_CH2: PA9 + TIM2_CH1: PA5 + TIM2_CH2: PB3 + TIM3_CH1: PB4 + TIM3_CH2: PB5 + TIM4_CH1: PB6 + TIM4_CH2: PB7 + TIM8_CH1: PC6 + TIM8_CH2: PC7 + +*/ + +void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim) +{ + GPIO_InitTypeDef GPIO_InitStruct; + + if(htim->Instance == TIM1){ + __TIM1_CLK_ENABLE(); + __GPIOA_CLK_ENABLE(); + GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF1_TIM1; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + } +}