From 08a511726244be8ca18d00df3c5906cd4d680ef6 Mon Sep 17 00:00:00 2001 From: Pespiri Date: Wed, 22 Dec 2021 21:29:34 +0100 Subject: [PATCH] add timing for 47kbps --- README.md | 1 + examples/recv/recv.ino | 1 + examples/send/send.ino | 1 + examples/set_mask_filter_recv/set_mask_filter_recv.ino | 4 +--- examples/set_mask_filter_send/set_mask_filter_send.ino | 2 +- keywords.txt | 1 + mcp_can.cpp | 6 ++++++ mcp_can_dfs.h | 5 +++++ 8 files changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ff3a266..86690ed 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ here are many examples implemented in this library. One of the examples is below #define CAN_31K25BPS 5 #define CAN_33KBPS 6 #define CAN_40KBPS 7 + #define CAN_47KBPS 19 #define CAN_50KBPS 8 #define CAN_80KBPS 9 #define CAN_83K3BPS 10 diff --git a/examples/recv/recv.ino b/examples/recv/recv.ino index 1a47feb..91d80ca 100644 --- a/examples/recv/recv.ino +++ b/examples/recv/recv.ino @@ -10,6 +10,7 @@ #define CAN_31K25BPS 5 #define CAN_33KBPS 6 #define CAN_40KBPS 7 + #define CAN_47KBPS 19 #define CAN_50KBPS 8 #define CAN_80KBPS 9 #define CAN_83K3BPS 10 diff --git a/examples/send/send.ino b/examples/send/send.ino index 89370cb..eee9dda 100644 --- a/examples/send/send.ino +++ b/examples/send/send.ino @@ -10,6 +10,7 @@ #define CAN_31K25BPS 5 #define CAN_33KBPS 6 #define CAN_40KBPS 7 + #define CAN_47KBPS 19 #define CAN_50KBPS 8 #define CAN_80KBPS 9 #define CAN_83K3BPS 10 diff --git a/examples/set_mask_filter_recv/set_mask_filter_recv.ino b/examples/set_mask_filter_recv/set_mask_filter_recv.ino index ed09cf1..9d66dba 100644 --- a/examples/set_mask_filter_recv/set_mask_filter_recv.ino +++ b/examples/set_mask_filter_recv/set_mask_filter_recv.ino @@ -10,6 +10,7 @@ #define CAN_31K25BPS 5 #define CAN_33KBPS 6 #define CAN_40KBPS 7 + #define CAN_47KBPS 19 #define CAN_50KBPS 8 #define CAN_80KBPS 9 #define CAN_83K3BPS 10 @@ -26,10 +27,7 @@ CANBed M0: https://www.longan-labs.cc/1030014.html CAN Bus Shield: https://www.longan-labs.cc/1030016.html OBD-II CAN Bus GPS Dev Kit: https://www.longan-labs.cc/1030003.html - */ -#include -#include "mcp_can.h" #include #include "mcp_can.h" diff --git a/examples/set_mask_filter_send/set_mask_filter_send.ino b/examples/set_mask_filter_send/set_mask_filter_send.ino index db2059a..47c22c0 100644 --- a/examples/set_mask_filter_send/set_mask_filter_send.ino +++ b/examples/set_mask_filter_send/set_mask_filter_send.ino @@ -11,6 +11,7 @@ #define CAN_31K25BPS 5 #define CAN_33KBPS 6 #define CAN_40KBPS 7 + #define CAN_47KBPS 19 #define CAN_50KBPS 8 #define CAN_80KBPS 9 #define CAN_83K3BPS 10 @@ -27,7 +28,6 @@ CANBed M0: https://www.longan-labs.cc/1030014.html CAN Bus Shield: https://www.longan-labs.cc/1030016.html OBD-II CAN Bus GPS Dev Kit: https://www.longan-labs.cc/1030003.html - */ #include diff --git a/keywords.txt b/keywords.txt index 2a13195..e925111 100644 --- a/keywords.txt +++ b/keywords.txt @@ -32,6 +32,7 @@ CAN_25KBPS LITERAL1 CAN_31KBPS LITERAL1 CAN_33KBPS LITERAL1 CAN_40KBPS LITERAL1 +CAN_47KBPS LITERAL1 CAN_50KBPS LITERAL1 CAN_80KBPS LITERAL1 CAN_83KBPS LITERAL1 diff --git a/mcp_can.cpp b/mcp_can.cpp index 1434405..c6c839e 100644 --- a/mcp_can.cpp +++ b/mcp_can.cpp @@ -273,6 +273,12 @@ byte MCP_CAN::mcp2515_configRate(const byte canSpeed) cfg3 = MCP_16MHz_40kBPS_CFG3; break; + case (CAN_47KBPS): + cfg1 = MCP_16MHz_47kBPS_CFG1; + cfg2 = MCP_16MHz_47kBPS_CFG2; + cfg3 = MCP_16MHz_47kBPS_CFG3; + break; + case (CAN_50KBPS): cfg1 = MCP_16MHz_50kBPS_CFG1; cfg2 = MCP_16MHz_50kBPS_CFG2; diff --git a/mcp_can_dfs.h b/mcp_can_dfs.h index cbe1df6..00df7d9 100644 --- a/mcp_can_dfs.h +++ b/mcp_can_dfs.h @@ -255,6 +255,10 @@ #define MCP_16MHz_50kBPS_CFG2 (0xFA) #define MCP_16MHz_50kBPS_CFG3 (0x87) +#define MCP_16MHz_47kBPS_CFG1 (0x06) +#define MCP_16MHz_47kBPS_CFG2 (0xBE) +#define MCP_16MHz_47kBPS_CFG3 (0x07) + #define MCP_16MHz_40kBPS_CFG1 (0x07) #define MCP_16MHz_40kBPS_CFG2 (0xFF) #define MCP_16MHz_40kBPS_CFG3 (0x87) @@ -326,6 +330,7 @@ #define CAN_31K25BPS 5 #define CAN_33KBPS 6 #define CAN_40KBPS 7 +#define CAN_47KBPS 19 #define CAN_50KBPS 8 #define CAN_80KBPS 9 #define CAN_83K3BPS 10