* correction in serial_api.c in getting index for interrupt.

* updated gpio_api.c for pin toggle(LED1=!LED1) working in code.
pull/1214/head
akhilpanayamparambil 2015-06-24 15:26:03 +05:30 committed by Karthik Purushothaman
parent c59613727e
commit 705dc7afc7
3 changed files with 8 additions and 3 deletions

View File

@ -46,6 +46,7 @@ void gpio_init(gpio_t *obj, PinName pin)
obj->OUTCLR = &port_base->OUTCLR.reg;
obj->OUTSET = &port_base->OUTSET.reg;
obj->IN = &port_base->IN.reg;
obj->OUT = &port_base->OUT.reg;
}
void gpio_mode(gpio_t *obj, PinMode mode)
@ -83,7 +84,7 @@ void gpio_dir(gpio_t *obj, PinDirection direction)
pin_conf.direction = PORT_PIN_DIR_INPUT;
break;
case PIN_OUTPUT:
pin_conf.direction = /*PORT_PIN_DIR_OUTPUT*/PORT_PIN_DIR_OUTPUT_WTH_READBACK;
pin_conf.direction = PORT_PIN_DIR_OUTPUT;
break;
case PIN_INPUT_OUTPUT:
pin_conf.direction = PORT_PIN_DIR_OUTPUT_WTH_READBACK;

View File

@ -32,6 +32,7 @@ typedef struct {
__IO uint32_t *OUTCLR;
__IO uint32_t *OUTSET;
__I uint32_t *IN;
__I uint32_t *OUT;
} gpio_t;
static inline void gpio_write(gpio_t *obj, int value)
@ -46,7 +47,10 @@ static inline void gpio_write(gpio_t *obj, int value)
static inline int gpio_read(gpio_t *obj)
{
MBED_ASSERT(obj->pin != (PinName)NC);
return ((*obj->IN & obj->mask) ? 1 : 0);
if (obj->direction == PIN_INPUT)
return ((*obj->IN & obj->mask) ? 1 : 0);
else
return ((*obj->OUT & obj->mask) ? 1 : 0);
}
static inline int gpio_is_connected(const gpio_t *obj)

View File

@ -497,7 +497,7 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b
*/
inline uint8_t serial_get_index(serial_t *obj)
{
switch ((int)pSERIAL_S(obj)) {
switch ((int)pUSART_S(obj)) {
case UART_0:
return 0;
case UART_1: