Adding LPUART support beside UART in STM32L4

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
ajie_dirgantara
Posts: 81
Joined: Fri Sep 02, 2016 9:26 am

Adding LPUART support beside UART in STM32L4

Post by ajie_dirgantara » Thu Oct 05, 2017 9:24 am

I want to add LPUART support by reuse uart.c implementation in stm32 ports. a question :

on uart.c :

Code: Select all

...
        #if defined(MICROPY_HW_UART8_TX) && defined(MICROPY_HW_UART8_RX)
        case PYB_UART_8:
            uart_unit = 8;
            UARTx = UART8;
            irqn = UART8_IRQn;
            pins[0] = &MICROPY_HW_UART8_TX;
            pins[1] = &MICROPY_HW_UART8_RX;
            __UART8_CLK_ENABLE();
            break;
        #endif

        #if defined(MICROPY_HW_LPUART1_TX) && defined(MICROPY_HW_LPUART1_RX)
        case PYB_LPUART_1:
            uart_unit = 9;
            UARTx = LPUART1;
            irqn = LPUART1_IRQn;
            pins[0] = &MICROPY_HW_LPUART1_TX;
            pins[1] = &MICROPY_HW_LPUART1_RX;
            __LPUART1_CLK_ENABLE();
            break;
        #endif
...
which one is correct? Use uart_unit 9 to init the lpuart, or maybe replace uart_unit 1 to become lpuart?

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Adding LPUART support beside UART in STM32L4

Post by dhylands » Thu Oct 05, 2017 4:01 pm

In the teensy 3.6 port (I guess I should update my branch to the new layout) I left the assignment of the actual port numbers upto the config file.

See:
https://github.com/dhylands/micropython ... oard.h#L54

and
https://github.com/dhylands/micropython ... art.c#L195

Post Reply