Skip to content

Commit 8a37d1c

Browse files
committed
Rename PinMap_PWM to PinMap_TIM
Define PinMap_PWM as PinMap_TIM for backward compatibility as several libraries use it. They should be updated to use the new name. Signed-off-by: Frederic Pillon <[email protected]>
1 parent 412b4f2 commit 8a37d1c

File tree

8 files changed

+17
-15
lines changed

8 files changed

+17
-15
lines changed

cores/arduino/HardwareTimer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ void HardwareTimer::setMode(uint32_t channel, TimerModes_t mode, PinName pin)
698698
if (pin != NC) {
699699
if ((int)get_pwm_channel(pin) == timChannel) {
700700
/* Configure PWM GPIO pins */
701-
pinmap_pinout(pin, PinMap_PWM);
701+
pinmap_pinout(pin, PinMap_TIM);
702702
#if defined(STM32F1xx)
703703
if ((mode == TIMER_INPUT_CAPTURE_RISING) || (mode == TIMER_INPUT_CAPTURE_FALLING) \
704704
|| (mode == TIMER_INPUT_CAPTURE_BOTHEDGE) || (mode == TIMER_INPUT_FREQ_DUTY_MEASUREMENT)) {
@@ -712,7 +712,7 @@ void HardwareTimer::setMode(uint32_t channel, TimerModes_t mode, PinName pin)
712712
}
713713

714714
#if defined(TIM_CCER_CC1NE)
715-
isComplementaryChannel[channel - 1] = STM_PIN_INVERTED(pinmap_function(pin, PinMap_PWM));
715+
isComplementaryChannel[channel - 1] = STM_PIN_INVERTED(pinmap_function(pin, PinMap_TIM));
716716
#endif
717717
}
718718
}

cores/arduino/pins_arduino.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ PinName analogInputToPinName(uint32_t pin);
281281

282282
#define digitalPinHasI2C(p) (pin_in_pinmap(digitalPinToPinName(p), PinMap_I2C_SDA) ||\
283283
pin_in_pinmap(digitalPinToPinName(p), PinMap_I2C_SCL))
284-
#define digitalPinHasPWM(p) (pin_in_pinmap(digitalPinToPinName(p), PinMap_PWM))
284+
#define digitalPinHasPWM(p) (pin_in_pinmap(digitalPinToPinName(p), PinMap_TIM))
285285
#define digitalPinHasSerial(p) (pin_in_pinmap(digitalPinToPinName(p), PinMap_UART_RX) ||\
286286
pin_in_pinmap(digitalPinToPinName(p), PinMap_UART_TX))
287287
#define digitalPinHasSPI(p) (pin_in_pinmap(digitalPinToPinName(p), PinMap_SPI_MOSI) ||\

cores/arduino/stm32/PeripheralPins.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ extern const PinMap PinMap_DAC[];
4646
extern const PinMap PinMap_I2C_SDA[];
4747
extern const PinMap PinMap_I2C_SCL[];
4848

49-
//*** PWM ***
50-
extern const PinMap PinMap_PWM[];
49+
//*** TIM ***
50+
/* For backward compatibilty */
51+
#define PinMap_PWM PinMap_TIM
52+
extern const PinMap PinMap_TIM[];
5153

5254
//*** SERIAL ***
5355
extern const PinMap PinMap_UART_TX[];

