Updated for the next revision of the motor board
HardwareSetup.cpp@7:e3a2ade56b79, 2020-08-26 (annotated)
- Committer:
- elijahsj
- Date:
- Wed Aug 26 23:42:07 2020 +0000
- Revision:
- 7:e3a2ade56b79
- Parent:
- 6:417655779dc5
Fully functional with high frequency loop
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elijahsj | 1:4c3c2b7337a6 | 1 | #include "mbed.h" |
elijahsj | 1:4c3c2b7337a6 | 2 | #include "HardwareSetup.h" |
elijahsj | 1:4c3c2b7337a6 | 3 | #include "stm32h7xx_hal.h" |
elijahsj | 1:4c3c2b7337a6 | 4 | |
elijahsj | 1:4c3c2b7337a6 | 5 | TIM_HandleTypeDef htim12; |
elijahsj | 1:4c3c2b7337a6 | 6 | TIM_HandleTypeDef htim15; |
elijahsj | 1:4c3c2b7337a6 | 7 | TIM_HandleTypeDef htim13; |
elijahsj | 1:4c3c2b7337a6 | 8 | TIM_HandleTypeDef htim14; |
elijahsj | 1:4c3c2b7337a6 | 9 | TIM_HandleTypeDef htim16; |
elijahsj | 1:4c3c2b7337a6 | 10 | TIM_HandleTypeDef htim17; |
elijahsj | 6:417655779dc5 | 11 | ADC_HandleTypeDef hadc1; |
elijahsj | 6:417655779dc5 | 12 | ADC_HandleTypeDef hadc2; |
elijahsj | 1:4c3c2b7337a6 | 13 | |
elijahsj | 3:2f46953e7c8b | 14 | int PWM_PERIOD; |
elijahsj | 1:4c3c2b7337a6 | 15 | void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim); |
elijahsj | 1:4c3c2b7337a6 | 16 | static void MX_TIM12_Init(void); |
elijahsj | 2:30503be9a375 | 17 | static void MX_TIM13_Init(void); |
elijahsj | 2:30503be9a375 | 18 | static void MX_TIM14_Init(void); |
elijahsj | 2:30503be9a375 | 19 | static void MX_TIM15_Init(void); |
elijahsj | 2:30503be9a375 | 20 | static void MX_TIM16_Init(void); |
elijahsj | 2:30503be9a375 | 21 | static void MX_TIM17_Init(void); |
elijahsj | 6:417655779dc5 | 22 | static void MX_ADC1_Init(void); |
elijahsj | 6:417655779dc5 | 23 | static void MX_ADC2_Init(void); |
elijahsj | 6:417655779dc5 | 24 | |
elijahsj | 7:e3a2ade56b79 | 25 | void config_adc1_channel(int val); |
elijahsj | 7:e3a2ade56b79 | 26 | void config_adc2_channel(int val); |
elijahsj | 6:417655779dc5 | 27 | |
elijahsj | 7:e3a2ade56b79 | 28 | AnalogIn currentA(PF_12); //Enable ADC hardware pin, don't use AnalogIn reads |
elijahsj | 7:e3a2ade56b79 | 29 | AnalogIn currentB(PF_11); //Enable ADC hardware pin, don't use AnalogIn reads |
elijahsj | 7:e3a2ade56b79 | 30 | AnalogIn currentC(PF_13); //Enable ADC hardware pin, don't use AnalogIn reads |
elijahsj | 7:e3a2ade56b79 | 31 | AnalogIn currentD(PA_4); //Enable ADC hardware pin, don't use AnalogIn reads |
elijahsj | 1:4c3c2b7337a6 | 32 | |
elijahsj | 3:2f46953e7c8b | 33 | void initHardware(int periodTicks){ |
elijahsj | 3:2f46953e7c8b | 34 | PWM_PERIOD = periodTicks; |
elijahsj | 1:4c3c2b7337a6 | 35 | /* Initialise the HAL Layer */ |
elijahsj | 1:4c3c2b7337a6 | 36 | HAL_Init(); |
elijahsj | 1:4c3c2b7337a6 | 37 | |
elijahsj | 1:4c3c2b7337a6 | 38 | /* Initialize all configured peripherals */ |
elijahsj | 1:4c3c2b7337a6 | 39 | MX_TIM12_Init(); |
elijahsj | 2:30503be9a375 | 40 | MX_TIM13_Init(); |
elijahsj | 2:30503be9a375 | 41 | MX_TIM14_Init(); |
elijahsj | 2:30503be9a375 | 42 | MX_TIM15_Init(); |
elijahsj | 2:30503be9a375 | 43 | MX_TIM16_Init(); |
elijahsj | 2:30503be9a375 | 44 | MX_TIM17_Init(); |
elijahsj | 6:417655779dc5 | 45 | MX_ADC1_Init(); |
elijahsj | 6:417655779dc5 | 46 | MX_ADC2_Init(); |
elijahsj | 7:e3a2ade56b79 | 47 | |
elijahsj | 2:30503be9a375 | 48 | |
elijahsj | 1:4c3c2b7337a6 | 49 | HAL_TIM_PWM_Start(&htim12, TIM_CHANNEL_1); // start pwm generation |
elijahsj | 1:4c3c2b7337a6 | 50 | HAL_TIM_PWM_Start(&htim12, TIM_CHANNEL_2); // start pwm generation |
elijahsj | 2:30503be9a375 | 51 | HAL_TIM_PWM_Start(&htim13, TIM_CHANNEL_1); // start pwm generation |
elijahsj | 2:30503be9a375 | 52 | HAL_TIM_PWM_Start(&htim14, TIM_CHANNEL_1); // start pwm generation |
elijahsj | 2:30503be9a375 | 53 | HAL_TIM_PWM_Start(&htim15, TIM_CHANNEL_1); // start pwm generation |
elijahsj | 2:30503be9a375 | 54 | HAL_TIM_PWM_Start(&htim15, TIM_CHANNEL_2); // start pwm generation |
elijahsj | 2:30503be9a375 | 55 | HAL_TIM_PWM_Start(&htim16, TIM_CHANNEL_1); // start pwm generation |
elijahsj | 2:30503be9a375 | 56 | HAL_TIM_PWM_Start(&htim17, TIM_CHANNEL_1); // start pwm generation |
elijahsj | 2:30503be9a375 | 57 | |
elijahsj | 1:4c3c2b7337a6 | 58 | } |
elijahsj | 1:4c3c2b7337a6 | 59 | |
elijahsj | 6:417655779dc5 | 60 | |
elijahsj | 6:417655779dc5 | 61 | |
elijahsj | 6:417655779dc5 | 62 | uint16_t readADC1(int channel){ |
elijahsj | 7:e3a2ade56b79 | 63 | config_adc1_channel(channel); |
elijahsj | 6:417655779dc5 | 64 | HAL_ADC_Start(&hadc1); |
elijahsj | 6:417655779dc5 | 65 | HAL_ADC_PollForConversion(&hadc1,20); |
elijahsj | 7:e3a2ade56b79 | 66 | uint32_t result = HAL_ADC_GetValue(&hadc1); |
elijahsj | 6:417655779dc5 | 67 | HAL_ADC_Stop (&hadc1); |
elijahsj | 7:e3a2ade56b79 | 68 | return result; |
elijahsj | 7:e3a2ade56b79 | 69 | |
elijahsj | 7:e3a2ade56b79 | 70 | } |
elijahsj | 6:417655779dc5 | 71 | |
elijahsj | 7:e3a2ade56b79 | 72 | void config_adc1_channel(int val) |
elijahsj | 7:e3a2ade56b79 | 73 | { |
elijahsj | 7:e3a2ade56b79 | 74 | ADC_ChannelConfTypeDef sConfig; |
elijahsj | 7:e3a2ade56b79 | 75 | if (val == 0){ |
elijahsj | 7:e3a2ade56b79 | 76 | sConfig.Channel = ADC_CHANNEL_6; |
elijahsj | 7:e3a2ade56b79 | 77 | sConfig.Rank = ADC_REGULAR_RANK_1; |
elijahsj | 7:e3a2ade56b79 | 78 | sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5; |
elijahsj | 7:e3a2ade56b79 | 79 | sConfig.SingleDiff = ADC_SINGLE_ENDED; |
elijahsj | 7:e3a2ade56b79 | 80 | sConfig.OffsetNumber = ADC_OFFSET_NONE; |
elijahsj | 7:e3a2ade56b79 | 81 | sConfig.Offset = 0; |
elijahsj | 7:e3a2ade56b79 | 82 | if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) |
elijahsj | 7:e3a2ade56b79 | 83 | { |
elijahsj | 7:e3a2ade56b79 | 84 | //Error_Handler(); |
elijahsj | 7:e3a2ade56b79 | 85 | } |
elijahsj | 7:e3a2ade56b79 | 86 | } |
elijahsj | 7:e3a2ade56b79 | 87 | else{ |
elijahsj | 7:e3a2ade56b79 | 88 | sConfig.Channel = ADC_CHANNEL_2; |
elijahsj | 7:e3a2ade56b79 | 89 | sConfig.Rank = ADC_REGULAR_RANK_1; |
elijahsj | 7:e3a2ade56b79 | 90 | sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5; |
elijahsj | 7:e3a2ade56b79 | 91 | sConfig.SingleDiff = ADC_SINGLE_ENDED; |
elijahsj | 7:e3a2ade56b79 | 92 | sConfig.OffsetNumber = ADC_OFFSET_NONE; |
elijahsj | 7:e3a2ade56b79 | 93 | sConfig.Offset = 0; |
elijahsj | 7:e3a2ade56b79 | 94 | if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) |
elijahsj | 7:e3a2ade56b79 | 95 | { |
elijahsj | 7:e3a2ade56b79 | 96 | //Error_Handler(); |
elijahsj | 7:e3a2ade56b79 | 97 | } |
elijahsj | 7:e3a2ade56b79 | 98 | } |
elijahsj | 7:e3a2ade56b79 | 99 | |
elijahsj | 6:417655779dc5 | 100 | } |
elijahsj | 6:417655779dc5 | 101 | |
elijahsj | 7:e3a2ade56b79 | 102 | |
elijahsj | 6:417655779dc5 | 103 | uint16_t readADC2(int channel){ |
elijahsj | 6:417655779dc5 | 104 | |
elijahsj | 7:e3a2ade56b79 | 105 | config_adc2_channel(channel); |
elijahsj | 6:417655779dc5 | 106 | HAL_ADC_Start(&hadc2); |
elijahsj | 6:417655779dc5 | 107 | HAL_ADC_PollForConversion(&hadc2,20); |
elijahsj | 7:e3a2ade56b79 | 108 | uint32_t result = HAL_ADC_GetValue(&hadc2); |
elijahsj | 6:417655779dc5 | 109 | HAL_ADC_Stop (&hadc2); |
elijahsj | 7:e3a2ade56b79 | 110 | return result; |
elijahsj | 6:417655779dc5 | 111 | } |
elijahsj | 6:417655779dc5 | 112 | |
elijahsj | 7:e3a2ade56b79 | 113 | void config_adc2_channel(int val) |
elijahsj | 7:e3a2ade56b79 | 114 | { |
elijahsj | 7:e3a2ade56b79 | 115 | ADC_ChannelConfTypeDef sConfig; |
elijahsj | 7:e3a2ade56b79 | 116 | if (val == 0){ |
elijahsj | 7:e3a2ade56b79 | 117 | sConfig.Channel = ADC_CHANNEL_18; |
elijahsj | 7:e3a2ade56b79 | 118 | sConfig.Rank = ADC_REGULAR_RANK_1; |
elijahsj | 7:e3a2ade56b79 | 119 | sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5; |
elijahsj | 7:e3a2ade56b79 | 120 | sConfig.SingleDiff = ADC_SINGLE_ENDED; |
elijahsj | 7:e3a2ade56b79 | 121 | sConfig.OffsetNumber = ADC_OFFSET_NONE; |
elijahsj | 7:e3a2ade56b79 | 122 | sConfig.Offset = 0; |
elijahsj | 7:e3a2ade56b79 | 123 | if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK) |
elijahsj | 7:e3a2ade56b79 | 124 | { |
elijahsj | 7:e3a2ade56b79 | 125 | //Error_Handler(); |
elijahsj | 7:e3a2ade56b79 | 126 | } |
elijahsj | 7:e3a2ade56b79 | 127 | } |
elijahsj | 7:e3a2ade56b79 | 128 | else{ |
elijahsj | 7:e3a2ade56b79 | 129 | sConfig.Channel = ADC_CHANNEL_2; |
elijahsj | 7:e3a2ade56b79 | 130 | sConfig.Rank = ADC_REGULAR_RANK_1; |
elijahsj | 7:e3a2ade56b79 | 131 | sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5; |
elijahsj | 7:e3a2ade56b79 | 132 | sConfig.SingleDiff = ADC_SINGLE_ENDED; |
elijahsj | 7:e3a2ade56b79 | 133 | sConfig.OffsetNumber = ADC_OFFSET_NONE; |
elijahsj | 7:e3a2ade56b79 | 134 | sConfig.Offset = 0; |
elijahsj | 7:e3a2ade56b79 | 135 | if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK) |
elijahsj | 7:e3a2ade56b79 | 136 | { |
elijahsj | 7:e3a2ade56b79 | 137 | //Error_Handler(); |
elijahsj | 7:e3a2ade56b79 | 138 | } |
elijahsj | 7:e3a2ade56b79 | 139 | } |
elijahsj | 7:e3a2ade56b79 | 140 | |
elijahsj | 7:e3a2ade56b79 | 141 | } |
elijahsj | 6:417655779dc5 | 142 | |
elijahsj | 6:417655779dc5 | 143 | static void MX_ADC1_Init(void) |
elijahsj | 6:417655779dc5 | 144 | { |
elijahsj | 6:417655779dc5 | 145 | ADC_MultiModeTypeDef multimode = {0}; |
elijahsj | 6:417655779dc5 | 146 | ADC_ChannelConfTypeDef sConfig = {0}; |
elijahsj | 6:417655779dc5 | 147 | /** Common config |
elijahsj | 6:417655779dc5 | 148 | */ |
elijahsj | 6:417655779dc5 | 149 | hadc1.Instance = ADC1; |
elijahsj | 6:417655779dc5 | 150 | hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1; |
elijahsj | 6:417655779dc5 | 151 | hadc1.Init.Resolution = ADC_RESOLUTION_16B; |
elijahsj | 7:e3a2ade56b79 | 152 | hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE; |
elijahsj | 6:417655779dc5 | 153 | hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV; |
elijahsj | 6:417655779dc5 | 154 | hadc1.Init.LowPowerAutoWait = DISABLE; |
elijahsj | 6:417655779dc5 | 155 | hadc1.Init.ContinuousConvMode = ENABLE; |
elijahsj | 7:e3a2ade56b79 | 156 | hadc1.Init.NbrOfConversion = 1; |
elijahsj | 6:417655779dc5 | 157 | hadc1.Init.DiscontinuousConvMode = DISABLE; |
elijahsj | 6:417655779dc5 | 158 | hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; |
elijahsj | 6:417655779dc5 | 159 | hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; |
elijahsj | 6:417655779dc5 | 160 | hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR; |
elijahsj | 6:417655779dc5 | 161 | hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED; |
elijahsj | 6:417655779dc5 | 162 | hadc1.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE; |
elijahsj | 6:417655779dc5 | 163 | hadc1.Init.OversamplingMode = DISABLE; |
elijahsj | 6:417655779dc5 | 164 | if (HAL_ADC_Init(&hadc1) != HAL_OK) |
elijahsj | 6:417655779dc5 | 165 | { |
elijahsj | 6:417655779dc5 | 166 | //Error_Handler(); |
elijahsj | 6:417655779dc5 | 167 | } |
elijahsj | 6:417655779dc5 | 168 | /** Configure Regular Channel |
elijahsj | 6:417655779dc5 | 169 | */ |
elijahsj | 6:417655779dc5 | 170 | sConfig.Channel = ADC_CHANNEL_2; |
elijahsj | 6:417655779dc5 | 171 | sConfig.Rank = ADC_REGULAR_RANK_1; |
elijahsj | 6:417655779dc5 | 172 | sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5; |
elijahsj | 6:417655779dc5 | 173 | sConfig.SingleDiff = ADC_SINGLE_ENDED; |
elijahsj | 6:417655779dc5 | 174 | sConfig.OffsetNumber = ADC_OFFSET_NONE; |
elijahsj | 6:417655779dc5 | 175 | sConfig.Offset = 0; |
elijahsj | 6:417655779dc5 | 176 | if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) |
elijahsj | 6:417655779dc5 | 177 | { |
elijahsj | 6:417655779dc5 | 178 | //Error_Handler(); |
elijahsj | 6:417655779dc5 | 179 | } |
elijahsj | 6:417655779dc5 | 180 | } |
elijahsj | 6:417655779dc5 | 181 | |
elijahsj | 6:417655779dc5 | 182 | /** |
elijahsj | 6:417655779dc5 | 183 | * @brief ADC2 Initialization Function |
elijahsj | 6:417655779dc5 | 184 | * @param None |
elijahsj | 6:417655779dc5 | 185 | * @retval None |
elijahsj | 6:417655779dc5 | 186 | */ |
elijahsj | 6:417655779dc5 | 187 | static void MX_ADC2_Init(void) |
elijahsj | 6:417655779dc5 | 188 | { |
elijahsj | 6:417655779dc5 | 189 | ADC_ChannelConfTypeDef sConfig = {0}; |
elijahsj | 6:417655779dc5 | 190 | /** Common config |
elijahsj | 6:417655779dc5 | 191 | */ |
elijahsj | 6:417655779dc5 | 192 | hadc2.Instance = ADC2; |
elijahsj | 6:417655779dc5 | 193 | hadc2.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1; |
elijahsj | 6:417655779dc5 | 194 | hadc2.Init.Resolution = ADC_RESOLUTION_16B; |
elijahsj | 7:e3a2ade56b79 | 195 | hadc2.Init.ScanConvMode = ADC_SCAN_DISABLE; |
elijahsj | 6:417655779dc5 | 196 | hadc2.Init.EOCSelection = ADC_EOC_SINGLE_CONV; |
elijahsj | 6:417655779dc5 | 197 | hadc2.Init.LowPowerAutoWait = DISABLE; |
elijahsj | 6:417655779dc5 | 198 | hadc2.Init.ContinuousConvMode = ENABLE; |
elijahsj | 7:e3a2ade56b79 | 199 | hadc2.Init.NbrOfConversion = 1; |
elijahsj | 6:417655779dc5 | 200 | hadc2.Init.DiscontinuousConvMode = DISABLE; |
elijahsj | 6:417655779dc5 | 201 | hadc2.Init.ExternalTrigConv = ADC_SOFTWARE_START; |
elijahsj | 6:417655779dc5 | 202 | hadc2.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; |
elijahsj | 6:417655779dc5 | 203 | hadc2.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR; |
elijahsj | 6:417655779dc5 | 204 | hadc2.Init.Overrun = ADC_OVR_DATA_PRESERVED; |
elijahsj | 6:417655779dc5 | 205 | hadc2.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE; |
elijahsj | 6:417655779dc5 | 206 | hadc2.Init.OversamplingMode = DISABLE; |
elijahsj | 6:417655779dc5 | 207 | if (HAL_ADC_Init(&hadc2) != HAL_OK) |
elijahsj | 6:417655779dc5 | 208 | { |
elijahsj | 6:417655779dc5 | 209 | //Error_Handler(); |
elijahsj | 6:417655779dc5 | 210 | } |
elijahsj | 7:e3a2ade56b79 | 211 | |
elijahsj | 6:417655779dc5 | 212 | /** Configure Regular Channel |
elijahsj | 6:417655779dc5 | 213 | */ |
elijahsj | 6:417655779dc5 | 214 | sConfig.Channel = ADC_CHANNEL_2; |
elijahsj | 6:417655779dc5 | 215 | sConfig.Rank = ADC_REGULAR_RANK_1; |
elijahsj | 6:417655779dc5 | 216 | sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5; |
elijahsj | 6:417655779dc5 | 217 | sConfig.SingleDiff = ADC_SINGLE_ENDED; |
elijahsj | 6:417655779dc5 | 218 | sConfig.OffsetNumber = ADC_OFFSET_NONE; |
elijahsj | 6:417655779dc5 | 219 | sConfig.Offset = 0; |
elijahsj | 6:417655779dc5 | 220 | if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK) |
elijahsj | 6:417655779dc5 | 221 | { |
elijahsj | 6:417655779dc5 | 222 | //Error_Handler(); |
elijahsj | 6:417655779dc5 | 223 | } |
elijahsj | 6:417655779dc5 | 224 | |
elijahsj | 6:417655779dc5 | 225 | } |
elijahsj | 6:417655779dc5 | 226 | |
elijahsj | 6:417655779dc5 | 227 | |
elijahsj | 1:4c3c2b7337a6 | 228 | static void MX_TIM12_Init(void) |
elijahsj | 1:4c3c2b7337a6 | 229 | { |
elijahsj | 1:4c3c2b7337a6 | 230 | __HAL_RCC_TIM12_CLK_ENABLE(); |
elijahsj | 1:4c3c2b7337a6 | 231 | TIM_OC_InitTypeDef sConfigOC = {0}; |
elijahsj | 1:4c3c2b7337a6 | 232 | htim12.Instance = TIM12; |
elijahsj | 1:4c3c2b7337a6 | 233 | htim12.Init.Prescaler = 0; |
elijahsj | 1:4c3c2b7337a6 | 234 | htim12.Init.CounterMode = TIM_COUNTERMODE_UP; |
elijahsj | 1:4c3c2b7337a6 | 235 | htim12.Init.Period = PWM_PERIOD; |
elijahsj | 1:4c3c2b7337a6 | 236 | htim12.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; |
elijahsj | 1:4c3c2b7337a6 | 237 | htim12.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; |
elijahsj | 1:4c3c2b7337a6 | 238 | if (HAL_TIM_PWM_Init(&htim12) != HAL_OK) |
elijahsj | 1:4c3c2b7337a6 | 239 | { |
elijahsj | 1:4c3c2b7337a6 | 240 | //Error_Handler(); |
elijahsj | 1:4c3c2b7337a6 | 241 | } |
elijahsj | 1:4c3c2b7337a6 | 242 | sConfigOC.OCMode = TIM_OCMODE_PWM1; |
elijahsj | 1:4c3c2b7337a6 | 243 | sConfigOC.Pulse = 0; |
elijahsj | 1:4c3c2b7337a6 | 244 | sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; |
elijahsj | 1:4c3c2b7337a6 | 245 | sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; |
elijahsj | 1:4c3c2b7337a6 | 246 | if (HAL_TIM_PWM_ConfigChannel(&htim12, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) |
elijahsj | 1:4c3c2b7337a6 | 247 | { |
elijahsj | 1:4c3c2b7337a6 | 248 | //Error_Handler(); |
elijahsj | 1:4c3c2b7337a6 | 249 | } |
elijahsj | 1:4c3c2b7337a6 | 250 | if (HAL_TIM_PWM_ConfigChannel(&htim12, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) |
elijahsj | 1:4c3c2b7337a6 | 251 | { |
elijahsj | 1:4c3c2b7337a6 | 252 | //Error_Handler(); |
elijahsj | 1:4c3c2b7337a6 | 253 | } |
elijahsj | 2:30503be9a375 | 254 | HAL_TIM_MspPostInit(&htim12); |
elijahsj | 2:30503be9a375 | 255 | } |
elijahsj | 2:30503be9a375 | 256 | |
elijahsj | 2:30503be9a375 | 257 | static void MX_TIM13_Init(void) |
elijahsj | 2:30503be9a375 | 258 | { |
elijahsj | 2:30503be9a375 | 259 | __HAL_RCC_TIM13_CLK_ENABLE(); |
elijahsj | 2:30503be9a375 | 260 | TIM_OC_InitTypeDef sConfigOC = {0}; |
elijahsj | 2:30503be9a375 | 261 | htim13.Instance = TIM13; |
elijahsj | 2:30503be9a375 | 262 | htim13.Init.Prescaler = 0; |
elijahsj | 2:30503be9a375 | 263 | htim13.Init.CounterMode = TIM_COUNTERMODE_UP; |
elijahsj | 2:30503be9a375 | 264 | htim13.Init.Period = PWM_PERIOD; |
elijahsj | 2:30503be9a375 | 265 | htim13.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; |
elijahsj | 2:30503be9a375 | 266 | htim13.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; |
elijahsj | 2:30503be9a375 | 267 | if (HAL_TIM_Base_Init(&htim13) != HAL_OK) |
elijahsj | 2:30503be9a375 | 268 | { |
elijahsj | 2:30503be9a375 | 269 | //Error_Handler(); |
elijahsj | 2:30503be9a375 | 270 | } |
elijahsj | 2:30503be9a375 | 271 | if (HAL_TIM_PWM_Init(&htim13) != HAL_OK) |
elijahsj | 2:30503be9a375 | 272 | { |
elijahsj | 2:30503be9a375 | 273 | //Error_Handler(); |
elijahsj | 2:30503be9a375 | 274 | } |
elijahsj | 2:30503be9a375 | 275 | sConfigOC.OCMode = TIM_OCMODE_PWM1; |
elijahsj | 2:30503be9a375 | 276 | sConfigOC.Pulse = 0; |
elijahsj | 2:30503be9a375 | 277 | sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; |
elijahsj | 2:30503be9a375 | 278 | sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; |
elijahsj | 2:30503be9a375 | 279 | if (HAL_TIM_PWM_ConfigChannel(&htim13, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) |
elijahsj | 2:30503be9a375 | 280 | { |
elijahsj | 2:30503be9a375 | 281 | //Error_Handler(); |
elijahsj | 2:30503be9a375 | 282 | } |
elijahsj | 2:30503be9a375 | 283 | HAL_TIM_MspPostInit(&htim13); |
elijahsj | 2:30503be9a375 | 284 | } |
elijahsj | 2:30503be9a375 | 285 | |
elijahsj | 2:30503be9a375 | 286 | static void MX_TIM14_Init(void) |
elijahsj | 2:30503be9a375 | 287 | { |
elijahsj | 2:30503be9a375 | 288 | __HAL_RCC_TIM14_CLK_ENABLE(); |
elijahsj | 2:30503be9a375 | 289 | TIM_OC_InitTypeDef sConfigOC = {0}; |
elijahsj | 2:30503be9a375 | 290 | htim14.Instance = TIM14; |
elijahsj | 2:30503be9a375 | 291 | htim14.Init.Prescaler = 0; |
elijahsj | 2:30503be9a375 | 292 | htim14.Init.CounterMode = TIM_COUNTERMODE_UP; |
elijahsj | 2:30503be9a375 | 293 | htim14.Init.Period = PWM_PERIOD; |
elijahsj | 2:30503be9a375 | 294 | htim14.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; |
elijahsj | 2:30503be9a375 | 295 | htim14.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; |
elijahsj | 2:30503be9a375 | 296 | if (HAL_TIM_Base_Init(&htim14) != HAL_OK) |
elijahsj | 2:30503be9a375 | 297 | { |
elijahsj | 2:30503be9a375 | 298 | //Error_Handler(); |
elijahsj | 2:30503be9a375 | 299 | } |
elijahsj | 2:30503be9a375 | 300 | if (HAL_TIM_PWM_Init(&htim14) != HAL_OK) |
elijahsj | 2:30503be9a375 | 301 | { |
elijahsj | 2:30503be9a375 | 302 | //Error_Handler(); |
elijahsj | 2:30503be9a375 | 303 | } |
elijahsj | 2:30503be9a375 | 304 | sConfigOC.OCMode = TIM_OCMODE_PWM1; |
elijahsj | 2:30503be9a375 | 305 | sConfigOC.Pulse = 0; |
elijahsj | 2:30503be9a375 | 306 | sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; |
elijahsj | 2:30503be9a375 | 307 | sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; |
elijahsj | 2:30503be9a375 | 308 | if (HAL_TIM_PWM_ConfigChannel(&htim14, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) |
elijahsj | 2:30503be9a375 | 309 | { |
elijahsj | 2:30503be9a375 | 310 | //Error_Handler(); |
elijahsj | 2:30503be9a375 | 311 | } |
elijahsj | 2:30503be9a375 | 312 | HAL_TIM_MspPostInit(&htim14); |
elijahsj | 2:30503be9a375 | 313 | } |
elijahsj | 1:4c3c2b7337a6 | 314 | |
elijahsj | 2:30503be9a375 | 315 | static void MX_TIM15_Init(void) |
elijahsj | 2:30503be9a375 | 316 | { |
elijahsj | 2:30503be9a375 | 317 | __HAL_RCC_TIM15_CLK_ENABLE(); |
elijahsj | 2:30503be9a375 | 318 | TIM_MasterConfigTypeDef sMasterConfig = {0}; |
elijahsj | 2:30503be9a375 | 319 | TIM_OC_InitTypeDef sConfigOC = {0}; |
elijahsj | 2:30503be9a375 | 320 | TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0}; |
elijahsj | 2:30503be9a375 | 321 | htim15.Instance = TIM15; |
elijahsj | 2:30503be9a375 | 322 | htim15.Init.Prescaler = 0; |
elijahsj | 2:30503be9a375 | 323 | htim15.Init.CounterMode = TIM_COUNTERMODE_UP; |
elijahsj | 2:30503be9a375 | 324 | htim15.Init.Period = PWM_PERIOD; |
elijahsj | 2:30503be9a375 | 325 | htim15.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; |
elijahsj | 2:30503be9a375 | 326 | htim15.Init.RepetitionCounter = 0; |
elijahsj | 2:30503be9a375 | 327 | htim15.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; |
elijahsj | 2:30503be9a375 | 328 | if (HAL_TIM_PWM_Init(&htim15) != HAL_OK) |
elijahsj | 2:30503be9a375 | 329 | { |
elijahsj | 2:30503be9a375 | 330 | //Error_Handler(); |
elijahsj | 2:30503be9a375 | 331 | } |
elijahsj | 2:30503be9a375 | 332 | sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; |
elijahsj | 2:30503be9a375 | 333 | sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; |
elijahsj | 2:30503be9a375 | 334 | if (HAL_TIMEx_MasterConfigSynchronization(&htim15, &sMasterConfig) != HAL_OK) |
elijahsj | 2:30503be9a375 | 335 | { |
elijahsj | 2:30503be9a375 | 336 | //Error_Handler(); |
elijahsj | 2:30503be9a375 | 337 | } |
elijahsj | 2:30503be9a375 | 338 | sConfigOC.OCMode = TIM_OCMODE_PWM1; |
elijahsj | 2:30503be9a375 | 339 | sConfigOC.Pulse = 0; |
elijahsj | 2:30503be9a375 | 340 | sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; |
elijahsj | 2:30503be9a375 | 341 | sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH; |
elijahsj | 2:30503be9a375 | 342 | sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; |
elijahsj | 2:30503be9a375 | 343 | sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET; |
elijahsj | 2:30503be9a375 | 344 | sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET; |
elijahsj | 2:30503be9a375 | 345 | if (HAL_TIM_PWM_ConfigChannel(&htim15, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) |
elijahsj | 2:30503be9a375 | 346 | { |
elijahsj | 2:30503be9a375 | 347 | //Error_Handler(); |
elijahsj | 2:30503be9a375 | 348 | } |
elijahsj | 2:30503be9a375 | 349 | if (HAL_TIM_PWM_ConfigChannel(&htim15, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) |
elijahsj | 2:30503be9a375 | 350 | { |
elijahsj | 2:30503be9a375 | 351 | //Error_Handler(); |
elijahsj | 2:30503be9a375 | 352 | } |
elijahsj | 2:30503be9a375 | 353 | sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE; |
elijahsj | 2:30503be9a375 | 354 | sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE; |
elijahsj | 2:30503be9a375 | 355 | sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF; |
elijahsj | 2:30503be9a375 | 356 | sBreakDeadTimeConfig.DeadTime = 0; |
elijahsj | 2:30503be9a375 | 357 | sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE; |
elijahsj | 2:30503be9a375 | 358 | sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH; |
elijahsj | 2:30503be9a375 | 359 | sBreakDeadTimeConfig.BreakFilter = 0; |
elijahsj | 2:30503be9a375 | 360 | sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE; |
elijahsj | 2:30503be9a375 | 361 | if (HAL_TIMEx_ConfigBreakDeadTime(&htim15, &sBreakDeadTimeConfig) != HAL_OK) |
elijahsj | 2:30503be9a375 | 362 | { |
elijahsj | 2:30503be9a375 | 363 | //Error_Handler(); |
elijahsj | 2:30503be9a375 | 364 | } |
elijahsj | 2:30503be9a375 | 365 | HAL_TIM_MspPostInit(&htim15); |
elijahsj | 2:30503be9a375 | 366 | |
elijahsj | 2:30503be9a375 | 367 | } |
elijahsj | 2:30503be9a375 | 368 | |
elijahsj | 2:30503be9a375 | 369 | static void MX_TIM16_Init(void) |
elijahsj | 2:30503be9a375 | 370 | { |
elijahsj | 2:30503be9a375 | 371 | __HAL_RCC_TIM16_CLK_ENABLE(); |
elijahsj | 2:30503be9a375 | 372 | TIM_OC_InitTypeDef sConfigOC = {0}; |
elijahsj | 2:30503be9a375 | 373 | TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0}; |
elijahsj | 2:30503be9a375 | 374 | htim16.Instance = TIM16; |
elijahsj | 2:30503be9a375 | 375 | htim16.Init.Prescaler = 0; |
elijahsj | 2:30503be9a375 | 376 | htim16.Init.CounterMode = TIM_COUNTERMODE_UP; |
elijahsj | 2:30503be9a375 | 377 | htim16.Init.Period = PWM_PERIOD; |
elijahsj | 2:30503be9a375 | 378 | htim16.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; |
elijahsj | 2:30503be9a375 | 379 | htim16.Init.RepetitionCounter = 0; |
elijahsj | 2:30503be9a375 | 380 | htim16.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; |
elijahsj | 2:30503be9a375 | 381 | if (HAL_TIM_Base_Init(&htim16) != HAL_OK) |
elijahsj | 2:30503be9a375 | 382 | { |
elijahsj | 2:30503be9a375 | 383 | //Error_Handler(); |
elijahsj | 2:30503be9a375 | 384 | } |
elijahsj | 2:30503be9a375 | 385 | if (HAL_TIM_PWM_Init(&htim16) != HAL_OK) |
elijahsj | 2:30503be9a375 | 386 | { |
elijahsj | 2:30503be9a375 | 387 | //Error_Handler(); |
elijahsj | 2:30503be9a375 | 388 | } |
elijahsj | 2:30503be9a375 | 389 | sConfigOC.OCMode = TIM_OCMODE_PWM1; |
elijahsj | 2:30503be9a375 | 390 | sConfigOC.Pulse = 0; |
elijahsj | 2:30503be9a375 | 391 | sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; |
elijahsj | 2:30503be9a375 | 392 | sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH; |
elijahsj | 2:30503be9a375 | 393 | sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; |
elijahsj | 2:30503be9a375 | 394 | sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET; |
elijahsj | 2:30503be9a375 | 395 | sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET; |
elijahsj | 2:30503be9a375 | 396 | if (HAL_TIM_PWM_ConfigChannel(&htim16, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) |
elijahsj | 2:30503be9a375 | 397 | { |
elijahsj | 2:30503be9a375 | 398 | //Error_Handler(); |
elijahsj | 2:30503be9a375 | 399 | } |
elijahsj | 2:30503be9a375 | 400 | sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE; |
elijahsj | 2:30503be9a375 | 401 | sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE; |
elijahsj | 2:30503be9a375 | 402 | sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF; |
elijahsj | 2:30503be9a375 | 403 | sBreakDeadTimeConfig.DeadTime = 0; |
elijahsj | 2:30503be9a375 | 404 | sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE; |
elijahsj | 2:30503be9a375 | 405 | sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH; |
elijahsj | 2:30503be9a375 | 406 | sBreakDeadTimeConfig.BreakFilter = 0; |
elijahsj | 2:30503be9a375 | 407 | sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE; |
elijahsj | 2:30503be9a375 | 408 | if (HAL_TIMEx_ConfigBreakDeadTime(&htim16, &sBreakDeadTimeConfig) != HAL_OK) |
elijahsj | 2:30503be9a375 | 409 | { |
elijahsj | 2:30503be9a375 | 410 | //Error_Handler(); |
elijahsj | 2:30503be9a375 | 411 | } |
elijahsj | 2:30503be9a375 | 412 | HAL_TIM_MspPostInit(&htim16); |
elijahsj | 2:30503be9a375 | 413 | |
elijahsj | 2:30503be9a375 | 414 | } |
elijahsj | 2:30503be9a375 | 415 | |
elijahsj | 2:30503be9a375 | 416 | static void MX_TIM17_Init(void) |
elijahsj | 2:30503be9a375 | 417 | { |
elijahsj | 2:30503be9a375 | 418 | __HAL_RCC_TIM17_CLK_ENABLE(); |
elijahsj | 2:30503be9a375 | 419 | TIM_OC_InitTypeDef sConfigOC = {0}; |
elijahsj | 2:30503be9a375 | 420 | TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0}; |
elijahsj | 2:30503be9a375 | 421 | htim17.Instance = TIM17; |
elijahsj | 2:30503be9a375 | 422 | htim17.Init.Prescaler = 0; |
elijahsj | 2:30503be9a375 | 423 | htim17.Init.CounterMode = TIM_COUNTERMODE_UP; |
elijahsj | 2:30503be9a375 | 424 | htim17.Init.Period = PWM_PERIOD; |
elijahsj | 2:30503be9a375 | 425 | htim17.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; |
elijahsj | 2:30503be9a375 | 426 | htim17.Init.RepetitionCounter = 0; |
elijahsj | 2:30503be9a375 | 427 | htim17.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; |
elijahsj | 2:30503be9a375 | 428 | if (HAL_TIM_Base_Init(&htim17) != HAL_OK) |
elijahsj | 2:30503be9a375 | 429 | { |
elijahsj | 2:30503be9a375 | 430 | //Error_Handler(); |
elijahsj | 2:30503be9a375 | 431 | } |
elijahsj | 2:30503be9a375 | 432 | if (HAL_TIM_PWM_Init(&htim17) != HAL_OK) |
elijahsj | 2:30503be9a375 | 433 | { |
elijahsj | 2:30503be9a375 | 434 | //Error_Handler(); |
elijahsj | 2:30503be9a375 | 435 | } |
elijahsj | 2:30503be9a375 | 436 | sConfigOC.OCMode = TIM_OCMODE_PWM1; |
elijahsj | 2:30503be9a375 | 437 | sConfigOC.Pulse = 0; |
elijahsj | 2:30503be9a375 | 438 | sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; |
elijahsj | 2:30503be9a375 | 439 | sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH; |
elijahsj | 2:30503be9a375 | 440 | sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; |
elijahsj | 2:30503be9a375 | 441 | sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET; |
elijahsj | 2:30503be9a375 | 442 | sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET; |
elijahsj | 2:30503be9a375 | 443 | if (HAL_TIM_PWM_ConfigChannel(&htim17, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) |
elijahsj | 2:30503be9a375 | 444 | { |
elijahsj | 2:30503be9a375 | 445 | //Error_Handler(); |
elijahsj | 2:30503be9a375 | 446 | } |
elijahsj | 2:30503be9a375 | 447 | sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE; |
elijahsj | 2:30503be9a375 | 448 | sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE; |
elijahsj | 2:30503be9a375 | 449 | sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF; |
elijahsj | 2:30503be9a375 | 450 | sBreakDeadTimeConfig.DeadTime = 0; |
elijahsj | 2:30503be9a375 | 451 | sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE; |
elijahsj | 2:30503be9a375 | 452 | sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH; |
elijahsj | 2:30503be9a375 | 453 | sBreakDeadTimeConfig.BreakFilter = 0; |
elijahsj | 2:30503be9a375 | 454 | sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE; |
elijahsj | 2:30503be9a375 | 455 | if (HAL_TIMEx_ConfigBreakDeadTime(&htim17, &sBreakDeadTimeConfig) != HAL_OK) |
elijahsj | 2:30503be9a375 | 456 | { |
elijahsj | 2:30503be9a375 | 457 | //Error_Handler(); |
elijahsj | 2:30503be9a375 | 458 | } |
elijahsj | 2:30503be9a375 | 459 | HAL_TIM_MspPostInit(&htim17); |
elijahsj | 2:30503be9a375 | 460 | |
elijahsj | 1:4c3c2b7337a6 | 461 | } |
elijahsj | 1:4c3c2b7337a6 | 462 | |
elijahsj | 1:4c3c2b7337a6 | 463 | void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) |
elijahsj | 1:4c3c2b7337a6 | 464 | { |
elijahsj | 2:30503be9a375 | 465 | /* GPIO Ports Clock Enable */ |
elijahsj | 1:4c3c2b7337a6 | 466 | __HAL_RCC_GPIOE_CLK_ENABLE(); |
elijahsj | 1:4c3c2b7337a6 | 467 | __HAL_RCC_GPIOC_CLK_ENABLE(); |
elijahsj | 1:4c3c2b7337a6 | 468 | __HAL_RCC_GPIOF_CLK_ENABLE(); |
elijahsj | 1:4c3c2b7337a6 | 469 | __HAL_RCC_GPIOH_CLK_ENABLE(); |
elijahsj | 1:4c3c2b7337a6 | 470 | __HAL_RCC_GPIOA_CLK_ENABLE(); |
elijahsj | 1:4c3c2b7337a6 | 471 | __HAL_RCC_GPIOB_CLK_ENABLE(); |
elijahsj | 1:4c3c2b7337a6 | 472 | __HAL_RCC_GPIOD_CLK_ENABLE(); |
elijahsj | 1:4c3c2b7337a6 | 473 | __HAL_RCC_GPIOG_CLK_ENABLE(); |
elijahsj | 1:4c3c2b7337a6 | 474 | |
elijahsj | 1:4c3c2b7337a6 | 475 | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
elijahsj | 1:4c3c2b7337a6 | 476 | if(htim->Instance==TIM12) |
elijahsj | 1:4c3c2b7337a6 | 477 | { |
elijahsj | 1:4c3c2b7337a6 | 478 | |
elijahsj | 1:4c3c2b7337a6 | 479 | /**TIM12 GPIO Configuration |
elijahsj | 1:4c3c2b7337a6 | 480 | PB14 ------> TIM12_CH1 |
elijahsj | 1:4c3c2b7337a6 | 481 | PB15 ------> TIM12_CH2 |
elijahsj | 1:4c3c2b7337a6 | 482 | */ |
elijahsj | 1:4c3c2b7337a6 | 483 | GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15; |
elijahsj | 1:4c3c2b7337a6 | 484 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
elijahsj | 1:4c3c2b7337a6 | 485 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
elijahsj | 1:4c3c2b7337a6 | 486 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
elijahsj | 1:4c3c2b7337a6 | 487 | GPIO_InitStruct.Alternate = GPIO_AF2_TIM12; |
elijahsj | 1:4c3c2b7337a6 | 488 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
elijahsj | 1:4c3c2b7337a6 | 489 | } |
elijahsj | 1:4c3c2b7337a6 | 490 | else if(htim->Instance==TIM13) |
elijahsj | 1:4c3c2b7337a6 | 491 | { |
elijahsj | 1:4c3c2b7337a6 | 492 | /**TIM13 GPIO Configuration |
elijahsj | 1:4c3c2b7337a6 | 493 | PA6 ------> TIM13_CH1 |
elijahsj | 1:4c3c2b7337a6 | 494 | */ |
elijahsj | 1:4c3c2b7337a6 | 495 | GPIO_InitStruct.Pin = GPIO_PIN_6; |
elijahsj | 1:4c3c2b7337a6 | 496 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
elijahsj | 1:4c3c2b7337a6 | 497 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
elijahsj | 1:4c3c2b7337a6 | 498 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
elijahsj | 1:4c3c2b7337a6 | 499 | GPIO_InitStruct.Alternate = GPIO_AF9_TIM13; |
elijahsj | 1:4c3c2b7337a6 | 500 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
elijahsj | 1:4c3c2b7337a6 | 501 | } |
elijahsj | 1:4c3c2b7337a6 | 502 | else if(htim->Instance==TIM14) |
elijahsj | 1:4c3c2b7337a6 | 503 | { |
elijahsj | 1:4c3c2b7337a6 | 504 | /**TIM14 GPIO Configuration |
elijahsj | 1:4c3c2b7337a6 | 505 | PF9 ------> TIM14_CH1 |
elijahsj | 1:4c3c2b7337a6 | 506 | */ |
elijahsj | 1:4c3c2b7337a6 | 507 | GPIO_InitStruct.Pin = GPIO_PIN_9; |
elijahsj | 1:4c3c2b7337a6 | 508 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
elijahsj | 1:4c3c2b7337a6 | 509 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
elijahsj | 1:4c3c2b7337a6 | 510 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
elijahsj | 1:4c3c2b7337a6 | 511 | GPIO_InitStruct.Alternate = GPIO_AF9_TIM14; |
elijahsj | 1:4c3c2b7337a6 | 512 | HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); |
elijahsj | 1:4c3c2b7337a6 | 513 | } |
elijahsj | 1:4c3c2b7337a6 | 514 | else if(htim->Instance==TIM15) |
elijahsj | 1:4c3c2b7337a6 | 515 | { |
elijahsj | 1:4c3c2b7337a6 | 516 | /**TIM15 GPIO Configuration |
elijahsj | 1:4c3c2b7337a6 | 517 | PE5 ------> TIM15_CH1 |
elijahsj | 1:4c3c2b7337a6 | 518 | PE6 ------> TIM15_CH2 |
elijahsj | 1:4c3c2b7337a6 | 519 | */ |
elijahsj | 1:4c3c2b7337a6 | 520 | GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6; |
elijahsj | 1:4c3c2b7337a6 | 521 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
elijahsj | 1:4c3c2b7337a6 | 522 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
elijahsj | 1:4c3c2b7337a6 | 523 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
elijahsj | 1:4c3c2b7337a6 | 524 | GPIO_InitStruct.Alternate = GPIO_AF4_TIM15; |
elijahsj | 1:4c3c2b7337a6 | 525 | HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); |
elijahsj | 1:4c3c2b7337a6 | 526 | } |
elijahsj | 1:4c3c2b7337a6 | 527 | else if(htim->Instance==TIM16) |
elijahsj | 1:4c3c2b7337a6 | 528 | { |
elijahsj | 1:4c3c2b7337a6 | 529 | /**TIM16 GPIO Configuration |
elijahsj | 1:4c3c2b7337a6 | 530 | PF6 ------> TIM16_CH1 |
elijahsj | 1:4c3c2b7337a6 | 531 | */ |
elijahsj | 1:4c3c2b7337a6 | 532 | GPIO_InitStruct.Pin = GPIO_PIN_6; |
elijahsj | 1:4c3c2b7337a6 | 533 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
elijahsj | 1:4c3c2b7337a6 | 534 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
elijahsj | 1:4c3c2b7337a6 | 535 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
elijahsj | 1:4c3c2b7337a6 | 536 | GPIO_InitStruct.Alternate = GPIO_AF1_TIM16; |
elijahsj | 1:4c3c2b7337a6 | 537 | HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); |
elijahsj | 1:4c3c2b7337a6 | 538 | } |
elijahsj | 1:4c3c2b7337a6 | 539 | else if(htim->Instance==TIM17) |
elijahsj | 1:4c3c2b7337a6 | 540 | { |
elijahsj | 1:4c3c2b7337a6 | 541 | /**TIM17 GPIO Configuration |
elijahsj | 1:4c3c2b7337a6 | 542 | PF7 ------> TIM17_CH1 |
elijahsj | 1:4c3c2b7337a6 | 543 | */ |
elijahsj | 1:4c3c2b7337a6 | 544 | GPIO_InitStruct.Pin = GPIO_PIN_7; |
elijahsj | 1:4c3c2b7337a6 | 545 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
elijahsj | 1:4c3c2b7337a6 | 546 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
elijahsj | 1:4c3c2b7337a6 | 547 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
elijahsj | 1:4c3c2b7337a6 | 548 | GPIO_InitStruct.Alternate = GPIO_AF1_TIM17; |
elijahsj | 1:4c3c2b7337a6 | 549 | HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); |
elijahsj | 1:4c3c2b7337a6 | 550 | } |
elijahsj | 1:4c3c2b7337a6 | 551 | |
elijahsj | 1:4c3c2b7337a6 | 552 | } |
elijahsj | 1:4c3c2b7337a6 | 553 | |
elijahsj | 1:4c3c2b7337a6 | 554 | |
elijahsj | 1:4c3c2b7337a6 | 555 | |
elijahsj | 1:4c3c2b7337a6 | 556 |