2016-10-07 09:49 AM
Hi,
First let me say how much i hate the new Cube L0 concept. Stdperipheral libraries were so much easier to use and cost so much less flash space. Baudrate generator value is calculated using this formula #define __DIV_LPUART(_PCLK_, _BAUD_) ((uint32_t)(((((uint64_t)_PCLK_)*256.0) + (((uint64_t)_BAUD_)/2U)) / (((uint64_t)_BAUD_)))) It's nice, everythin in 64bit, except for the 256.0. This piece of code adds double arithmetics to the whole code. My (wanna be) bootloader went from 12kB to 6kB just by replacing this formula with: ((uint32_t)(((((uint64_t)_PCLK_) << 8) + (((uint64_t)_BAUD_) >> 1)) / (((uint64_t)_BAUD_))))2016-10-07 11:35 AM
I agree on the SPL stuff, and yikes!! Looks like LISP, they probably wanted 256L, still the divide has to be expensive.
It is a bit like the SDIO code, where they transform the blocks into byte offsets and back again repeatedly for no reason, and had to use 64-bit math for 4GB cards, where the rest of us can get 2TB keeping the block count in 32-bit.