Skip to content

Commit bbf5cbc

Browse files
committed
Merge pull request ARMmbed#397 from 0xc0170/dev_k20d50m
[K20D50M] K20D5M -> K20D50M
2 parents 0280e5b + 0de2a89 commit bbf5cbc

37 files changed

+115
-56
lines changed

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/PinNames.h renamed to libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/PinNames.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,10 @@ typedef enum {
197197
LED_BLUE = PTA2,
198198

199199
// mbed original LED naming
200-
LED1 = LED_BLUE,
200+
LED1 = LED_RED,
201201
LED2 = LED_GREEN,
202-
LED3 = LED_RED,
203-
LED4 = LED_RED,
202+
LED3 = LED_BLUE,
203+
LED4 = LED_BLUE,
204204

205205
// USB Pins
206206
USBTX = PTB17,
@@ -231,6 +231,12 @@ typedef enum {
231231
A4 = PTB1,
232232
A5 = PTB0,
233233

234+
I2C_SCL = D15,
235+
I2C_SDA = D14,
236+
237+
TSI_ELEC0 = PTB16,
238+
TSI_ELEC1 = PTB17,
239+
234240
// Not connected
235241
NC = (int)0xFFFFFFFF
236242
} PinName;

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/analogin_api.c renamed to libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/analogin_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "pinmap.h"
2121
#include "clk_freqs.h"
2222

23+
#define MAX_FADC 6000000
24+
2325
static const PinMap PinMap_ADC[] = {
2426
{PTC2, ADC0_SE4b, 0},
2527
{PTD1, ADC0_SE5b, 0},
@@ -34,8 +36,6 @@ static const PinMap PinMap_ADC[] = {
3436
{NC, NC, 0}
3537
};
3638

37-
#define MAX_FADC 6000000
38-
3939
void analogin_init(analogin_t *obj, PinName pin) {
4040
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
4141
MBED_ASSERT(obj->adc != (ADCName)NC);

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/gpio_irq_api.c renamed to libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/gpio_irq_api.c

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -30,45 +30,63 @@ static gpio_irq_handler irq_handler;
3030
#define IRQ_EITHER_EDGE PORT_PCR_IRQC(11)
3131

3232
static void handle_interrupt_in(PORT_Type *port, int ch_base) {
33-
uint32_t mask = 0, i;
34-
35-
for (i = 0; i < 32; i++) {
36-
uint32_t pmask = (1 << i);
37-
if (port->ISFR & pmask) {
38-
mask |= pmask;
39-
uint32_t id = channel_ids[ch_base + i];
40-
if (id == 0)
41-
continue;
42-
43-
GPIO_Type *gpio = PTA;
44-
gpio_irq_event event = IRQ_NONE;
45-
uint32_t port_num = (port - PORTA) >> 12;
46-
switch (port->PCR[i] & PORT_PCR_IRQC_MASK) {
47-
case IRQ_RAISING_EDGE:
48-
event = IRQ_RISE;
49-
break;
50-
51-
case IRQ_FALLING_EDGE:
52-
event = IRQ_FALL;
53-
break;
54-
55-
case IRQ_EITHER_EDGE:
56-
gpio += (port_num * 0x40);
57-
event = (gpio->PDIR & pmask) ? (IRQ_RISE) : (IRQ_FALL);
58-
break;
59-
}
60-
if (event != IRQ_NONE)
61-
irq_handler(id, event);
33+
uint32_t isfr;
34+
uint32_t pin;
35+
36+
while ((isfr = port->ISFR) != 0) {
37+
pin = 31 - __CLZ(isfr);
38+
uint32_t id = channel_ids[ch_base + pin];
39+
if (id == 0) {
40+
continue;
41+
}
42+
43+
GPIO_Type *gpio = PTA;
44+
gpio_irq_event event = IRQ_NONE;
45+
uint32_t port_num = (port - PORTA) >> 12;
46+
47+
switch (port->PCR[pin] & PORT_PCR_IRQC_MASK) {
48+
case IRQ_RAISING_EDGE:
49+
event = IRQ_RISE;
50+
break;
51+
case IRQ_FALLING_EDGE:
52+
event = IRQ_FALL;
53+
break;
54+
case IRQ_EITHER_EDGE:
55+
gpio += (port_num * 0x40);
56+
event = (gpio->PDIR & (1 << pin)) ? (IRQ_RISE) : (IRQ_FALL);
57+
break;
58+
}
59+
if (event != IRQ_NONE) {
60+
irq_handler(id, event);
6261
}
62+
port->ISFR = 1 << pin;
6363
}
64-
port->ISFR = mask;
6564
}
6665

67-
void gpio_irqA(void) {handle_interrupt_in(PORTA, 0);}
68-
void gpio_irqB(void) {handle_interrupt_in(PORTB, 32);}
69-
void gpio_irqC(void) {handle_interrupt_in(PORTC, 64);}
70-
void gpio_irqD(void) {handle_interrupt_in(PORTD, 96);}
71-
void gpio_irqE(void) {handle_interrupt_in(PORTE, 128);}
66+
void gpio_irqA(void) {
67+
handle_interrupt_in(PORTA, 0);
68+
}
69+
70+
void gpio_irqB(void)
71+
{
72+
handle_interrupt_in(PORTB, 32);
73+
}
74+
75+
void gpio_irqC(void)
76+
{
77+
handle_interrupt_in(PORTC, 64);
78+
}
79+
80+
void gpio_irqD(void)
81+
{
82+
handle_interrupt_in(PORTD, 96);
83+
}
84+
85+
void gpio_irqE(void)
86+
{
87+
handle_interrupt_in(PORTE, 128);
88+
}
89+
7290

7391
int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id) {
7492
if (pin == NC)

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/serial_api.c renamed to libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/serial_api.c

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,20 @@
2626

2727
static const PinMap PinMap_UART_TX[] = {
2828
{PTB17, UART_0, 3},
29-
{NC , NC , 0}
29+
{PTC4 , UART_1, 3},
30+
{PTD3 , UART_2, 3},
31+
{PTD7 , UART_0, 3},
32+
{PTE0 , UART_1, 3},
33+
{NC , NC , 0}
3034
};
3135

3236
static const PinMap PinMap_UART_RX[] = {
3337
{PTB16, UART_0, 3},
34-
{NC , NC , 0}
38+
{PTC3 , UART_1, 3},
39+
{PTD2 , UART_2, 3},
40+
{PTD6 , UART_0, 3},
41+
{PTE1 , UART_1, 3},
42+
{NC , NC , 0}
3543
};
3644

3745
#define UART_NUM 3
@@ -52,18 +60,33 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
5260
obj->uart = (UART_Type *)uart;
5361
// enable clk
5462
switch (uart) {
55-
case UART_0: SIM->SOPT2 |= SIM_SOPT2_PLLFLLSEL_MASK;
56-
SIM->SCGC5 |= SIM_SCGC5_PORTA_MASK; SIM->SCGC4 |= SIM_SCGC4_UART0_MASK; break;
57-
case UART_1: SIM->SCGC5 |= SIM_SCGC5_PORTC_MASK; SIM->SCGC4 |= SIM_SCGC4_UART1_MASK; break;
58-
case UART_2: SIM->SCGC5 |= SIM_SCGC5_PORTD_MASK; SIM->SCGC4 |= SIM_SCGC4_UART2_MASK; break;
63+
case UART_0:
64+
SIM->SOPT2 |= SIM_SOPT2_PLLFLLSEL_MASK;
65+
SIM->SCGC5 |= SIM_SCGC5_PORTA_MASK;
66+
SIM->SCGC4 |= SIM_SCGC4_UART0_MASK;
67+
break;
68+
case UART_1:
69+
SIM->SCGC5 |= SIM_SCGC5_PORTC_MASK;
70+
SIM->SCGC4 |= SIM_SCGC4_UART1_MASK;
71+
break;
72+
case UART_2:
73+
SIM->SCGC5 |= SIM_SCGC5_PORTD_MASK;
74+
SIM->SCGC4 |= SIM_SCGC4_UART2_MASK;
75+
break;
5976
}
6077
// Disable UART before changing registers
6178
obj->uart->C2 &= ~(UART_C2_RE_MASK | UART_C2_TE_MASK);
6279

6380
switch (uart) {
64-
case UART_0: obj->index = 0; break;
65-
case UART_1: obj->index = 1; break;
66-
case UART_2: obj->index = 2; break;
81+
case UART_0:
82+
obj->index = 0;
83+
break;
84+
case UART_1:
85+
obj->index = 1;
86+
break;
87+
case UART_2:
88+
obj->index = 2;
89+
break;
6790
}
6891

6992
// set default baud rate and format
@@ -131,9 +154,20 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b
131154

132155
uint32_t parity_enable, parity_select;
133156
switch (parity) {
134-
case ParityNone: parity_enable = 0; parity_select = 0; break;
135-
case ParityOdd : parity_enable = 1; parity_select = 1; data_bits++; break;
136-
case ParityEven: parity_enable = 1; parity_select = 0; data_bits++; break;
157+
case ParityNone:
158+
parity_enable = 0;
159+
parity_select = 0;
160+
break;
161+
case ParityOdd :
162+
parity_enable = 1;
163+
parity_select = 1;
164+
data_bits++;
165+
break;
166+
case ParityEven:
167+
parity_enable = 1;
168+
parity_select = 0;
169+
data_bits++;
170+
break;
137171
default:
138172
break;
139173
}

workspace_tools/build_release.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
('KL25Z', ('ARM', 'GCC_ARM')),
4646
('KL46Z', ('ARM', 'GCC_ARM')),
4747
('K64F', ('ARM', 'GCC_ARM')),
48+
('K20D50M', ('ARM', 'GCC_ARM')),
4849

4950
('NUCLEO_F030R8', ('ARM', 'uARM')),
5051
('NUCLEO_F072RB', ('ARM', 'uARM')),

workspace_tools/export/gccarm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class GccArm(Exporter):
2828
'KL25Z',
2929
'KL46Z',
3030
'K64F',
31-
'K20D5M',
31+
'K20D50M',
3232
'LPC4088',
3333
'LPC11U24',
3434
'LPC1114',

workspace_tools/export/uvision4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Uvision4(Exporter):
2828
'KL25Z',
2929
'KL46Z',
3030
'K64F',
31-
'K20D5M',
31+
'K20D50M',
3232
'LPC1347',
3333
'LPC1114',
3434
'LPC11C24',

workspace_tools/targets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def __init__(self):
124124
self.is_disk_virtual = True
125125

126126

127-
class K20D5M(Target):
127+
class K20D50M(Target):
128128
def __init__(self):
129129
Target.__init__(self)
130130
self.core = "Cortex-M4"
@@ -550,7 +550,7 @@ def __init__(self):
550550
KL05Z(),
551551
KL25Z(),
552552
KL46Z(),
553-
K20D5M(),
553+
K20D50M(),
554554
K64F(),
555555
LPC812(),
556556
LPC810(),

0 commit comments

Comments
 (0)