File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed
Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,18 @@ void AF_Tim2_pins_encoder(){
1414 HAL_GPIO_Init (GPIOA , & GPIO_InitStruct );
1515}
1616
17+ // Set PA_0 and PA_1 as alternate function 1 -> TIM5
18+ void AF_Tim5_pins_encoder (){
19+ GPIO_InitTypeDef GPIO_InitStruct ;
20+ __HAL_RCC_TIM5_CLK_ENABLE ();
21+ __HAL_RCC_GPIOA_CLK_ENABLE ();
22+ GPIO_InitStruct .Pin = GPIO_PIN_0 |GPIO_PIN_1 ;
23+ GPIO_InitStruct .Mode = GPIO_MODE_AF_PP ;
24+ GPIO_InitStruct .Pull = GPIO_NOPULL ;
25+ GPIO_InitStruct .Alternate = GPIO_AF2_TIM5 ;
26+ HAL_GPIO_Init (GPIOA , & GPIO_InitStruct );
27+ }
28+
1729// Set PC_6 and PC_7 as alternate function 2 -> TIM3
1830void AF_Tim3_pins_encoder (){
1931 GPIO_InitTypeDef GPIO_InitStruct ;
Original file line number Diff line number Diff line change 11#include " Arduino_Robot_Firmware.h"
22
3- Encoder enc_right (TIM2 );
3+ Encoder enc_right (TIM5 );
44Encoder enc_left (TIM3);
55RGBled led1 (LED_1_RED, LED_1_GREEN, LED_1_BLUE);
66
77
88void setup (){
99 Serial.begin (115200 );
1010 Serial.println (" Start" );
11- AF_Tim2_pins_encoder ();
11+ AF_Tim5_pins_encoder ();
1212 AF_Tim3_pins_encoder ();
1313 enc_right.begin ();
1414 enc_left.begin ();
You can’t perform that action at this time.
0 commit comments