cores/arduino/wiring_analog.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void analogWrite(uint32_t ulPin, uint32_t ulValue)
197197
} else
198198
#endif //HAL_DAC_MODULE_ENABLED && !HAL_DAC_MODULE_ONLY
199199
#if defined(HAL_TIM_MODULE_ENABLED) && !defined(HAL_TIM_MODULE_ONLY)
200-
if (pin_in_pinmap(p, PinMap_PWM)) {
200+
if (pin_in_pinmap(p, PinMap_TIM)) {
201201
if (is_pin_configured(p, g_anOutputPinConfigured) == false) {
202202
set_pin_configured(p, g_anOutputPinConfigured);
203203
}

cores/arduino/wiring_digital.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void pinMode(uint32_t ulPin, uint32_t ulMode)
4141
} else
4242
#endif //HAL_DAC_MODULE_ENABLED && !HAL_DAC_MODULE_ONLY
4343
#if defined(HAL_TIM_MODULE_ENABLED) && !defined(HAL_TIM_MODULE_ONLY)
44-
if (pin_in_pinmap(p, PinMap_PWM)) {
44+
if (pin_in_pinmap(p, PinMap_TIM)) {
4545
pwm_stop(p);
4646
}
4747
#endif //HAL_TIM_MODULE_ENABLED && !HAL_TIM_MODULE_ONLY

libraries/SrcWrapper/src/stm32/analog.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static uint32_t get_adc_internal_channel(PinName pin)
274274
#if defined(HAL_TIM_MODULE_ENABLED) && !defined(HAL_TIM_MODULE_ONLY)
275275
uint32_t get_pwm_channel(PinName pin)
276276
{
277-
uint32_t function = pinmap_function(pin, PinMap_PWM);
277+
uint32_t function = pinmap_function(pin, PinMap_TIM);
278278
uint32_t channel = 0;
279279
switch (STM_PIN_CHANNEL(function)) {
280280
case 1:
@@ -1026,17 +1026,17 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
10261026
*/
10271027
void pwm_start(PinName pin, uint32_t PWM_freq, uint32_t value, TimerCompareFormat_t resolution)
10281028
{
1029-
TIM_TypeDef *Instance = (TIM_TypeDef *)pinmap_peripheral(pin, PinMap_PWM);
1029+
TIM_TypeDef *Instance = (TIM_TypeDef *)pinmap_peripheral(pin, PinMap_TIM);
10301030
HardwareTimer *HT;
10311031
TimerModes_t previousMode;
10321032
uint32_t index = get_timer_index(Instance);
10331033
if (HardwareTimer_Handle[index] == NULL) {
1034-
HardwareTimer_Handle[index]->__this = new HardwareTimer((TIM_TypeDef *)pinmap_peripheral(pin, PinMap_PWM));
1034+
HardwareTimer_Handle[index]->__this = new HardwareTimer((TIM_TypeDef *)pinmap_peripheral(pin, PinMap_TIM));
10351035
}
10361036

10371037
HT = (HardwareTimer *)(HardwareTimer_Handle[index]->__this);
10381038

1039-
uint32_t channel = STM_PIN_CHANNEL(pinmap_function(pin, PinMap_PWM));
1039+
uint32_t channel = STM_PIN_CHANNEL(pinmap_function(pin, PinMap_TIM));
10401040

10411041
previousMode = HT->getMode(channel);
10421042
if (previousMode != TIMER_OUTPUT_COMPARE_PWM1) {
@@ -1056,11 +1056,11 @@ void pwm_start(PinName pin, uint32_t PWM_freq, uint32_t value, TimerCompareForma
10561056
*/
10571057
void pwm_stop(PinName pin)
10581058
{
1059-
TIM_TypeDef *Instance = (TIM_TypeDef *)pinmap_peripheral(pin, PinMap_PWM);
1059+
TIM_TypeDef *Instance = (TIM_TypeDef *)pinmap_peripheral(pin, PinMap_TIM);
10601060
HardwareTimer *HT;
10611061
uint32_t index = get_timer_index(Instance);
10621062
if (HardwareTimer_Handle[index] == NULL) {
1063-
HardwareTimer_Handle[index]->__this = new HardwareTimer((TIM_TypeDef *)pinmap_peripheral(pin, PinMap_PWM));
1063+
HardwareTimer_Handle[index]->__this = new HardwareTimer((TIM_TypeDef *)pinmap_peripheral(pin, PinMap_TIM));
10641064
}
10651065

10661066
HT = (HardwareTimer *)(HardwareTimer_Handle[index]->__this);

variants/STM32F4xx/FYSETC_S6/variant.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ extern "C" {
129129
#define PIN_WIRE_SCL PB8
130130

131131
// Timer Definitions
132-
// Do not use timer used by PWM pin. See PinMap_PWM.
132+
// Do not use timer used by PWM pin. See PinMap_TIM.
133133
#define TIMER_TONE TIM6
134134
#define TIMER_SERVO TIM2
135135
#define TIMER_SERIAL TIM7

variants/STM32MP1xx/STM32MP157_DK/variant.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ extern "C" {
122122
#define USER_BTN USER1_BTN
123123

124124
// Timer Definitions (optional)
125-
//Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c
125+
//Do not use timer used by PWM pins when possible. See PinMap_TIM in PeripheralPins.c
126126
// Unused Timers: TIM6, TIM7 (Those are basic timers usually for DACs, not capable to PWM)
127127
// LPTIM[1:5]
128128
#define TIMER_TONE TIM7

0 commit comments

Comments
 (0)