NMEA2000 Library
0.1
Library to handle NMEA 2000 Communication written in C++
|
Automatic library selection according to the selected board. More...
#include "N2kMsg.h"
#include "NMEA2000.h"
#include <SPI.h>
#include <mcp_can.h>
#include <NMEA2000_mcp.h>
Go to the source code of this file.
Macros | |
#define | MCP_CAN_CLOCK_SET MCP_16MHz |
The Clock frequency for the MCP CAN is 16MHz. More... | |
#define | MCP_CAN_RX_BUFFER_SIZE 1 |
Definition of the MCP RX Buffer Size Value of 1 is a small buffer size to save memory. More... | |
#define | N2k_CAN_INT_PIN 0xff |
Definition of the CAN Interrupt Pin This defines the number of the CAN Interrupt PIN. Default Value 0xff means not Interrupt PIN in use. More... | |
#define | N2k_SPI_CS_PIN 53 |
Definition of the SPI ChipSelectPin for the CAN Transceiver This defines the the I/O Pin uses for the Chip Select Line to the corresponding CAN Transceiver. More... | |
#define | USE_MCP_CAN_CLOCK_SET 16 |
Definition of the Clock frequency for the MCP CAN. More... | |
#define | USE_N2K_ARDUINO_CAN 9 |
Use the Official Arduino CAN Library. More... | |
#define | USE_N2K_AVR_CAN 4 |
Use the AVR CAN Library. More... | |
#define | USE_N2K_CAN USE_N2K_MCP_CAN |
Selector for the right board. More... | |
#define | USE_N2K_DUE_CAN 2 |
Use the Arduino Due CAN Library. More... | |
#define | USE_N2K_ESP32_CAN 7 |
Use the ESP32 CAN Library. More... | |
#define | USE_N2K_MBED_CAN 6 |
Use the MBED CAN Library. More... | |
#define | USE_N2K_MCP_CAN 1 |
Use the mcp_can library. More... | |
#define | USE_N2K_SOCKET_CAN 5 |
Use the Linux Socket CAN Library. More... | |
#define | USE_N2K_TEENSY_CAN 3 |
Use the Teensy3.x CAN Library. More... | |
#define | USE_N2K_TEENSYX_CAN 8 |
Use the Teensy4.x CAN Library. More... | |
Variables | |
tNMEA2000 & | NMEA2000 =*(new tNMEA2000_mcp(N2k_SPI_CS_PIN,MCP_CAN_CLOCK_SET,N2k_CAN_INT_PIN,MCP_CAN_RX_BUFFER_SIZE)) |
Automatic library selection according to the selected board.
Just include this <NMEA2000_CAN.h> to your project and it will automatically select suitable CAN library according to board selected on Arduino development environment. You can still force library by adding one of next defines before including NMEA2000_CAN.h:
Depending of your board you will need to also install "driver" libraries:
see also Hardware depended libraries
Arduino CAN shield (mcp_can) with MCP2515 chip:
Arduino DUE internal CAN:
Teensy 3.2-3.6 internal CAN:
Teensy 4.X internal CAN:
ESP32 internal CAN:
AVR:
MBED (note that there may be problem with fastpackets on MBED):
RPi socket CAN:
There are also library specific defines:
mcp_can:
esp32:
Teensy:
Teensyx:
Arduino DUE:
Definition in file NMEA2000_CAN.h.
#define MCP_CAN_CLOCK_SET MCP_16MHz |
The Clock frequency for the MCP CAN is 16MHz.
Definition at line 347 of file NMEA2000_CAN.h.
#define MCP_CAN_RX_BUFFER_SIZE 1 |
Definition of the MCP RX Buffer Size Value of 1 is a small buffer size to save memory.
Definition at line 313 of file NMEA2000_CAN.h.
#define N2k_CAN_INT_PIN 0xff |
Definition of the CAN Interrupt Pin This defines the number of the CAN Interrupt PIN. Default Value 0xff means not Interrupt PIN in use.
Definition at line 305 of file NMEA2000_CAN.h.
#define N2k_SPI_CS_PIN 53 |
Definition of the SPI ChipSelectPin for the CAN Transceiver This defines the the I/O Pin uses for the Chip Select Line to the corresponding CAN Transceiver.
Definition at line 325 of file NMEA2000_CAN.h.
#define USE_MCP_CAN_CLOCK_SET 16 |
Definition of the Clock frequency for the MCP CAN.
Definition at line 333 of file NMEA2000_CAN.h.
#define USE_N2K_ARDUINO_CAN 9 |
Use the Official Arduino CAN Library.
Definition at line 191 of file NMEA2000_CAN.h.
#define USE_N2K_AVR_CAN 4 |
Use the AVR CAN Library.
Definition at line 157 of file NMEA2000_CAN.h.
#define USE_N2K_CAN USE_N2K_MCP_CAN |
Selector for the right board.
Definition at line 225 of file NMEA2000_CAN.h.
#define USE_N2K_DUE_CAN 2 |
Use the Arduino Due CAN Library.
Definition at line 142 of file NMEA2000_CAN.h.
#define USE_N2K_ESP32_CAN 7 |
#define USE_N2K_MBED_CAN 6 |
Use the MBED CAN Library.
Definition at line 172 of file NMEA2000_CAN.h.
#define USE_N2K_MCP_CAN 1 |
Use the mcp_can library.
CAN_BUS_shield libraries will be originally found on https://github.com/Seeed-Studio/CAN_BUS_Shield There is improved library, which branch can be found on https://github.com/peppeve/CAN_BUS_Shield.
That works also with Maple mini and 8 MHz clock. Hopefully these improvements will be applied to original library
Definition at line 135 of file NMEA2000_CAN.h.
#define USE_N2K_SOCKET_CAN 5 |
Use the Linux Socket CAN Library.
Definition at line 165 of file NMEA2000_CAN.h.
#define USE_N2K_TEENSY_CAN 3 |
Use the Teensy3.x CAN Library.
Definition at line 150 of file NMEA2000_CAN.h.
#define USE_N2K_TEENSYX_CAN 8 |
Use the Teensy4.x CAN Library.
Definition at line 185 of file NMEA2000_CAN.h.
tNMEA2000& NMEA2000 =*(new tNMEA2000_mcp(N2k_SPI_CS_PIN,MCP_CAN_CLOCK_SET,N2k_CAN_INT_PIN,MCP_CAN_RX_BUFFER_SIZE)) |
Definition at line 350 of file NMEA2000_CAN.h.