mirror of https://github.com/ARMmbed/mbed-os.git
Refactored bits of gpio_api.c
In between the last two commits, I added debugging lines using serial to try and locate the line of code that was causing the issues with GPIO. However, didn't get anywhere with this because the gpio_write function is defined in a header file, rather than in an implementation file, so the printf function can't go there. As a result, it's just refactoring.pull/17/head
parent
c703096234
commit
66ca1c9db2
|
@ -41,20 +41,20 @@ void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) {
|
||||||
LPC_GPIO_TypeDef *port_reg;
|
LPC_GPIO_TypeDef *port_reg;
|
||||||
|
|
||||||
switch (pin & 0xF000) {
|
switch (pin & 0xF000) {
|
||||||
case 0x0000:
|
case 0x0000:
|
||||||
port_reg = LPC_GPIO0;
|
port_reg = LPC_GPIO0;
|
||||||
break;
|
break;
|
||||||
case 0x1000:
|
case 0x1000:
|
||||||
port_reg = LPC_GPIO1;
|
port_reg = LPC_GPIO1;
|
||||||
break;
|
break;
|
||||||
case 0x2000:
|
case 0x2000:
|
||||||
port_reg = LPC_GPIO2;
|
port_reg = LPC_GPIO2;
|
||||||
break;
|
break;
|
||||||
case 0x3000:
|
case 0x3000:
|
||||||
port_reg = LPC_GPIO3;
|
port_reg = LPC_GPIO3;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#warning TODO (@toyowata): Need to check array offset
|
#warning TODO (@toyowata): Need to check array offset
|
||||||
|
@ -63,7 +63,9 @@ void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) {
|
||||||
obj->reg_in = &port_reg->DATA;
|
obj->reg_in = &port_reg->DATA;
|
||||||
obj->reg_data= &port_reg->DATA;
|
obj->reg_data= &port_reg->DATA;
|
||||||
|
|
||||||
|
|
||||||
gpio_dir(obj, direction);
|
gpio_dir(obj, direction);
|
||||||
|
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case PIN_OUTPUT: pin_mode(pin, PullNone); break;
|
case PIN_OUTPUT: pin_mode(pin, PullNone); break;
|
||||||
case PIN_INPUT : pin_mode(pin, PullDown); break;
|
case PIN_INPUT : pin_mode(pin, PullDown); break;
|
||||||
|
|
Loading…
Reference in New Issue