computeTimings required PCLK to be an exact integer multiple of the
target bitrate. On MSI-PLL/LSE clocked L4 boards PCLK is 79.96MHz, so the
1Mbit search truncated 79.96 to 79 (prime), found no solution, and left
the CAN interface uninitialised. Round the prescaler search to nearest
and accept the closest achievable bitrate within 1%. This is a no-op
where PCLK is an exact multiple, so other boards are unaffected.
As commented and detailed in the previous commit, it wasn't commonly used
and was disabled by switching the hardware to FIFO mode, so there is no
need for the software support.
Changes behavior on bxCAN based flight controllers only.
AP_Periph was already assuming this behavior by never checking the write
result of `select` and instead just sending frames and relying on the
mailbox full check.
This therefore fixes AP_Periph misordering multi-part messages. Each part
is the same priority, so in priority mode the hardware transmits in slot
order, which may not equal queue order.
bxCAN based flight controllers no longer use priority now, but FDCAN
always used FIFO mode so this brings the drivers closer anyway.
In all cases before and after this patch, priority is maintained in
libcanard so only the highest priority frames are dequeued for
transmission by the hardware anyway. But if a high priority message is
enqueued in the hardware, it will not be transmitted until lower priority
messages in the hardware are sent first. This is against CAN priority
semantics, where higher priority messages should be transmitted first.
Fortunately, it has worked well in practice. (Though there was still the
possibility for a higher priority message to be dequeued and not have
space in the hardware even in priority mode).
This is due to the way that the APB peripheral was configured. RCC_APB1ENR1_CAN2EN was not accounted for in the CAN hardware init, so CAN2 clock init was never attempted.
I copied the way CAN1 is initialized based on different hardware description headers.
this saves flash space and makes CAN forwarding for any bus without
reconfigure/reboot easy. CAN filtering is not useful in the main
flight controller firmware as we want to see nearly all packets