From bada194ebe7490c25ca7589366224d4ae0f80eab Mon Sep 17 00:00:00 2001 From: jaakkoiot Date: Mon, 17 Oct 2022 09:15:24 +0300 Subject: [PATCH] Modbus changed into static library --- Modbus/.cproject | 186 ++++++++++++++++++ Modbus/.project | 3 - Modbus/inc/{ModbusLeader.h => ModbusMaster.h} | 5 +- Modbus/inc/ModbusRegister.h | 2 +- Modbus/inc/SerialPort.h | 2 + Modbus/inc/Uart.h | 1 - Modbus/inc/crc16.h | 2 +- Modbus/inc/word.h | 7 +- .../{ModbusLeader.cpp => ModbusMaster.cpp} | 2 +- Modbus/src/SerialPort.cpp | 1 - Modbus/src/Uart.cpp | 13 -- Modbus/src/tester.cpp | 45 ----- 12 files changed, 198 insertions(+), 71 deletions(-) create mode 100644 Modbus/.cproject rename Modbus/inc/{ModbusLeader.h => ModbusMaster.h} (99%) rename Modbus/src/{ModbusLeader.cpp => ModbusMaster.cpp} (99%) delete mode 100644 Modbus/src/tester.cpp diff --git a/Modbus/.cproject b/Modbus/.cproject new file mode 100644 index 0000000..5e35dbd --- /dev/null +++ b/Modbus/.cproject @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <?xml version="1.0" encoding="UTF-8"?> +<TargetConfig> +<Properties property_2="LPC15xx_256K.cfx" property_3="NXP" property_4="LPC1549" property_count="5" version="100300"/> +<infoList vendor="NXP"> +<info chip="LPC1549" connectscript="LPC15RunBootRomConnect.scp" flash_driver="LPC15xx_256K.cfx" match_id="0x0" name="LPC1549" resetscript="LPC15RunBootRomReset.scp" stub="crt_emu_cm3_gen"> +<chip> +<name>LPC1549</name> +<family>LPC15xx</family> +<vendor>NXP (formerly Philips)</vendor> +<reset board="None" core="Real" sys="Real"/> +<clock changeable="TRUE" freq="12MHz" is_accurate="TRUE"/> +<memory can_program="true" id="Flash" is_ro="true" type="Flash"/> +<memory id="RAM" type="RAM"/> +<memory id="Periph" is_volatile="true" type="Peripheral"/> +<memoryInstance derived_from="Flash" id="MFlash256" location="0x0" size="0x40000"/> +<memoryInstance derived_from="RAM" id="Ram0_16" location="0x2000000" size="0x4000"/> +<memoryInstance derived_from="RAM" id="Ram1_16" location="0x2004000" size="0x4000"/> +<memoryInstance derived_from="RAM" id="Ram2_4" location="0x2008000" size="0x1000"/> +</chip> +<processor> +<name gcc_name="cortex-m3">Cortex-M3</name> +<family>Cortex-M</family> +</processor> +</info> +</infoList> +</TargetConfig> + + + LPCXpresso1549 + + diff --git a/Modbus/.project b/Modbus/.project index c7d3ce5..3e28dd2 100644 --- a/Modbus/.project +++ b/Modbus/.project @@ -3,8 +3,6 @@ Modbus - lpc_chip_15xx - DigitalIoPin @@ -22,7 +20,6 @@ org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature org.eclipse.cdt.managedbuilder.core.managedBuildNature org.eclipse.cdt.managedbuilder.core.ScannerConfigNature diff --git a/Modbus/inc/ModbusLeader.h b/Modbus/inc/ModbusMaster.h similarity index 99% rename from Modbus/inc/ModbusLeader.h rename to Modbus/inc/ModbusMaster.h index d038569..18e7978 100644 --- a/Modbus/inc/ModbusLeader.h +++ b/Modbus/inc/ModbusMaster.h @@ -56,7 +56,6 @@ Set to 1 to enable debugging features within class: #include #include #endif -#include uint32_t millis(); #define BYTE 0xA5 @@ -72,6 +71,8 @@ uint32_t millis(); // functions to manipulate words ///#include "util/word.h" #include "word.h" + + #include "SerialPort.h" /* _____CLASS DEFINITIONS____________________________________________________ */ @@ -278,4 +279,4 @@ class ModbusMaster /** @example examples/Basic/Basic.pde @example examples/PhoenixContact_nanoLC/PhoenixContact_nanoLC.pde -*/ \ No newline at end of file +*/ diff --git a/Modbus/inc/ModbusRegister.h b/Modbus/inc/ModbusRegister.h index af20be9..198d94e 100644 --- a/Modbus/inc/ModbusRegister.h +++ b/Modbus/inc/ModbusRegister.h @@ -1,7 +1,7 @@ #ifndef MODBUSREGISTER_H_ #define MODBUSREGISTER_H_ -#include "ModbusLeader.h" +#include "ModbusMaster.h" class ModbusRegister { public: diff --git a/Modbus/inc/SerialPort.h b/Modbus/inc/SerialPort.h index 6e89b6e..f84581d 100644 --- a/Modbus/inc/SerialPort.h +++ b/Modbus/inc/SerialPort.h @@ -1,3 +1,5 @@ + + #ifndef SERIALPORT_H_ #define SERIALPORT_H_ diff --git a/Modbus/inc/Uart.h b/Modbus/inc/Uart.h index ce3c007..c72ac3b 100644 --- a/Modbus/inc/Uart.h +++ b/Modbus/inc/Uart.h @@ -8,7 +8,6 @@ #ifndef LPCUART_H_ #define LPCUART_H_ -#include #include "chip.h" struct LpcPinMap { diff --git a/Modbus/inc/crc16.h b/Modbus/inc/crc16.h index 0f50fdd..27ea89e 100644 --- a/Modbus/inc/crc16.h +++ b/Modbus/inc/crc16.h @@ -54,7 +54,7 @@ obtain a copy. #ifndef _UTIL_CRC16_H_ #define _UTIL_CRC16_H_ -#include + /** @ingroup util_crc16 Processor-independent CRC-16 calculation. diff --git a/Modbus/inc/word.h b/Modbus/inc/word.h index 667fd4a..78db36c 100644 --- a/Modbus/inc/word.h +++ b/Modbus/inc/word.h @@ -35,7 +35,7 @@ This header file provides utility functions for manipulating words. #ifndef _UTIL_WORD_H_ #define _UTIL_WORD_H_ -#include + /** @ingroup util_word Return low word of a 32-bit integer. @@ -43,8 +43,9 @@ This header file provides utility functions for manipulating words. @param uint32_t ww (0x00000000..0xFFFFFFFF) @return low word of input (0x0000..0xFFFF) */ -static inline uint16_t lowWord(uint32_t ww) { -return (uint16_t) ((ww) & 0xFFFF); +static inline uint16_t lowWord(uint32_t ww) +{ + return (uint16_t) ((ww) & 0xFFFF); } diff --git a/Modbus/src/ModbusLeader.cpp b/Modbus/src/ModbusMaster.cpp similarity index 99% rename from Modbus/src/ModbusLeader.cpp rename to Modbus/src/ModbusMaster.cpp index 92a8958..4aef169 100644 --- a/Modbus/src/ModbusLeader.cpp +++ b/Modbus/src/ModbusMaster.cpp @@ -29,7 +29,7 @@ Arduino library for communicating with Modbus slaves over RS232/485 (via RTU pro /* _____PROJECT INCLUDES_____________________________________________________ */ -#include "ModbusLeader.h" +#include "ModbusMaster.h" #include "crc16.h" diff --git a/Modbus/src/SerialPort.cpp b/Modbus/src/SerialPort.cpp index 953d99a..36084a4 100644 --- a/Modbus/src/SerialPort.cpp +++ b/Modbus/src/SerialPort.cpp @@ -1,7 +1,6 @@ #include "SerialPort.h" - SerialPort::SerialPort() { if(!u) { LpcPinMap none = {-1, -1}; // unused pin has negative values in it diff --git a/Modbus/src/Uart.cpp b/Modbus/src/Uart.cpp index 6a45cae..87b725a 100644 --- a/Modbus/src/Uart.cpp +++ b/Modbus/src/Uart.cpp @@ -1,7 +1,6 @@ #include #include "Uart.h" - static LpcUart *u0; static LpcUart *u1; static LpcUart *u2; @@ -13,28 +12,16 @@ extern "C" { */ void UART0_IRQHandler(void) { - /* Want to handle any errors? Do it here. */ - - /* Use default ring buffer handler. Override this with your own - code if you need more capability. */ if(u0) u0->isr(); } void UART1_IRQHandler(void) { - /* Want to handle any errors? Do it here. */ - - /* Use default ring buffer handler. Override this with your own - code if you need more capability. */ if(u1) u1->isr(); } void UART2_IRQHandler(void) { - /* Want to handle any errors? Do it here. */ - - /* Use default ring buffer handler. Override this with your own - code if you need more capability. */ if(u2) u2->isr(); } diff --git a/Modbus/src/tester.cpp b/Modbus/src/tester.cpp deleted file mode 100644 index a2935ea..0000000 --- a/Modbus/src/tester.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#if defined (__USE_LPCOPEN) -#if defined(NO_BOARD_LIB) -#include "chip.h" -#else -#include "board.h" -#endif -#endif - -#include -#include "ModbusMaster.h" -// TODO: insert other include files here - -// TODO: insert other definitions and declarations here - -int main(void) { - -#if defined (__USE_LPCOPEN) - // Read clock settings and update SystemCoreClock variable - SystemCoreClockUpdate(); -#if !defined(NO_BOARD_LIB) - // Set up and initialize all required blocks and - // functions related to the board hardware - Board_Init(); - // Set the LED to the state of "On" - Board_LED_Set(0, true); -#endif -#endif - - // TODO: insert code here - ModbusMaster MIO_12V(1); - ModbusMaster CO2_sensor(240); - ModbusMaster RH_sensor(241); - - - // Force the counter to be placed into memory - volatile static int i = 0 ; - // Enter an infinite loop, just incrementing a counter - while(1) { - i++ ; - // "Dummy" NOP to allow source level single - // stepping of tight while() loop - __asm volatile ("nop"); - } - return 0 ; -}