Skip to content

Commit f1bce73

Browse files
Sadik.OzerSadik.Ozer
authored andcommitted
Provide all uart mapping
Signed-off-by: Sadik.Ozer <Sadik.Ozer@maximintegrated.com>
1 parent 65e6595 commit f1bce73

File tree

4 files changed

+83
-34
lines changed

4 files changed

+83
-34
lines changed

targets/TARGET_Maxim/TARGET_MAX32670/Libraries/PeriphDrivers/Include/MAX32670/mxc_pins.h

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@
4242

4343
#include "gpio.h"
4444

45+
typedef enum {
46+
MAP_A,
47+
MAP_B,
48+
MAP_C
49+
} sys_map_t;
50+
4551
/***** Global Variables *****/
4652
// Predefined GPIO Configurations
4753
extern const mxc_gpio_cfg_t gpio_cfg_extclk;
@@ -52,15 +58,24 @@ extern const mxc_gpio_cfg_t gpio_cfg_i2c2b;
5258
extern const mxc_gpio_cfg_t gpio_cfg_i2c2c;
5359

5460

55-
extern const mxc_gpio_cfg_t gpio_cfg_uart0;
56-
extern const mxc_gpio_cfg_t gpio_cfg_uart0_flow;
57-
extern const mxc_gpio_cfg_t gpio_cfg_uart0_flow_disable;
58-
extern const mxc_gpio_cfg_t gpio_cfg_uart1;
59-
extern const mxc_gpio_cfg_t gpio_cfg_uart1_flow;
60-
extern const mxc_gpio_cfg_t gpio_cfg_uart1_flow_disable;
61-
extern const mxc_gpio_cfg_t gpio_cfg_uart2;
62-
extern const mxc_gpio_cfg_t gpio_cfg_uart2_flow;
63-
extern const mxc_gpio_cfg_t gpio_cfg_uart2_flow_disable;
61+
extern const mxc_gpio_cfg_t gpio_cfg_uart0a;
62+
extern const mxc_gpio_cfg_t gpio_cfg_uart0a_flow;
63+
extern const mxc_gpio_cfg_t gpio_cfg_uart0a_flow_disable;
64+
extern const mxc_gpio_cfg_t gpio_cfg_uart0b;
65+
extern const mxc_gpio_cfg_t gpio_cfg_uart0b_flow;
66+
extern const mxc_gpio_cfg_t gpio_cfg_uart0b_flow_disable;
67+
68+
extern const mxc_gpio_cfg_t gpio_cfg_uart1a;
69+
extern const mxc_gpio_cfg_t gpio_cfg_uart1a_flow;
70+
extern const mxc_gpio_cfg_t gpio_cfg_uart1a_flow_disable;
71+
extern const mxc_gpio_cfg_t gpio_cfg_uart1b;
72+
extern const mxc_gpio_cfg_t gpio_cfg_uart1b_flow;
73+
extern const mxc_gpio_cfg_t gpio_cfg_uart1b_flow_disable;
74+
75+
extern const mxc_gpio_cfg_t gpio_cfg_uart2b;
76+
extern const mxc_gpio_cfg_t gpio_cfg_uart2b_flow;
77+
extern const mxc_gpio_cfg_t gpio_cfg_uart2b_flow_disable;
78+
6479
extern const mxc_gpio_cfg_t gpio_cfg_uart3;
6580
extern const mxc_gpio_cfg_t gpio_cfg_uart3_flow;
6681
extern const mxc_gpio_cfg_t gpio_cfg_uart3_flow_disable;

