diff --git a/GMP252Sensor/.cproject b/GMP252Sensor/.cproject new file mode 100644 index 0000000..44abe71 --- /dev/null +++ b/GMP252Sensor/.cproject @@ -0,0 +1,268 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <?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 + + + \ No newline at end of file diff --git a/GMP252Sensor/.gitignore b/GMP252Sensor/.gitignore new file mode 100644 index 0000000..3df573f --- /dev/null +++ b/GMP252Sensor/.gitignore @@ -0,0 +1 @@ +/Debug/ diff --git a/GMP252Sensor/.project b/GMP252Sensor/.project new file mode 100644 index 0000000..fa5d12b --- /dev/null +++ b/GMP252Sensor/.project @@ -0,0 +1,32 @@ + + + GMP252Sensor + + + lpc_chip_15xx + Modbus + GMP252Sensor + StateHandler + I2C + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + 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/GMP252Sensor/inc/GMP252.h b/GMP252Sensor/inc/GMP252.h new file mode 100644 index 0000000..9a0ecb6 --- /dev/null +++ b/GMP252Sensor/inc/GMP252.h @@ -0,0 +1,25 @@ +/* + * GMP252.h + * + * Created on: 20 Oct 2022 + * Author: evgenymeshcheryakov + */ + +#ifndef GMP252_H_ +#define GMP252_H_ + +#include "ModbusMaster.h" +#include "ModbusRegister.h" + +class GMP252 { +public: + GMP252(); + int read(); + virtual ~GMP252(); +private: + ModbusMaster sens; + ModbusRegister regInt; + ModbusRegister regFloat; +}; + +#endif /* GMP252_H_ */ diff --git a/GMP252Sensor/liblinks.xml b/GMP252Sensor/liblinks.xml new file mode 100644 index 0000000..1dc1803 --- /dev/null +++ b/GMP252Sensor/liblinks.xml @@ -0,0 +1,32 @@ + + + + + ${MacroStart}workspace_loc:/${ProjName}/inc${MacroEnd} + + + ${MacroStart}workspace_loc:/${ProjName}/inc${MacroEnd} + + + ${ProjName} + + + ${MacroStart}workspace_loc:/${ProjName}/Debug${MacroEnd} + + + ${MacroStart}workspace_loc:/${ProjName}/Release${MacroEnd} + + + ${ProjName} + + + diff --git a/GMP252Sensor/src/GMP252.cpp b/GMP252Sensor/src/GMP252.cpp new file mode 100644 index 0000000..8ec7783 --- /dev/null +++ b/GMP252Sensor/src/GMP252.cpp @@ -0,0 +1,25 @@ +/* + * GMP252.cpp + * + * Created on: 20 Oct 2022 + * Author: evgenymeshcheryakov + */ + +#include "GMP252.h" + +GMP252::GMP252(): sens{240}, regInt{&sens, 0x0100}, regFloat{&sens, 0x0000}{ + + sens.begin(9600); + +} + +int GMP252:: read() { + int result = regInt.read(); + return result; +} + + +GMP252::~GMP252() { + // TODO Auto-generated destructor stub +} + diff --git a/HMP60Sensor/.cproject b/HMP60Sensor/.cproject new file mode 100644 index 0000000..403e2e3 --- /dev/null +++ b/HMP60Sensor/.cproject @@ -0,0 +1,262 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <?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 + + + \ No newline at end of file diff --git a/HMP60Sensor/.gitignore b/HMP60Sensor/.gitignore new file mode 100644 index 0000000..3df573f --- /dev/null +++ b/HMP60Sensor/.gitignore @@ -0,0 +1 @@ +/Debug/ diff --git a/HMP60Sensor/.project b/HMP60Sensor/.project new file mode 100644 index 0000000..6f46f92 --- /dev/null +++ b/HMP60Sensor/.project @@ -0,0 +1,31 @@ + + + HMP60Sensor + + + lpc_chip_15xx + HMP60Sensor + Modbus + I2C + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + 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/HMP60Sensor/inc/HMP60.h b/HMP60Sensor/inc/HMP60.h new file mode 100644 index 0000000..d1e3815 --- /dev/null +++ b/HMP60Sensor/inc/HMP60.h @@ -0,0 +1,27 @@ +/* + * HMP60.h + * + * Created on: 20 Oct 2022 + * Author: evgenymeshcheryakov + */ + +#ifndef HMP60_H_ +#define HMP60_H_ + +#include "ModbusMaster.h" +#include "ModbusRegister.h" + +class HMP60 { +public: + HMP60(); + int readRH(); + int readT(); + virtual ~HMP60(); +private: + ModbusMaster sens; + ModbusRegister regRHint; + ModbusRegister regRHfloat; + ModbusRegister regTint; +}; + +#endif /* HMP60_H_ */ diff --git a/HMP60Sensor/liblinks.xml b/HMP60Sensor/liblinks.xml new file mode 100644 index 0000000..1dc1803 --- /dev/null +++ b/HMP60Sensor/liblinks.xml @@ -0,0 +1,32 @@ + + + + + ${MacroStart}workspace_loc:/${ProjName}/inc${MacroEnd} + + + ${MacroStart}workspace_loc:/${ProjName}/inc${MacroEnd} + + + ${ProjName} + + + ${MacroStart}workspace_loc:/${ProjName}/Debug${MacroEnd} + + + ${MacroStart}workspace_loc:/${ProjName}/Release${MacroEnd} + + + ${ProjName} + + + diff --git a/HMP60Sensor/src/HMP60.cpp b/HMP60Sensor/src/HMP60.cpp new file mode 100644 index 0000000..602d039 --- /dev/null +++ b/HMP60Sensor/src/HMP60.cpp @@ -0,0 +1,29 @@ +/* + * HMP60.cpp + * + * Created on: 20 Oct 2022 + * Author: evgenymeshcheryakov + */ + +#include + +HMP60::HMP60() : sens{241}, regRHint{&sens, 0x0100}, + regTint{&sens, 0x0101}, regRHfloat{&sens, 0x0000} +{ + sens.begin(9600); +} + +int HMP60::readRH() { + int result = regRHint.read(); + return result/10; +} + +int HMP60::readT() { + int result = regTint.read(); + return result/10; +} + +HMP60::~HMP60() { + // TODO Auto-generated destructor stub +} + diff --git a/Modbus/src/ModbusRegister.cpp b/Modbus/src/ModbusRegister.cpp index a642bbc..335d6cf 100644 --- a/Modbus/src/ModbusRegister.cpp +++ b/Modbus/src/ModbusRegister.cpp @@ -22,6 +22,8 @@ int ModbusRegister::read() { void ModbusRegister::write(int value) { // write only if not - if(hr) m->writeSingleRegister(addr, value); // not checking if write succeeds + volatile uint8_t error = 15; + if(hr) + error = m->writeSingleRegister(addr, value); }