mbed-os/hal
Kevin Bracey 904d4e4d2b Make ticker computation use shift-by-0
Runtime code that analysed clock frequency to determine numerator and
denominator for conversion to standard 1MHz failed to handle the case
of either being 1 correctly.

Although it would spot other values that could be performed as shifts,
it failed to spot that 1 is "shift by 0", so would end up doing runtime
multiply and/or divide by 1. The runtime divide by 1 could be slow on a
Cortex-M0 device, increasing interrupt latency.

UART character loss on STM32F0 devices has been traced to this incorrect
code.

Correct the `exact_log2` routine so that `exact_log2(1)` returns 0 to
fix this.

Original code had a single special no-multiply-or-divide case for
hardware clock frequency being exactly 1MHz, as USTICKER is on STM32F0 -
this code lacks that but has a more general special case that covers all
shift-convertible frequencies like 500kHz or 8MHz, which should be
similar speed as shifts are cheap.
2021-04-12 09:46:42 +03:00
..
TARGET_FLASH_CMSIS_ALGO Create FLASH CMSIS ALGO target to remove dependency on MBED_TARGET_LABELS 2021-02-19 16:56:37 +00:00
docs Replace USBTX/RX everywhere else 2021-03-24 10:11:30 +00:00
include/hal Replace USBTX/RX in docs 2021-03-24 10:18:34 +00:00
source Make ticker computation use shift-by-0 2021-04-12 09:46:42 +03:00
tests Update FPGA documentation 2021-04-06 15:13:51 +01:00
usb CMake: add mbed-os and mbed-baremetal targets 2020-11-06 17:25:22 +00:00
CMakeLists.txt Create FLASH CMSIS ALGO target to remove dependency on MBED_TARGET_LABELS 2021-02-19 16:56:37 +00:00