Skip to content

Commit

Permalink
K64F - RTC and I2C implementation (using KPSDK HAL)
Browse files Browse the repository at this point in the history
	- instance correction in objects and peripherals names headers
  • Loading branch information
0xc0170 committed Feb 22, 2014
1 parent 7ef3fbd commit 8093df5
Show file tree
Hide file tree
Showing 9 changed files with 250 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ typedef enum {
} RTCName;

typedef enum {
UART_0 = (int)UART0_BASE,
UART_1 = (int)UART1_BASE,
UART_2 = (int)UART2_BASE
UART_0 = 0,
UART_1 = 1,
UART_2 = 2,
} UARTName;

#define STDIO_UART_TX USBTX
#define STDIO_UART_RX USBRX
#define STDIO_UART UART_0

typedef enum {
I2C_0 = (int)I2C0_BASE,
I2C_0 = 0,
} I2CName;

#define TPM_SHIFT 8
Expand Down Expand Up @@ -98,7 +98,7 @@ typedef enum {


typedef enum {
SPI_0 = (int)SPI0_BASE,
SPI_0 = 0,
} SPIName;

#ifdef __cplusplus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ uint32_t gpio_set(PinName pin) {
}

void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) {
if (pin == NC)
if (pin == NC) {
return;
}

if (direction) {
gpio_output_pin_t output = {0};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ static void handle_interrupt_in(PortName port, int ch_base) {
event = (gpio_hal_read_pin_input(port, i)) ? (IRQ_RISE) : (IRQ_FALL);
break;
}
if (event != IRQ_NONE)
if (event != IRQ_NONE) {
irq_handler(id, event);
}
}
}
port_hal_clear_port_interrupt_flag(port);
Expand All @@ -69,11 +70,11 @@ void gpio_irqD(void) {handle_interrupt_in(PortD, 96);}
void gpio_irqE(void) {handle_interrupt_in(PortE, 128);}

int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id) {
if (pin == NC)
if (pin == NC) {
return -1;
}

irq_handler = handler;

obj->port = pin >> GPIO_PORT_SHIFT;
obj->pin = pin & 0x7F;

Expand Down Expand Up @@ -159,7 +160,6 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable) {
break;
}

// Interrupt configuration and clear interrupt
port_hal_configure_pin_interrupt(obj->port, obj->pin, irq_settings);
port_hal_clear_pin_interrupt_flag(obj->port, obj->pin);
}
Expand Down
Loading

0 comments on commit 8093df5

Please sign in to comment.