Page 1 of 1

STM32L0/L4 LPUART support  Topic is solved

Posted: Tue Sep 12, 2017 12:09 pm
by vrollei
Hi,

updated ChibiOS 17.6.0 USARTv2 driver with STM32L0/L4 LPUART support is attached.
Is it possible to review and merge?

Re: STM32L0/L4 LPUART support

Posted: Tue Sep 12, 2017 12:28 pm
by Giovanni
Thanks.

Weekend task.

Giovanni

Re: STM32L0/L4 LPUART support

Posted: Sun Sep 24, 2017 4:03 pm
by Giovanni
Hi,

The patch is not aligned with trunk, the real problem is that it uses 64 bits arithmetic in usart_start(), is this really required?

Also, all mcuconf.h files should be aligned with the new settings.

Giovanni

Re: STM32L0/L4 LPUART support

Posted: Sun Sep 24, 2017 6:02 pm
by vrollei
Hi,

64-bit part is completely the same as in hal_serial.c:
#if STM32_SERIAL_USE_LPUART1
if ( sdp == &LPSD1 )
{
u->BRR = (uint32_t)( ( (uint64_t)sdp->clock * 256 ) / config->speed);
}
else
#endif

if it is a problem, will try to do it only with uint32_t.

mcuconf.h files should be aligned: do you mean to define STM32_HAS_LPUART1 in all stm32_registry.h?

Re: STM32L0/L4 LPUART support

Posted: Sun Sep 24, 2017 6:10 pm
by Giovanni
I have not noticed it in the serial driver... thanks for pointing that out. If you find a 32bits-only solution then I will apply it also on the serial driver, if not then let's keep the 64 bits arithmetics.

Correct, all registry files have to be updated and have those keys to FALSE. All L4 mcuconf.h files have to be updated too but we are in the middle of huge HAL changes so that will be done at the end, no need to do this now.

Giovanni

Re: STM32L0/L4 LPUART support

Posted: Mon Sep 25, 2017 3:47 pm
by vrollei
Hi,

STM32_HAS_LPUART1 macro set in all stm32_registry.h files already, so there is no reason to change it again, we need just merge l0/l4 registry file with new LPUART macros and hal_uart_lld

I would suggest this solution for 32bits only arithmetic:

Code: Select all

if sdp->clock <= 0xFFFFFF then
   BRR = (sdp->clock * 256 ) / config->speed
else
   BRR = ((sdp->clock / 100) * 256 ) / (config->speed / 100)