From 8878d0970b5ed2fb0ecd4dfd37f8c2b745e5bd4f Mon Sep 17 00:00:00 2001 From: Michael Jonker Date: Mon, 7 Dec 2015 21:12:24 +0100 Subject: [PATCH] V2.2.0 commit. Version compatible with IDE >=1.6.5 (tested up to 1.6.7.NBLD20151124) --- .gitignore | 3 +- InstallationInstructions.txt | 28 +++ README.md | 6 +- README.txt | 4 +- extras/.gitignore | 4 + extras/DisableHardwareSerial.h | 41 ++++ extras/boards.txt | 216 ++++++++++++++++++ library.properties | 4 +- src/.gitignore | 4 - src/HardwareSerialRS485.cpp | 6 - src/HardwareSerialRS485.h | 32 +-- src/boards.txt | 176 -------------- src/utility/.gitignore | 5 +- src/utility/HardwareSerialRS485_Enabled.h | 24 +- .../HardwareSerialRS485_configuration.h | 28 +-- src/utility/USARTdef.h | 5 +- 16 files changed, 341 insertions(+), 245 deletions(-) create mode 100644 InstallationInstructions.txt create mode 100644 extras/DisableHardwareSerial.h create mode 100644 extras/boards.txt delete mode 100644 src/boards.txt rename src/{ => utility}/HardwareSerialRS485_configuration.h (84%) diff --git a/.gitignore b/.gitignore index 7030dc4..a29817f 100644 --- a/.gitignore +++ b/.gitignore @@ -12,9 +12,10 @@ #this file !.gitignore -#the HardwareSerialRS485 descriptions (for human, librarien and IDE) +#the HardwareSerialRS485 descriptions/instructions (for human, librarien and IDE) !readme.txt !readme.md +!InstallationInstructions.txt !library.properties !keywords.txt diff --git a/InstallationInstructions.txt b/InstallationInstructions.txt new file mode 100644 index 0000000..a05eadf --- /dev/null +++ b/InstallationInstructions.txt @@ -0,0 +1,28 @@ +Arduino RS485 communication software + +by Michael Jonker + +This file gives the installation instructions of HardwareSerialRS485. + +For detailed instructions see: https://github.com/MichaelJonker/HardwareSerialRS485/wiki/installation-and-deployment + +To use the HardwareSerialRS485 library you have to specify to which ports the TE and RE* enable lines the RS485 interface transceiver is connected. +For convenience, you are advised to define your RS485 specific boards using the following instructions: + +a) Create the following folder structure under your Arduino Project Folder : + /hardware/HardwareSerialRS485/avr + where is your existing Arduino project folder, i.e. the folder under which all your sketches are + residing as well as the libraries folder with the user installed libraries. + +b) Copy the following files to /hardware/HardwareSerialRS485/avr + /libraries/HardwareSerialRS485/extras/boards.txt + /libraries/HardwareSerialRS485/extras/DisableHardwareSerial.h + These files are distributed together with this library. + +c) Edit the file boards.txt to configure your board specific parameters for the RS485 WE and RE* connections, through + the definitions "-DRS485configuration_TRxControl=TRxControl< 'B', 7, 6 >" in the extra_flags values. + Detailed instructions are given in the boards.txt file and on the project wiki pages. + +For the latest development, questions and issue reporting, visit the project page: https://github.com/MichaelJonker/HardwareSerialRS485 + +For full documentation see the project wiki pages: https://github.com/MichaelJonker/HardwareSerialRS485/wiki diff --git a/README.md b/README.md index fbc9b27..7dcd3e8 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ by Michael Jonker -[//]: # (This README.md file is written in github flavoured markdown. This file is visualized best by opening the project page on https://github.com/MichaelJonker/HardwareSerialRS485.) +[//]: # (This README.md file is written in github flavoured markdown. This file is visualized best by opening the project page on https://github.com/MichaelJonker/HardwareSerialRS485 .) [//]: # (for embedding comments in Markdown, see http://stackoverflow.com/questions/4823468/store-comments-in-markdown-syntax) [//]: # (https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) @@ -10,7 +10,7 @@ by Michael Jonker This project provides a software suite to support the use of an RS485 transceiver connected to the USART (Tx/Rx pins) in a half-duplex, concurrent multi-drop (i.e. multi-master, multi-slave) environment. For this purpose, the software suite provides capabilities for message addressing and filtering as well as collision detection and collision avoidance. -Project page: https://github.com/MichaelJonker/HardwareSerialRS485 - For full information see the wiki pages on https://github.com/MichaelJonker/HardwareSerialRS485/wiki + +Project page: https://github.com/MichaelJonker/HardwareSerialRS485 diff --git a/README.txt b/README.txt index 956c034..ddf48bb 100644 --- a/README.txt +++ b/README.txt @@ -7,6 +7,8 @@ This project provides a software suite to support the use of an RS485 transceive in a half-duplex, concurrent multi-drop (i.e. multi-master, multi-slave) environment. For this purpose, the software suite provides capabilities for message addressing and filtering as well as collision detection and collision avoidance. -For the latest development visit the project page: https://github.com/MichaelJonker/HardwareSerialRS485 +For concise installation instructions, see the file InstallationInstructions.txt For full documentation see the project wiki pages: https://github.com/MichaelJonker/HardwareSerialRS485/wiki + +For the latest development, questions and issue reporting, visit the project page: https://github.com/MichaelJonker/HardwareSerialRS485 \ No newline at end of file diff --git a/extras/.gitignore b/extras/.gitignore index d76a995..8987888 100644 --- a/extras/.gitignore +++ b/extras/.gitignore @@ -12,5 +12,9 @@ #this file !.gitignore +# the boards.txt and DisableHardwareSerial.h +!boards.txt +!DisableHardwareSerial.h + #subfolder !documentation \ No newline at end of file diff --git a/extras/DisableHardwareSerial.h b/extras/DisableHardwareSerial.h new file mode 100644 index 0000000..f835199 --- /dev/null +++ b/extras/DisableHardwareSerial.h @@ -0,0 +1,41 @@ +/* DisableHardwareSerial.h + +Copyright (c) 2015 Michael Jonker. All right reserved. + +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 +*/ + + +// To disable the HardwareSerial class, this file is to be included ahead of the Arduino.h header file. This can be achieved with a +// ...extra_flags=-include DisableHardwareSerial.h "-I{runtime.platform.path}" compile directive in the boards.txt file. +// Note: prior to the Arduino IDE 1.6.6, the disabling of HardwareSerial class was done by the HardwareSerialRS485.h header. With IDE 1.6.6 +// the inclusion of Arduino.h has been moved to the very first line of the sketch, making this option impossible. +// +// for more information see https://github.com/MichaelJonker/HardwareSerialRS485/wiki/installation-and-deployment + + +// disables the inclusion of HardwareSerial.h +#define HardwareSerial_h + +// this is still needed by main.cpp (serialEventRun is defined by HardwareSerialRS485.h) +extern void serialEventRun(void) __attribute__((weak)); + +// we also make up for the missing Stream.h in "USBAPI.h" +#include "Stream.h" + +// to include HardwareSerialRS485.h unconditionally, uncomment the follwoing line +// you might also need to add an extra include directive in a extra_flag of the boards.txt file to add the folder library/HardwareSerialRS485/src +// #include "HardwareSerialRS485.h" + diff --git a/extras/boards.txt b/extras/boards.txt new file mode 100644 index 0000000..3334439 --- /dev/null +++ b/extras/boards.txt @@ -0,0 +1,216 @@ +# This boards.txt file can be tailored to your needs +# +# builtin boards are defined in \hardware\arduino\avr\boards.txt + +#https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification +#.recipe.hooks.[sketch|libraries|core|linking|objcopy|savehex].[prebuild|postbuild].sequenceNumber.pattern= + +# a rather complex way to create a file that defines the getBuildTime() method returning the build date and time stamp. +# this code has been commented out, you can uncomment and further addapt it if you gave a cygwin installation +# IDE -- 1.6.5 ; create and add __BuildTime__ to the {build.path} folder +#RS485_Arduino_Uno.recipe.hooks.sketch.prebuild.01.pattern=c:/cygwin64/bin/bash -c '/usr/bin/echo -e `/usr/bin/date +"#include \\"arduino.h\\"\\\nconst __FlashStringHelper* getBuildTime() { static const char __BuildTime__[] PROGMEM =\\"Build-%Y%m%d%H%M%S\\"; return reinterpret_cast (&__BuildTime__[0]); }"` >`/usr/bin/cygpath "{build.path}\__BuildTime__.cpp"`' +#RS485_Arduino_Micro.recipe.hooks.sketch.prebuild.01.pattern=c:/cygwin64/bin/bash -c '/usr/bin/echo -e `/usr/bin/date +"#include \\"arduino.h\\"\\\nconst __FlashStringHelper* getBuildTime() { static const char __BuildTime__[] PROGMEM =\\"Build-%Y%m%d%H%M%S\\"; return reinterpret_cast (&__BuildTime__[0]); }"` >`/usr/bin/cygpath "{build.path}\__BuildTime__.cpp"`' + +# IDE 1.6.6 -- ; create and add __BuildTime__ to the {build.path}/sketch folder +#RS485_Arduino_Uno.recipe.hooks.sketch.prebuild.01.pattern=c:/cygwin64/bin/bash -c '/usr/bin/echo -e `/usr/bin/date +"#include \\"arduino.h\\"\\\nconst __FlashStringHelper* getBuildTime() { static const char __BuildTime__[] PROGMEM =\\"Build-%Y%m%d%H%M%S\\"; return reinterpret_cast (&__BuildTime__[0]); }"` >`/usr/bin/cygpath "{build.path}\sketch\__BuildTime__.cpp"`' +#RS485_Arduino_Micro.recipe.hooks.sketch.prebuild.01.pattern=c:/cygwin64/bin/bash -c '/usr/bin/echo -e `/usr/bin/date +"#include \\"arduino.h\\"\\\nconst __FlashStringHelper* getBuildTime() { static const char __BuildTime__[] PROGMEM =\\"Build-%Y%m%d%H%M%S\\"; return reinterpret_cast (&__BuildTime__[0]); }"` >`/usr/bin/cygpath "{build.path}\sketch\__BuildTime__.cpp"`' + + +#create a sub-menu for our 485 enabled boards with specific configuration options +menu.RS485=RS485 options + +# define the RS485 aware boards +RS485_Arduino_Uno.name=Arduino UNO with RS485 +RS485_Arduino_Micro.name=Arduino Micro with RS485 + + +## as set up in the platform.txt file: +## recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}" +## recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}" +## compiler.c.cmd=avr-gcc +## compiler.cpp.cmd=avr-g++ +## compiler.c.flags=-c -g -Os {compiler.warning_flags} -ffunction-sections -fdata-sections -MMD +## compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD +## compiler.c.extra_flags= +## compiler.cpp.extra_flags= +## buid.extra_flags= +## buid.extra_flags is used in boaards,txt to set USB options for Atmel32u4 based boards + +## TODO +## RS485_Arduino_Uno.compiler.cpp.flags=-DEF2Acpp -c -g -Os {compiler.warning_flags.all} -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD + + +# As of IDE 1.6.6, the header "Arduino.h" is #included before anything else in the sketch. To intercept the loading of the classical HardwareSerial header file +# we force include the file DisableHardwareSerial.h (which resides in the same folder {runtime.platform.path} as this boards file.) +RS485_Arduino_Uno.RS485_flags=-include DisableHardwareSerial.h "-I{runtime.platform.path}" +RS485_Arduino_Micro.RS485_flags=-include DisableHardwareSerial.h "-I{runtime.platform.path}" +RS485_Arduino_Micro.build.extra_flags={build.usb_flags} + + +# +#Define submenu items for RS485_Arduino_Uno =========================== +RS485_Arduino_Uno.menu.RS485.option1=RS485 +RS485_Arduino_Uno.menu.RS485.option1.compiler.cpp.extra_flags= {RS485_flags} "-DRS485configuration_TRxControl=TRxControl< 'B', 2, 3 >" + +RS485_Arduino_Uno.menu.RS485.option2=no RS485 +RS485_Arduino_Uno.menu.RS485.option2.compiler.cpp.extra_flags= {RS485_flags} "-DRS485configuration_HardwareSerialRS485_0=HardwareSerialRS485< USART0 >" + +#Define submenue items for RS485_Arduino_Micro ========================= +RS485_Arduino_Micro.menu.RS485.option1=RS485 TxE=B7 RxE*=B6 +RS485_Arduino_Micro.menu.RS485.option1.compiler.cpp.extra_flags= {RS485_flags} "-DRS485configuration_TRxControl=TRxControl< 'B', 7, 6 >" + +RS485_Arduino_Micro.menu.RS485.option2=RS485 TxE=B7 RxE*=B6 RxBuffer[256] +RS485_Arduino_Micro.menu.RS485.option2.compiler.cpp.extra_flags= {RS485_flags} "-DRS485configuration_TRxControl=TRxControl< 'B', 7, 6 >" "-DRS485configuration_TRxBufferParameters=6, 8, 0x20" + +RS485_Arduino_Micro.menu.RS485.option3=no RS485 +RS485_Arduino_Micro.menu.RS485.option3.compiler.cpp.extra_flags= {RS485_flags} "-DRS485configuration_HardwareSerialRS485_1=HardwareSerialRS485< USART1, RS485configuration_TRxBufferParameters >" + + +################################################################################## +# These values can be adapted by you # +################################################################################## +# This is the list of defintions that can be addapted and added to the .menu.RS485..build.extra_flags= +# "-DRS485configuration_TRxBufferParameters=6, 6, 0x20" +# "-DRS485configuration_TRxControl=TRxControl< 'B', 2, 3 >" +# "-DRS485configuration_RS485helper=RS485serial< RS485configuration_TRxControl >" +# "-DRS485configuration_MessageFilterParameters=MFP< '{', '}' >" +# "-DRS485configuration_MessageFilter=MessageFilter< RS485configuration_MessageFilterParameters > " +# "-DRS485configuration_HardwareSerialRS485_0=HardwareSerialRS485< USART0, RS485configuration_TRxBufferParameters, RS485configuration_RS485helper, RS485configuration_MessageFilter >" +# +# Note: you can also add your own c preprocessor #defines like: +# "-DAnswer=0x2A" + + +# The connection of Arduino port to the WE and RE* are specified in the macro defintion RS485configuration_TRxControl=TRxControl< 'B', 2, 3 > +# through the template parameters of the TRxControl template class. The first template parameter specifies the port, the second and third parameter +# specify the port pins for the WE and RE* connection. N.B. the mapping between the port pins of the Atmega IC and the Arduino shield PINS (D0...D13, A0...A5) +# for the UNO (Atmega328p) and Micro/Leonardo (Atmega 32u4) are not identical. +#Example on the UNO, if you connected TxE with D10 (B2) and RxE* with D11 (B3), you need TRxControl< 'B', 2, 3 > +# on the Micro, if you connected TxE with D10 (B6) and RxE* with D11 (B7), you need TRxControl< 'B', 6, 7 > +# N.B. there is no support to drive enable pins from different ports. +# This table specifies the mapping between Atmega port pins and Arduino shield pins +# Port UNO Micro +# PB0 14 D8 8 RXLED/SS +# PB1 15 D9 9 SCK +# PB2 16 D10/SS 10 MOSI +# PB3 17 D11/MOSI 11 MISO +# PB4 18 D12/MISO 28 D8 +# PB5 19 D13/SCK 29 D9 +# PB6 9 XTAL1 30 D10 +# PB7 10 XTAL2 12 D11 +# +# PC0 23 A0 +# PC1 24 A1 +# PC2 25 A2 +# PC3 26 A3 +# PC4 27 A4/SCA +# PC5 28 A5/SCL +# PC6 1 Reset 31 D5 +# PC7 32 D13 +# +# PD0 2 D0/RX 18 D3/SCL +# PD1 3 D1/TX 19 D2/SDA +# PD2 4 D2 20 D0/RX +# PD3 5 D3 21 D1/TX +# PD4 6 D4 25 D4 +# PD5 11 D5 22 -- TXLED +# PD6 12 D6 26 D12 +# PD7 13 D7 27 D6 +# +# PE2 1 D7 +# PE6 33 HWB +# +# PF0 41 A5 +# PF1 40 A4 +# PF4 39 A3 +# PF5 38 A2 +# PF6 37 A1 +# PF7 36 A0 +# + + +# A number of defintions have to be copied from the standard board file, i.e. \hardware\arduino\avr\boards.txt, for every board that we adapt. +# these values are copied from the Arduino UNO +RS485_Arduino_Uno.vid.0=0x2341 +RS485_Arduino_Uno.pid.0=0x0043 +RS485_Arduino_Uno.vid.1=0x2341 +RS485_Arduino_Uno.pid.1=0x0001 +RS485_Arduino_Uno.vid.2=0x2A03 +RS485_Arduino_Uno.pid.2=0x0043 +RS485_Arduino_Uno.vid.3=0x2341 +RS485_Arduino_Uno.pid.3=0x0243 + +RS485_Arduino_Uno.build.mcu=atmega328p +RS485_Arduino_Uno.build.f_cpu=16000000L +RS485_Arduino_Uno.build.board=AVR_UNO +RS485_Arduino_Uno.build.core=arduino:arduino +RS485_Arduino_Uno.build.variant=arduino:standard + +RS485_Arduino_Uno.upload.tool=arduino:avrdude +RS485_Arduino_Uno.upload.protocol=arduino +RS485_Arduino_Uno.upload.maximum_size=32256 +RS485_Arduino_Uno.upload.maximum_data_size=2048 +RS485_Arduino_Uno.upload.speed=115200 + +RS485_Arduino_Uno.bootloader.tool=arduino:avrdude +RS485_Arduino_Uno.bootloader.low_fuses=0xFF +RS485_Arduino_Uno.bootloader.high_fuses=0xDE +RS485_Arduino_Uno.bootloader.extended_fuses=0x05 +RS485_Arduino_Uno.bootloader.unlock_bits=0x3F +RS485_Arduino_Uno.bootloader.lock_bits=0x0F +#RS485_Arduino_Uno.bootloader.file=optiboot/optiboot_atmega328.hex + + +# these values are copied from the Arduino Micro +RS485_Arduino_Micro.vid.0=0x2341 +RS485_Arduino_Micro.pid.0=0x0037 +RS485_Arduino_Micro.vid.1=0x2341 +RS485_Arduino_Micro.pid.1=0x8037 +RS485_Arduino_Micro.vid.2=0x2A03 +RS485_Arduino_Micro.pid.2=0x0037 +RS485_Arduino_Micro.vid.3=0x2A03 +RS485_Arduino_Micro.pid.3=0x8037 + +RS485_Arduino_Micro.vid.4=0x2341 +RS485_Arduino_Micro.pid.4=0x0237 +# If the board is a 2341:0237 use 2341:8237 for build and set +# other parameters as well +RS485_Arduino_Micro.vid.4.build.vid=0x2341 +RS485_Arduino_Micro.vid.4.build.pid=0x8237 +RS485_Arduino_Micro.vid.4.build.usb_product="Genuino Micro" +RS485_Arduino_Micro.vid.4.bootloader.file=caterina/Caterina-Genuino-Micro.hex + +RS485_Arduino_Micro.vid.5=0x2341 +RS485_Arduino_Micro.pid.5=0x8237 +# If the board is a 2341:8237 use 2341:8237 for build and set +# other paramters as well +RS485_Arduino_Micro.vid.5.build.vid=0x2341 +RS485_Arduino_Micro.vid.5.build.pid=0x8237 +RS485_Arduino_Micro.vid.5.build.usb_product="Genuino Micro" +RS485_Arduino_Micro.vid.5.bootloader.file=caterina/Caterina-Genuino-Micro.hex + +RS485_Arduino_Micro.build.mcu=atmega32u4 +RS485_Arduino_Micro.build.f_cpu=16000000L +RS485_Arduino_Micro.build.vid=0x2341 +RS485_Arduino_Micro.build.pid=0x8037 +RS485_Arduino_Micro.build.usb_product="Arduino Micro" +RS485_Arduino_Micro.build.board=AVR_MICRO +RS485_Arduino_Micro.build.core=arduino:arduino +RS485_Arduino_Micro.build.variant=arduino:micro + +RS485_Arduino_Micro.upload.tool=arduino:avrdude +RS485_Arduino_Micro.upload.protocol=avr109 +RS485_Arduino_Micro.upload.maximum_size=28672 +RS485_Arduino_Micro.upload.maximum_data_size=2560 +RS485_Arduino_Micro.upload.speed=57600 +RS485_Arduino_Micro.upload.disable_flushing=true +RS485_Arduino_Micro.upload.use_1200bps_touch=true +RS485_Arduino_Micro.upload.wait_for_upload_port=true + +RS485_Arduino_Micro.bootloader.tool=arduino:avrdude +RS485_Arduino_Micro.bootloader.low_fuses=0xff +RS485_Arduino_Micro.bootloader.high_fuses=0xd8 +RS485_Arduino_Micro.bootloader.extended_fuses=0xcb +#RS485_Arduino_Micro.bootloader.file=caterina/Caterina-Micro.hex +RS485_Arduino_Micro.bootloader.unlock_bits=0x3F +RS485_Arduino_Micro.bootloader.lock_bits=0x2F \ No newline at end of file diff --git a/library.properties b/library.properties index af07197..6876695 100644 --- a/library.properties +++ b/library.properties @@ -1,9 +1,9 @@ name=HardwareSerial_RS485 -version=2.1.0 +version=2.2.0 author=Michael Jonker maintainer=Michael Jonker sentence=Concurrent multi-drop (i.e. multi-master, multi-slave) RS485 communication library paragraph=This library supports an RS485 transceiver connected to the USART (Tx/Rx) pins of the Arduino in a half-duplex, concurrent multi-drop environment. It provides message addressing and filtering as well as collision detection and avoidance. category=Communication -url=https://github.com/MichaelJonker/HardwareSerialRS485 +url=https://github.com/MichaelJonker/HardwareSerialRS485/wiki architectures=avr diff --git a/src/.gitignore b/src/.gitignore index 76706f4..2350c36 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -19,9 +19,5 @@ #the Messagereader header file !MessageReader.h -#the HardwareSerialRS485_configuration and boards.txt -!HardwareSerialRS485_configuration.h -!boards.txt - # sub folders !utility \ No newline at end of file diff --git a/src/HardwareSerialRS485.cpp b/src/HardwareSerialRS485.cpp index 2ebd06e..f5d1351 100644 --- a/src/HardwareSerialRS485.cpp +++ b/src/HardwareSerialRS485.cpp @@ -25,12 +25,6 @@ from the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA // Todo look at possibility of #pragma interface / #pragma implementation -#if defined(HardwareSerial_use_classical_version) -// we use the classical version, we include the cpp code from HardwareSerial.cpp -#warning "HardwareSerialRS485 uses classical version ======================================================" -#include "HardwareSerial.cpp" -#endif - /* testing options: diff --git a/src/HardwareSerialRS485.h b/src/HardwareSerialRS485.h index ebb66c1..efaf147 100644 --- a/src/HardwareSerialRS485.h +++ b/src/HardwareSerialRS485.h @@ -25,12 +25,12 @@ from the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA #error “The __FILE__ library only supports boards with an AVR.” #endif +#if !defined(HardwareSerial_h) // if HardwareSerial was not disabled yet... +#define HardwareSerial_h // make sure that it gets disabled +#endif -#if !defined(HardwareSerial_use_classical_version) -#if !defined(HardwareSerial_h) - #define HardwareSerial_h /* block loading the classsical version of HardwareSerial */ -#else - #error "HardwareSerial.h already loaded. The file HardwareSerialRS485.h must be included before the #include ""Arduino.h"" (whether explicit or implicit)." +#if defined(Serial_8N1) // we use a different 'marker' to detect the presence of HardwareSerial.h + #error "HardwareSerial.h already loaded. You have not selected an RS485 specific board, or your boards.txt file is incomplete (see documentation https://github.com/MichaelJonker/HardwareSerialRS485/wiki/installation-and-deployment)." #endif #include "utility/Messagefilter.h" @@ -39,7 +39,7 @@ from the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA // The definitions RS485configuration_HardwareSerialRS485_ for the HardwareSerial classes are provided by the file "HardwareSerialRS485_configuration.h" // For a HardwareSerialRS485_ class to be created, both the RS485configuration_HardwareSerialRS485_ should be defined, and a corresponding (i.e. target hardware dependent) USART class should exists. -#include "HardwareSerialRS485_configuration.h" +#include "utility/HardwareSerialRS485_configuration.h" #if 1 /* define HardwareSerialRS485_0...3 and the corresponding objects Serial0...3 */ @@ -95,8 +95,6 @@ from the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA HardwareSerialRS485_0 Serial0; template<> HardwareSerialRS485_0& HardwareSerialRS485_0::ourSerialObject = Serial0; link_USART_Vectors(USART0, Serial0); - void serialEvent0() __attribute__((weak)); - void serialEvent0() {} #endif #endif #if defined(UCSR1A) @@ -104,8 +102,6 @@ from the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA HardwareSerialRS485_1 Serial1; template<> HardwareSerialRS485_1& HardwareSerialRS485_1::ourSerialObject = Serial1; link_USART_Vectors(USART1, Serial1); - void serialEvent1() __attribute__((weak)); - void serialEvent1() {} #endif #endif #if defined(UCSR2A) @@ -113,8 +109,6 @@ from the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA HardwareSerialRS485_2 Serial2; template<> HardwareSerialRS485_2& HardwareSerialRS485_2::ourSerialObject = Serial2; link_USART_Vectors(USART2, Serial2); - void serialEvent2() __attribute__((weak)); - void serialEvent2() {} #endif #endif #if defined(UCSR3A) @@ -122,34 +116,32 @@ from the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA HardwareSerialRS485_3 Serial3; template<> HardwareSerialRS485_3& HardwareSerialRS485_3::ourSerialObject = Serial3; link_USART_Vectors(USART3, Serial3); - void serialEvent3() __attribute__((weak)); - void serialEvent3() {} #endif #endif // build up serialEventRun // IMHO serialEventRun is a useless function, I put it here for compatability with HardwareSerial -extern void serialEventRun(void) __attribute__((weak)); +//todo extern void serialEventRun(void) __attribute__((weak)); void serialEventRun(void) { #if defined(UCSR0A) #if defined(RS485configuration_HardwareSerialRS485_0) - if (Serial0.available()) serialEvent0(); + if (Serial0.available()) Serial0_Event(); #endif #endif #if defined(UCSR1A) #if defined(RS485configuration_HardwareSerialRS485_1) - if (Serial1.available()) serialEvent1(); + if (Serial1.available()) Serial1_Event(); #endif #endif #if defined(UCSR2A) #if defined(RS485configuration_HardwareSerialRS485_2) - if (Serial2.available()) serialEvent2(); + if (Serial2.available()) Serial2_Event(); #endif #endif #if defined(UCSR3A) #if defined(RS485configuration_HardwareSerialRS485_3) - if (Serial3.available()) serialEvent3(); + if (Serial3.available()) Serial3_Event(); #endif #endif } @@ -157,6 +149,4 @@ void serialEventRun(void) #endif // defined(Implement_HardwareSerialRS485) ++ ==================================================================================================== -#endif // !defined(HardwareSerial_use_classical_version) - #endif // !defined(HardwareSerialRS485_h) \ No newline at end of file diff --git a/src/boards.txt b/src/boards.txt deleted file mode 100644 index 0bf2090..0000000 --- a/src/boards.txt +++ /dev/null @@ -1,176 +0,0 @@ -# This boards.txt file can be tailored to your needs -# -# builtin boards are located on ... \Arduino\hardware\arduino\avr - -https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification -#RS485_Arduino_Uno.recipe.hooks.[sketch|libraries|core|linking|objcopy|savehex].[prebuild|postbuild].sequenceNumber.pattern= - - -# a rather complex way to create a file that defines the getBuildTime() method returning the build date and time stamp. -# this code has been commented out, you can uncomment and further addapt it if you gave a cygwin installation -## RS485_Arduino_Uno.recipe.hooks.sketch.prebuild.01.pattern=c:/cygwin/bin/bash -c '/usr/bin/echo -e `/usr/bin/date +"#include \\"arduino.h\\"\\\nconst __FlashStringHelper* getBuildTime() { static const char __BuildTime__[] PROGMEM =\\"Build-%Y%m%d%H%M%S\\"; return reinterpret_cast (&__BuildTime__[0]); }"` >`/usr/bin/cygpath "{build.path}\__BuildTime__.cpp"`' -## RS485_Arduino_Micro.recipe.hooks.sketch.prebuild.01.pattern=c:/cygwin/bin/bash -c '/usr/bin/echo -e `/usr/bin/date +"#include \\"arduino.h\\"\\\nconst __FlashStringHelper* getBuildTime() { static const char __BuildTime__[] PROGMEM =\\"Build-%Y%m%d%H%M%S\\"; return reinterpret_cast (&__BuildTime__[0]); }"` >`/usr/bin/cygpath "{build.path}\__BuildTime__.cpp"`' - - -#create a sub-menu for our 485 enabled boards with specific configuration options -menu.RS485=RS485 options - -############################################################## - -RS485_Arduino_Uno.name=Arduino UNO with RS485 -RS485_Arduino_Micro.name=Arduino Micro with RS485 - -# we could also overwrite this in the local platform.txt but... -RS485_Arduino_Uno.compiler.cpp.extra_flags=-std=c++11 -RS485_Arduino_Micro.compiler.cpp.extra_flags=-std=c++11 - - -################################################################################## -# These values should be adapted by you # -################################################################################## -# This is the list of defintions that can be modified and added to the .menu.RS485.optionX.build.extra_flags= -# "-DRS485configuration_TRxBufferParameters=6, 6, ' '" -# "-DRS485configuration_TRxControl=TRxControl< 'B', 2, 3 >" -# "-DRS485configuration_RS485helper=RS485serial< RS485configuration_TRxControl >" -# "-DRS485configuration_MessageFilterParameters=MFP< '{', '}' >" -# "-DRS485configuration_MessageFilter=MessageFilter< RS485configuration_MessageFilterParameters > " -# "-DRS485configuration_HardwareSerialRS485_0=HardwareSerialRS485< USART0, RS485configuration_TRxBufferParameters, RS485configuration_RS485helper, RS485configuration_MessageFilter >" -# -# Note: you can also add your own c preprocessor #defines -# "-DAnswer=0x2A" -# -#Define submenue items for RS485_Arduino_Uno =========================== -RS485_Arduino_Uno.menu.RS485.option1=RS485 -RS485_Arduino_Uno.menu.RS485.option1.build.extra_flags= "-DRS485configuration_TRxControl=TRxControl< 'B', 2, 3 >" "-I{runtime.platform.path}" - -RS485_Arduino_Uno.menu.RS485.option2=no RS485 -RS485_Arduino_Uno.menu.RS485.option2.build.extra_flags= "-DRS485configuration_HardwareSerialRS485_0=HardwareSerialRS485< USART0 >" "-DAnswer=0x2A" "-I{runtime.platform.path}" - -# classical. This option (commented out), gives back the classical HardwareSerial class that is distributed with the Arduino installation. It has only some usage in development. -# However, if your code calls any extended HardwareSerialRS485 feature, it will fail to compile. -# The recommended way to use a HardwareSerial without RS485 functionality, is to use menu option 'no RS485'. Alternatively, if you really want the classical version don't use the HarwareSerialRS485 library. -#RS485_Arduino_Uno.menu.RS485.option9=Classical -#RS485_Arduino_Uno.menu.RS485.option9.build.extra_flags= -DHardwareSerial_use_classical_version - -#Define submenue items for RS485_Arduino_Micro ========================= -RS485_Arduino_Micro.menu.RS485.option1=RS485 TxE=B7 RxE*=B6 -RS485_Arduino_Micro.menu.RS485.option1.build.extra_flags={build.usb_flags} "-DRS485configuration_TRxControl=TRxControl< 'B', 7, 6 >" "-I{runtime.platform.path}" - -RS485_Arduino_Micro.menu.RS485.option2=RS485 TxE=B7 RxE*=B6 RxBuffer[256] -RS485_Arduino_Micro.menu.RS485.option2.build.extra_flags={build.usb_flags} "-DRS485configuration_TRxControl=TRxControl< 'B', 7, 6 >" "-DRS485configuration_TRxBufferParameters=6, 8, ' '" "-I{runtime.platform.path}" - -RS485_Arduino_Micro.menu.RS485.option3=no RS485 -RS485_Arduino_Micro.menu.RS485.option3.build.extra_flags={build.usb_flags} "-DRS485configuration_HardwareSerialRS485_1=HardwareSerialRS485< USART1, RS485configuration_TRxBufferParameters >" "-I{runtime.platform.path}" - - -# This table contains the mapping between Ardiuno PINS (D0...D13, A0...A5) and Atmega ports for the UNO (Atmega328p) and Micro/Leonardo (Atmega 324u) -#Example on the UNO, if you connected TxE with D10 (B2) and RxE* with D11 (B3), you meed 'B', 2, 3 -# on the Micro, if you connected TxE with D11 (B7) and RxE* with D10 (B6), you meed 'B', 7, 6 -# There is no support to drive enable pins from different ports. -# Port UNO Micro -# PB0 14 D8 8 RXLED/SS -# PB1 15 D9 9 SCK -# PB2 16 D10/SS 10 MOSI -# PB3 17 D11/MOSI 11 MISO -# PB4 18 D12/MISO 28 D8 -# PB5 19 D13/SCK 29 D9 -# PB6 9 XTAL1 30 D10 -# PB7 10 XTAL2 12 D11 -# -# PC0 23 A0 -# PC1 24 A1 -# PC2 25 A2 -# PC3 26 A3 -# PC4 27 A4/SCA -# PC5 28 A5/SCL -# PC6 1 Reset 31 D5 -# PC7 32 D13 -# -# PD0 2 D0/RX 18 D3/SCL -# PD1 3 D1/TX 19 D2/SDA -# PD2 4 D2 20 D0/RX -# PD3 5 D3 21 D1/TX -# PD4 6 D4 25 D4 -# PD5 11 D5 22 -- TXLED -# PD6 12 D6 26 D12 -# PD7 13 D7 27 D6 -# -# PE2 1 D7 -# PE6 33 HWB -# -# PF0 41 A5 -# PF1 40 A4 -# PF4 39 A3 -# PF5 38 A2 -# PF6 37 A1 -# PF7 36 A0 -# - - -# A number of defintions have to be copied from the standard board.txt file located in the folder ... \Arduino\hardware\arduino\avr, for every board that we adapt. -# these values are copied from the Arduino UNO values from the boards file in the Arduino distribution -RS485_Arduino_Uno.vid.0=0x2341 -RS485_Arduino_Uno.pid.0=0x0043 -RS485_Arduino_Uno.vid.1=0x2341 -RS485_Arduino_Uno.pid.1=0x0001 -RS485_Arduino_Uno.vid.2=0x2A03 -RS485_Arduino_Uno.pid.2=0x0043 - -RS485_Arduino_Uno.build.mcu=atmega328p -RS485_Arduino_Uno.build.f_cpu=16000000L -RS485_Arduino_Uno.build.board=AVR_UNO -RS485_Arduino_Uno.build.core=arduino:arduino -RS485_Arduino_Uno.build.variant=arduino:standard -RS485_Arduino_Uno.build.extra_flags= -DHardwareSerial_use_classical_version - -RS485_Arduino_Uno.upload.tool=arduino:avrdude -RS485_Arduino_Uno.upload.protocol=arduino -RS485_Arduino_Uno.upload.maximum_size=32256 -RS485_Arduino_Uno.upload.maximum_data_size=2048 -RS485_Arduino_Uno.upload.speed=115200 - -RS485_Arduino_Uno.bootloader.tool=arduino:avrdude -RS485_Arduino_Uno.bootloader.low_fuses=0xFF -RS485_Arduino_Uno.bootloader.high_fuses=0xDE -RS485_Arduino_Uno.bootloader.extended_fuses=0x05 -RS485_Arduino_Uno.bootloader.unlock_bits=0x3F -RS485_Arduino_Uno.bootloader.lock_bits=0x0F -RS485_Arduino_Uno.bootloader.file=optiboot/optiboot_atmega328.hex - - -# these values are copied from the Arduino Micro values from the boards file in the Arduino distribution -RS485_Arduino_Micro.vid.0=0x2341 -RS485_Arduino_Micro.pid.0=0x0037 -RS485_Arduino_Micro.vid.1=0x2341 -RS485_Arduino_Micro.pid.1=0x8037 -RS485_Arduino_Micro.vid.2=0x2A03 -RS485_Arduino_Micro.pid.2=0x0037 -RS485_Arduino_Micro.vid.3=0x2A03 -RS485_Arduino_Micro.pid.3=0x8037 - -RS485_Arduino_Micro.build.mcu=atmega32u4 -RS485_Arduino_Micro.build.f_cpu=16000000L -RS485_Arduino_Micro.build.vid=0x2341 -RS485_Arduino_Micro.build.pid=0x8037 -RS485_Arduino_Micro.build.usb_product="Arduino Micro" -RS485_Arduino_Micro.build.board=AVR_MICRO -RS485_Arduino_Micro.build.core=arduino:arduino -RS485_Arduino_Micro.build.variant=arduino:micro -RS485_Arduino_Micro.build.extra_flags={build.usb_flags} -DHardwareSerial_use_classical_version - -RS485_Arduino_Micro.upload.tool=arduino:avrdude -RS485_Arduino_Micro.upload.protocol=avr109 -RS485_Arduino_Micro.upload.maximum_size=28672 -RS485_Arduino_Micro.upload.maximum_data_size=2560 -RS485_Arduino_Micro.upload.speed=57600 -RS485_Arduino_Micro.upload.disable_flushing=true -RS485_Arduino_Micro.upload.use_1200bps_touch=true -RS485_Arduino_Micro.upload.wait_for_upload_port=true - -RS485_Arduino_Micro.bootloader.tool=arduino:avrdude -RS485_Arduino_Micro.bootloader.low_fuses=0xff -RS485_Arduino_Micro.bootloader.high_fuses=0xd8 -RS485_Arduino_Micro.bootloader.extended_fuses=0xcb -RS485_Arduino_Micro.bootloader.file=caterina/Caterina-Micro.hex -RS485_Arduino_Micro.bootloader.unlock_bits=0x3F -RS485_Arduino_Micro.bootloader.lock_bits=0x2F \ No newline at end of file diff --git a/src/utility/.gitignore b/src/utility/.gitignore index 4f86ee0..debae4c 100644 --- a/src/utility/.gitignore +++ b/src/utility/.gitignore @@ -23,4 +23,7 @@ !USARTdef.h #template definitions for generic bit handling -!BitManipulation.h \ No newline at end of file +!BitManipulation.h + +#the HardwareSerialRS485_configuration.h +!HardwareSerialRS485_configuration.h \ No newline at end of file diff --git a/src/utility/HardwareSerialRS485_Enabled.h b/src/utility/HardwareSerialRS485_Enabled.h index 3ed62d4..96d91c9 100644 --- a/src/utility/HardwareSerialRS485_Enabled.h +++ b/src/utility/HardwareSerialRS485_Enabled.h @@ -500,7 +500,7 @@ this function has been coded such that if called with a compile time constant as virtual size_t write(uint8_t c) __attribute__((__used__)); int flush(unsigned char retries) __attribute__((__used__)); - void diagnose(const __FlashStringHelper* reason=0, Print& out=ourSerialObject) __attribute__((__used__)); // TODO validate why I cannot use *this ? + void diagnose(const __FlashStringHelper* reason=0, Print& out=ourSerialObject) __attribute__((__used__)); // TODO investigate why I cannot use *this ? private: @@ -551,16 +551,8 @@ inline void recoverTransfer(bool waitForIdle) // method to recover from an RS485 } -/* the following mechanism is the only way I found so far to force the emission of flush(int) and diagnose() - to test compilations (bash shell syntax): -export ArduinoIDE=/fill-in-your-path-to-arduino-IDE-folder -export ArduinoProjects=/fill-in-your-path-to-arduino-project-folder -cd $ArduinoProjects/libraries/HardwareSerialRS485 -$ArduinoIDE/hardware/tools/avr/bin/avr-g++ -E -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DARDUINO=105 -I$ArduinoIDE/hardware/arduino/avr/cores/arduino -I$ArduinoIDE/hardware/arduino/avr/variants/standard -I. HardwareSerialRS485.cpp >HardwareSerialRS485.cpp.e -$ArduinoIDE/hardware/tools/avr/bin/avr-g++ -S -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DARDUINO=105 -I$ArduinoIDE/hardware/arduino/avr/cores/arduino -I$ArduinoIDE/hardware/arduino/avr/variants/standard -I. HardwareSerialRS485.cpp -o HardwareSerialRS485.cpp.s -$ArduinoIDE/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DARDUINO=105 -I$ArduinoIDE/hardware/arduino/avr/cores/arduino -I$ArduinoIDE/hardware/arduino/avr/variants/standard -I. HardwareSerialRS485.cpp -o HardwareSerialRS485.cpp.o -*/ - virtual void neverUsed() //todo, check for alternatives to force emission, look at possibility of #pragma interface / #pragma implementation +/* the following mechanism is the only way I found so far to force the emission of flush(int) and diagnose() */ + virtual void neverUsed() //todo, check for alternatives, look at possibility of #pragma interface / #pragma implementation { flush(0); diagnose(); @@ -570,6 +562,16 @@ cd $ArduinoProjects/libraries/HardwareSerialRS485 }; // class HardwareSerialRS485 ====================================================================================================================== +/* to test compilations (bash shell syntax): +export ArduinoIDE=/fill-in-your-path-to-arduino-IDE-folder +export ArduinoProjects=/fill-in-your-path-to-arduino-project-folder +cd $ArduinoProjects/libraries/HardwareSerialRS485 +$ArduinoIDE/hardware/tools/avr/bin/avr-g++ -E -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DARDUINO=105 -I$ArduinoIDE/hardware/arduino/avr/cores/arduino -I$ArduinoIDE/hardware/arduino/avr/variants/standard -I. HardwareSerialRS485.cpp >HardwareSerialRS485.cpp.e +$ArduinoIDE/hardware/tools/avr/bin/avr-g++ -S -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DARDUINO=105 -I$ArduinoIDE/hardware/arduino/avr/cores/arduino -I$ArduinoIDE/hardware/arduino/avr/variants/standard -I. HardwareSerialRS485.cpp -o HardwareSerialRS485.cpp.s +$ArduinoIDE/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DARDUINO=105 -I$ArduinoIDE/hardware/arduino/avr/cores/arduino -I$ArduinoIDE/hardware/arduino/avr/variants/standard -I. HardwareSerialRS485.cpp -o HardwareSerialRS485.cpp.o +*/ + + #if defined(Implement_HardwareSerialRS485) // ++========================================================================================================= // this code is activated when the code is included from the HardwareSerialRS485.CPP file // this is my personal style choice to keep all HardwareSerialRS485 related code together in one file (at the price of some negligible extra bytes to be processed by the compiler). diff --git a/src/HardwareSerialRS485_configuration.h b/src/utility/HardwareSerialRS485_configuration.h similarity index 84% rename from src/HardwareSerialRS485_configuration.h rename to src/utility/HardwareSerialRS485_configuration.h index 8360d35..639ef44 100644 --- a/src/HardwareSerialRS485_configuration.h +++ b/src/utility/HardwareSerialRS485_configuration.h @@ -23,26 +23,20 @@ from the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA /* define HardwareSerialRS485 classes for all possible USARTs. */ -/* Important, this file may exists in more than one location: - A functional default/template/example file is located in folder libraries/HardwareSerialRS485/src - A copied and adapted file may be located in a sub folder of the hardware folder in the user project directory. - - To tailor the HardwareSerialRS485 configuration, the user is advised to copy the two files: - - libraries/HardwareSerialRS485/src/HardwareSerialRS485_configuration.h and - - libraries/HardwareSerialRS485/src/boards.txt - to a folder hardware/HardwareSerialRS485/avr (which is to be created in the user project folder, i.e. the folder - where all sketches and user libraries are located). - These two file can then be further tailored to the need of the user. For further explanations see the comments in this file and in boards.txt file. - */ +/* The configuration of the HardwareSerialRS485 classes is controlled by a number of preprocessor macros, all starting with the prefix RS485configuration_. + These preprocessor macros can be adapted in the boards.txt file. In case no definition is given by the boards.txt file, + then default values are taken from this file. + + To tailor the HardwareSerialRS485 configuration using the boards.txt file, the user is advised to follow the instructions in the file + HardwareSerialRS485/InstallationIntructions.txt . + See also https://github.com/MichaelJonker/HardwareSerialRS485/wiki/installation-and-deployment + Only those definitions of RS485configuration_HardwareSerialRS485_ will be used for which a corresponding (i.e. target hardware dependent) UCSRA register is defined. -// These definitions specify the configuration of the HardwareSerialRS485 classes and may (should) be tailored by the user as needed. -// Only those definitions of RS485configuration_HardwareSerialRS485_ will be used for which a corresponding (i.e. target hardware dependent) UCSRA register is defined. + Although not recommended, this file can be hacked and placed in a /utility subfolder of the folder where the customized boards.txt file has been placed. + */ -// The configuration of the HardwareSerialRS485 classes is controlled by a number of preprocessor macros, all starting with the prefix RS485configuration_. -// These preprocessor macros can be adapted in this header file or (preferred) in the boards.txt file. In case no definition is given by the boards.txt file, -// then default values are taken from this file. #if !defined(RS485configuration_TRxBufferParameters) @@ -67,6 +61,8 @@ from the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA #if defined(Implement_HardwareSerialRS485) // only print the warning once #if !defined(RS485configuration_RS485helper) // and not if the user defined his own RS485helper #warning "No definition of RS485configuration_TRxControl was given, a possibly defunct default is now used." +// TODO Change #warning to #error; Tricky, RS485configuration_TRxControl/RS485configuration_RS485helper is not always needed +// (e.g. in case we have defined all classes without RS485) #endif #endif #endif diff --git a/src/utility/USARTdef.h b/src/utility/USARTdef.h index 23940c3..705b8e1 100644 --- a/src/utility/USARTdef.h +++ b/src/utility/USARTdef.h @@ -195,10 +195,9 @@ Conclusion, as we use TXC interrupts, we maintain the TX_active status in the so ISR(T_USART##_UDRE_vect) { T_SERIAL.dreInt(); } \ ISR(T_USART##_TX_vect) { T_SERIAL.txcInt(); } \ ISR(T_USART##_RX_vect) { T_SERIAL.rxcInt(); } \ -void serialEvent() __attribute__((weak)); \ -void serialEvent() {} \ +void T_SERIAL##_Event() __attribute__((weak)); \ +void T_SERIAL##_Event() {} \ volatile unsigned char T_USART::swReg; -//TODO change defunct defintion of serialEvent into serialEvent /* todo: any use for these thoughts? or is it better to define our friends elsewhere. //To resolve friendship ...