As you already noticed 95kb/s is missing from most libraries. The reason is that you cannot derive that bitrate from the same crystal used for all the other standard CAN bitrates.
The bitrate is derived by dividing the clock frequency non-fractional. When you work backwards, you can see that you would need to divide 16 and 8MHz by a fraction to get 95kHz.
16MHz / 95kHz = 168.42
8MHz / 95kHz = 84.21
With an 8MHz crystal you could get a bit rate of 95.238kb/s when you divide by 84.
The MCP2515 divides the clock by 2 and then you can use a 1:2 prescaler and 21TQ = 84.
The configuration registers would need to be CNF1 = 0x01, CNF2 = 0xBB, CNF3 = 0x07.
There is a high likelihood this will not work. The CAN bit timing requires a high precision.
The better way would be to get a crystal that has the right frequency so the bitrate can be created accurately. 9.5MHz and 19MHz would be the first obvious choices. But there are others possible.
9.5MHz - CNF1 = 0x01, CNF2 = 0xBF, CNF3 = 0x07.
19MHz - CNF1 = 0x03, CNF2 = 0xBF, CNF3 = 0x07.
To modify the library, you need to
- add a new clock speed to the CAN_CLOCK enum in mcp2515.h
- add some defines just above CAN_CLOCK the enum
define MCP_19MHz_95kBPS_CFG1 (0x03)
define MCP_19MHz_95kBPS_CFG2 (0xBF)
define MCP_91MHz_95kBPS_CFG3 (0x07)
- In the mcp2515.cpp file create a new case in the following function. You only need to create one speed setting for 95kb/s.
MCP2515::ERROR MCP2515::setBitrate(const CAN_SPEED canSpeed, CAN_CLOCK canClock)
Let me know when you have any questions.