STM32L0/L4 LPUART support Topic is solved

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
Post Reply
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

STM32L0/L4 LPUART support

Post by vrollei »

Hi,

updated ChibiOS 17.6.0 USARTv2 driver with STM32L0/L4 LPUART support is attached.
Is it possible to review and merge?
Attachments
lpuart.tar.gz
(14.35 KiB) Downloaded 416 times
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32L0/L4 LPUART support

Post by Giovanni »

Thanks.

Weekend task.

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32L0/L4 LPUART support

Post 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
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Re: STM32L0/L4 LPUART support

Post 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?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32L0/L4 LPUART support

Post 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
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Re: STM32L0/L4 LPUART support

Post 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)
Post Reply