theCore-embedded / theCore

theCore: C++ embedded framework
https://forgge.github.io/theCore
Mozilla Public License 2.0
81 stars 23 forks source link

Fix generation of the UART configs #365

Closed forGGe closed 6 years ago

forGGe commented 6 years ago

Generated UART configs are not valid.

Suppose, configuration JSON looks like:


{
    "platform": {
        "name": "tm4c",
        "console": "UART0",
        "uart": [
            {
                "id": "UART0",
                "alias": "test_uart",
                "comment": "UART-over-USB console output"
            },
            {
                "id": "UART1",
                "alias": "another_uart",
                "comment": "Example UART"
            }
        ]
    }
}

Expected generated code:

namespace ecl
{

// UART configuration ---------------------------------------------------------

/* UART-over-USB console output */
static constexpr uart_channel UART0_channel = uart_channel::ch0;
using UART0_driver = uart<UART0_channel>;
using platform_console = UART0_driver;
using test_uart = UART0_driver;

/* Example UART */
static constexpr uart_channel UART1_channel = uart_channel::ch1;
using UART1_driver = uart<UART1_channel>;
using another_uart = UART1_driver;

} // namespace ecl

Actual:

namespace ecl
{

// UART configuration ---------------------------------------------------------

/* UART-over-USB console output */
static constexpr uart_channel template_console_dev = uart_channel::ch0;
using platform_console = uart<template_console_dev>;

/* Example UART */
static constexpr uart_channel template_console_dev = uart_channel::ch1;
using platform_console = uart<template_console_dev>;

} // namespace ecl

See: https://forgge.github.io/theCore/platform/ti-tivac-tm4c123g.html#example-output