Skip to content

Commit 8093df5

Browse files
committed
K64F - RTC and I2C implementation (using KPSDK HAL)
- instance correction in objects and peripherals names headers
1 parent 7ef3fbd commit 8093df5

File tree

9 files changed

+250
-67
lines changed

9 files changed

+250
-67
lines changed

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/PeripheralNames.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ typedef enum {
2727
} RTCName;
2828

2929
typedef enum {
30-
UART_0 = (int)UART0_BASE,
31-
UART_1 = (int)UART1_BASE,
32-
UART_2 = (int)UART2_BASE
30+
UART_0 = 0,
31+
UART_1 = 1,
32+
UART_2 = 2,
3333
} UARTName;
3434

3535
#define STDIO_UART_TX USBTX
3636
#define STDIO_UART_RX USBRX
3737
#define STDIO_UART UART_0
3838

3939
typedef enum {
40-
I2C_0 = (int)I2C0_BASE,
40+
I2C_0 = 0,
4141
} I2CName;
4242

4343
#define TPM_SHIFT 8
@@ -98,7 +98,7 @@ typedef enum {
9898

9999

100100
typedef enum {
101-
SPI_0 = (int)SPI0_BASE,
101+
SPI_0 = 0,
102102
} SPIName;
103103

104104
#ifdef __cplusplus

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/gpio_api.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ uint32_t gpio_set(PinName pin) {
2525
}
2626

2727
void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) {
28-
if (pin == NC)
28+
if (pin == NC) {
2929
return;
30+
}
3031

3132
if (direction) {
3233
gpio_output_pin_t output = {0};

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/gpio_irq_api.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ static void handle_interrupt_in(PortName port, int ch_base) {
5555
event = (gpio_hal_read_pin_input(port, i)) ? (IRQ_RISE) : (IRQ_FALL);
5656
break;
5757
}
58-
if (event != IRQ_NONE)
58+
if (event != IRQ_NONE) {
5959
irq_handler(id, event);
60+
}
6061
}
6162
}
6263
port_hal_clear_port_interrupt_flag(port);
@@ -69,11 +70,11 @@ void gpio_irqD(void) {handle_interrupt_in(PortD, 96);}
6970
void gpio_irqE(void) {handle_interrupt_in(PortE, 128);}
7071

7172
int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id) {
72-
if (pin == NC)
73+
if (pin == NC) {
7374
return -1;
75+
}
7476

7577
irq_handler = handler;
76-
7778
obj->port = pin >> GPIO_PORT_SHIFT;
7879
obj->pin = pin & 0x7F;
7980

@@ -159,7 +160,6 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable) {
159160
break;
160161
}
161162

162-
// Interrupt configuration and clear interrupt
163163
port_hal_configure_pin_interrupt(obj->port, obj->pin, irq_settings);
164164
port_hal_clear_pin_interrupt_flag(obj->port, obj->pin);
165165
}

0 commit comments

Comments
 (0)