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(){};
12
12
13
13
int STM32SpeedDirInput::init (){
14
14
pinMode (_pin_dir, INPUT);
15
- return STM32PWMInput::init ();
15
+ return STM32PWMInput::initialize ();
16
16
};
17
17
18
18
Original file line number Diff line number Diff line change 6
6
7
7
8
8
STM32PWMInput::STM32PWMInput (int pin){
9
- _pin = pin;
9
+ _pin = digitalPinToPinName ( pin) ;
10
10
};
11
11
12
12
@@ -16,11 +16,10 @@ STM32PWMInput::~STM32PWMInput(){};
16
16
17
17
18
18
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);
24
23
timer.Init .Prescaler = 0 ;
25
24
timer.Init .CounterMode = TIM_COUNTERMODE_UP;
26
25
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 {
10
10
STM32PWMInput (int pin);
11
11
~STM32PWMInput ();
12
12
13
- int init ();
13
+ int initialize ();
14
14
15
15
float getDutyCyclePercent ();
16
16
uint32_t getDutyCycleTicks ();
17
17
uint32_t getPeriodTicks ();
18
18
protected:
19
- int _pin;
19
+ PinName _pin;
20
20
TIM_HandleTypeDef timer;
21
21
};
22
22
You can’t perform that action at this time.
0 commit comments