aboutsummaryrefslogtreecommitdiff
path: root/ports/stm32/uart.c
AgeCommit message (Collapse)Author
2021-04-28stm32/uart: Fix H7 UART clock source configuration.iabdalkader
Previously to this commit, Usart16ClockSelection was overwritten and Usart234578ClockSelection was not set.
2021-04-13stm32/uart: Use LL_USART_GetBaudRate to compute baudrate.Damien George
This function includes the UART prescaler in the calculation (if it has one, eg on H7 and WB MCUs). Signed-off-by: Damien George <damien@micropython.org>
2021-02-21stm32/uart: Add support for LPUART1 on L0, L4, H7 and WB MCUs.Chris Mason
Add LPUART1 as a standard UART. No low power features are supported, yet. LPUART1 is enabled as the next available UART after the standard U(S)ARTs: STM32WB: LPUART1 = UART(2) STM32L0: LPUART1 = UART(6) STM32L4: LPUART1 = UART(6) STM32H7: LPUART1 = UART(9) On all ports: LPUART1 = machine.UART('LP1') LPUART1 is enabled by defining MICROPY_HW_LPUART1_TX and MICROPY_HW_LPUART1_RX in mpconfigboard.h. Signed-off-by: Chris Mason <c.mason@inchipdesign.com.au>
2021-02-14stm32/uart: Add uart_set_baudrate function.Damien George
This allows changing the baudrate of the UART without reinitialising it (reinitialising can lead to spurious characters sent on the TX line). Signed-off-by: Damien George <damien@micropython.org>
2020-09-08stm32/uart: Allow static IRQ handler registration.Jim Mussared
This will allow the HCI UART to use a non-heap mp_irq_obj_t, which avoids needing to make a root pointer for it.
2020-02-28all: Reformat C and Python source code with tools/codeformat.py.Damien George
This is run with uncrustify 0.70.1, and black 19.10b0.
2019-12-05stm32/uart: Add support for UART4/5 on L0 MCUs.Chris Mason
2019-09-27stm32/uart: Add RTS/CTS pin configuration support to UART4.Andrew Leech
2019-07-17stm32: Add initial support for STM32WBxx MCUs.Damien George
This new series of MCUs is similar to the L4 series with an additional Cortex-M0 coprocessor. The firmware for the wireless stack must be managed separately and MicroPython does not currently interface to it. Supported features so far include: RTC, UART, USB, internal flash filesystem.
2019-07-05stm32: Add initial support for STM32L0xx MCUs.Damien George
2019-07-03stm32: Update components to work with new H7xx HAL.Damien George
2019-05-02stm32: Add support for F413 MCUs.Chris Mason
Includes: - Support for CAN3. - Support for UART9 and UART10. - stm32f413xg.ld and stm32f413xh.ld linker scripts. - stm32f413_af.csv alternate function mapping. - startup_stm32f413xx.s because F413 has different interrupt vector table. - Memory configuration with: 240K filesystem, 240K heap, 16K stack.
2019-04-01stm32/uart: Handle correctly the char overrun case of RXNE=0 and ORE=1.Damien George
Fixes issue #3375.
2018-12-30stm32/uart: Make sure user IRQs are handled even with a keyboard intr.Damien George
2018-12-30stm32/uart: Clear overrun error flag after reading RX data register.Damien George
On MCUs other than F4 the ORE (overrun error) flag needs to be cleared independently of clearing RXNE, even though both are wired to trigger the same RXNE IRQ. In the case that an overrun occurred it's necessary to explicitly clear the ORE flag or else the RXNE interrupt will keep firing.
2018-12-29stm32/uart: Always enable global UART IRQ handler on init.Damien George
Otherwise IRQs may not be enabled for the user UART.irq() handler. In particular this fixes the user IRQ_RXIDLE interrupt so that it triggers even when there is no RX buffer.
2018-12-29stm32/uart: Fix uart_rx_any in case of no buffer to return 0 or 1.Damien George
2018-12-29stm32: Implement UART.irq() method with initial support for RX idle IRQ.Tobias Badertscher
2018-12-10stm32/uart: Add ability to have a static built-in UART object.Damien George
A static UART is useful for internal peripherals that require a UART and need to persist outside the soft-reset loop.
2018-12-10stm32/uart: Move config of char_width/char_mask to uart.c.Damien George
2018-12-10stm32/uart: For UART init, pass in params directly, not via HAL struct.Damien George
To provide a cleaner and more abstract C-level interface to the UART.
2018-12-10stm32/uart: Simplify deinit of UART, no need to call HAL.Damien George
The HAL just clears UE and then clears all the UART control registers.
2018-12-10stm32/uart: Remove HAL's UART_HandleTypeDef from UART object struct.Damien George
This UART_HandleTypeDef is quite large (around 70 bytes in RAM needed for each UART object) and is not needed: instead the state of the peripheral held in its registers provides all the required information.
2018-12-10stm32/uart: Factor out code to set RX buffer to function uart_set_rxbuf.Damien George
2018-12-10stm32/uart: Rework uart_get_baudrate so it doesn't need a UART handle.Damien George
2018-12-10stm32/uart: Factor out code from machine_uart.c that computes baudrate.Damien George
2018-12-10stm32: Split out UART Python bindings from uart.c to machine_uart.c.Damien George
2018-12-05stm32/uart: Add rxbuf keyword arg to UART constructor and init method.Damien George
As per the machine.UART documentation, this is used to set the length of the RX buffer. The legacy read_buf_len argument is retained for backwards compatibility, with rxbuf overriding it if provided.
2018-12-04stm32/uart: Always show the flow setting when printing a UART object.Damien George
Also change the order of printing of flow so it is after stop (so bits, parity, stop are one after the other), and reduce code size by using mp_print_str instead of mp_printf where possible. See issue #1981.
2018-09-21stm32/uart: Add support for USART3-8 on F0 MCUs.Damien George
2018-07-08stm32: Support compiling with object representation D.Damien George
With this and previous patches the stm32 port can now be compiled using object representation D (nan boxing). Note that native code and frozen mpy files with float constants are currently not supported with this object representation.
2018-05-28stm32: Add support for STM32F0 MCUs.Damien George
2018-05-02stm32/irq: Define IRQ priorities directly as encoded hardware values.Damien George
For a given IRQn (eg UART) there's no need to carry around both a PRI and SUBPRI value (eg IRQ_PRI_UART, IRQ_SUBPRI_UART). Instead, the IRQ_PRI_UART value has been changed in this patch to be the encoded hardware value, using NVIC_EncodePriority. This way the NVIC_SetPriority function can be used directly, instead of going through HAL_NVIC_SetPriority which must do extra processing to encode the PRI+SUBPRI. For a priority grouping of 4 (4 bits for preempt priority, 0 bits for the sub-priority), which is used in the stm32 port, the IRQ_PRI_xxx constants remain unchanged in their value. This patch also "fixes" the use of raise_irq_pri() which should be passed the encoded value (but as mentioned above the unencoded value is the same as the encoded value for priority grouping 4, so there was no bug from this error).
2018-04-23stm32/uart: Allow ctrl-C to work with UARTs put on REPL via os.dupterm.Damien George
2018-04-23stm32/uart: Allow ctrl-C to issue keyboard intr when REPL is over UART.Damien George
2018-03-28stm32: Change pin_X and pyb_pin_X identifiers to be pointers to objects.Damien George
Rather than pin objects themselves. The actual object is now pin_X_obj and defines are provided so that pin_X is &pin_X_obj. This makes it so that code that uses pin objects doesn't need to know if they are literals or objects (that need pointers taken) or something else. They are just entities that can be passed to the map_hal_pin_xxx functions. This mirrors how the core handles constant objects (eg mp_const_none which is &mp_const_none_obj) and allows for the possibility of different implementations of the pin layer. For example, prior to this patch there was the following: extern const pin_obj_t pin_A0; #define pyb_pin_X1 pin_A0 ... mp_hal_pin_high(&pin_A0); and now there is: extern const pin_obj_t pin_A0_obj; #define pin_A0 (&pin_A0_obj) #define pyb_pin_X1 pin_A0 ... mp_hal_pin_high(pin_A0); This patch should have minimal effect on board configuration files. The only change that may be needed is if a board has .c files that configure pins.
2018-03-27stm32: Consolidate include of genhdr/pins.h to single location in pin.h.Damien George
genhdr/pins.h is an internal header file that defines all of the pin objects and it's cleaner to have pin.h include it (where the struct's for these objects are defined) rather than an explicit include by every user.
2018-03-17stm32: Use STM32xx macros instead of MCU_SERIES_xx to select MCU type.Damien George
The CMSIS files for the STM32 range provide macros to distinguish between the different MCU series: STM32F4, STM32F7, STM32H7, STM32L4, etc. Prefer to use these instead of custom ones.
2018-03-09stm32/uart: Add UART support for H7 MCUs.iabdalkader
2018-02-13stm32: Update HAL macro and constant names to use newer versions.Damien George
Newer versions of the HAL use names which are cleaner and more self-consistent amongst the HAL itself. This patch switches to use those names in most places so it is easier to update the HAL in the future.
2017-12-23stm32/uart: Support board configs with CTS/RTS on UART6.Damien George
2017-12-22stm32/uart: Add support for 7-bit modes: 7N1 and 7N2.Peter D. Gray
2017-10-19stm32/mphalport: Improve efficiency of mp_hal_stdout_tx_strn_cooked.Damien George
Also simplifies the code by removing the specialised (and inefficient) cooked functions from UART and USB_VCP.
2017-10-04all: Remove inclusion of internal py header files.Damien George
Header files that are considered internal to the py core and should not normally be included directly are: py/nlr.h - internal nlr configuration and declarations py/bc0.h - contains bytecode macro definitions py/runtime0.h - contains basic runtime enums Instead, the top-level header files to include are one of: py/obj.h - includes runtime0.h and defines everything to use the mp_obj_t type py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h, and defines everything to use the general runtime support functions Additional, specific headers (eg py/objlist.h) can be included if needed.
2017-09-06ports: Make new ports/ sub-directory and move all ports there.Damien George
This is to keep the top-level directory clean, to make it clear what is core and what is a port, and to allow the repository to grow with new ports in a sustainable way.