File tree Expand file tree Collapse file tree 3 files changed +8
-9
lines changed
Expand file tree Collapse file tree 3 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ STM32SpeedDirInput::~STM32SpeedDirInput(){};
1212
1313int STM32SpeedDirInput::init (){
1414 pinMode (_pin_dir, INPUT);
15- return STM32PWMInput::init ();
15+ return STM32PWMInput::initialize ();
1616};
1717
1818
Original file line number Diff line number Diff line change 66
77
88STM32PWMInput::STM32PWMInput (int pin){
9- _pin = pin;
9+ _pin = digitalPinToPinName ( pin) ;
1010};
1111
1212
@@ -16,11 +16,10 @@ STM32PWMInput::~STM32PWMInput(){};
1616
1717
1818
19- int STM32PWMInput::init (){
20- PinName pinN = digitalPinToPinName (_pin);
21- pinmap_pinout (pinN, PinMap_TIM);
22- uint32_t channel = STM_PIN_CHANNEL (pinmap_function (pinN, PinMap_TIM));
23- timer.Instance = (TIM_TypeDef *)pinmap_peripheral (pinN, PinMap_TIM);
19+ int STM32PWMInput::initialize (){
20+ pinmap_pinout (_pin, PinMap_TIM);
21+ uint32_t channel = STM_PIN_CHANNEL (pinmap_function (_pin, PinMap_TIM));
22+ timer.Instance = (TIM_TypeDef *)pinmap_peripheral (_pin, PinMap_TIM);
2423 timer.Init .Prescaler = 0 ;
2524 timer.Init .CounterMode = TIM_COUNTERMODE_UP;
2625 timer.Init .Period = 4.294967295E9 ; // TODO max period, depends on which timer is used - 32 bits or 16 bits
Original file line number Diff line number Diff line change @@ -10,13 +10,13 @@ class STM32PWMInput {
1010 STM32PWMInput (int pin);
1111 ~STM32PWMInput ();
1212
13- int init ();
13+ int initialize ();
1414
1515 float getDutyCyclePercent ();
1616 uint32_t getDutyCycleTicks ();
1717 uint32_t getPeriodTicks ();
1818 protected:
19- int _pin;
19+ PinName _pin;
2020 TIM_HandleTypeDef timer;
2121};
2222
You can’t perform that action at this time.
0 commit comments