Skip to content

Commit 99c49a2

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 7011b58 commit 99c49a2

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
@@ -259,7 +259,7 @@ static uint32_t get_adc_internal_channel(PinName pin)
259259
#if defined(HAL_TIM_MODULE_ENABLED) && !defined(HAL_TIM_MODULE_ONLY)
260260
uint32_t get_pwm_channel(PinName pin)
261261
{
262-
uint32_t function = pinmap_function(pin, PinMap_PWM);
262+
uint32_t function = pinmap_function(pin, PinMap_TIM);
263263
uint32_t channel = 0;
264264
switch (STM_PIN_CHANNEL(function)) {
265265
case 1:
@@ -1013,17 +1013,17 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
10131013
*/
10141014
void pwm_start(PinName pin, uint32_t PWM_freq, uint32_t value, TimerCompareFormat_t resolution)
10151015
{
1016-
TIM_TypeDef *Instance = (TIM_TypeDef *)pinmap_peripheral(pin, PinMap_PWM);
1016+
TIM_TypeDef *Instance = (TIM_TypeDef *)pinmap_peripheral(pin, PinMap_TIM);
10171017
HardwareTimer *HT;
10181018
TimerModes_t previousMode;
10191019
uint32_t index = get_timer_index(Instance);
10201020
if (HardwareTimer_Handle[index] == NULL) {
1021-
HardwareTimer_Handle[index]->__this = new HardwareTimer((TIM_TypeDef *)pinmap_peripheral(pin, PinMap_PWM));
1021+
HardwareTimer_Handle[index]->__this = new HardwareTimer((TIM_TypeDef *)pinmap_peripheral(pin, PinMap_TIM));
10221022
}
10231023

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

1026-
uint32_t channel = STM_PIN_CHANNEL(pinmap_function(pin, PinMap_PWM));
1026+
uint32_t channel = STM_PIN_CHANNEL(pinmap_function(pin, PinMap_TIM));
10271027

10281028
previousMode = HT->getMode(channel);
10291029
if (previousMode != TIMER_OUTPUT_COMPARE_PWM1) {
@@ -1043,11 +1043,11 @@ void pwm_start(PinName pin, uint32_t PWM_freq, uint32_t value, TimerCompareForma
10431043
*/
10441044
void pwm_stop(PinName pin)
10451045
{
1046-
TIM_TypeDef *Instance = (TIM_TypeDef *)pinmap_peripheral(pin, PinMap_PWM);
1046+
TIM_TypeDef *Instance = (TIM_TypeDef *)pinmap_peripheral(pin, PinMap_TIM);
10471047
HardwareTimer *HT;
10481048
uint32_t index = get_timer_index(Instance);
10491049
if (HardwareTimer_Handle[index] == NULL) {
1050-
HardwareTimer_Handle[index]->__this = new HardwareTimer((TIM_TypeDef *)pinmap_peripheral(pin, PinMap_PWM));
1050+
HardwareTimer_Handle[index]->__this = new HardwareTimer((TIM_TypeDef *)pinmap_peripheral(pin, PinMap_TIM));
10511051
}
10521052

10531053
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)