Skip to content

Commit

Permalink
chore(Boards,PeriphDrivers): Add Olimex selection, treat UART3 as oth…
Browse files Browse the repository at this point in the history
…er UARTs, and fix BCB build errors for MAX32572 (#914)
  • Loading branch information
sihyung-maxim authored Feb 12, 2024
1 parent f5bd0ae commit d4a64f0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 69 deletions.
6 changes: 5 additions & 1 deletion Libraries/Boards/MAX32572/BCB/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ endif
SRCS += board.c
SRCS += stdio.c
SRCS += led.c
SRCS += w25.c
SRCS += pb.c

MISC_DRIVERS_DIR ?= $(LIBS_DIR)/MiscDrivers
PROJ_CFLAGS+=-DSPIXF_RAM
PROJ_CFLAGS+=-DEXT_FLASH_W25

MISC_DRIVERS_DIR ?= $(MAXIM_PATH)/Libraries/MiscDrivers

# Where to find BSP source files
VPATH += $(BOARD_DIR)/Source
Expand Down
4 changes: 4 additions & 0 deletions Libraries/Boards/MAX32572/EvKit_V1/adapters.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
CMSIS-DAP, interface/cmsis-dap.cfg
MAX32625_PICO, interface/cmsis-dap.cfg
OLIMEX-ARM-USB-OCD-H, interface/ftdi/olimex-arm-usb-ocd-h.cfg
OLIMEX-ARM-USB-OCD-H SWD, interface/ftdi/olimex-arm-usb-ocd-h.cfg -f interface/ftdi/olimex-arm-jtag-swd.cfg
OLIMEX-ARM-USB-TINY-H, interface/ftdi/olimex-arm-usb-tiny-h.cfg
OLIMEX-ARM-USB-TINY-H SWD, interface/ftdi/olimex-arm-usb-tiny-h.cfg -f interface/ftdi/olimex-arm-jtag-swd.cfg
70 changes: 2 additions & 68 deletions Libraries/PeriphDrivers/Source/UART/uart_me55.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,59 +131,12 @@ int MXC_UART_ReadyForSleep(mxc_uart_regs_t *uart)
int MXC_UART_SetFrequency(mxc_uart_regs_t *uart, unsigned int baud, mxc_uart_clock_t clock)
{
int freq;
int mod = 0;
int clkdiv = 0;

if (MXC_UART_GET_IDX(uart) < 0) {
return E_BAD_PARAM;
}

// check if the uart is LPUART
if (uart == MXC_UART3) {
// OSR default value
uart->osr = 5;

switch (clock) {
case MXC_UART_APB_CLK:
clkdiv = ((IBRO_FREQ) / baud);
mod = ((IBRO_FREQ) % baud);
break;

case MXC_UART_EXT_CLK:
uart->ctrl |= MXC_S_UART_CTRL_BCLKSRC_EXTERNAL_CLOCK;
break;

case MXC_UART_ERTCO_CLK:
uart->ctrl |= MXC_S_UART_CTRL_BCLKSRC_CLK2;
uart->ctrl |= MXC_F_UART_CTRL_FDM;
if (baud == 9600) {
clkdiv = 7;
mod = 0;
} else {
clkdiv = ((ERTCO_FREQ * 2) / baud);
mod = ((ERTCO_FREQ * 2) % baud);
}

if (baud > 2400) {
uart->osr = 0;
} else {
uart->osr = 1;
}
break;

default:
return E_BAD_PARAM;
}

if (!clkdiv || mod > (baud / 2)) {
clkdiv++;
}
uart->clkdiv = clkdiv;

freq = MXC_UART_GetFrequency(uart);
} else {
freq = MXC_UART_RevB_SetFrequency((mxc_uart_revb_regs_t *)uart, baud, clock);
}
freq = MXC_UART_RevB_SetFrequency((mxc_uart_revb_regs_t *)uart, baud, clock);

if (freq > 0) {
// Enable baud clock and wait for it to become ready.
Expand All @@ -196,30 +149,11 @@ int MXC_UART_SetFrequency(mxc_uart_regs_t *uart, unsigned int baud, mxc_uart_clo

int MXC_UART_GetFrequency(mxc_uart_regs_t *uart)
{
int periphClock = 0;

if (MXC_UART_GET_IDX(uart) < 0) {
return E_BAD_PARAM;
}

// check if UARt is LP UART
if (uart == MXC_UART3) {
if ((uart->ctrl & MXC_F_UART_CTRL_BCLKSRC) == MXC_S_UART_CTRL_BCLKSRC_EXTERNAL_CLOCK) {
return E_NOT_SUPPORTED;
} else if ((uart->ctrl & MXC_F_UART_CTRL_BCLKSRC) ==
MXC_S_UART_CTRL_BCLKSRC_PERIPHERAL_CLOCK) {
periphClock = IBRO_FREQ;
} else if ((uart->ctrl & MXC_F_UART_CTRL_BCLKSRC) == MXC_S_UART_CTRL_BCLKSRC_CLK2) {
periphClock = ERTCO_FREQ * 2;
} else if ((uart->ctrl & MXC_F_UART_CTRL_BCLKSRC) == MXC_S_UART_CTRL_BCLKSRC_CLK3) {
periphClock = INRO_FREQ * 2;
} else {
return E_BAD_PARAM;
}
return (periphClock / uart->clkdiv);
} else {
return MXC_UART_RevB_GetFrequency((mxc_uart_revb_regs_t *)uart);
}
return MXC_UART_RevB_GetFrequency((mxc_uart_revb_regs_t *)uart);
}

int MXC_UART_SetDataSize(mxc_uart_regs_t *uart, int dataSize)
Expand Down

0 comments on commit d4a64f0

Please sign in to comment.