This patch adds the STM32L4x5 USART (Universal Synchronous/Asynchronous Receiver/Transmitter) device and is part of a series implementing the STM32L4x5 with a few peripherals.
It implements the necessary functionalities to receive/send characters over the serial port, which are useful to communicate with the program currently running. Many thanks Peter for your review, I think I addressed almost everything. I'm just unsure about how to handle the waiting time in the tests. I understand your concerns about the unreliability of using the wallclock time but I don't understand how using clock_step() would make it more reliable. We will always be waiting on something that is out of our control (i.e. the OS). I increased the delay from 5s to 10min to match the microbit test and added a comment (I paraphrased your comment, is that okay ?). I also saw that Philippe Mathieu-Daudé have sent a patchset with the first commit of this patchset and another commit to make clock_set_mul_div() return a boolean. If this is merged before this patchset (which will probably be the case), I will remove the first commit. Changes from v1 to v2: - Use asynchronous transmission for serial communication (based on cmsdk-apb-uart implementation) - Use qemu_log_mask instead of error_report - Squash the commit that renamed the base struct - Use switch statements where appropriate - Fix RDR and TDR mask size - Increase time limit in tests - Remove the global qtest in the tests - Use assert when checking the interrupt number in the tests - Correct usage of g_autofree in the SoC Arnaud Minier (6): hw/misc/stm32l4x5_rcc: Propagate period when enabling a clock hw/char: Implement STM32L4x5 USART skeleton hw/char/stm32l4x5_usart: Enable serial read and write hw/char/stm32l4x5_usart: Add options for serial parameters setting hw/arm: Add the USART to the stm32l4x5 SoC tests/qtest: Add tests for the STM32L4x5 USART MAINTAINERS | 1 + docs/system/arm/b-l475e-iot01a.rst | 2 +- hw/arm/Kconfig | 1 + hw/arm/stm32l4x5_soc.c | 82 +++- hw/char/Kconfig | 3 + hw/char/meson.build | 1 + hw/char/stm32l4x5_usart.c | 632 +++++++++++++++++++++++++++++ hw/char/trace-events | 12 + hw/misc/stm32l4x5_rcc.c | 7 +- include/hw/arm/stm32l4x5_soc.h | 13 + include/hw/char/stm32l4x5_usart.h | 67 +++ tests/qtest/meson.build | 3 +- tests/qtest/stm32l4x5_usart-test.c | 326 +++++++++++++++ 13 files changed, 1141 insertions(+), 9 deletions(-) create mode 100644 hw/char/stm32l4x5_usart.c create mode 100644 include/hw/char/stm32l4x5_usart.h create mode 100644 tests/qtest/stm32l4x5_usart-test.c -- 2.34.1