mirror of https://github.com/ARMmbed/mbed-os.git
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?pull/24/head
parent
cc56997a70
commit
461a3dd0d2
|
@ -41,7 +41,7 @@ static const PinMap PinMap_ADC[] = {
|
|||
|
||||
void analogin_init(analogin_t *obj, PinName pin) {
|
||||
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
|
||||
if (obj->adc == (uint32_t)NC) {
|
||||
if (obj->adc == (ADCName)NC) {
|
||||
error("ADC pin mapping failed");
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ static const PinMap PinMap_DAC[] = {
|
|||
|
||||
void analogout_init(dac_t *obj, PinName pin) {
|
||||
obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC);
|
||||
if (obj->dac == (uint32_t)NC) {
|
||||
if (obj->dac == (DACName)NC) {
|
||||
error("DAC pin mapping failed");
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "error.h"
|
||||
|
||||
void pin_function(PinName pin, int function) {
|
||||
if (pin == (uint32_t)NC) return;
|
||||
if (pin == (PinName)NC) return;
|
||||
|
||||
uint32_t port_n = (uint32_t)pin >> PORT_SHIFT;
|
||||
uint32_t pin_n = (uint32_t)(pin & 0x7C) >> 2;
|
||||
|
@ -30,7 +30,7 @@ void pin_function(PinName pin, int function) {
|
|||
}
|
||||
|
||||
void pin_mode(PinName pin, PinMode mode) {
|
||||
if (pin == (uint32_t)NC) { return; }
|
||||
if (pin == (PinName)NC) { return; }
|
||||
|
||||
__IO uint32_t* pin_pcr = (__IO uint32_t*)(PORTA_BASE + pin);
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ static const PinMap PinMap_PWM[] = {
|
|||
void pwmout_init(pwmout_t* obj, PinName pin) {
|
||||
// determine the channel
|
||||
PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
|
||||
if (pwm == (uint32_t)NC)
|
||||
if (pwm == (PWMName)NC)
|
||||
error("PwmOut pin mapping failed");
|
||||
|
||||
unsigned int port = (unsigned int)pin >> PORT_SHIFT;
|
||||
|
|
Loading…
Reference in New Issue