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;
|
||||
|
||||
switch (pin & 0xF000) {
|
||||
case 0x0000:
|
||||
port_reg = LPC_GPIO0;
|
||||
break;
|
||||
case 0x1000:
|
||||
port_reg = LPC_GPIO1;
|
||||
break;
|
||||
case 0x2000:
|
||||
port_reg = LPC_GPIO2;
|
||||
break;
|
||||
case 0x3000:
|
||||
port_reg = LPC_GPIO3;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
case 0x0000:
|
||||
port_reg = LPC_GPIO0;
|
||||
break;
|
||||
case 0x1000:
|
||||
port_reg = LPC_GPIO1;
|
||||
break;
|
||||
case 0x2000:
|
||||
port_reg = LPC_GPIO2;
|
||||
break;
|
||||
case 0x3000:
|
||||
port_reg = LPC_GPIO3;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
#warning TODO (@toyowata): Need to check array offset
|
||||
|
@ -62,8 +62,10 @@ void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) {
|
|||
obj->reg_dir = &port_reg->DIR;
|
||||
obj->reg_in = &port_reg->DATA;
|
||||
obj->reg_data= &port_reg->DATA;
|
||||
|
||||
|
||||
gpio_dir(obj, direction);
|
||||
|
||||
switch (direction) {
|
||||
case PIN_OUTPUT: pin_mode(pin, PullNone); break;
|
||||
case PIN_INPUT : pin_mode(pin, PullDown); break;
|
||||
|
|
Loading…
Reference in New Issue