targets/TARGET_Maxim/TARGET_MAX32670/Libraries/PeriphDrivers/Include/MAX32670/uart.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ struct _mxc_uart_req_t {
164164
*
165165
* @return Success/Fail, see \ref MXC_Error_Codes for a list of return codes.
166166
*/
167-
int MXC_UART_Init(mxc_uart_regs_t* uart, unsigned int baud, mxc_uart_clock_t clock);
167+
int MXC_UART_Init(mxc_uart_regs_t* uart, unsigned int baud, mxc_uart_clock_t clock, sys_map_t map);
168168

169169
/**
170170
* @brief Disable and shutdown UART peripheral.
@@ -251,7 +251,7 @@ int MXC_UART_SetParity(mxc_uart_regs_t* uart, mxc_uart_parity_t parity);
251251
*
252252
* @return Success/Fail, see \ref MXC_Error_Codes for a list of return codes.
253253
*/
254-
int MXC_UART_SetFlowCtrl(mxc_uart_regs_t* uart, mxc_uart_flow_t flowCtrl, int rtsThreshold);
254+
int MXC_UART_SetFlowCtrl(mxc_uart_regs_t* uart, mxc_uart_flow_t flowCtrl, int rtsThreshold, sys_map_t map);
255255

256256
/**
257257
* @brief Sets the clock source for the baud rate generator

targets/TARGET_Maxim/TARGET_MAX32670/Libraries/PeriphDrivers/Source/SYS/pins_me15.c

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,28 @@ const mxc_gpio_cfg_t gpio_cfg_i2c0 = { MXC_GPIO0, (MXC_GPIO_PIN_
4949
const mxc_gpio_cfg_t gpio_cfg_i2c1 = { MXC_GPIO0, (MXC_GPIO_PIN_12 | MXC_GPIO_PIN_13), MXC_GPIO_FUNC_ALT1, MXC_GPIO_PAD_PULL_UP, MXC_GPIO_VSSEL_VDDIO};
5050
const mxc_gpio_cfg_t gpio_cfg_i2c2 = { MXC_GPIO0, (MXC_GPIO_PIN_18 | MXC_GPIO_PIN_19), MXC_GPIO_FUNC_ALT1, MXC_GPIO_PAD_PULL_UP, MXC_GPIO_VSSEL_VDDIO};
5151

52-
const mxc_gpio_cfg_t gpio_cfg_uart0 = { MXC_GPIO0, (MXC_GPIO_PIN_8 | MXC_GPIO_PIN_9), MXC_GPIO_FUNC_ALT1, MXC_GPIO_PAD_NONE };
53-
const mxc_gpio_cfg_t gpio_cfg_uart0_flow = { MXC_GPIO0, (MXC_GPIO_PIN_10 | MXC_GPIO_PIN_11), MXC_GPIO_FUNC_ALT1, MXC_GPIO_PAD_NONE };
54-
const mxc_gpio_cfg_t gpio_cfg_uart0_flow_disable = { MXC_GPIO0, (MXC_GPIO_PIN_10 | MXC_GPIO_PIN_11), MXC_GPIO_FUNC_IN, MXC_GPIO_PAD_NONE };
55-
const mxc_gpio_cfg_t gpio_cfg_uart1 = { MXC_GPIO0, (MXC_GPIO_PIN_28 | MXC_GPIO_PIN_29), MXC_GPIO_FUNC_ALT1, MXC_GPIO_PAD_NONE };
56-
const mxc_gpio_cfg_t gpio_cfg_uart1_flow = { MXC_GPIO0, (MXC_GPIO_PIN_30 | MXC_GPIO_PIN_31), MXC_GPIO_FUNC_ALT1, MXC_GPIO_PAD_NONE };
57-
const mxc_gpio_cfg_t gpio_cfg_uart1_flow_disable = { MXC_GPIO0, (MXC_GPIO_PIN_30 | MXC_GPIO_PIN_31), MXC_GPIO_FUNC_IN, MXC_GPIO_PAD_NONE };
58-
const mxc_gpio_cfg_t gpio_cfg_uart2 = { MXC_GPIO0, (MXC_GPIO_PIN_14 | MXC_GPIO_PIN_15), MXC_GPIO_FUNC_ALT2, MXC_GPIO_PAD_NONE };
59-
const mxc_gpio_cfg_t gpio_cfg_uart2_flow = { MXC_GPIO0, (MXC_GPIO_PIN_16 | MXC_GPIO_PIN_17), MXC_GPIO_FUNC_ALT2, MXC_GPIO_PAD_NONE };
60-
const mxc_gpio_cfg_t gpio_cfg_uart2_flow_disable = { MXC_GPIO0, (MXC_GPIO_PIN_16 | MXC_GPIO_PIN_17), MXC_GPIO_FUNC_IN, MXC_GPIO_PAD_NONE };
61-
const mxc_gpio_cfg_t gpio_cfg_uart3 = { MXC_GPIO0, (MXC_GPIO_PIN_26 | MXC_GPIO_PIN_27), MXC_GPIO_FUNC_ALT1, MXC_GPIO_PAD_NONE };
62-
const mxc_gpio_cfg_t gpio_cfg_uart3_flow = { MXC_GPIO0, (MXC_GPIO_PIN_24 | MXC_GPIO_PIN_25), MXC_GPIO_FUNC_ALT1, MXC_GPIO_PAD_NONE };
63-
const mxc_gpio_cfg_t gpio_cfg_uart3_flow_disable = { MXC_GPIO0, (MXC_GPIO_PIN_24 | MXC_GPIO_PIN_25), MXC_GPIO_FUNC_IN, MXC_GPIO_PAD_NONE };
52+
const mxc_gpio_cfg_t gpio_cfg_uart0a = { MXC_GPIO0, (MXC_GPIO_PIN_8 | MXC_GPIO_PIN_9), MXC_GPIO_FUNC_ALT1, MXC_GPIO_PAD_NONE };
53+
const mxc_gpio_cfg_t gpio_cfg_uart0a_flow = { MXC_GPIO0, (MXC_GPIO_PIN_10 | MXC_GPIO_PIN_11), MXC_GPIO_FUNC_ALT1, MXC_GPIO_PAD_NONE };
54+
const mxc_gpio_cfg_t gpio_cfg_uart0a_flow_disable = { MXC_GPIO0, (MXC_GPIO_PIN_10 | MXC_GPIO_PIN_11), MXC_GPIO_FUNC_IN, MXC_GPIO_PAD_NONE };
55+
56+
const mxc_gpio_cfg_t gpio_cfg_uart0b = { MXC_GPIO0, (MXC_GPIO_PIN_24 | MXC_GPIO_PIN_25), MXC_GPIO_FUNC_ALT2, MXC_GPIO_PAD_NONE };
57+
const mxc_gpio_cfg_t gpio_cfg_uart0b_flow = { MXC_GPIO0, (MXC_GPIO_PIN_26 | MXC_GPIO_PIN_27), MXC_GPIO_FUNC_ALT2, MXC_GPIO_PAD_NONE };
58+
const mxc_gpio_cfg_t gpio_cfg_uart0b_flow_disable = { MXC_GPIO0, (MXC_GPIO_PIN_26 | MXC_GPIO_PIN_27), MXC_GPIO_FUNC_IN, MXC_GPIO_PAD_NONE };
59+
60+
const mxc_gpio_cfg_t gpio_cfg_uart1a = { MXC_GPIO0, (MXC_GPIO_PIN_28 | MXC_GPIO_PIN_29), MXC_GPIO_FUNC_ALT1, MXC_GPIO_PAD_NONE };
61+
const mxc_gpio_cfg_t gpio_cfg_uart1a_flow = { MXC_GPIO0, (MXC_GPIO_PIN_30 | MXC_GPIO_PIN_31), MXC_GPIO_FUNC_ALT1, MXC_GPIO_PAD_NONE };
62+
const mxc_gpio_cfg_t gpio_cfg_uart1a_flow_disable = { MXC_GPIO0, (MXC_GPIO_PIN_30 | MXC_GPIO_PIN_31), MXC_GPIO_FUNC_IN, MXC_GPIO_PAD_NONE };
63+
64+
const mxc_gpio_cfg_t gpio_cfg_uart1b = { MXC_GPIO0, (MXC_GPIO_PIN_2 | MXC_GPIO_PIN_3), MXC_GPIO_FUNC_ALT2, MXC_GPIO_PAD_NONE };
65+
const mxc_gpio_cfg_t gpio_cfg_uart1b_flow = { MXC_GPIO0, (MXC_GPIO_PIN_4 | MXC_GPIO_PIN_5), MXC_GPIO_FUNC_ALT2, MXC_GPIO_PAD_NONE };
66+
const mxc_gpio_cfg_t gpio_cfg_uart1b_flow_disable = { MXC_GPIO0, (MXC_GPIO_PIN_4 | MXC_GPIO_PIN_5), MXC_GPIO_FUNC_IN, MXC_GPIO_PAD_NONE };
67+
68+
const mxc_gpio_cfg_t gpio_cfg_uart2b = { MXC_GPIO0, (MXC_GPIO_PIN_14 | MXC_GPIO_PIN_15), MXC_GPIO_FUNC_ALT2, MXC_GPIO_PAD_NONE };
69+
const mxc_gpio_cfg_t gpio_cfg_uart2b_flow = { MXC_GPIO0, (MXC_GPIO_PIN_16 | MXC_GPIO_PIN_17), MXC_GPIO_FUNC_ALT2, MXC_GPIO_PAD_NONE };
70+
const mxc_gpio_cfg_t gpio_cfg_uart2b_flow_disable = { MXC_GPIO0, (MXC_GPIO_PIN_16 | MXC_GPIO_PIN_17), MXC_GPIO_FUNC_IN, MXC_GPIO_PAD_NONE };
71+
const mxc_gpio_cfg_t gpio_cfg_uart3 = { MXC_GPIO0, (MXC_GPIO_PIN_26 | MXC_GPIO_PIN_27), MXC_GPIO_FUNC_ALT1, MXC_GPIO_PAD_NONE };
72+
const mxc_gpio_cfg_t gpio_cfg_uart3_flow = { MXC_GPIO0, (MXC_GPIO_PIN_24 | MXC_GPIO_PIN_25), MXC_GPIO_FUNC_ALT1, MXC_GPIO_PAD_NONE };
73+
const mxc_gpio_cfg_t gpio_cfg_uart3_flow_disable = { MXC_GPIO0, (MXC_GPIO_PIN_24 | MXC_GPIO_PIN_25), MXC_GPIO_FUNC_IN, MXC_GPIO_PAD_NONE };
6474

6575
const mxc_gpio_cfg_t gpio_cfg_i2s0 = { MXC_GPIO0, (MXC_GPIO_PIN_8 | MXC_GPIO_PIN_9 | MXC_GPIO_PIN_10 | MXC_GPIO_PIN_11), MXC_GPIO_FUNC_ALT2, MXC_GPIO_PAD_NONE };
6676

targets/TARGET_Maxim/TARGET_MAX32670/Libraries/PeriphDrivers/Source/UART/uart_me15.c

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ int MXC_UART_AsyncStop(mxc_uart_regs_t* uart)
5858
return MXC_UART_RevB_AsyncStop ((mxc_uart_revb_regs_t*) uart);
5959
}
6060

61-
int MXC_UART_Init(mxc_uart_regs_t* uart, unsigned int baud, mxc_uart_clock_t clock)
61+
int MXC_UART_Init(mxc_uart_regs_t* uart, unsigned int baud, mxc_uart_clock_t clock, sys_map_t map)
6262
{
6363
int retval;
6464

@@ -95,17 +95,25 @@ int MXC_UART_Init(mxc_uart_regs_t* uart, unsigned int baud, mxc_uart_clock_t clo
9595

9696
switch (MXC_UART_GET_IDX(uart)) {
9797
case 0:
98-
MXC_GPIO_Config(&gpio_cfg_uart0);
98+
if (map == MAP_B) {
99+
MXC_GPIO_Config(&gpio_cfg_uart0b);
100+
} else {
101+
MXC_GPIO_Config(&gpio_cfg_uart0a);
102+
}
99103
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_UART0);
100104
break;
101105

102106
case 1:
103-
MXC_GPIO_Config(&gpio_cfg_uart1);
107+
if (map == MAP_B) {
108+
MXC_GPIO_Config(&gpio_cfg_uart1b);
109+
} else {
110+
MXC_GPIO_Config(&gpio_cfg_uart1a);
111+
}
104112
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_UART1);
105113
break;
106114

107115
case 2:
108-
MXC_GPIO_Config(&gpio_cfg_uart2);
116+
MXC_GPIO_Config(&gpio_cfg_uart2b);
109117
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_UART2);
110118
break;
111119

@@ -344,20 +352,28 @@ int MXC_UART_SetParity(mxc_uart_regs_t* uart, mxc_uart_parity_t parity)
344352
return MXC_UART_RevB_SetParity ((mxc_uart_revb_regs_t*) uart, parity);
345353
}
346354

347-
int MXC_UART_SetFlowCtrl(mxc_uart_regs_t* uart, mxc_uart_flow_t flowCtrl, int rtsThreshold)
355+
int MXC_UART_SetFlowCtrl(mxc_uart_regs_t* uart, mxc_uart_flow_t flowCtrl, int rtsThreshold, sys_map_t map)
348356
{
349357
if(flowCtrl == MXC_UART_FLOW_EN) {
350358
switch (MXC_UART_GET_IDX(uart)) {
351359
case 0:
352-
MXC_GPIO_Config(&gpio_cfg_uart0_flow);
360+
if (map == MAP_B) {
361+
MXC_GPIO_Config(&gpio_cfg_uart0b_flow);
362+
} else {
363+
MXC_GPIO_Config(&gpio_cfg_uart0a_flow);
364+
}
353365
break;
354366

355367
case 1:
356-
MXC_GPIO_Config(&gpio_cfg_uart1_flow);
368+
if (map == MAP_B) {
369+
MXC_GPIO_Config(&gpio_cfg_uart1b_flow);
370+
} else {
371+
MXC_GPIO_Config(&gpio_cfg_uart1a_flow);
372+
}
357373
break;
358374

359375
case 2:
360-
MXC_GPIO_Config(&gpio_cfg_uart2_flow);
376+
MXC_GPIO_Config(&gpio_cfg_uart2b_flow);
361377
break;
362378

363379
case 3:
@@ -371,15 +387,23 @@ int MXC_UART_SetFlowCtrl(mxc_uart_regs_t* uart, mxc_uart_flow_t flowCtrl, int rt
371387
else {
372388
switch (MXC_UART_GET_IDX(uart)) {
373389
case 0:
374-
MXC_GPIO_Config(&gpio_cfg_uart0_flow_disable);
390+
if (map == MAP_B) {
391+
MXC_GPIO_Config(&gpio_cfg_uart0b_flow_disable);
392+
} else {
393+
MXC_GPIO_Config(&gpio_cfg_uart0a_flow_disable);
394+
}
375395
break;
376396

377397
case 1:
378-
MXC_GPIO_Config(&gpio_cfg_uart1_flow_disable);
398+
if (map == MAP_B) {
399+
MXC_GPIO_Config(&gpio_cfg_uart1b_flow_disable);
400+
} else {
401+
MXC_GPIO_Config(&gpio_cfg_uart1a_flow_disable);
402+
}
379403
break;
380404

381405
case 2:
382-
MXC_GPIO_Config(&gpio_cfg_uart2_flow_disable);
406+
MXC_GPIO_Config(&gpio_cfg_uart2b_flow_disable);
383407
break;
384408

385409
case 3:

0 commit comments

Comments
 (0)