mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 12:40:15 +01:00
stm32/pyb_can: Add ability to calculate CAN bit timing from baudrate.
Calculate the bit timing from baudrate if provided, allowing sample point override. This makes it a lot easier to make CAN work between different MCUs with different clocks, prescalers etc. Tested on F4, F7 and H7 Y/V variants.
This commit is contained in:
committed by
Damien George
parent
a13d1b50c9
commit
20f8ce1982
@@ -49,7 +49,7 @@ Class Methods
|
||||
Methods
|
||||
-------
|
||||
|
||||
.. method:: CAN.init(mode, extframe=False, prescaler=100, *, sjw=1, bs1=6, bs2=8, auto_restart=False)
|
||||
.. method:: CAN.init(mode, extframe=False, prescaler=100, *, sjw=1, bs1=6, bs2=8, auto_restart=False, baudrate=0, sample_point=75)
|
||||
|
||||
Initialise the CAN bus with the given parameters:
|
||||
|
||||
@@ -67,6 +67,11 @@ Methods
|
||||
- *auto_restart* sets whether the controller will automatically try and restart
|
||||
communications after entering the bus-off state; if this is disabled then
|
||||
:meth:`~CAN.restart()` can be used to leave the bus-off state
|
||||
- *baudrate* if a baudrate other than 0 is provided, this function will try to automatically
|
||||
calculate a CAN bit-timing (overriding *prescaler*, *bs1* and *bs2*) that satisfies both
|
||||
the baudrate and the desired *sample_point*.
|
||||
- *sample_point* given in a percentage of the bit time, the *sample_point* specifies the position
|
||||
of the last bit sample with respect to the whole bit time. The default *sample_point* is 75%.
|
||||
|
||||
The time quanta tq is the basic unit of time for the CAN bus. tq is the CAN
|
||||
prescaler value divided by PCLK1 (the frequency of internal peripheral bus 1);
|
||||
|
||||
Reference in New Issue
Block a user