Skip to content

Commit cc56997

Browse files
committed
Cast to matching enumeration type instead of uint32_t
This commit targets the LPC11U24 code, whereas a previous one targetted similar issues in the LPC1768 mbed HAL code. These changes were made to silence GCC warnings and fix potential bugs where they would never be equal when the enumeration wasn't a 32-bit type. For example, pinmap.c used to contain this code: if (pin == (uint32_t)NC) return; I switched it to: if (pin == (PinName)NC) return; I wonder why this casting to uint32_t was done in the first place? Maybe another supported compiler requires it?
1 parent 8fe7276 commit cc56997

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/analogin_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static const PinMap PinMap_ADC[] = {
4646

4747
void analogin_init(analogin_t *obj, PinName pin) {
4848
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
49-
if (obj->adc == (uint32_t)NC) {
49+
if (obj->adc == (ADCName)NC) {
5050
error("ADC pin mapping failed");
5151
}
5252

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pinmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#define LPC_IOCON1_BASE (LPC_IOCON_BASE + 0x60)
2121

2222
void pin_function(PinName pin, int function) {
23-
if (pin == (uint32_t)NC) return;
23+
if (pin == (PinName)NC) return;
2424

2525
uint32_t pin_number = (uint32_t)pin;
2626

@@ -33,7 +33,7 @@ void pin_function(PinName pin, int function) {
3333
}
3434

3535
void pin_mode(PinName pin, PinMode mode) {
36-
if (pin == (uint32_t)NC) { return; }
36+
if (pin == (PinName)NC) { return; }
3737

3838
uint32_t pin_number = (uint32_t)pin;
3939
uint32_t drain = ((uint32_t) mode & (uint32_t) OpenDrain) >> 2;

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pwmout_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static unsigned int pwm_clock_mhz;
7171
void pwmout_init(pwmout_t* obj, PinName pin) {
7272
// determine the channel
7373
PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
74-
if (pwm == (uint32_t)NC)
74+
if (pwm == (PWMName)NC)
7575
error("PwmOut pin mapping failed");
7676

7777
obj->pwm = pwm;

0 commit comments

Comments
 (0)