Skip to content

NMEA2000_can2040 library for Raspberry Pi Pico using CAN2040 PIO implementation

License

Notifications You must be signed in to change notification settings

speters/NMEA2000_can2040

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alpha status

sending does still not work

NMEA2000_can2040 library for Raspberry Pi Pico / RP2040

NMEA2000_can2040 is a driver supplement to NMEA2000 library by Timo Lappalainen.

It is based on the CAN2040 implementation by Kevin O'Connor which makes use of the Raspberry Pi Pico's PIO.

Besides the Raspberry Pi Pico, only a CAN transceiver with 3.3V IO like the SN65HVD230 (marking code VP230) is necessary.

Usage

// include NMEA2000_can2040.h header instead of NMEA2000_CAN.h
#include <NMEA2000_can2040.h>
#include <N2kMsg.h>
#include <NMEA2000.h>

// set NMEA2000 class
tNMEA2000_can2040 NMEA2000;

You can set PIO, TX-Pin & RX-Pin as follows:

  /// @brief NMEA2000 constructor
  /// @param _Pio PIO to use, either 0 or 1
  /// @param _TxPin TX pin, default defined CAN2040_TX_PIN 3
  /// @param _RxPin RX pin, default defined CAN2040_RX_PIN 4
  tNMEA2000_can2040(uint32_t _Pio = CAN2040_PIO, uint32_t _TxPin = CAN2040_TX_PIN, uint32_t _RxPin = CAN2040_RX_PIN);

Or use the preprocessor defines CAN2040_PIO, CAN2040_TX_PIN, CAN2040_RX_PIN before the inclusion of NMEA2000_can2040.h.

Hardware setup

You should use a CAN transceiver with 3.3V I/O, as the Pico RP2040 is a 3.3V device.

Connection example following the default setup: CAN transceiver connection to Raspberry Pi Pico

Make sure your bus termination is correct.

Licenses

CAN2040 is released under GPLv3.

NMEA2000_can2040 is released under MIT License (now get that sorted...).