Code Monkey home page Code Monkey logo

nmea2000_stm32's Introduction

NMEA2000_STM32 CAN library

Designed for STM32F105 CAN gateway. https://github.com/BitterAndReal/STM32_NMEA2000_CAN_gateway Might also works with F103 / F107 / F405 / F407... and other STM32 MCU's with integrated bxCAN controller.

To use this library, you will also need:

                           ┌───────────────────────────┐
                           │  STM32F1xx_HAL_Driver     │
                           │                           │
                           │  STM32F1xx_LL_Driver      │
                           └────────┬────────────┬─────┘
                                    │            │
┌──────────────────┐     ┌──────────▼────────┐   │
│  NMEA2000 class  │     │  STM32_CAN class  │   │
└────────────┬─────┘     └─────┬─────────┬───┘   │
             │                 │         │       │
      ┌──────▼─────────────────▼─────┐   │       │
      │ NMEA2000_STM32 derived class │   │       │
      └───────────────┬──────────────┘   │       │
                      │                  │       │
┌─────────────────────▼──────────────────▼───────▼────┐
│  YOUR STM32 PROJECT                                 │
└─────────────────────────────────────────────────────┘

Examples


STM23CubeIDE setup

If you are not very experienced with STM23CubeIDE this guide can help to configure a project for your own STM32 based hardware. I recommend start with this example

  • Create a STM32 C++ project in STM23CubeIDE
  • Select your MCU which will add the correct HAL to your project.
  • We can not directly call C++ from the main.c

    Create your own application.cpp & application.hpp files with your C++ project setup() and loop() which are called from with extern "C" {... From there you can include "NMEA2000.h" & "NMEA2000_STM32.hpp" & "STM32_CAN.hpp" and call the NMEA2000 methods.

  • In Cube MX configure external clock settings of your MCU.

    CAN bus needs an external clock source!

  • Activate the CAN bus you want to use.
  • Enable the CAN RX1 interrupt in the NVIC settings
  • Enable the CAN TX interrupt in the NVIC settings
  • Copy the NMEA2000 and NMEA_STM32 library's to your "Libs" folder of your STM32Cube project or use linked git submodules.
    // Use the following git commands to add submodules
    cd YourProjectRepo/Libs
    git submodule add https://github.com/ttlappalainen/NMEA2000
    git submodule update --init --recursive
    git submodule add https://github.com/BitterAndReal/NMEA2000_STM32
    git submodule update --init --recursive
    git submodule add https://github.com/BitterAndReal/STM32_CAN
    git submodule update --init --recursive
    // and update them with 
    git pull --recurse-submodules
    git submodule update --remote --recursive
    
  • Add the library folders to the G++ compiler include paths:
    • Select your project in the Project Explorer.
    • go to: File > Properties > C/C++ Build > Settings > MCU G++ Compiler > Include paths
    • Add the NMEA2000 and NMEA_STM32 library folders to the included paths
  • If you want to use the CAN init of the library, which sets the CAN baud rate and filters, disable the STM32CubeIDE generated code.

    Navigate to “Project Manager” > “Advanced Settings” find MX_CAN#_Init” and enable “Do Not Generate Function Call”.

  • By default, the peripheral MSP initialization function HAL_CAN_MspInit (in stm32xxx_hal_msp.c) is automatically called and takes care of the configuration of the CAN_RX/TX GPIOs, enabling of the peripheral clock and enabling of the CAN interrupts
  • Check the following link for NMEA2000 examples. https://github.com/ttlappalainen/NMEA2000/tree/master/Examples

Thanks for the great NMEA2000 CAN lib example Teensyx by ttlappalainen. https://github.com/ttlappalainen/NMEA2000_Teensyx


License

The MIT License

Copyright (c) 2022 Minos Eigenheer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-
1301  USA

nmea2000_stm32's People

Contributors

minoseigenheer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

safinwb

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.