NMEA2000 Library  0.1
Library to handle NMEA 2000 Communication written in C++
N2kDef.h
Go to the documentation of this file.
1/*
2 * N2kDef.h
3 * Copyright (c) 2019-2024 Timo Lappalainen, Kave Oy, www.kave.fi
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21*/
22
23/*************************************************************************/
29#ifndef _tN2kDef_H_
30#define _tN2kDef_H_
31
32#include <stdint.h>
33
34#if !defined(ARDUINO)
35extern "C" {
36// Current uptime in milliseconds. Must be implemented by application.
37extern uint32_t millis();
38}
39#endif
40
41// Declare PROGMEM macros to nothing on non-AVR targets.
42#if !defined(__AVR__) && !defined(ARDUINO)
43// ESP8266 provides it's own definition - Do not override it.
44#if !defined(ARDUINO_ARCH_ESP8266)
45#define PROGMEM
46#define pgm_read_byte(var) *var
47#define pgm_read_word(var) *var
48#define pgm_read_dword(var) *var
49#endif
50#endif
51
52// Definition for the F(str) macro. On Arduinos use what the framework
53// provides to utilize the Stream class. On standard AVR8 we declare
54// our own helper class which is handled by the N2kStream. On anything
55// else we resort to char strings.
56#if defined(ARDUINO)
57#include <WString.h>
58#elif defined(__AVR__)
59#include <avr/pgmspace.h>
60class __FlashStringHelper;
61#define F(str) (reinterpret_cast<const __FlashStringHelper*>(PSTR(str)))
62#else
63#ifndef F
64#define F(str) str
65#endif
66#endif
67
68#endif
uint32_t millis()