Skip to content

Commit

Permalink
imxrt-multi: Allow UART_CONSOLE_USER to be defined empty
Browse files Browse the repository at this point in the history
JIRA: RTOS-754
  • Loading branch information
jmaksymowicz committed Sep 27, 2024
1 parent ad38807 commit 3af1373
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
35 changes: 22 additions & 13 deletions multi/imxrt-multi/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@

/* clang-format on */

#if !defined(UART_CONSOLE) && !defined(RTT_CHANNEL_CONSOLE)
#ifndef UART_CONSOLE
#if defined(__CPU_IMXRT105X)
#define UART_CONSOLE 1
#elif defined(__CPU_IMXRT106X)
Expand All @@ -766,14 +766,22 @@
#endif
#endif

#if defined(UART_CONSOLE)
#if ISEMPTY(UART_CONSOLE)
#error "UART_CONSOLE must not be empty"
#elif UART_CONSOLE <= 0
#if !ISEMPTY(UART_CONSOLE)
#if UART_CONSOLE <= 0
#error "Invalid value for UART_CONSOLE"
#endif
#endif

#if defined(UART_CONSOLE_USER)
#if !ISEMPTY(UART_CONSOLE_USER)
#if (UART_CONSOLE_USER <= 0)
#error "Invalid value for UART_CONSOLE_USER"
#endif
#endif
#else
#define UART_CONSOLE_USER UART_CONSOLE
#endif


/* RTT */

Expand Down Expand Up @@ -802,18 +810,19 @@
#endif


#if defined(UART_CONSOLE) && defined(RTT_CHANNEL_CONSOLE)
#error "Console on UART and RTT not supported"
#elif defined(RTT_CHANNEL_CONSOLE)
#if ISEMPTY(RTT_CHANNEL_CONSOLE)
#error "RTT_CHANNEL_CONSOLE must not be empty"
#elif RTT_CHANNEL_CONSOLE < 0
#ifndef RTT_CHANNEL_CONSOLE
#define RTT_CHANNEL_CONSOLE
#elif !ISEMPTY(RTT_CHANNEL_CONSOLE)
#if RTT_CHANNEL_CONSOLE < 0
#error "Invalid value for RTT_CHANNEL_CONSOLE"
#endif

#define ONLY_RTT_CONSOLE
#endif

#if !ISEMPTY(UART_CONSOLE_USER) && !ISEMPTY(RTT_CHANNEL_CONSOLE)
#error "Console on both UART and RTT not supported"
#elif ISEMPTY(UART_CONSOLE_USER) && ISEMPTY(RTT_CHANNEL_CONSOLE)
#error "Console must be either on UART or RTT"
#endif

/* SPI */

Expand Down
9 changes: 6 additions & 3 deletions multi/imxrt-multi/imxrt-multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,13 @@ static void uart_dispatchMsg(msg_t *msg)

switch (id) {
case id_console:
#ifdef ONLY_RTT_CONSOLE
#if !ISEMPTY(RTT_CHANNEL_CONSOLE)
rtt_handleMsg(msg, RTT_CHANNEL_CONSOLE + id_rtt0);
#else
#elif !ISEMPTY(UART_CONSOLE_USER)
uart_handleMsg(msg, UART_CONSOLE - 1 + id_uart1);
#else
/* TODO: Add support for no console */
msg->o.err = -ENODEV;
#endif
break;

Expand Down Expand Up @@ -608,7 +611,7 @@ int main(void)
oid.id = id_console;
create_dev(&oid, _PATH_CONSOLE);

#ifdef ONLY_RTT_CONSOLE
#if !ISEMPTY(RTT_CHANNEL_CONSOLE)
libklog_init(rtt_klogCblk);
#else
libklog_init(uart_klogCblk);
Expand Down
2 changes: 1 addition & 1 deletion multi/imxrt-multi/rtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ int rtt_init(void)

void rtt_klogCblk(const char *data, size_t size)
{
#ifdef RTT_CHANNEL_CONSOLE
#if !ISEMPTY(RTT_CHANNEL_CONSOLE)
libtty_write(&rtt_common.uarts[rttPos[RTT_CHANNEL_CONSOLE]].tty_common, data, size, 0);
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions multi/imxrt-multi/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,8 @@ static void uart_initPins(void)

void uart_klogCblk(const char *data, size_t size)
{
#ifdef UART_CONSOLE
libtty_write(&uart_common.uarts[uartPos[UART_CONSOLE - 1]].tty_common, data, size, 0);
#if !ISEMPTY(UART_CONSOLE_USER)
libtty_write(&uart_common.uarts[uartPos[UART_CONSOLE_USER - 1]].tty_common, data, size, 0);
#endif
}

Expand Down

0 comments on commit 3af1373

Please sign in to comment.