Skip to content

Commit 461a3dd

Browse files
committed
Cast to matching enumeration type instead of uint32_t
This commit targets the KL25Z code, whereas previous ones targetted similar issues in the LPC1768 and LPC11U24 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 cc56997 commit 461a3dd

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL25Z/analogin_api.c

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

4242
void analogin_init(analogin_t *obj, PinName pin) {
4343
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
44-
if (obj->adc == (uint32_t)NC) {
44+
if (obj->adc == (ADCName)NC) {
4545
error("ADC pin mapping failed");
4646
}
4747

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL25Z/analogout_api.c

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

2929
void analogout_init(dac_t *obj, PinName pin) {
3030
obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC);
31-
if (obj->dac == (uint32_t)NC) {
31+
if (obj->dac == (DACName)NC) {
3232
error("DAC pin mapping failed");
3333
}
3434

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL25Z/pinmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "error.h"
1818

1919
void pin_function(PinName pin, int function) {
20-
if (pin == (uint32_t)NC) return;
20+
if (pin == (PinName)NC) return;
2121

2222
uint32_t port_n = (uint32_t)pin >> PORT_SHIFT;
2323
uint32_t pin_n = (uint32_t)(pin & 0x7C) >> 2;
@@ -30,7 +30,7 @@ void pin_function(PinName pin, int function) {
3030
}
3131

3232
void pin_mode(PinName pin, PinMode mode) {
33-
if (pin == (uint32_t)NC) { return; }
33+
if (pin == (PinName)NC) { return; }
3434

3535
__IO uint32_t* pin_pcr = (__IO uint32_t*)(PORTA_BASE + pin);
3636

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL25Z/pwmout_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static const PinMap PinMap_PWM[] = {
4848
void pwmout_init(pwmout_t* obj, PinName pin) {
4949
// determine the channel
5050
PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
51-
if (pwm == (uint32_t)NC)
51+
if (pwm == (PWMName)NC)
5252
error("PwmOut pin mapping failed");
5353

5454
unsigned int port = (unsigned int)pin >> PORT_SHIFT;

0 commit comments

Comments
 (0)