尚未偵測到更新。GitHub 發布版本後會顯示在這裡。
個人 GitHub 帳號下公開儲存庫的擁有者可以登入並驗證所有權,自行管理介紹,無需管理員核准。
登入並產生驗證檔案,在 30 分鐘內將其提交至此儲存庫的預設分支。其他分支或分叉儲存庫中的檔案無效。然後在下方檢查檔案,即可無需管理員核准直接管理專案。請保留檔案以維持管理權限。
如需登入,將前往登入頁面。登入後請回到此處,再次點擊所選的驗證按鈕。
在專案資料夾中執行 /nomorevibe verify,即可驗證所有權並自行管理介紹。
一分鐘完成驗證C99 CAN FD bit-timing library for Bosch M_CAN: finds exact settings, encodes NBTP/DBTP/TDCR with transmitter delay compensation. No heap, tested against the web calculator, CI with sanitizers.
翻譯準備中
取自儲存庫 README
正在載入完整 README。
檢視完整 README ↗A small C99 library that finds CAN FD bit timings for Bosch M_CAN-style controllers, and encodes them into
the NBTP, DBTP and TDCR registers, including transmitter delay compensation. No dependencies, no heap,
one header. It is the C version of the calculator on
moutazm.com/projects/can-tools, and the tests check that both agree.
$ ./canfd-bt 40 500 80 2000 75
4 valid settings, best:
nominal brp 1 tq 80 = 1 + 63 + 16 sjw 16 sample point 80.00 %
data brp 1 tq 20 = 1 + 14 + 5 sjw 5 sample point 75.00 %
TDC on, TDCO = 15 clock cycles
M_CAN NBTP 0x1E003E0F DBTP 0x00800D44 TDCR 0x00000F00
Linux ip link set can0 up type can bitrate 500000 sample-point 0.800 dbitrate 2000000 dsample-point 0.750 fd on
For a CAN clock, a nominal and a data bit rate and two target sample points it:
m_can driver uses):
nominal prescaler 1–512, TSEG1 2–256, TSEG2 2–128; data prescaler 1–32, TSEG1 1–32, TSEG2 1–16;TDCO = data BRP × (1 + TSEG1) and says whether TDC is
allowed (ISO 11898-1: data prescaler 1 or 2 only);#include "canfd_bittiming.h"
cfd_setting best[3];
size_t n = cfd_solve(40000000u, 500000u, 0.80, 2000000u, 0.75, true, best, 3);
if (n) {
bool tdc = cfd_tdc_possible(&best[0].data);
uint32_t nbtp = cfd_mcan_nbtp(&best[0].nominal);
uint32_t dbtp = cfd_mcan_dbtp(&best[0].data, tdc);
uint32_t tdcr = cfd_mcan_tdcr(&best[0].data);
}
cfd_solve returns how many valid settings exist and writes the best max (up to 64) into your buffer, best
first. Pass NULL, 0 to only count.
make # libcanfd_bittiming.a + the canfd-bt command-line tool
make test # unit tests
CI builds with gcc and clang, -std=c99 -Wall -Wextra -Wpedantic -Wshadow -Wconversion -Werror, and runs the
tests again under AddressSanitizer and UndefinedBehaviorSanitizer. The reference cases in
tests/test_bittiming.c (prescalers, time quanta, segments, SJW, register values, TDCO, number of solutions) were
generated by the website's JavaScript, so a change in either one shows up as a failing test.
MIT