From 81a79648a168a1167c5ad97d4068621c1751a353 Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 7 Nov 2018 11:17:14 +0100 Subject: [PATCH] Many changes from 2018 --- DS18B20_ADC/DS18B20_ADC.atsln | 22 + DS18B20_ADC/DS18B20_ADC.c | 201 +++++++ DS18B20_ADC/DS18B20_ADC.cproj | 147 +++++ DS18B20_BMP280/DS18B20_BMP280.c | 40 +- .../DS18B20_BMP280_DS2438_SHT.cproj | 37 +- DS18B20_BMP280_DS2438_SHT/DS18B20_DS2438.c | 147 ++--- DS18B20_CDM7160/DS18B20_CDM7160.c | 65 +-- .../DS18B20_CDM7160_DS18B20_BMP280.atsln | 22 + .../DS18B20_CDM7160_DS18B20_BMP280.cproj | 171 ++++++ .../DS18B20_DS18B20.c | 180 ++++++ .../DS18B20_CDM7160_DS2438_HDC1080.atsln | 22 + .../DS18B20_CDM7160_DS2438_HDC1080.c | 249 ++++++++ .../DS18B20_CDM7160_DS2438_HDC1080.cproj | 175 ++++++ DS18B20_DS2408/DS18B20_DS2408.atsln | 22 + DS18B20_DS2408/DS18B20_DS2408.c | 245 ++++++++ DS18B20_DS2408/DS18B20_DS2408.cproj | 183 ++++++ DS18B20_LPS225HB_DS2438_SHT/DS18B20_DS2438.c | 209 +++++++ .../DS18B20_LPS225HB_DS2438_SHT.atsln | 22 + .../DS18B20_LPS225HB_DS2438_SHT.cproj | 175 ++++++ DS18B20_MAX44009/DS18B20_MAX44009.c | 49 +- DS18B20_MAX44009/DS18B20_MAX44009.cproj | 92 +-- DS18B20_MAX44009_DS2438_SHT/DS18B20_DS2438.c | 165 ++---- .../DS18B20_MAX44009_DS2438_SHT.cproj | 8 +- DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_DS18B20.c | 168 ++++++ .../DS18B20_SHT_DS18B20_SHT.atsln | 22 + .../DS18B20_SHT_DS18B20_SHT.cproj | 171 ++++++ DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_DS18B20.c | 167 ++++++ .../DS18B20_SHT_DS18B20_SHT.atsln | 22 + .../DS18B20_SHT_DS18B20_SHT.cproj | 171 ++++++ DS18B20_Thermocouble/DS18B20_TC.cproj | 146 ++--- .../DS18B20_DS2438.c | 150 ++--- .../DS18B20_Thermocouble_DS2438_SHT.atsln | 44 +- .../DS18B20_Thermocouble_DS2438_SHT.cproj | 8 +- .../DS18B20_DS2438.c | 100 +--- .../DS18B20_VOC_DS2438_SHT.atsln | 22 + .../DS18B20_VOC_DS2438_SHT.cproj | 157 +++++ DS18B20_VOC_DS2438_SHT/DS18B20_DS2438.c | 2 +- DS2408/DS2408.atsln | 22 + DS2408/DS2408.c | 216 +++++++ DS2408/DS2408.cproj | 183 ++++++ DS2413_DS2413/DS2413_DS2413.atsln | 22 + DS2413_DS2413/DS2413_DS2413.c | 209 +++++++ DS2413_DS2413/DS2413_DS2413.cproj | 145 +++++ DS2423_DS2413/DS2423_DS2413.c | 35 +- DS2423_DS2423/DS2423_DS2423.c | 57 +- DS2438_ADC/DS2438_ADC.atsln | 22 + DS2438_ADC/DS2438_ADC.c | 191 ++++++ DS2438_ADC/DS2438_ADC.cproj | 145 +++++ .../DS2438_ADC_DS2438_ADC.atsln | 22 + .../DS2438_ADC_DS2438_ADC.cproj | 145 +++++ DS2438_ADC_DS2438_ADC/DS2438_DS2438.c | 241 ++++++++ DS2438_CDM7160/DS2438_CDM7160.atsln | 22 + DS2438_CDM7160/DS2438_CDM7160.c | 180 ++++++ DS2438_CDM7160/DS2438_CDM7160.cproj | 149 +++++ .../DS2438_CDM7160_DS2438_BMP280.atsln | 22 + ...38_CDM7160_DS2438_BMP280.componentinfo.xml | 4 + DS2438_CDM7160_DS2438_BMP280/DS2438_DS2438.c | 187 ++++++ DS2438_DHT11/DS2438_DHT22.atsln | 22 + DS2438_DHT11/DS2438_DHT22.c | 316 ++++++++++ DS2438_DHT11/DS2438_DHT22.cproj | 145 +++++ DS2438_DHT22/DS2438_DHT22.cproj | 18 +- .../DS2438_Fenster_Kontakt.atsln | 22 + .../DS2438_Fenster_Kontakt.c | 208 +++++++ .../DS2438_Fenster_Kontakt.cproj | 144 +++++ DS2438_Fenster_Kontakt/OWDS2438.S | 196 +++++++ DS2438_HDC1080/DS2438_HDC1080.atsln | 44 +- DS2438_HDC2010/DS2438_HDC2010.atsln | 22 + DS2438_HDC2010/DS2438_HDC2010.c | 199 +++++++ DS2438_HDC2010/DS2438_HDC2010.cproj | 151 +++++ .../DS2438_DS2438.c | 444 ++++++++++++++ .../DS2438_MAX44009_VOC_DS2438_HDC.atsln | 22 + .../DS2438_MAX44009_VOC_DS2438_HDC.cproj | 170 ++++++ .../DS2438_DS2438.c | 442 ++++++++++++++ .../DS2438_MAX44009_VOC_DS2438_SHT.atsln | 22 + .../DS2438_MAX44009_VOC_DS2438_SHT.cproj | 163 ++++++ .../DS2438_DS2438.c | 189 ++++++ .../DS2438_SHT2X_DS2438_BMP280_MAX44009.atsln | 22 + .../DS2438_SHT2X_DS2438_BMP280_MAX44009.cproj | 163 ++++++ DS2438_SHT2X_DS2438_LPS225HB/DS2438_DS2438.c | 282 +++++++++ .../DS2438_SHT2X_DS2438_LPS225HB.atsln | 22 + .../DS2438_SHT2X_DS2438_LPS225HB.cproj | 159 +++++ DS2438_SHT3X/DS2438_SHT3X.c | 4 +- DS2438_SHT3X/DS2438_SHT3X.cproj | 130 +++-- DS2450/DS2450.c | 79 ++- DS2450/DS2450.cproj | 161 ++--- DS2450/OWDS2450.S | 10 +- DS2450_ADC/DS2450.c | 305 ++++++++++ DS2450_ADC/DS2450_ADC.atsln | 22 + DS2450_ADC/DS2450_ADC.cproj | 146 +++++ DS2450_ADC/OWDS2450.S | 248 ++++++++ DS2450_ADC_JOE2/DS2450.c | 305 ++++++++++ DS2450_ADC_JOE2/DS2450_ADC.atsln | 22 + DS2450_ADC_JOE2/DS2450_ADC_JOE2.cproj | 146 +++++ DS2450_ADC_JOE2/OWDS2450.S | 248 ++++++++ DS2450_APDS9960/DS2450_APDS9960.atsln | 44 +- DS2450_APDS9960/DS2450_APDS9960.cproj | 302 +++++----- DS2450_APDS9960/OWDS2450.S | 248 ++++++++ DS2450_BME680/DS2450_BME680.atsln | 22 + DS2450_BME680/DS2450_BME680.c | 272 +++++++++ DS2450_BME680/DS2450_BME680.cproj | 154 +++++ DS2450_BME680/OWDS2450.S | 248 ++++++++ DS2450_BMP280/OWDS2450.S | 247 ++++++++ DS2450_CDM7160/DS2450_CDM7160.atsln | 22 + DS2450_CDM7160/DS2450_CDM7160.c | 280 +++++++++ DS2450_CDM7160/DS2450_CDM7160.cproj | 145 +++++ DS2450_CDM7160/OWDS2450.S | 247 ++++++++ .../DS2450_CDM7160_BMP280.atsln | 22 + DS2450_CDM7160_BMP280/DS2450_CDM7160_BMP280.c | 272 +++++++++ .../DS2450_CDM7160_BMP280.cproj | 146 +++++ DS2450_DSM501A/DS2450_DSM501A.atsln | 22 + DS2450_DSM501A/DS2450_DSM501A.c | 312 ++++++++++ DS2450_DSM501A/DS2450_DSM501A.cproj | 145 +++++ DS2450_IAQCORE/DS2450_IAQCORE.atsln | 44 +- DS2450_IAQCORE/DS2450_IAQCORE.c | 2 +- DS2450_IAQCORE/DS2450_IAQCORE.cproj | 276 ++++----- DS2450_LPS225HB/DS2450_LPS225HB.atsln | 22 + DS2450_LPS225HB/DS2450_LPS225HB.c | 292 ++++++++++ DS2450_LPS225HB/DS2450_LPS225HB.cproj | 142 +++++ DS2450_LPS225HB/OWDS2450.S | 247 ++++++++ DS2450_MAX44008/DS2450_MAX44008.atsln | 22 + DS2450_MAX44008/DS2450_MAX44008.c | 270 +++++++++ DS2450_MAX44008/DS2450_MAX44008.cproj | 135 +++++ DS2450_MAX44008/OWDS2450.S | 248 ++++++++ DS2450_SGP30/DS2450_SGP30.atsln | 22 + DS2450_SGP30/DS2450_SGP30.c | 265 +++++++++ DS2450_SGP30/DS2450_SGP30.cproj | 158 +++++ DS2450_SGP30/OWDS2450.S | 250 ++++++++ DS2450_SHT2X_BMP280/DS2450_SHT2X_BMP280.atsln | 44 +- .../DS2450_SHT2X_BMP280_MAX44009.c | 90 +-- .../DS2450_SHT2X_BMP280_MAX44009.cproj | 16 +- .../DS2450_SHT2X_MAX44009.atsln | 44 +- DS2450_SHT2X_MAX44009/DS2450_SHT2X_MAX44009.c | 6 +- .../DS2450_SHT2X_MAX44009.cproj | 24 +- DS2450_SHT3X/DS2450_SHT3X.atsln | 22 + DS2450_SHT3X/DS2450_SHT3X.c | 298 ++++++++++ DS2450_SHT3X/DS2450_SHT3X.cproj | 148 +++++ DS2450_SHT3X/OWDS2450.S | 247 ++++++++ DS2450_VOC_SHT/DS2450_VOC_SHT.atsln | 22 + DS2450_VOC_SHT/DS2450_VOC_SHT.c | 519 +++++++++++++++++ DS2450_VOC_SHT/DS2450_VOC_SHT.cproj | 147 +++++ DS2450_VOC_SHT/OWDS2450.S | 247 ++++++++ common/I2C/BME680.c | 16 +- common/I2C/BMP280.c | 91 ++- common/I2C/BMP280.h | 1 + common/I2C/CDM7160.c | 2 +- common/I2C/HDC2010.c | 291 ++++++++++ common/I2C/HDC2010.h | 42 ++ common/I2C/LPS225HB.c | 129 +++++ common/I2C/LPS225HB.h | 42 ++ common/I2C/MAX44009.c | 2 +- common/I2C/SGP30.c | 2 + common/I2C/SHT2x.c | 2 +- common/I2C/SHT2xV2.c | 8 +- common/I2C/SHT3x.c | 2 +- common/I2C/TSL256x.c | 2 +- common/I2C/TWI_Master.c | 367 ++++++++++++ common/I2C/TWI_Master.h | 147 +++++ common/I2C/USI_TWI_Master.c | 7 +- common/I2C/USI_TWI_Master.h | 15 +- common/OWCRC8_16.s | 105 ++++ common/OWConfig.s | 6 +- common/OWDS18B20_DS18B20.S | 392 +++++++++++++ common/OWDS18B20_DS2408.S | 456 +++++++++++++++ common/OWDS18B20_DS2438.S | 38 +- common/OWDS2408.S | 255 ++++++++ common/OWDS2413_DS2413.S | 248 ++++++++ common/OWDS2438_DS2438.S | 13 +- common/OWDS2450_DS2423.S | 548 ++++++++++++++++++ common/OWDS2450_DS2450.S | 440 ++++++++++++++ common/OWPinInterrupt.s | 4 +- common/OWRomFunctions.s | 36 +- common/OWRomFunctionsDual.s | 38 +- common/OWSet_ATMEGA168.s | 167 ++++++ common/OWSet_ATTINYX4.s | 36 +- common/calibr.c | 5 + common/calibr.h | 1 - common/owSlave_tools.h | 187 ++++++ programmer/programmer/programmer.asmproj | 12 +- .../programmer/programmer_8MHz_2017.asm | 489 ++++++++++++++++ .../programmer_atmega328.asm | 497 ++++++++++++++++ .../programmer_atmega328.asmproj | 89 +++ .../programmer_atmega328.atsln | 22 + 182 files changed, 22796 insertions(+), 1505 deletions(-) create mode 100644 DS18B20_ADC/DS18B20_ADC.atsln create mode 100644 DS18B20_ADC/DS18B20_ADC.c create mode 100644 DS18B20_ADC/DS18B20_ADC.cproj create mode 100644 DS18B20_CDM7160_DS18B20_BMP280/DS18B20_CDM7160_DS18B20_BMP280.atsln create mode 100644 DS18B20_CDM7160_DS18B20_BMP280/DS18B20_CDM7160_DS18B20_BMP280.cproj create mode 100644 DS18B20_CDM7160_DS18B20_BMP280/DS18B20_DS18B20.c create mode 100644 DS18B20_CDM7160_DS2438_HDC1080/DS18B20_CDM7160_DS2438_HDC1080.atsln create mode 100644 DS18B20_CDM7160_DS2438_HDC1080/DS18B20_CDM7160_DS2438_HDC1080.c create mode 100644 DS18B20_CDM7160_DS2438_HDC1080/DS18B20_CDM7160_DS2438_HDC1080.cproj create mode 100644 DS18B20_DS2408/DS18B20_DS2408.atsln create mode 100644 DS18B20_DS2408/DS18B20_DS2408.c create mode 100644 DS18B20_DS2408/DS18B20_DS2408.cproj create mode 100644 DS18B20_LPS225HB_DS2438_SHT/DS18B20_DS2438.c create mode 100644 DS18B20_LPS225HB_DS2438_SHT/DS18B20_LPS225HB_DS2438_SHT.atsln create mode 100644 DS18B20_LPS225HB_DS2438_SHT/DS18B20_LPS225HB_DS2438_SHT.cproj create mode 100644 DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_DS18B20.c create mode 100644 DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_SHT_DS18B20_SHT.atsln create mode 100644 DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_SHT_DS18B20_SHT.cproj create mode 100644 DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_DS18B20.c create mode 100644 DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_SHT_DS18B20_SHT.atsln create mode 100644 DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_SHT_DS18B20_SHT.cproj create mode 100644 DS18B20_VOC_DS2438_SHT direct/DS18B20_VOC_DS2438_SHT.atsln create mode 100644 DS18B20_VOC_DS2438_SHT direct/DS18B20_VOC_DS2438_SHT.cproj create mode 100644 DS2408/DS2408.atsln create mode 100644 DS2408/DS2408.c create mode 100644 DS2408/DS2408.cproj create mode 100644 DS2413_DS2413/DS2413_DS2413.atsln create mode 100644 DS2413_DS2413/DS2413_DS2413.c create mode 100644 DS2413_DS2413/DS2413_DS2413.cproj create mode 100644 DS2438_ADC/DS2438_ADC.atsln create mode 100644 DS2438_ADC/DS2438_ADC.c create mode 100644 DS2438_ADC/DS2438_ADC.cproj create mode 100644 DS2438_ADC_DS2438_ADC/DS2438_ADC_DS2438_ADC.atsln create mode 100644 DS2438_ADC_DS2438_ADC/DS2438_ADC_DS2438_ADC.cproj create mode 100644 DS2438_ADC_DS2438_ADC/DS2438_DS2438.c create mode 100644 DS2438_CDM7160/DS2438_CDM7160.atsln create mode 100644 DS2438_CDM7160/DS2438_CDM7160.c create mode 100644 DS2438_CDM7160/DS2438_CDM7160.cproj create mode 100644 DS2438_CDM7160_DS2438_BMP280/DS2438_CDM7160_DS2438_BMP280.atsln create mode 100644 DS2438_CDM7160_DS2438_BMP280/DS2438_CDM7160_DS2438_BMP280.componentinfo.xml create mode 100644 DS2438_CDM7160_DS2438_BMP280/DS2438_DS2438.c create mode 100644 DS2438_DHT11/DS2438_DHT22.atsln create mode 100644 DS2438_DHT11/DS2438_DHT22.c create mode 100644 DS2438_DHT11/DS2438_DHT22.cproj create mode 100644 DS2438_Fenster_Kontakt/DS2438_Fenster_Kontakt.atsln create mode 100644 DS2438_Fenster_Kontakt/DS2438_Fenster_Kontakt.c create mode 100644 DS2438_Fenster_Kontakt/DS2438_Fenster_Kontakt.cproj create mode 100644 DS2438_Fenster_Kontakt/OWDS2438.S create mode 100644 DS2438_HDC2010/DS2438_HDC2010.atsln create mode 100644 DS2438_HDC2010/DS2438_HDC2010.c create mode 100644 DS2438_HDC2010/DS2438_HDC2010.cproj create mode 100644 DS2438_MAX44009_VOC_DS2438_HDC_direct/DS2438_DS2438.c create mode 100644 DS2438_MAX44009_VOC_DS2438_HDC_direct/DS2438_MAX44009_VOC_DS2438_HDC.atsln create mode 100644 DS2438_MAX44009_VOC_DS2438_HDC_direct/DS2438_MAX44009_VOC_DS2438_HDC.cproj create mode 100644 DS2438_MAX44009_VOC_DS2438_SHT_direct/DS2438_DS2438.c create mode 100644 DS2438_MAX44009_VOC_DS2438_SHT_direct/DS2438_MAX44009_VOC_DS2438_SHT.atsln create mode 100644 DS2438_MAX44009_VOC_DS2438_SHT_direct/DS2438_MAX44009_VOC_DS2438_SHT.cproj create mode 100644 DS2438_SHT2X_DS2438_BMP280_MAX44009/DS2438_DS2438.c create mode 100644 DS2438_SHT2X_DS2438_BMP280_MAX44009/DS2438_SHT2X_DS2438_BMP280_MAX44009.atsln create mode 100644 DS2438_SHT2X_DS2438_BMP280_MAX44009/DS2438_SHT2X_DS2438_BMP280_MAX44009.cproj create mode 100644 DS2438_SHT2X_DS2438_LPS225HB/DS2438_DS2438.c create mode 100644 DS2438_SHT2X_DS2438_LPS225HB/DS2438_SHT2X_DS2438_LPS225HB.atsln create mode 100644 DS2438_SHT2X_DS2438_LPS225HB/DS2438_SHT2X_DS2438_LPS225HB.cproj create mode 100644 DS2450_ADC/DS2450.c create mode 100644 DS2450_ADC/DS2450_ADC.atsln create mode 100644 DS2450_ADC/DS2450_ADC.cproj create mode 100644 DS2450_ADC/OWDS2450.S create mode 100644 DS2450_ADC_JOE2/DS2450.c create mode 100644 DS2450_ADC_JOE2/DS2450_ADC.atsln create mode 100644 DS2450_ADC_JOE2/DS2450_ADC_JOE2.cproj create mode 100644 DS2450_ADC_JOE2/OWDS2450.S create mode 100644 DS2450_APDS9960/OWDS2450.S create mode 100644 DS2450_BME680/DS2450_BME680.atsln create mode 100644 DS2450_BME680/DS2450_BME680.c create mode 100644 DS2450_BME680/DS2450_BME680.cproj create mode 100644 DS2450_BME680/OWDS2450.S create mode 100644 DS2450_BMP280/OWDS2450.S create mode 100644 DS2450_CDM7160/DS2450_CDM7160.atsln create mode 100644 DS2450_CDM7160/DS2450_CDM7160.c create mode 100644 DS2450_CDM7160/DS2450_CDM7160.cproj create mode 100644 DS2450_CDM7160/OWDS2450.S create mode 100644 DS2450_CDM7160_BMP280/DS2450_CDM7160_BMP280.atsln create mode 100644 DS2450_CDM7160_BMP280/DS2450_CDM7160_BMP280.c create mode 100644 DS2450_CDM7160_BMP280/DS2450_CDM7160_BMP280.cproj create mode 100644 DS2450_DSM501A/DS2450_DSM501A.atsln create mode 100644 DS2450_DSM501A/DS2450_DSM501A.c create mode 100644 DS2450_DSM501A/DS2450_DSM501A.cproj create mode 100644 DS2450_LPS225HB/DS2450_LPS225HB.atsln create mode 100644 DS2450_LPS225HB/DS2450_LPS225HB.c create mode 100644 DS2450_LPS225HB/DS2450_LPS225HB.cproj create mode 100644 DS2450_LPS225HB/OWDS2450.S create mode 100644 DS2450_MAX44008/DS2450_MAX44008.atsln create mode 100644 DS2450_MAX44008/DS2450_MAX44008.c create mode 100644 DS2450_MAX44008/DS2450_MAX44008.cproj create mode 100644 DS2450_MAX44008/OWDS2450.S create mode 100644 DS2450_SGP30/DS2450_SGP30.atsln create mode 100644 DS2450_SGP30/DS2450_SGP30.c create mode 100644 DS2450_SGP30/DS2450_SGP30.cproj create mode 100644 DS2450_SGP30/OWDS2450.S create mode 100644 DS2450_SHT3X/DS2450_SHT3X.atsln create mode 100644 DS2450_SHT3X/DS2450_SHT3X.c create mode 100644 DS2450_SHT3X/DS2450_SHT3X.cproj create mode 100644 DS2450_SHT3X/OWDS2450.S create mode 100644 DS2450_VOC_SHT/DS2450_VOC_SHT.atsln create mode 100644 DS2450_VOC_SHT/DS2450_VOC_SHT.c create mode 100644 DS2450_VOC_SHT/DS2450_VOC_SHT.cproj create mode 100644 DS2450_VOC_SHT/OWDS2450.S create mode 100644 common/I2C/HDC2010.c create mode 100644 common/I2C/HDC2010.h create mode 100644 common/I2C/LPS225HB.c create mode 100644 common/I2C/LPS225HB.h create mode 100644 common/I2C/TWI_Master.c create mode 100644 common/I2C/TWI_Master.h create mode 100644 common/OWCRC8_16.s create mode 100644 common/OWDS18B20_DS18B20.S create mode 100644 common/OWDS18B20_DS2408.S create mode 100644 common/OWDS2408.S create mode 100644 common/OWDS2413_DS2413.S create mode 100644 common/OWDS2450_DS2423.S create mode 100644 common/OWDS2450_DS2450.S create mode 100644 common/OWSet_ATMEGA168.s create mode 100644 common/owSlave_tools.h create mode 100644 programmer/programmer/programmer_8MHz_2017.asm create mode 100644 programmer_atmega328/programmer_atmega328/programmer_atmega328.asm create mode 100644 programmer_atmega328/programmer_atmega328/programmer_atmega328.asmproj create mode 100644 programmer_atmega328/programmer_atmega328/programmer_atmega328.atsln diff --git a/DS18B20_ADC/DS18B20_ADC.atsln b/DS18B20_ADC/DS18B20_ADC.atsln new file mode 100644 index 0000000..ace6033 --- /dev/null +++ b/DS18B20_ADC/DS18B20_ADC.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS18B20_ADC", "DS18B20_ADC.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.ActiveCfg = Debug|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.Build.0 = Debug|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.ActiveCfg = Release|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS18B20_ADC/DS18B20_ADC.c b/DS18B20_ADC/DS18B20_ADC.c new file mode 100644 index 0000000..36bd271 --- /dev/null +++ b/DS18B20_ADC/DS18B20_ADC.c @@ -0,0 +1,201 @@ + +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include + +extern void OWINIT(); +extern void EXTERN_SLEEP(); + + + +uint8_t owid[8]={0x28, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0xAC};/**/ +uint8_t config_info[26]={0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x02,6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + +#if (owid>128) +#error "Variable not correct" +#endif + +extern uint8_t mode; +extern uint8_t gcontrol; +extern uint8_t reset_indicator; +extern uint8_t alarmflag; + + +volatile uint8_t wdcounter; + + +typedef union { + volatile uint8_t bytes[8]; + struct { + uint16_t temp; //0 + uint8_t TH; //2 + uint8_t TL; //3 + uint8_t config; //4 + uint8_t rrFF; //5 + uint8_t rr00; //6 + uint8_t rr10; //7 + }; +} pack_t; +volatile pack_t pack; + + + + +#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) +ISR(WATCHDOG_vect) { +#else +ISR(WDT_vect) { +#endif + //sleep_disable(); // Disable Sleep on Wakeup + wdcounter++; + if (reset_indicator==1) reset_indicator++; + else if (reset_indicator==2) mode=0; +/* if (timeout==2) { + DIS_TIMER; + EN_OWINT; + mode=OWM_SLEEP; + } + timeout++;*/ + //sleep_enable(); // Enable Sleep Mode + +} + + +volatile double V,ktemp; + +uint16_t ADmess() { + ADMUX=0b00101100; //3V ADC2+ ADC1- 1x + ADCSRA|=(1<0) { +// ares[par]=ADmess(); + par++; + if (par>15) par=0; + wdcounter=0; + sum=0; + for(uint8_t i=0;i<16;i++) { + //sum+=ares[i]; + sum+=ADmess(); + } + + + } + if (gcontrol) { + PORTB|=(1<125*16) V=125*16; + if (V<-55*16) V=-55*16; + + uint16_t htemp=V; + + uint8_t t8=pack.temp>>4; + uint8_t af=0; + if (t8>pack.TH) af=1; + if (t8<=pack.TL) af=1; + cli(); + pack.temp=htemp; + alarmflag=af; + sei(); + EXTERN_SLEEP(); + PORTB&=~(1< + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + {7a5672fe-8226-4158-b931-e1f36b9a8858} + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS18B20_TC + DS18B20_ADC + DS18B20_TC + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + debugWIRE + + J41800000789 + 0x1E930C + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Default (-Wa,-g) + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Default (-Wa,-g) + + + + + + compile + OWDS18B20.S + + + compile + + + + \ No newline at end of file diff --git a/DS18B20_BMP280/DS18B20_BMP280.c b/DS18B20_BMP280/DS18B20_BMP280.c index 78bb7d6..8cfc5a6 100644 --- a/DS18B20_BMP280/DS18B20_BMP280.c +++ b/DS18B20_BMP280/DS18B20_BMP280.c @@ -39,10 +39,10 @@ #include #include "../common/I2C/USI_TWI_Master.h" #include "../common/I2C/BMP280.h" +#include "../common/owSlave_tools.h" -extern void OWINIT(); -extern void EXTERN_SLEEP(); +#define OWST_EXTERN_VARS @@ -54,10 +54,7 @@ uint8_t config_info[26]={0x02,0x03, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,14,0x0 #error "Variable not correct" #endif -extern uint8_t mode; -extern uint8_t gcontrol; -extern uint8_t reset_indicator; -extern uint8_t alarmflag; + @@ -84,7 +81,8 @@ volatile pack_t pack; int main(void){ - PRR|=(1<1 - - - - - - - - - + + + + + + + + + - custom + com.atmel.avrdbg.tool.atmelice @@ -62,8 +62,7 @@ Simulator - - + J41800000789 0x1E930C @@ -76,6 +75,8 @@ Custom Programming Tool + 0 + @@ -148,10 +149,6 @@ - - compile - SHT2x.c - compile calibr.c @@ -160,9 +157,13 @@ compile BMP280.c - + + compile + SHT2xV2.c + + compile - USI_TWI_Master.c + TWI_Master.c compile diff --git a/DS18B20_BMP280_DS2438_SHT/DS18B20_DS2438.c b/DS18B20_BMP280_DS2438_SHT/DS18B20_DS2438.c index e379db8..4dc0ba0 100644 --- a/DS18B20_BMP280_DS2438_SHT/DS18B20_DS2438.c +++ b/DS18B20_BMP280_DS2438_SHT/DS18B20_DS2438.c @@ -37,13 +37,13 @@ #include #include #include -#include "../common/I2C/USI_TWI_Master.h" -#include "../common/I2C/SHT2x.h" +#include "../common/I2C/TWI_Master.h" +#include "../common/I2C/SHT2xV2.h" #include "../common/I2C/BMP280.h" #include "../common/calibr.h" +#include "../common/owSlave_tools.h" -extern void OWINIT(); -extern void EXTERN_SLEEP(); +OWST_EXTERN_VARS uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x18};/**/ @@ -53,37 +53,8 @@ uint8_t config_info1[26]={0x02,0x03, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,14,0x uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0x00,0x00, 0x02,7,0x00,7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; -#if (owid>128) -#error "Variable not correct" -#endif - -extern uint8_t mode; -extern uint8_t gcontrol; -extern uint8_t reset_indicator; -extern uint8_t alarmflag; -volatile uint8_t wdcounter=3; - - -#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) -ISR(WATCHDOG_vect) { - #else - ISR(WDT_vect) { - -#endif - //sleep_disable(); // Disable Sleep on Wakeup - wdcounter++; - if (reset_indicator==1) reset_indicator++; - else if (reset_indicator==2) mode=0; -/* if (timeout==2) { - DIS_TIMER; - EN_OWINT; - mode=OWM_SLEEP; - } - timeout++;*/ - //sleep_enable(); // Enable Sleep Mode - -} +OWST_WDT_ISR typedef union { volatile uint8_t bytes[8]; @@ -132,43 +103,23 @@ volatile pack2_t pack2; -volatile int16_t am2302_temp; -volatile uint16_t am2302_hum; +volatile int16_t DS2438_2_TEMP; +volatile uint16_t DS2438_2_VAD; +volatile uint16_t DS2438_2_VDD=0x01F4; +OWST_TESTSW -int testSW(void) { - uint8_t r; - DDRB&=~(1<2) { - SHT2x_MeasurePoll(HUMIDITY, &sRH); - // --- measure temperature with "Polling Mode" (no hold master) --- - SHT2x_MeasurePoll(TEMP, &sT); - //-- calculate humidity and temperature -- - temperatureC = SHT2x_CalcTemperatureC(sT); - humidityRH = SHT2x_CalcRH(sRH); - humidityRH=calibr_hum(temperatureC,-0.45,humidityRH)*10.0; - temperatureC=temperatureC*10.0-4.5; + getSHT2xHumTemp(&temperatureC,&humidityRH); + double RH=calibr_hum(temperatureC,-0.2,humidityRH)*10.0; + double TC =temperatureC *10.0-2; + if (testSW()) { - am2302_hum= humidityRH*10.0; - am2302_temp=temperatureC*25.6; + DS2438_2_VAD=RH; + DS2438_2_TEMP=(double)TC*25.6; //am2302_temp=am2302_temp-20; - config_info2[5]=8; + config_info2[5]=12; + DS2438_2_VDD=0x01F4; }else{ - double hhum=(1.0546-0.000216*temperatureC)*(humidityRH); + double hhum=(1.0546-0.000216*TC)*(RH); //am2302_hum=0.318*hhum +76.0; - am2302_hum=0.31*hhum +80; - am2302_temp=temperatureC*25.6; + DS2438_2_VAD=0.31*hhum +80; + DS2438_2_TEMP=TC*25.6; //am2302_temp=am2302_temp-20; config_info2[5]=7; + DS2438_2_VDD=0x01F4; } wdcounter=0; } @@ -269,23 +204,7 @@ int main(void){ } - -#if defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) - if (((TIMSK & (1< #include #include +#include "../common/owSlave_tools.h" #include "../common/I2C/USI_TWI_Master.h" #include "../common/I2C/CDM7160.h" -extern void OWINIT(); - -extern void EXTERN_SLEEP(); - +OWST_EXTERN_VARS uint8_t owid[8]={0x28, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x77, 0x6B};/**/ uint8_t config_info[26]={10,21, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; -#if (owid>128) -#error "Variable not correct" -#endif - -extern uint8_t mode; -extern uint8_t gcontrol; -extern uint8_t reset_indicator; -extern uint8_t alarmflag; -volatile uint8_t wdcounter=5; - -#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) -ISR(WATCHDOG_vect) { -#else -ISR(WDT_vect) { -#endif - wdcounter++; - if (reset_indicator==1) reset_indicator++; - else if (reset_indicator==2) mode=0; - -} - -uint8_t max_adr=0; +OWST_WDT_ISR typedef union { volatile uint8_t bytes[8]; @@ -94,10 +71,10 @@ volatile pack_t pack; -int main(void){ - PORTB&=~(1< + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + {7a5672fe-8226-4158-b931-e1f36b9a8858} + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS18B20_DS2438 + DS18B20_CDM7160_DS18B20_BMP280 + DS18B20_DS2438 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + debugWIRE + + + + + debugWIRE + + com.atmel.avrdbg.tool.simulator + + + Simulator + + + J41800000789 + 0x1E930C + + + + + debugWIRE + + custom + + + Custom Programming Tool + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + + + + + + compile + BMP280.c + + + compile + CDM7160.c + + + compile + TWI_Master.c + + + compile + OWDS18B20_DS18B20.S + + + compile + + + + \ No newline at end of file diff --git a/DS18B20_CDM7160_DS18B20_BMP280/DS18B20_DS18B20.c b/DS18B20_CDM7160_DS18B20_BMP280/DS18B20_DS18B20.c new file mode 100644 index 0000000..60adf1e --- /dev/null +++ b/DS18B20_CDM7160_DS18B20_BMP280/DS18B20_DS18B20.c @@ -0,0 +1,180 @@ +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/TWI_Master.h" +#include "../common/I2C/CDM7160.h" +#include "../common/I2C/BMP280.h" +#include "../common/owSlave_tools.h" + +OWST_EXTERN_VARS + + +uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x26, 0x05, 0x35};/**/ +uint8_t owid2[8]={0x28, 0xA4, 0xD9, 0x84, 0x00, 0x26, 0x05, 0xB0};/**/ + +uint8_t config_info1[26]={10,21,0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +uint8_t config_info2[26]={0x02,0x03,0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,14,0x00,0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + + + +OWST_WDT_ISR + +typedef union { + volatile uint8_t bytes[8]; + struct { + uint16_t temp; //0 + uint8_t TH; //2 + uint8_t TL; //3 + uint8_t config; //4 + uint8_t rrFF; //5 + uint8_t rr00; //6 + uint8_t rr10; //7 + }; +} pack1_t; +volatile pack1_t pack1,pack2; + + + + + + + + + +OWST_TESTSW + + +uint8_t userRegister[1]; +uint16_t CO2,BMP; + +int main(void){ + OWST_INIT_USI_ON + + pack1.temp=0x0550; + pack1.config=0x7F; + pack1.TH=75; + pack1.TL=70; + pack1.rrFF=0xFF; + pack1.rr00=0; + pack1.rr10=0x10; + PORTA=0xFF; + PORTB=0xFF; + OWINIT(); + OWST_EN_PULLUP + + OWST_WDR_CONFIG8 + + if (testSW()) { + config_info2[5]=12; + }else{ + config_info2[5]=7; + } + + MCUSR=0; + TWI_Master_Initialise(); + bmp280Init(); + _delay_ms(50); + bmp280Init(); + + CDM7160softReset(); + _delay_ms(200); + + CDM7160setMode(0); //Power Down Mode + _delay_ms(200); + CDM7160setAvCount(0x3F); + CDM7160setFMode(1); + CO2=CDM7160getCO2(); + CDM7160setMode(1); + _delay_ms(200); + gcontrol=1; + _delay_ms(10); + gcontrol=1; + sei(); + while(1) { + + if (gcontrol) { + wdcounter=3; + + } + + if (wdcounter>2) { + volatile int16_t l=(int16_t)CDM7160getCO2()-1280; + + uint16_t w1=l; + uint32_t P; + int32_t t; + bmp280ConvertInt(&t,&P,1); + P=P-70000; + P=P/20; + uint16_t w2=P; + uint8_t t81=w1>>4; + uint8_t af1=0; + if (t81>pack1.TH) af1=1; + if (t81<=pack1.TL) af1=1; + + cli(); + pack1.temp=w1; + //pack.temp++; + alarmflag=af1; + sei(); + + + + cli(); + pack2.temp=w2; + sei(); + //pack.temp++; + gcontrol=0; + + + + wdcounter=0; + } + + if (gcontrol) { + gcontrol=0; + EXTERN_SLEEP(); + + } + + OWST_MAIN_END + } + + +} \ No newline at end of file diff --git a/DS18B20_CDM7160_DS2438_HDC1080/DS18B20_CDM7160_DS2438_HDC1080.atsln b/DS18B20_CDM7160_DS2438_HDC1080/DS18B20_CDM7160_DS2438_HDC1080.atsln new file mode 100644 index 0000000..e158f97 --- /dev/null +++ b/DS18B20_CDM7160_DS2438_HDC1080/DS18B20_CDM7160_DS2438_HDC1080.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS18B20_CDM7160_DS2438_HDC1080", "DS18B20_CDM7160_DS2438_HDC1080.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.ActiveCfg = Debug|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.Build.0 = Debug|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.ActiveCfg = Release|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS18B20_CDM7160_DS2438_HDC1080/DS18B20_CDM7160_DS2438_HDC1080.c b/DS18B20_CDM7160_DS2438_HDC1080/DS18B20_CDM7160_DS2438_HDC1080.c new file mode 100644 index 0000000..2c4c57d --- /dev/null +++ b/DS18B20_CDM7160_DS2438_HDC1080/DS18B20_CDM7160_DS2438_HDC1080.c @@ -0,0 +1,249 @@ +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/USI_TWI_Master.h" +#include "../common/I2C/HDC1080.h" +#include "../common/calibr.h" +#include "../common/I2C/CDM7160.h" + +extern void OWINIT(); +extern void EXTERN_SLEEP(); + + +uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x17, 0x05, 0xDC};/**/ +uint8_t owid2[8]={0x26, 0xA3, 0xD9, 0x84, 0x00, 0x17, 0x05, 0xA3};/**/ +uint8_t config_info1[26]={10,13, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0x00,0x00, 0x02,11,0x00,11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + + +extern uint8_t mode; +extern uint8_t gcontrol; +extern uint8_t reset_indicator; +extern uint8_t alarmflag; + +volatile uint8_t wdcounter=5; + +typedef union { + volatile uint8_t bytes[8]; + struct { + uint16_t temp; //0 + uint8_t TH; //2 + uint8_t TL; //3 + uint8_t config; //4 + uint8_t rrFF; //5 + uint8_t rr00; //6 + uint8_t rr10; //7 + }; +} pack1_t; +volatile pack1_t pack1; + +typedef union { + + volatile uint8_t bytes[64]; + struct { + uint8_t status; //1 + int16_t temp; //2 + uint16_t voltage; //4 + uint16_t current; //6 + uint8_t threshold; //8 + + uint8_t page1[8]; //9 + uint8_t page2[8]; //17 + uint8_t page3[8]; //25 + uint8_t page4[8]; //33 + uint8_t page5[8]; //41 + uint8_t page6[8]; //49 + uint8_t page7[8]; //57 + //uint8_t crc; //65 + }; +} pack2_t; +volatile pack2_t pack2; + + + +volatile int16_t am2302_temp; +volatile uint16_t am2302_hum; + +uint8_t userRegister[1]; +int16_t sRH,sT; +double temperatureC,humidityRH; +volatile double l; + +#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) +ISR(WATCHDOG_vect) { +#else +ISR(WDT_vect) { +#endif + wdcounter++; + if (reset_indicator==1) reset_indicator++; + else if (reset_indicator==2) mode=0; + + +} + +int testSW(void) { + uint8_t r; + DDRB&=~(1<2) { + //PORTB|=(1<>4; + uint8_t af=0; + if (t8>pack1.TH) af=1; + if (t8<=pack1.TL) af=1; + cli(); + pack1.temp=w; + //pack.temp++; + alarmflag=af; + sei(); + //CDM7160setMode(0); + //EXTERN_SLEEP(); + } + if (gcontrol) { + gcontrol=0; + + } + + if (((TIMSK0 & (1< + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + {7a5672fe-8226-4158-b931-e1f36b9a8858} + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS18B20_MAX44009 + DS18B20_CDM7160_DS2438_HDC1080 + DS18B20_MAX44009 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + debugWIRE + + + + + + + + com.atmel.avrdbg.tool.simulator + + + Simulator + + + J41800000789 + 0x1E930C + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Default (-Wa,-g) + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Default (-Wa,-g) + + + + + + compile + calibr.c + + + compile + CDM7160.c + + + compile + HDC1080.c + + + compile + USI_TWI_Master.c + + + compile + OWDS18B20_DS2438.S + + + compile + + + + \ No newline at end of file diff --git a/DS18B20_DS2408/DS18B20_DS2408.atsln b/DS18B20_DS2408/DS18B20_DS2408.atsln new file mode 100644 index 0000000..90bc8f1 --- /dev/null +++ b/DS18B20_DS2408/DS18B20_DS2408.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS18B20_DS2408", "DS18B20_DS2408.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS18B20_DS2408/DS18B20_DS2408.c b/DS18B20_DS2408/DS18B20_DS2408.c new file mode 100644 index 0000000..315c589 --- /dev/null +++ b/DS18B20_DS2408/DS18B20_DS2408.c @@ -0,0 +1,245 @@ + +// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/TWI_Master.h" +#include "../common/owSlave_tools.h" +#include "../common/I2C/SHT3x.h" +#include "../common/calibr.h" + + +#include + +extern void OWINIT(); +extern void EXTERN_SLEEP(); +extern uint8_t stat_to_sample; + +uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x18};/**/ +uint8_t owid2[8]={0x29, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x01, 0x73};/**/ +uint8_t config_info1[26]={0x01,0x01, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +uint8_t config_info2[26]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0,0,0,0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + +OWST_EXTERN_VARS + +OWST_WDT_ISR + + + +typedef union { + volatile uint8_t bytes[8]; + struct { + int16_t temp; //0 + uint8_t TH; //2 + uint8_t TL; //3 + uint8_t config; //4 + uint8_t rrFF; //5 + uint8_t rr00; //6 + uint8_t rr10; //7 + }; +} pack1_t; +volatile pack1_t pack1; + +typedef union { + volatile uint8_t bytes[0x20]; + struct { + uint8_t PIO_Logic_State; // 0088h + uint8_t PIO_Output_Latch_State; + uint8_t PIO_Activity_Latch_State; + uint8_t Conditional_Search_Channel_Selection_Mask; + uint8_t Conditional_Search_Channel_Polarity_Selection; + uint8_t Status; //008D + uint8_t FF1; + uint8_t FF2; + + }; +} pack2_t; +volatile pack2_t pack2; + +uint8_t values[10]; +uint8_t ap=1; + +uint8_t crc8_f() { + uint8_t lscrc=0x0; + for(uint8_t i=0;i<5;i++) { + uint8_t v=values[i]; + //if (v==0) v=0xFF; + uint8_t bit=1; + uint8_t lb; + for(uint8_t j=0;j<8;j++) { + if ((v&bit)==bit) lb=1; else lb=0; + if ((lscrc&1)!=lb) lscrc=(lscrc>>1)^0x8c; else lscrc=(lscrc>>1); + bit=bit*2; + + + } + } + return lscrc; +} + + +//Umstellung + +//rh=(T-25)*(0,01+0,00008*x)-2,0468+0,0367*x-0,0000015955*x*x +//d1 for 3V +#define d1 -39.7 +#define d2 0.01 +inline uint16_t calcSHT75_T(double real_t) { + return (real_t-d1)/d2; +} + +inline uint16_t calcSHT75RH_lin(double real_RHlin) { + return 11501.1-0.280297*sqrt(1667284153.0-7977500.0*real_RHlin); +} + +inline double calcSHT75H_tcorr(double real_t,double real_RHtrue) { + return real_RHtrue-(real_t-25)*(0.01+0.00008*calcSHT75RH_lin(real_RHtrue)); + +} + + +double T=20.0; +double RH=60; + +int main(void){ + OWST_INIT_USI_ON; + pack2.FF1=0xFF; + pack2.FF2=0xFF; + //0x0E 0x19 0x48 0x00 + if (RH<8) RH=8; + uint16_t lt=calcSHT75_T(T); + double lfc=calcSHT75H_tcorr(T,RH); + uint16_t lf=calcSHT75RH_lin(lfc); + values[0]=0x00; + values[1]=lt&0xFF; if (values[1]==0) values[1]=1; + values[2]=lt>>8; if (values[2]==0) values[2]=1; + values[3]=lf&0xFF; if (values[3]==0) values[3]=1; + values[4]=lf>>8; if (values[4]==0) values[4]=1; + values[5]=0x5D; + values[6]=0x00; + values[7]=0x00; + values[5]=crc8_f(); + + OWINIT(); + + TWI_Master_Initialise(); + initSHT3x(0); + _delay_ms(100); + + + getSHT3xHumTemp(0,&T,&RH); + OWST_WDR_CONFIG8; + sei(); + stat_to_sample=0x55; + while (1) { + //stat_to_sample=0; + if (reset_indicator) { + // ap=0; + // stat_to_sample=0; + // reset_indicator=0; + } + if (wdcounter>3) { + + wdcounter=0; + RH=RH+0.2; + getSHT3xHumTemp(0,&T,&RH); + //pack1.temp=T*16.0; + lt=calcSHT75_T(T); + lfc=calcSHT75H_tcorr(T,RH); + lf=calcSHT75RH_lin(lfc); + values[0]=0x00; + values[1]=lt&0xFF; if (values[1]==0) values[1]=1; + values[2]=lt>>8; if (values[2]==0) values[2]=1; + values[3]=lf&0xFF; if (values[3]==0) values[3]=1; + values[4]=lf>>8; if (values[4]==0) values[4]=1; + values[5]=crc8_f(); + if (values[5]==0) values[3]=values[3]+1; //CRC darf nicht 0 sein ... warum auch immer + values[5]=crc8_f(); + } + pack2.Status|=0x80; + if (gcontrol&1) { + uint8_t bb=1; + for(uint8_t i=0;i<8;i++) { + if ((pack2.PIO_Logic_State&bb)!=(pack2.PIO_Output_Latch_State&bb)) pack2.PIO_Activity_Latch_State|=bb; + bb=bb*2; + } + pack2.PIO_Logic_State=pack2.PIO_Output_Latch_State; + gcontrol&=~0x01; + } + if (gcontrol&2) { + pack2.PIO_Activity_Latch_State=0; + gcontrol&=~0x02; + } + if (gcontrol&4) { + stat_to_sample=values[ap]; + ap++; + if (ap>5) { + ap=0; + } + gcontrol&=~0x04; + } + if (gcontrol&8) { + ap=1; + stat_to_sample=values[ap]; + ap++; + //if (ap>5) ap=1; + gcontrol&=~0x08; + } + if ((gcontrol&16)==16) { + + + uint16_t w=T*16.0; + uint8_t t8=w>>4; + uint8_t af=0; + if (t8>pack1.TH) af=1; + if (t8<=pack1.TL) af=1; + cli(); + pack1.temp=w; + //pack.temp++; + alarmflag=af; + sei(); + gcontrol=0; + EXTERN_SLEEP(); + } + + OWST_MAIN_END + } + + + +} diff --git a/DS18B20_DS2408/DS18B20_DS2408.cproj b/DS18B20_DS2408/DS18B20_DS2408.cproj new file mode 100644 index 0000000..733515c --- /dev/null +++ b/DS18B20_DS2408/DS18B20_DS2408.cproj @@ -0,0 +1,183 @@ + + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS2450 + DS18B20_DS2408 + DS2450 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + debugWIRE + J41800000789 + 0x1E930C + + + + 125000 + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + 125000 + 0 + + + + + + ISP + + com.atmel.avrdbg.tool.simulator + + + Simulator + + + + + + ISP + + custom + + + Custom Programming Tool + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Default (-Wa,-g) + + + + + + compile + calibr.c + + + compile + SHT3x.c + + + compile + TWI_Master.c + + + compile + OWDS18B20_DS2408.S + + + compile + + + + \ No newline at end of file diff --git a/DS18B20_LPS225HB_DS2438_SHT/DS18B20_DS2438.c b/DS18B20_LPS225HB_DS2438_SHT/DS18B20_DS2438.c new file mode 100644 index 0000000..a663f2f --- /dev/null +++ b/DS18B20_LPS225HB_DS2438_SHT/DS18B20_DS2438.c @@ -0,0 +1,209 @@ +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/USI_TWI_Master.h" +#include "../common/I2C/SHT2xV2.h" +#include "../common/I2C/LPS225HB.h" +#include "../common/calibr.h" +#include "../common/owSlave_tools.h" + +OWST_EXTERN_VARS + + +uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x18};/**/ +uint8_t owid2[8]={0x26, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x67};/**/ + +uint8_t config_info1[26]={0x02,0x03, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0x00,0x00, 0x02,7,0x00,7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + + + +OWST_WDT_ISR + +typedef union { + volatile uint8_t bytes[8]; + struct { + uint16_t temp; //0 + uint8_t TH; //2 + uint8_t TL; //3 + uint8_t config; //4 + uint8_t rrFF; //5 + uint8_t rr00; //6 + uint8_t rr10; //7 + }; +} pack1_t; +volatile pack1_t pack1; + + + +typedef union { + #if defined(__AVR_ATtiny25__) + volatile uint8_t bytes[16]; + #else + volatile uint8_t bytes[64]; + #endif + struct { + uint8_t status; //1 + int16_t temp; //2 + uint16_t voltage; //4 + uint16_t current; //6 + uint8_t threshold; //8 + + uint8_t page1[8]; //9 + #if defined(__AVR_ATtiny25__) + #else + uint8_t page2[8]; //17 + uint8_t page3[8]; //25 + uint8_t page4[8]; //33 + uint8_t page5[8]; //41 + uint8_t page6[8]; //49 + uint8_t page7[8]; //57 + //uint8_t crc; //65 + #endif + }; +} pack2_t; +volatile pack2_t pack2; + + + + +volatile int16_t DS2438_2_TEMP; +volatile uint16_t DS2438_2_VAD; +volatile uint16_t DS2438_2_VDD=0x01F4; + +OWST_TESTSW + + +uint8_t userRegister[1]; +int16_t sRH,sT; +double temperatureC,humidityRH; +volatile double l; + uint32_t P; + int16_t t; + +int main(void){ + OWST_INIT_USI_ON + + pack1.temp=0x0550; + pack1.config=0x7F; + pack1.TH=75; + pack1.TL=70; + pack1.rrFF=0xFF; + pack1.rr00=0; + pack1.rr10=0x10; + PORTA=0xFF; + PORTB=0xFF; + OWINIT(); + OWST_EN_PULLUP + + OWST_WDR_CONFIG8 + + if (testSW()) { + config_info2[5]=12; + }else{ + config_info2[5]=7; + } + pack2.page3[0]=0xF1; + + MCUSR=0; + USI_TWI_Master_Initialise(); + + initSHT2x(); + _delay_ms(10); + LPS225HB_Init(); + gcontrol=1; + sei(); + while(1) { + + if (gcontrol) { + wdcounter=3; + + } + + if (wdcounter>2) { + getSHT2xHumTemp(&temperatureC,&humidityRH); + double RH=calibr_hum(temperatureC,-0.2,humidityRH)*10.0; + double TC =temperatureC *10.0-2; + + if (testSW()) { + DS2438_2_VAD=RH; + DS2438_2_TEMP=(double)TC*25.6; + //am2302_temp=am2302_temp-20; + config_info2[5]=12; + + }else{ + + double hhum=(1.0546-0.000216*TC)*(RH); + //am2302_hum=0.318*hhum +76.0; + DS2438_2_VAD=0.31*hhum +80; + DS2438_2_TEMP=TC*25.6; + //am2302_temp=am2302_temp-20; + config_info2[5]=7; + } + wdcounter=0; + } + + if ((gcontrol&1)==1) { + + LPS225HB_Readi(&t,&P); + P=P-(uint32_t)700*4096; + P=(double)P/819.2; + uint16_t w=P; + uint8_t t8=w>>4; + uint8_t af=0; + if (t8>pack1.TH) af=1; + if (t8<=pack1.TL) af=1; + cli(); + pack1.temp=w; + //pack.temp++; + alarmflag=af; + sei(); + gcontrol=0; + EXTERN_SLEEP(); + } + if (gcontrol) { + gcontrol=0; + + } + + OWST_MAIN_END + } + + +} \ No newline at end of file diff --git a/DS18B20_LPS225HB_DS2438_SHT/DS18B20_LPS225HB_DS2438_SHT.atsln b/DS18B20_LPS225HB_DS2438_SHT/DS18B20_LPS225HB_DS2438_SHT.atsln new file mode 100644 index 0000000..467ee29 --- /dev/null +++ b/DS18B20_LPS225HB_DS2438_SHT/DS18B20_LPS225HB_DS2438_SHT.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS18B20_LPS225HB_DS2438_SHT", "DS18B20_LPS225HB_DS2438_SHT.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.ActiveCfg = Debug|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.Build.0 = Debug|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.ActiveCfg = Release|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS18B20_LPS225HB_DS2438_SHT/DS18B20_LPS225HB_DS2438_SHT.cproj b/DS18B20_LPS225HB_DS2438_SHT/DS18B20_LPS225HB_DS2438_SHT.cproj new file mode 100644 index 0000000..35eade1 --- /dev/null +++ b/DS18B20_LPS225HB_DS2438_SHT/DS18B20_LPS225HB_DS2438_SHT.cproj @@ -0,0 +1,175 @@ + + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + {7a5672fe-8226-4158-b931-e1f36b9a8858} + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS18B20_DS2438 + DS18B20_LPS225HB_DS2438_SHT + DS18B20_DS2438 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + debugWIRE + + + + + debugWIRE + + com.atmel.avrdbg.tool.simulator + + + Simulator + + + J41800000789 + 0x1E930C + + + + + debugWIRE + + custom + + + Custom Programming Tool + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + + + + + + compile + calibr.c + + + compile + LPS225HB.c + + + compile + SHT2xV2.c + + + compile + USI_TWI_Master.c + + + compile + OWDS18B20_DS2438.S + + + compile + + + + \ No newline at end of file diff --git a/DS18B20_MAX44009/DS18B20_MAX44009.c b/DS18B20_MAX44009/DS18B20_MAX44009.c index 4aeb0e8..1ebcf7c 100644 --- a/DS18B20_MAX44009/DS18B20_MAX44009.c +++ b/DS18B20_MAX44009/DS18B20_MAX44009.c @@ -40,25 +40,13 @@ #include #include "../common/I2C/USI_TWI_Master.h" #include "../common/I2C/MAX44009.h" +#include "../common/owSlave_tools.h" - -extern void OWINIT(); - -extern void EXTERN_SLEEP(); - - +OWST_EXTERN_VARS +//-D__4MHZ__ uint8_t owid[8]={0x28, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x77, 0x6B};/**/ uint8_t config_info[26]={0x03,0x04, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; -#if (owid>128) -#error "Variable not correct" -#endif - -extern uint8_t mode; -extern uint8_t gcontrol; -extern uint8_t reset_indicator; -extern uint8_t alarmflag; - uint8_t max_adr=0; @@ -84,7 +72,7 @@ volatile pack_t pack; int main(void){ - PRR|=(1<1 - - - - - - - - - + + + + + + + + + com.atmel.avrdbg.tool.atmelice @@ -46,7 +46,7 @@ debugWIRE com.atmel.avrdbg.tool.atmelice - J41800000779 + J41800000789 Atmel-ICE debugWIRE @@ -63,45 +63,47 @@ Simulator + J41800000789 + 0x1E930C - -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" - True - True - True - True - False - True - True - - - DEBUG - - - - - %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include - - - Optimize (-O1) - True - True - Default (-g2) - True - - - libm - - - - - %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include - - - Default (-Wa,-g) - + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Default (-Wa,-g) + diff --git a/DS18B20_MAX44009_DS2438_SHT/DS18B20_DS2438.c b/DS18B20_MAX44009_DS2438_SHT/DS18B20_DS2438.c index 4e8d28b..efd0454 100644 --- a/DS18B20_MAX44009_DS2438_SHT/DS18B20_DS2438.c +++ b/DS18B20_MAX44009_DS2438_SHT/DS18B20_DS2438.c @@ -40,69 +40,21 @@ #include #include "../common/I2C/USI_TWI_Master.h" #include "../common/I2C/MAX44009.h" -#include "../common/I2C/SHT2x.h" +#include "../common/I2C/SHT2xV2.h" +#include "../common/calibr.h" +#include "../common/owSlave_tools.h" -extern void OWINIT(); -extern void EXTERN_SLEEP(); - +OWST_EXTERN_VARS uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x18};/**/ uint8_t owid2[8]={0x26, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x67};/**/ uint8_t config_info1[26]={0x03,0x04, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0x00,0x00, 0x02,7,0x00,7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; - - -#if (owid>128) -#error "Variable not correct" -#endif - -extern uint8_t mode; -extern uint8_t gcontrol; -extern uint8_t reset_indicator; -extern uint8_t alarmflag; -volatile uint8_t wdcounter=5; - - -#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) -ISR(WATCHDOG_vect) { -#else -ISR(WDT_vect) { -#endif - //sleep_disable(); // Disable Sleep on Wakeup - wdcounter++; - if (reset_indicator==1) reset_indicator++; - else if (reset_indicator==2) mode=0; -/* if (timeout==2) { - DIS_TIMER; - EN_OWINT; - mode=OWM_SLEEP; - } - timeout++;*/ - //sleep_enable(); // Enable Sleep Mode - -} - -int testSW(void) { - uint8_t r; - DDRB&=~(1<2) { - //PORTB|=(1<1000) humidityRH=1000; - if (testSW()) { - am2302_hum= humidityRH*10.0; - am2302_temp=temperatureC*25.6; - // - config_info2[5]=8; - - }else{ - - double hhum=(1.0546-0.000216*temperatureC)*(humidityRH); - //am2302_hum=0.318*hhum +76.0; - am2302_hum=0.31*hhum +80; - am2302_temp=temperatureC*25.6; - //am2302_temp=am2302_temp-45; - config_info2[5]=7; + getSHT2xHumTemp(&temperatureC,&humidityRH); + double RH=calibr_hum(temperatureC,-0.2,humidityRH)*10.0; + double TC =temperatureC *10.0-2; + + if (testSW()) { + DS2438_2_VAD=RH; + DS2438_2_TEMP=TC*25.6; + //am2302_temp=am2302_temp-20; + config_info2[5]=12; + DS2438_2_VDD=0x01F4; + + }else{ + + double hhum=(1.0546-0.000216*TC)*(RH); + //am2302_hum=0.318*hhum +76.0; + DS2438_2_VAD=0.31*hhum +80; + DS2438_2_TEMP=TC*25.6; + //am2302_temp=am2302_temp-20; + config_info2[5]=7; + DS2438_2_VDD=0x01F4; } wdcounter=0; } @@ -258,24 +186,7 @@ int main(void){ sei(); EXTERN_SLEEP(); } - - - -#if defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) - if (((TIMSK & (1< - + compile - SHT2x.c + calibr.c compile MAX44009.c + + compile + SHT2xV2.c + compile USI_TWI_Master.c diff --git a/DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_DS18B20.c b/DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_DS18B20.c new file mode 100644 index 0000000..562a5f8 --- /dev/null +++ b/DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_DS18B20.c @@ -0,0 +1,168 @@ +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/USI_TWI_Master.h" +#include "../common/I2C/SHT2xV2.h" +#include "../common/I2C/BMP280.h" +#include "../common/calibr.h" +#include "../common/owSlave_tools.h" + +OWST_EXTERN_VARS + + +uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x26, 0x05, 0x35};/**/ +uint8_t owid2[8]={0x28, 0xA4, 0xD9, 0x84, 0x00, 0x26, 0x05, 0xB0};/**/ + +uint8_t config_info1[26]={0x01,0x01, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +uint8_t config_info2[26]={0x04,0x01, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,7,0x00,0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + + + +OWST_WDT_ISR + +typedef union { + volatile uint8_t bytes[8]; + struct { + uint16_t temp; //0 + uint8_t TH; //2 + uint8_t TL; //3 + uint8_t config; //4 + uint8_t rrFF; //5 + uint8_t rr00; //6 + uint8_t rr10; //7 + }; +} pack1_t; +volatile pack1_t pack1,pack2; + + + + + + + + + +OWST_TESTSW + + +uint8_t userRegister[1]; +int16_t sRH,sT; +double temperatureC,humidityRH; +volatile double l; + uint32_t P; + int32_t t; + +int main(void){ + OWST_INIT_USI_ON + + pack1.temp=0x0550; + pack1.config=0x7F; + pack1.TH=75; + pack1.TL=70; + pack1.rrFF=0xFF; + pack1.rr00=0; + pack1.rr10=0x10; + PORTA=0xFF; + PORTB=0xFF; + OWINIT(); + OWST_EN_PULLUP + + OWST_WDR_CONFIG8 + + if (testSW()) { + config_info2[5]=12; + }else{ + config_info2[5]=7; + } + + MCUSR=0; + USI_TWI_Master_Initialise(); + + initSHT2x(); + _delay_ms(10); + gcontrol=1; + sei(); + while(1) { + + if (gcontrol) { + wdcounter=3; + + } + + if (wdcounter>2) { + getSHT2xHumTemp(&temperatureC,&humidityRH); + double RH=calibr_hum(temperatureC,-0.2,humidityRH)*16.0; + double TC =(temperatureC+0.2) *16.0; + uint16_t w1=TC; + uint8_t t81=w1>>4; + uint8_t af1=0; + if (t81>pack1.TH) af1=1; + if (t81<=pack1.TL) af1=1; + + cli(); + pack1.temp=w1; + //pack.temp++; + alarmflag=af1; + sei(); + + + uint16_t w2=RH; + + cli(); + pack2.temp=w2; + sei(); + //pack.temp++; + gcontrol=0; + + + + wdcounter=0; + } + + if (gcontrol) { + gcontrol=0; + EXTERN_SLEEP(); + + } + + OWST_MAIN_END + } + + +} \ No newline at end of file diff --git a/DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_SHT_DS18B20_SHT.atsln b/DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_SHT_DS18B20_SHT.atsln new file mode 100644 index 0000000..4a55022 --- /dev/null +++ b/DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_SHT_DS18B20_SHT.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS18B20_SHT_DS18B20_SHT", "DS18B20_SHT_DS18B20_SHT.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.ActiveCfg = Debug|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.Build.0 = Debug|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.ActiveCfg = Release|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_SHT_DS18B20_SHT.cproj b/DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_SHT_DS18B20_SHT.cproj new file mode 100644 index 0000000..9ed54df --- /dev/null +++ b/DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_SHT_DS18B20_SHT.cproj @@ -0,0 +1,171 @@ + + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + {7a5672fe-8226-4158-b931-e1f36b9a8858} + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS18B20_DS2438 + DS18B20_SHT_DS18B20_SHT + DS18B20_DS2438 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + debugWIRE + + + + + debugWIRE + + com.atmel.avrdbg.tool.simulator + + + Simulator + + + J41800000789 + 0x1E930C + + + + + debugWIRE + + custom + + + Custom Programming Tool + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + + + + + + compile + calibr.c + + + compile + SHT2xV2.c + + + compile + USI_TWI_Master.c + + + compile + OWDS18B20_DS18B20.S + + + compile + + + + \ No newline at end of file diff --git a/DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_DS18B20.c b/DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_DS18B20.c new file mode 100644 index 0000000..cc06287 --- /dev/null +++ b/DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_DS18B20.c @@ -0,0 +1,167 @@ +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/USI_TWI_Master.h" +#include "../common/I2C/SHT3x.h" +#include "../common/calibr.h" +#include "../common/owSlave_tools.h" + +OWST_EXTERN_VARS + + +uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x26, 0x05, 0x35};/**/ +uint8_t owid2[8]={0x28, 0xA4, 0xD9, 0x84, 0x00, 0x26, 0x05, 0xB0};/**/ + +uint8_t config_info1[26]={0x01,0x01, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +uint8_t config_info2[26]={0x04,0x01, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,7,0x00,0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + + + +OWST_WDT_ISR + +typedef union { + volatile uint8_t bytes[8]; + struct { + uint16_t temp; //0 + uint8_t TH; //2 + uint8_t TL; //3 + uint8_t config; //4 + uint8_t rrFF; //5 + uint8_t rr00; //6 + uint8_t rr10; //7 + }; +} pack1_t; +volatile pack1_t pack1,pack2; + + + + + + + + + +OWST_TESTSW + + +uint8_t userRegister[1]; +int16_t sRH,sT; +double temperatureC,humidityRH; +volatile double l; + uint32_t P; + int32_t t; + +int main(void){ + OWST_INIT_USI_ON + + pack1.temp=0x0550; + pack1.config=0x7F; + pack1.TH=75; + pack1.TL=70; + pack1.rrFF=0xFF; + pack1.rr00=0; + pack1.rr10=0x10; + PORTA=0xFF; + PORTB=0xFF; + OWINIT(); + OWST_EN_PULLUP + + OWST_WDR_CONFIG8 + + if (testSW()) { + config_info2[5]=12; + }else{ + config_info2[5]=7; + } + + MCUSR=0; + USI_TWI_Master_Initialise(); + + initSHT3x(0); + _delay_ms(10); + gcontrol=1; + sei(); + while(1) { + + if (gcontrol) { + wdcounter=3; + + } + + if (wdcounter>2) { + getSHT3xHumTemp(0,&temperatureC,&humidityRH); + double RH=calibr_hum(temperatureC,-0.2,humidityRH)*16.0; + double TC =(temperatureC+0.2) *16.0; + uint16_t w1=TC; + uint8_t t81=w1>>4; + uint8_t af1=0; + if (t81>pack1.TH) af1=1; + if (t81<=pack1.TL) af1=1; + + cli(); + pack1.temp=w1; + //pack.temp++; + alarmflag=af1; + sei(); + + + uint16_t w2=RH; + + cli(); + pack2.temp=w2; + sei(); + //pack.temp++; + gcontrol=0; + + + + wdcounter=0; + } + + if (gcontrol) { + gcontrol=0; + EXTERN_SLEEP(); + + } + + OWST_MAIN_END + } + + +} \ No newline at end of file diff --git a/DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_SHT_DS18B20_SHT.atsln b/DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_SHT_DS18B20_SHT.atsln new file mode 100644 index 0000000..4a55022 --- /dev/null +++ b/DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_SHT_DS18B20_SHT.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS18B20_SHT_DS18B20_SHT", "DS18B20_SHT_DS18B20_SHT.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.ActiveCfg = Debug|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.Build.0 = Debug|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.ActiveCfg = Release|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_SHT_DS18B20_SHT.cproj b/DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_SHT_DS18B20_SHT.cproj new file mode 100644 index 0000000..f4f3054 --- /dev/null +++ b/DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_SHT_DS18B20_SHT.cproj @@ -0,0 +1,171 @@ + + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + {7a5672fe-8226-4158-b931-e1f36b9a8858} + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS18B20_DS2438 + DS18B20_SHT_DS18B20_SHT + DS18B20_DS2438 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + debugWIRE + + + + + debugWIRE + + com.atmel.avrdbg.tool.simulator + + + Simulator + + + J41800000789 + 0x1E930C + + + + + debugWIRE + + custom + + + Custom Programming Tool + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + + + + + + compile + calibr.c + + + compile + SHT3x.c + + + compile + USI_TWI_Master.c + + + compile + OWDS18B20_DS18B20.S + + + compile + + + + \ No newline at end of file diff --git a/DS18B20_Thermocouble/DS18B20_TC.cproj b/DS18B20_Thermocouble/DS18B20_TC.cproj index a12b106..d3dd73d 100644 --- a/DS18B20_Thermocouble/DS18B20_TC.cproj +++ b/DS18B20_Thermocouble/DS18B20_TC.cproj @@ -34,7 +34,7 @@ - + @@ -46,90 +46,92 @@ debugWIRE com.atmel.avrdbg.tool.atmelice - J41800000779 + J41800000789 Atmel-ICE debugWIRE + J41800000789 + 0x1E930C - -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" - True - True - True - True - False - True - True - - - DEBUG - - - - - %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include - - - Optimize (-O1) - True - True - Default (-g2) - True - - - libm - - - - - %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include - - - Default (-Wa,-g) - + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Default (-Wa,-g) + - -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" - True - True - True - True - False - True - True - - - DEBUG - - - - - %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include - - - Optimize (-O1) - True - True - Default (-g2) - True - - - libm - - - - - %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include - - - Default (-Wa,-g) - + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Default (-Wa,-g) + diff --git a/DS18B20_Thermocouble_DS2438_SHT/DS18B20_DS2438.c b/DS18B20_Thermocouble_DS2438_SHT/DS18B20_DS2438.c index 4927b99..8ffaa53 100644 --- a/DS18B20_Thermocouble_DS2438_SHT/DS18B20_DS2438.c +++ b/DS18B20_Thermocouble_DS2438_SHT/DS18B20_DS2438.c @@ -39,17 +39,25 @@ #include #include #include "../common/I2C/USI_TWI_Master.h" -#include "../common/I2C/SHT2x.h" +#include "../common/I2C/SHT2xV2.h" +#include "../common/owSlave_tools.h" +OWST_EXTERN_VARS -extern void OWINIT(); -extern void EXTERN_SLEEP(); +//#define K_Type +#define J_Type +#ifdef K_Type //const float k_rs[54] PROGMEM ={0.000000,24.125000,48.585366,72.731707,96.829268,121.097561,145.700000,170.600000,195.650000,220.625000,245.365854,269.853659,294.119048,318.195122,342.166667,366.000000,389.761905,413.428571,437.023810,460.558140,484.047619,507.511628,530.976190,554.418605,577.883721,601.395349,624.952381,648.571429,672.285714,696.073171,719.976190,744.000000,768.146341,792.439024,816.853659,841.414634,866.125000,890.975000,916.000000,941.179487,966.525000,992.025641,1017.717949,1043.589744,1069.657895,1095.945946,1122.432432,1149.184211,1176.189189,1203.472222,1231.083333,1259.000000,1287.285714,1315.941176}; const float k_rs[61] PROGMEM ={ -212.538462, -166.260870, -124.892857, -97.562500, -66.888889, -34.157895, 0.000000, 24.125000, 48.585366, 72.731707, 96.829268, 121.097561, 145.700000, 170.600000, 195.650000, 220.625000, 245.365854, 269.853659, 294.119048, 318.192771, 342.166667, 366.000000, 389.761905, 413.428571, 437.023810, 460.558140, 484.047619, 507.511628, 530.976190, 554.418605, 577.883721, 601.395349, 624.952381, 648.571429, 672.285714, 696.073171, 719.976190, 744.000000, 768.146341, 792.439024, 816.853659, 841.414634, 866.125000, 890.975000, 916.000000, 941.179487, 966.525000, 992.025641, 1017.717949, 1043.589744, 1069.657895, 1095.945946, 1122.432432, 1149.173333, 1176.189189, 1203.472222, 1231.083333, 1259.000000, 1287.285714, 1315.941176, 1344.941176}; #define k_ofs 6 +#endif +#ifdef J_Type +#define k_ofs 0 +//J-Type +const float k_rs[70] PROGMEM ={0, 18.302913, 34.830476, 50.783019, 70.653704, 90.505455, 110.341818, 130.165455, 149.163636, 160.791071, 180.596364, 200.398214, 220.200000, 240.000000, 250.882883, 270.603636, 290.409091, 310.216364, 330.025455, 342.472727, 360.649091, 380.461818, 400.275000, 420.087273, 435.275676, 450.703636, 470.503636, 490.298214, 510.082456, 523.486726, 540.621053, 560.370175, 580.105172, 591.979487, 610.527119, 630.213559, 644.601653, 660.534426, 680.168852, 690.787097, 710.391935, 729.123810, 740.559375, 760.126562, 770.684615, 790.235385, 800.782812, 820.331250, 834.681250, 850.446032, 870.017460, 880.600000, 900.196774, 911.099187, 930.432787, 950.073333, 960.728333, 980.396667, 1000.078333, 1010.772881, 1030.475862, 1050.187931, 1065.717241, 1080.631034, 1100.358621, 1120.089655, 1131.840000,1150.556897, 1170.294737, 1190.035088}; +#endif -//const float j_rs[70] PROGMEM ={0, 18.302913, 34.830476, 50.783019, 70.653704, 90.505455, 110.341818, 130.165455, 149.163636, 160.791071, 180.596364, 200.398214, 220.200000, 240.000000, 250.882883, 270.603636, 290.409091, 310.216364, 330.025455, 342.472727, 360.649091, 380.461818, 400.275000, 420.087273, 435.275676, 450.703636, 470.503636, 490.298214, 510.082456, 523.486726, 540.621053, 560.370175, 580.105172, 591.979487, 610.527119, 630.213559, 644.601653, 660.534426, 680.168852, 690.787097, 710.391935, 729.123810, 740.559375, 760.126562, 770.684615, 790.235385, 800.782812, 820.331250, 834.681250, 850.446032, 870.017460, 880.600000, 900.196774, 911.099187, 930.432787, 950.073333, 960.728333, 980.396667, 1000.078333, 1010.772881, 1030.475862, 1050.187931, 1065.717241, 1080.631034, 1100.358621, 1120.089655, 1131.840000,1150.556897, 1170.294737, 1190.035088}; double gettemp_rs(double V) { uint8_t iv=(uint8_t)(V+k_ofs); float t0=pgm_read_float(&(k_rs[iv])); @@ -66,55 +74,8 @@ uint8_t owid2[8]={0x26, 0xA7, 0xD9, 0x84, 0x00, 0x00, 0x03, 0x20};/**/ uint8_t config_info1[26]={0x01,0x02 ,0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0x00,0x00, 0x02,7,0x00,7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; -#if (owid>128) -#error "Variable not correct" -#endif - -extern uint8_t mode; -extern uint8_t gcontrol; -extern uint8_t reset_indicator; -extern uint8_t alarmflag; -volatile uint8_t wdcounter=5; - - -#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) -ISR(WATCHDOG_vect) { -#else -ISR(WDT_vect) { -#endif - //sleep_disable(); // Disable Sleep on Wakeup - wdcounter++; - if (reset_indicator==1) reset_indicator++; - else if (reset_indicator==2) mode=0; -/* if (timeout==2) { - DIS_TIMER; - EN_OWINT; - mode=OWM_SLEEP; - } - timeout++;*/ - //sleep_enable(); // Enable Sleep Mode - -} - -int testSW(void) { - uint8_t r; - DDRB&=~(1<0) { if (par==0) { - //PORTB|=(1<1000) humidityRH=1000; + getSHT2xHumTemp(&temperatureC,&humidityRH); + double RH=humidityRH*10.0; + TC =temperatureC *10.0; + if (testSW()) { - am2302_hum= humidityRH*10.0; - am2302_temp=temperatureC*25.6; - // - config_info2[5]=8; - }else{ - double hhum=(1.0546-0.000216*temperatureC)*(humidityRH); - //am2302_hum=0.318*hhum +76.0; - am2302_hum=0.31*hhum +80; - am2302_temp=temperatureC*25.6; - //am2302_temp=am2302_temp-45; + DS2438_2_VAD=RH; + DS2438_2_TEMP=TC*25.6; + + config_info2[5]=12; + + }else{ + + double hhum=(1.0546-0.000216*TC)*(RH); + DS2438_2_VAD=0.31*hhum +80; + DS2438_2_TEMP=TC*25.6; config_info2[5]=7; } } + DS2438_2_VDD=0x01F4; ares[par]=ADmess(); par++; if (par>15) par=0; wdcounter=0; } - if (gcontrol==1) { + if ((gcontrol&1)==1) { gcontrol=0; sum=0; for(uint8_t i=0;i<16;i++) { sum+=ares[i]; } - V=sum/20.0/1024.0*1.12*1000.0/16.0;//Spannung in mV + V=sum/20.0/1024.0*1.18*1000.0/16.0;//Spannung in mV //V=sum/20.0/1024.0*1.01*1000.0/16.0; int16_t htemp; ktemp=gettemp_rs(V); //htemp=(ktemp*16)/10; - htemp=(ktemp*16+temperatureC*1.6)/10; + htemp=(ktemp*16+TC*1.6)/10; int16_t w=htemp; int8_t t8=w>>4; diff --git a/DS18B20_Thermocouble_DS2438_SHT/DS18B20_Thermocouble_DS2438_SHT.atsln b/DS18B20_Thermocouble_DS2438_SHT/DS18B20_Thermocouble_DS2438_SHT.atsln index 2e0e72c..1dd9222 100644 --- a/DS18B20_Thermocouble_DS2438_SHT/DS18B20_Thermocouble_DS2438_SHT.atsln +++ b/DS18B20_Thermocouble_DS2438_SHT/DS18B20_Thermocouble_DS2438_SHT.atsln @@ -1,22 +1,22 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Atmel Studio Solution File, Format Version 11.00 -VisualStudioVersion = 14.0.23107.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS18B20_Thermocouble_DS2438_SHT", "DS18B20_Thermocouble_DS2438_SHT.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|AVR = Debug|AVR - Release|AVR = Release|AVR - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.ActiveCfg = Debug|AVR - {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.Build.0 = Debug|AVR - {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.ActiveCfg = Release|AVR - {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.Build.0 = Release|AVR - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS18B20_Thermocouble_DS2438_SHT", "DS18B20_Thermocouble_DS2438_SHT.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.ActiveCfg = Debug|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.Build.0 = Debug|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.ActiveCfg = Release|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS18B20_Thermocouble_DS2438_SHT/DS18B20_Thermocouble_DS2438_SHT.cproj b/DS18B20_Thermocouble_DS2438_SHT/DS18B20_Thermocouble_DS2438_SHT.cproj index 738bf15..752c526 100644 --- a/DS18B20_Thermocouble_DS2438_SHT/DS18B20_Thermocouble_DS2438_SHT.cproj +++ b/DS18B20_Thermocouble_DS2438_SHT/DS18B20_Thermocouble_DS2438_SHT.cproj @@ -34,7 +34,7 @@ - + @@ -63,6 +63,8 @@ Simulator + 0 + @@ -135,9 +137,9 @@ - + compile - SHT2x.c + SHT2xV2.c compile diff --git a/DS18B20_VOC_DS2438_SHT direct/DS18B20_DS2438.c b/DS18B20_VOC_DS2438_SHT direct/DS18B20_DS2438.c index 5b3461c..2522a0e 100644 --- a/DS18B20_VOC_DS2438_SHT direct/DS18B20_DS2438.c +++ b/DS18B20_VOC_DS2438_SHT direct/DS18B20_DS2438.c @@ -42,9 +42,9 @@ #include "../common/I2C/USI_TWI_Master.h" #include "../common/I2C/SHT2xV2.h" #include "../common/calibr.h" +#include "../common/owSlave_tools.h" -extern void OWINIT(void); -extern void EXTERN_SLEEP(void); +OWST_EXTERN_VARS @@ -58,24 +58,11 @@ volatile uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 11,0x08, 0x0 #error "Variable not correct" #endif -extern uint8_t mode; -extern uint8_t gcontrol; -extern uint8_t reset_indicator; -extern uint8_t alarmflag; -volatile uint8_t wdcounter=1; extern uint8_t cpsp; +OWST_WDT_ISR -#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) -ISR(WATCHDOG_vect) { - #else - ISR(WDT_vect) { - #endif - wdcounter++; - if (reset_indicator==1) reset_indicator++; - else if (reset_indicator==2) mode=0; -} typedef union { @@ -155,12 +142,13 @@ ISR(WATCHDOG_vect) { - volatile int16_t am2302_temp; - volatile uint16_t am2302_hum; + volatile int16_t DS2438_2_TEMP; + volatile uint16_t DS2438_2_VAD; + volatile uint16_t DS2438_2_VDD=0x01F4; + + OWST_TESTSW - uint8_t userRegister[1]; - int16_t sRH,sT; double temperatureC,humidityRH,hhum; volatile double l; @@ -183,25 +171,6 @@ ISR(WATCHDOG_vect) { double la[4]; uint8_t lainit=1; - int testSW(void) { - uint8_t r; - DDRB&=~(1<>4; uint8_t af=0; @@ -469,27 +417,13 @@ ISR(WATCHDOG_vect) { sei(); EXTERN_SLEEP(); } - if ((gcontrol==2)||(gcontrol==3)) { + if (gcontrol) { gcontrol=0; } - #if defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) - if (((TIMSK & (1< + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + {7a5672fe-8226-4158-b931-e1f36b9a8858} + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS18B20_DS2438 + DS18B20_VOC_DS2438_SHT + DS18B20_DS2438 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + debugWIRE + + + + + + + + com.atmel.avrdbg.tool.simulator + + + Simulator + + + J41800000789 + 0x1E930C + 0 + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + True + + + libm + + + Default (-Wa,-g) + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + + + + + + compile + calibr.c + + + compile + SHT2xV2.c + + + compile + USI_TWI_Master.c + + + compile + OWDS18B20_DS2438.S + + + compile + + + + \ No newline at end of file diff --git a/DS18B20_VOC_DS2438_SHT/DS18B20_DS2438.c b/DS18B20_VOC_DS2438_SHT/DS18B20_DS2438.c index 09b528d..03d0e68 100644 --- a/DS18B20_VOC_DS2438_SHT/DS18B20_DS2438.c +++ b/DS18B20_VOC_DS2438_SHT/DS18B20_DS2438.c @@ -456,7 +456,7 @@ int main(void){ } - if (gcontrol==1) { + if ((gcontrol&1)==1) { uint16_t w=l; uint8_t t8=w>>4; uint8_t af=0; diff --git a/DS2408/DS2408.atsln b/DS2408/DS2408.atsln new file mode 100644 index 0000000..a06ac81 --- /dev/null +++ b/DS2408/DS2408.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2408", "DS2408.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2408/DS2408.c b/DS2408/DS2408.c new file mode 100644 index 0000000..fa738a4 --- /dev/null +++ b/DS2408/DS2408.c @@ -0,0 +1,216 @@ + +// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/TWI_Master.h" +#include "../common/owSlave_tools.h" +#include "../common/I2C/SHT3x.h" +#include "../common/calibr.h" + + +#include + +extern void OWINIT(); +extern void EXTERN_SLEEP(); +extern uint8_t stat_to_sample; + +uint8_t owid[8]={0x29, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x01, 0x73};/**/ +uint8_t config_info[26]={0x06,0x09,0x06,0x09,0x06,0x09,0x06,0x09,0x02,20,20,20,20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + +OWST_EXTERN_VARS + +OWST_WDT_ISR + +typedef union { + volatile uint8_t bytes[0x20]; + struct { + uint8_t PIO_Logic_State; // 0088h + uint8_t PIO_Output_Latch_State; + uint8_t PIO_Activity_Latch_State; + uint8_t Conditional_Search_Channel_Selection_Mask; + uint8_t Conditional_Search_Channel_Polarity_Selection; + uint8_t Status; //008D + uint8_t FF1; + uint8_t FF2; + + }; +} pack_t; +volatile pack_t pack; + +uint8_t values[10]; +uint8_t ap=1; + +uint8_t crc8() { + uint8_t lscrc=0x0; + for(uint8_t i=0;i<5;i++) { + uint8_t v=values[i]; + //if (v==0) v=0xFF; + uint8_t bit=1; + uint8_t lb; + for(uint8_t j=0;j<8;j++) { + if ((v&bit)==bit) lb=1; else lb=0; + if ((lscrc&1)!=lb) lscrc=(lscrc>>1)^0x8c; else lscrc=(lscrc>>1); + bit=bit*2; + + + } + } + return lscrc; +} + +//Umstellung + +//rh=(T-25)*(0,01+0,00008*x)-2,0468+0,0367*x-0,0000015955*x*x +//d1 for 3V +#define d1 -39.7 +#define d2 0.01 +inline uint16_t calcSHT75_T(double real_t) { + return (real_t-d1)/d2; +} + +inline uint16_t calcSHT75RH_lin(double real_RHlin) { + return 11501.1-0.280297*sqrt(1667284153.0-7977500.0*real_RHlin); +} + +inline double calcSHT75H_tcorr(double real_t,double real_RHtrue) { + return real_RHtrue-(real_t-25)*(0.01+0.00008*calcSHT75RH_lin(real_RHtrue)); + +} + + +double T=20.0; +double RH=60; + +int main(void){ + OWST_INIT_USI_ON; + pack.FF1=0xFF; + pack.FF2=0xFF; + //0x0E 0x19 0x48 0x00 + if (RH<8) RH=8; + uint16_t lt=calcSHT75_T(T); + double lfc=calcSHT75H_tcorr(T,RH); + uint16_t lf=calcSHT75RH_lin(lfc); + values[0]=0x00; + values[1]=lt&0xFF; if (values[1]==0) values[1]=1; + values[2]=lt>>8; if (values[2]==0) values[2]=1; + values[3]=lf&0xFF; if (values[3]==0) values[3]=1; + values[4]=lf>>8; if (values[4]==0) values[4]=1; + values[5]=0x5D; + values[1]=8; + values[2]=26; + values[3]=0; + values[4]=5; + values[5]=0x5D; + values[6]=0x00; + values[7]=0x00; + values[5]=crc8(); + OWINIT(); + + TWI_Master_Initialise(); + initSHT3x(0); + _delay_ms(100); + + + getSHT3xHumTemp(0,&T,&RH); + OWST_WDR_CONFIG8; + sei(); + stat_to_sample=0x55; + while (1) { + //stat_to_sample=0; + if (reset_indicator) { + // ap=0; + // stat_to_sample=0; + // reset_indicator=0; + } + if (wdcounter>3) { + + wdcounter=0; + RH=RH+0.2; + getSHT3xHumTemp(0,&T,&RH); + lt=calcSHT75_T(T); + lfc=calcSHT75H_tcorr(T,RH); + lf=calcSHT75RH_lin(lfc); + values[0]=0x00; + values[1]=lt&0xFF; if (values[1]==0) values[1]=1; + values[2]=lt>>8; if (values[2]==0) values[2]=1; + values[3]=lf&0xFF; if (values[3]==0) values[3]=1; + values[4]=lf>>8; if (values[4]==0) values[4]=1; + values[1]=8; + values[2]=26; + values[3]=0; + values[4]=5; + values[5]=0x5D; + values[5]=crc8(); + } + pack.Status|=0x80; + if (gcontrol&1) { + uint8_t bb=1; + for(uint8_t i=0;i<8;i++) { + if ((pack.PIO_Logic_State&bb)!=(pack.PIO_Output_Latch_State&bb)) pack.PIO_Activity_Latch_State|=bb; + bb=bb*2; + } + pack.PIO_Logic_State=pack.PIO_Output_Latch_State; + gcontrol&=~0x01; + } + if (gcontrol&2) { + pack.PIO_Activity_Latch_State=0; + gcontrol&=~0x02; + } + if (gcontrol&4) { + stat_to_sample=values[ap]; + ap++; + if (ap>5) { + ap=0; + } + gcontrol&=~0x04; + } + if (gcontrol&8) { + ap=1; + stat_to_sample=values[ap]; + ap++; + //if (ap>5) ap=1; + gcontrol&=~0x08; + } + + OWST_MAIN_END + } + + + +} diff --git a/DS2408/DS2408.cproj b/DS2408/DS2408.cproj new file mode 100644 index 0000000..e840c97 --- /dev/null +++ b/DS2408/DS2408.cproj @@ -0,0 +1,183 @@ + + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS2450 + DS2408 + DS2450 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + debugWIRE + J41800000789 + 0x1E930C + + + + 125000 + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + 125000 + 0 + + + + + + ISP + + com.atmel.avrdbg.tool.simulator + + + Simulator + + + + + + ISP + + custom + + + Custom Programming Tool + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Default (-Wa,-g) + + + + + + compile + calibr.c + + + compile + SHT3x.c + + + compile + TWI_Master.c + + + compile + OWDS2408.S + + + compile + + + + \ No newline at end of file diff --git a/DS2413_DS2413/DS2413_DS2413.atsln b/DS2413_DS2413/DS2413_DS2413.atsln new file mode 100644 index 0000000..b201cf3 --- /dev/null +++ b/DS2413_DS2413/DS2413_DS2413.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2413_DS2413", "DS2413_DS2413.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.ActiveCfg = Debug|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.Build.0 = Debug|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.ActiveCfg = Release|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2413_DS2413/DS2413_DS2413.c b/DS2413_DS2413/DS2413_DS2413.c new file mode 100644 index 0000000..75a63a9 --- /dev/null +++ b/DS2413_DS2413/DS2413_DS2413.c @@ -0,0 +1,209 @@ +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +//!!!!!Max Program size 7551 Byte +#define _CPULLUP_ +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/owSlave_tools.h" + + +//#define FHEM_PLATINE +#define W1DAQ +//#define JOE_M +volatile uint8_t owid1[8]={0x3A, 0x01, 0xDA, 0x84, 0x00, 0x00, 0x05, 0xA3};/**/ +volatile uint8_t owid2[8]={0x3A, 0x02, 0xDA, 0x84, 0x00, 0x00, 0x05, 0xFA};/**/ +uint8_t config_info1[26]={0,0,0,0,0,0,0,0,0x02,0,0,0,0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //+2 for CRC +uint8_t config_info2[26]={0,0,0,0,0,0,0,0,0x02,0,0,0,0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //+2 for CRC + +#if (owid>128) +#error "Variable not correct" +#endif + +OWST_EXTERN_VARS + +uint8_t pin_state1; +uint8_t pin_set1; +uint8_t pin_state2; +uint8_t pin_set2; + +OWST_WDT_ISR + + +#if defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) +#define PCINT_VECTOR PCINT0_vect +#define PIN_REG PINA +#define PIN_DDR DDRA + +#ifdef FHEM_PLATINE +#define PIN_PIOA1 (1< + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + {7a5672fe-8226-4158-b931-e1f36b9a8858} + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS18B20_DS2438 + DS2413_DS2413 + DS18B20_DS2438 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 0 + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + + + + 125000 + + ISP + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + ISP + + + + + + + + com.atmel.avrdbg.tool.simulator + + + Simulator + + + J41800000789 + 0x1E930C + 125000 + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + True + + + libm + + + Default (-Wa,-g) + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + + + + + + compile + OWDS2413_DS2413.S + + + compile + + + + \ No newline at end of file diff --git a/DS2423_DS2413/DS2423_DS2413.c b/DS2423_DS2413/DS2423_DS2413.c index a44b62b..bac5365 100644 --- a/DS2423_DS2413/DS2423_DS2413.c +++ b/DS2423_DS2413/DS2423_DS2413.c @@ -42,7 +42,9 @@ extern void OWINIT(void); extern void EXTERN_SLEEP(void); -#define FHEM_PLATINE +//#define FHEM_PLATINE +//#define JOE_M +#define W1DAQ volatile uint8_t owid1[8]={0x1D, 0x1D, 0xDA, 0x84, 0x00, 0x00, 0x05, 0xD9};/**/ volatile uint8_t owid2[8]={0x3A, 0x3A, 0xDA, 0x84, 0x00, 0x00, 0x05, 0xB6};/**/ @@ -102,12 +104,28 @@ volatile uint8_t changefromeeprom; //LEDS #define LPIN_CH2 (1<Ruecksetzen for (uint8_t i=2;i<4;i++) { diff --git a/DS2423_DS2423/DS2423_DS2423.c b/DS2423_DS2423/DS2423_DS2423.c index 1dbd395..9166850 100644 --- a/DS2423_DS2423/DS2423_DS2423.c +++ b/DS2423_DS2423/DS2423_DS2423.c @@ -43,7 +43,10 @@ extern void OWINIT(void); extern void EXTERN_SLEEP(void); + //#define FHEM_PLATINE +//#define JOE_M +#define W1DAQ volatile uint8_t owid1[8]={0x1D, 0x40, 0xDA, 0x84, 0x00, 0x00, 0x05, 0xBD};/**/ volatile uint8_t owid2[8]={0x1D, 0x41, 0xDA, 0x84, 0x00, 0x00, 0x05, 0x8A};/**/ @@ -102,7 +105,9 @@ volatile uint8_t changefromeeprom; //LEDS #define LPIN_CH2 (1< minus of Comperator falls down -> output of Comperator rises - #ifdef FHEM_PLATINE +#ifdef FHEM_PLATINE //Switch std AIN1 to A0 ADCSRA&=~(1<Ruecksetzen if ((counters1.c32[2]!=0)||(counters1.c32[3]!=0)||(counters2.c32[2]!=0)||(counters2.c32[3]!=0)) { counters1.c32[0]++; counters2.c32[0]++; for (uint8_t i=2;i<4;i++) { @@ -286,9 +310,20 @@ int main(void){ } } #endif + if (((TIMSK0 & (1< +#include +#include +#include +#include +#include + + +extern void OWINIT(); +extern void EXTERN_SLEEP(); + +uint8_t owid[8]={0x26, 0xA3, 0xD9, 0x84, 0xDD, 0xDD, 0x05, 0xF9};/**/ +uint8_t config_info[26]={0x01,0x06, 0x05,0x08, 0x06,0x08, 0x00,0x00, 0x02,0x09,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + + + +extern uint8_t mode; +extern uint8_t gcontrol; +extern uint8_t reset_indicator; +extern uint8_t alarmflag; + +volatile uint8_t wdcounter; + + +typedef union { + + volatile uint8_t bytes[64]; + struct { + uint8_t status; //1 + int16_t temp; //2 + uint16_t voltage; //4 + uint16_t current; //6 + uint8_t threshold; //8 + + uint8_t page1[8]; //9 + uint8_t page2[8]; //17 + uint8_t page3[8]; //25 + uint8_t page4[8]; //33 + uint8_t page5[8]; //41 + uint8_t page6[8]; //49 + uint8_t page7[8]; //57 + //uint8_t crc; //65 + }; +} pack_t; +volatile pack_t pack; + + +volatile int16_t am2302_temp; +volatile uint16_t am2302_hum; + + + +volatile uint8_t am2302_mode=0; +volatile uint8_t timeout=0; + + + + + + +uint8_t userRegister[1]; +int16_t sRH,sT; +volatile double temperatureC,humidityRH; +volatile double l; + +#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) +ISR(WATCHDOG_vect) { + #else +ISR(WDT_vect) { + #endif + wdcounter++; + if (reset_indicator==1) reset_indicator++; + else if (reset_indicator==2) mode=0; +} + +int testSW(void) { + uint8_t r; + DDRB&=~(1<=16) { + uint16_t sum=0; + for(uint8_t i=0;i<16;i++) { + ADCSRA|=(1< + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS2438_DHT22 + DS2438_ADC + DS2438_DHT22 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + J41800000789 + 0x1E930C + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + debugWIRE + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Default (-Wa,-g) + + + + + + compile + OWDS2438.S + + + compile + + + + \ No newline at end of file diff --git a/DS2438_ADC_DS2438_ADC/DS2438_ADC_DS2438_ADC.atsln b/DS2438_ADC_DS2438_ADC/DS2438_ADC_DS2438_ADC.atsln new file mode 100644 index 0000000..0427374 --- /dev/null +++ b/DS2438_ADC_DS2438_ADC/DS2438_ADC_DS2438_ADC.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2438_ADC_DS2438_ADC", "DS2438_ADC_DS2438_ADC.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.ActiveCfg = Debug|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.Build.0 = Debug|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.ActiveCfg = Release|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2438_ADC_DS2438_ADC/DS2438_ADC_DS2438_ADC.cproj b/DS2438_ADC_DS2438_ADC/DS2438_ADC_DS2438_ADC.cproj new file mode 100644 index 0000000..c3e44e3 --- /dev/null +++ b/DS2438_ADC_DS2438_ADC/DS2438_ADC_DS2438_ADC.cproj @@ -0,0 +1,145 @@ + + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + {7a5672fe-8226-4158-b931-e1f36b9a8858} + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS18B20_DS2438 + DS2438_ADC_DS2438_ADC + DS18B20_DS2438 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + + + + 125000 + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + debugWIRE + + + + + + + + com.atmel.avrdbg.tool.simulator + + + Simulator + + + J41800000789 + 0x1E930C + 125000 + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + True + + + libm + + + Default (-Wa,-g) + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + + + + + + compile + OWDS2438_DS2438.S + + + compile + + + + \ No newline at end of file diff --git a/DS2438_ADC_DS2438_ADC/DS2438_DS2438.c b/DS2438_ADC_DS2438_ADC/DS2438_DS2438.c new file mode 100644 index 0000000..b9a7040 --- /dev/null +++ b/DS2438_ADC_DS2438_ADC/DS2438_DS2438.c @@ -0,0 +1,241 @@ +// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +//!!!!!Max Program size 7551 Byte + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/owSlave_tools.h" + + +OWST_EXTERN_VARS +OWST_WDT_ISR + + +//#define W1DAQ +#define JOE_M +volatile uint8_t owid1[8]={0x26, 0x61, 0xDA, 0x84, 0x00, 0x00, 0x03, 0x43};/**/ +volatile uint8_t owid2[8]={0x26, 0x62, 0xDA, 0x84, 0x00, 0x00, 0x03, 0x1A};/**/ +volatile uint8_t config_info1[26]={6,6,6,0x08, 6,8, 0x00,0x00, 0x02,20,20,20,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +volatile uint8_t config_info2[26]={6,6, 6,0x08,6,8, 0,0, 0x02,20,20,20,0,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + +#if (owid>128) +#error "Variable not correct" +#endif + +#ifdef JOE_M +#define PIN_PIOA1 (1<2) { + + wdcounter=0; + ADMUX=OWST_ADCIN_REFINT; + _delay_us(100); + VCC=owst_ADC_runf(); + VCC=(1.079*65472.0)/VCC; + DS2438_2_VDD=VCC*100; + DS2438_1_VDD=VCC*100; + + if (testSW()) { + ADMUX= ADDIFF1; //ADC0 + ADC1 - Gain 1 + _delay_us(100); + VAD_A=owst_ADC_runf(); + if (VAD_A<3100) { + ADMUX= ADDIFF1G; //ADC0 + ADC1 - Gain 20 + _delay_us(100); + VAD_A=owst_ADC_runf(); + VAD_A=VCC/20.0*VAD_A/65472.0; + } else { + VAD_A=owst_ADC_OSS_runf(); + VAD_A=VCC*VAD_A/65472.0; + } + DS2438_1_VAD=VAD_A*100; + DS2438_1_TEMP=VAD_A*256; + + ADMUX= ADDIFF2; //ADC0 + ADC1 - Gain 1 + _delay_us(100); + VAD_B=owst_ADC_runf(); + if (VAD_B<3100) { + ADMUX= ADDIFF2G; //ADC0 + ADC1 - Gain 20 + _delay_us(100); + VAD_B=owst_ADC_runf(); + VAD_B=VCC/20.0*VAD_B/65472.0; + } else { + VAD_B=owst_ADC_OSS_runf(); + VAD_B=VCC*VAD_B/65472.0; + } + DS2438_2_VAD=VAD_B*100; + DS2438_2_TEMP=VAD_B*256; + + + + } else { + ADMUX=ADMA1; + _delay_us(100); + VAD_A=owst_ADC_OSS_runf(); + VAD_A=VCC*VAD_A/65472.0; + DS2438_1_TEMP=VAD_A*256; + + ADMUX=ADMB1; + _delay_us(100); + VAD_B=owst_ADC_OSS_runf(); + VAD_B=VCC*VAD_B/65472.0; + DS2438_1_VAD=VAD_B*100; + + ADMUX=ADMA2; + _delay_us(100); + VAD_C=owst_ADC_OSS_runf(); + VAD_C=VCC*VAD_C/65472.0; + DS2438_2_TEMP=VAD_C*256; + + ADMUX=ADMB2; + _delay_us(100); + VAD_D=owst_ADC_OSS_runf(); + VAD_D=VCC*VAD_D/65472.0; + DS2438_2_VAD=VAD_D*100; + } + + + + + } + + + OWST_MAIN_END + } + + +} diff --git a/DS2438_CDM7160/DS2438_CDM7160.atsln b/DS2438_CDM7160/DS2438_CDM7160.atsln new file mode 100644 index 0000000..6121562 --- /dev/null +++ b/DS2438_CDM7160/DS2438_CDM7160.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2438_CDM7160", "DS2438_CDM7160.cproj", "{91468D4F-8AE2-4C59-8A35-549C49E00934}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {91468D4F-8AE2-4C59-8A35-549C49E00934}.Debug|AVR.ActiveCfg = Debug|AVR + {91468D4F-8AE2-4C59-8A35-549C49E00934}.Debug|AVR.Build.0 = Debug|AVR + {91468D4F-8AE2-4C59-8A35-549C49E00934}.Release|AVR.ActiveCfg = Release|AVR + {91468D4F-8AE2-4C59-8A35-549C49E00934}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2438_CDM7160/DS2438_CDM7160.c b/DS2438_CDM7160/DS2438_CDM7160.c new file mode 100644 index 0000000..7fc2e0a --- /dev/null +++ b/DS2438_CDM7160/DS2438_CDM7160.c @@ -0,0 +1,180 @@ +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/USI_TWI_Master.h" +#include "../common/I2C/CDM7160.h" + +extern void OWINIT(); +extern void EXTERN_SLEEP(); + +uint8_t owid[8]={0x26, 0xA2, 0xD9, 0x88, 0x00, 0x00, 0x05, 0x04};/**/ +uint8_t config_info[26]={10,13, 0x05,0x08, 10,22, 0x00,0x00, 0x02,0x07,0x00,0x07,0x00,0x00,0x00,0x00, 0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + + +extern uint8_t mode; +extern uint8_t gcontrol; +extern uint8_t reset_indicator; +extern uint8_t alarmflag; + +volatile uint8_t wdcounter=5; + + +typedef union { + + volatile uint8_t bytes[64]; + struct { + uint8_t status; //1 + int16_t temp; //2 + uint16_t voltage; //4 + uint16_t current; //6 + uint8_t threshold; //8 + + uint8_t page1[8]; //9 + uint8_t page2[8]; //17 + uint8_t page3[8]; //25 + uint8_t page4[8]; //33 + uint8_t page5[8]; //41 + uint8_t page6[8]; //49 + uint8_t page7[8]; //57 + //uint8_t crc; //65 + }; +} pack_t; +volatile pack_t pack; + + + +volatile int16_t am2302_temp; +volatile uint16_t am2302_hum; + +uint8_t userRegister[1]; +double temperatureC,humidityRH; +volatile double l; + +#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) +ISR(WATCHDOG_vect) { +#else +ISR(WDT_vect) { +#endif + wdcounter++; + if (reset_indicator==1) reset_indicator++; + else if (reset_indicator==2) mode=0; + + +} + +int testSW(void) { + uint8_t r; + DDRB&=~(1<2) { + am2302_temp=CDM7160getCO2(); + am2302_hum=am2302_temp/10; + wdcounter=0; + } + + if (((TIMSK0 & (1< + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + {91468d4f-8ae2-4c59-8a35-549c49e00934} + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS2438_SHT2X + DS2438_CDM7160 + DS2438_SHT2X + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + debugWIRE + + J41800000789 + 0x1E930C + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + + + + + + compile + calibr.c + + + compile + CDM7160.c + + + compile + USI_TWI_Master.c + + + compile + OWDS2438.S + + + compile + + + + \ No newline at end of file diff --git a/DS2438_CDM7160_DS2438_BMP280/DS2438_CDM7160_DS2438_BMP280.atsln b/DS2438_CDM7160_DS2438_BMP280/DS2438_CDM7160_DS2438_BMP280.atsln new file mode 100644 index 0000000..8f8ecf9 --- /dev/null +++ b/DS2438_CDM7160_DS2438_BMP280/DS2438_CDM7160_DS2438_BMP280.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2438_CDM7160_DS2438_BMP280", "DS2438_CDM7160_DS2438_BMP280.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.ActiveCfg = Debug|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.Build.0 = Debug|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.ActiveCfg = Release|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2438_CDM7160_DS2438_BMP280/DS2438_CDM7160_DS2438_BMP280.componentinfo.xml b/DS2438_CDM7160_DS2438_BMP280/DS2438_CDM7160_DS2438_BMP280.componentinfo.xml new file mode 100644 index 0000000..52c412d --- /dev/null +++ b/DS2438_CDM7160_DS2438_BMP280/DS2438_CDM7160_DS2438_BMP280.componentinfo.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/DS2438_CDM7160_DS2438_BMP280/DS2438_DS2438.c b/DS2438_CDM7160_DS2438_BMP280/DS2438_DS2438.c new file mode 100644 index 0000000..ffc5e8b --- /dev/null +++ b/DS2438_CDM7160_DS2438_BMP280/DS2438_DS2438.c @@ -0,0 +1,187 @@ +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +//!!!!!Max Program size 7551 Byte + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/TWI_Master.h" +#include "../common/I2C/BMP280.h" +#include "../common/I2C/CDM7160.h" +#include "../common/owSlave_tools.h" + + +OWST_EXTERN_VARS + + + +volatile uint8_t owid1[8]={0x26, 0x01, 0x01, 0x01, 0x00, 0x00, 0x03, 0xF6};/**/ +volatile uint8_t owid2[8]={0x26, 0x02, 0x01, 0x01, 0x00, 0x00, 0x03, 0xAF};/**/ +volatile uint8_t config_info1[26]={1,6, 10,8, 10,8, 0x00,0x00, 0x02,14,16,16,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +volatile uint8_t config_info2[26]={1,6, 2,8, 2,8, 0,0 , 0x02,14,14,14,0,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + + + +typedef union { + volatile uint8_t bytes[64]; + struct { + uint8_t status; //1 + int16_t temp; //2 + uint16_t voltage; //4 + int16_t current; //6 + uint8_t threshold; //8 + uint8_t page1[8]; //9 + uint8_t page2[8]; //17 + + uint8_t page3[8]; //25 + + uint8_t page4[8]; //33 + uint8_t page5[8]; //41 + uint8_t page6[8]; //49 + uint8_t page7[8]; //57 + + }; +} pack1_t; +volatile pack1_t pack1; + + + + +typedef union { + volatile uint8_t bytes[64]; + struct { + uint8_t status; //1 + int16_t temp; //2 + uint16_t voltage; //4 + int16_t current; //6 + uint8_t threshold; //8 + + uint8_t page1[8]; //9 + + uint8_t page2[8]; //17 + uint8_t page3[8]; //25 + + uint8_t page4[8]; //33 + uint8_t page5[8]; //41 + uint8_t page6[8]; //25 + uint8_t page7[8]; //57 + + }; +} pack2_t; +volatile pack2_t pack2; + +OWST_WDT_ISR +OWST_TESTSW + + + + + +volatile int16_t DS2438_1_TEMP; +volatile uint16_t DS2438_1_VAD; +volatile uint16_t DS2438_1_VDD; +volatile int16_t DS2438_2_TEMP; +volatile uint16_t DS2438_2_VAD; +volatile uint16_t DS2438_2_VDD; + + + +double temperatureC,humidityRH,hhum; +double l; +uint32_t P; +int32_t t; +uint8_t max_adr=0; +int16_t CO2; + + +int main(void){ + OWST_INIT_USI_ON + OWINIT(); + OWST_WDR_CONFIG8 + OWST_EN_PULLUP + + pack1.page3[0]=0xF1; + pack2.page3[0]=0xF4; + + TWI_Master_Initialise(); + CDM7160softReset(); + _delay_ms(200); + + CDM7160setMode(0); //Power Down Mode + _delay_ms(200); + CDM7160setAvCount(0x3F); + CDM7160setFMode(1); + CO2=CDM7160getCO2(); + CDM7160setMode(1); + _delay_ms(200); + + bmp280Init(); + + + + + gcontrol=1; + sei(); + + while(1) { + if (gcontrol) wdcounter=4; + if (wdcounter>3) { //8s + wdcounter=0; + bmp280ConvertInt(&t,&P,1); + _delay_ms(100); + CO2=CDM7160getCO2()-35; + double cc=(double)CO2/(P/101300.0*298.0/(273.0+t/100.0)); + DS2438_2_TEMP=t/100.0*256.0; + DS2438_1_TEMP=CO2; + DS2438_1_VDD=cc/10; + DS2438_1_VAD=(cc-DS2438_1_VDD*10)*100; + DS2438_2_VDD=P/1000; + DS2438_2_VAD=(P-DS2438_2_VDD*1000); + + + } + + if (gcontrol) { + gcontrol=0; + } + + + OWST_MAIN_END + } + + +} diff --git a/DS2438_DHT11/DS2438_DHT22.atsln b/DS2438_DHT11/DS2438_DHT22.atsln new file mode 100644 index 0000000..ea73243 --- /dev/null +++ b/DS2438_DHT11/DS2438_DHT22.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2438_DHT22", "DS2438_DHT22.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2438_DHT11/DS2438_DHT22.c b/DS2438_DHT11/DS2438_DHT22.c new file mode 100644 index 0000000..b120ab3 --- /dev/null +++ b/DS2438_DHT11/DS2438_DHT22.c @@ -0,0 +1,316 @@ +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include + + +extern void OWINIT(); +extern void EXTERN_SLEEP(); + +uint8_t owid[8]={0x26, 0xA2, 0xD9, 0x84, 0xDD, 0xDD, 0x05, 0xCE};/**/ +uint8_t config_info[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0x00,0x00, 0x02,0x09,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + + + +extern uint8_t mode; +extern uint8_t gcontrol; +extern uint8_t reset_indicator; +extern uint8_t alarmflag; + +volatile uint8_t wdcounter; + + +typedef union { + + volatile uint8_t bytes[64]; + struct { + uint8_t status; //1 + int16_t temp; //2 + uint16_t voltage; //4 + uint16_t current; //6 + uint8_t threshold; //8 + + uint8_t page1[8]; //9 + uint8_t page2[8]; //17 + uint8_t page3[8]; //25 + uint8_t page4[8]; //33 + uint8_t page5[8]; //41 + uint8_t page6[8]; //49 + uint8_t page7[8]; //57 + //uint8_t crc; //65 + }; +} pack_t; +volatile pack_t pack; + + +#define DDR_SENSOR DDRA +#define PORT_SENSOR PORTA +#define PIN_SENSOR PINA +#define SENSOR PINA2 + +#define SENSOR_sda_out DDR_SENSOR |= (1 << SENSOR) +#define SENSOR_sda_in DDR_SENSOR &= ~(1 << SENSOR);PORT_SENSOR |= (1 << SENSOR) // release sda => hi in consequence of pullup +#define SENSOR_sda_low PORT_SENSOR &= ~(1 << SENSOR) +#define SENSOR_sda_hi PORT_SENSOR |= (1 << SENSOR) +#define SENSOR_is_hi PIN_SENSOR & (1 << SENSOR) +#define SENSOR_is_low !(PIN_SENSOR & (1 << SENSOR)) + +volatile int16_t am2302_temp; +volatile uint16_t am2302_hum; + + +uint8_t am_wait(uint8_t _time,uint8_t _signal){ + TCNT1=0; + while(TCNT1==0); + if (_signal) + while((SENSOR_is_hi)&&(TCNT1<_time)) {} + else + while((SENSOR_is_low)&&(TCNT1<_time)) {} + + if (TCNT1>=_time) {return 1;} + return 0; +} + +volatile uint8_t am2302_mode=0; +volatile uint8_t timeout=0; + + + + + + +uint8_t userRegister[1]; +int16_t sRH,sT; +volatile double temperatureC,humidityRH; +volatile double l; + +#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) +ISR(WATCHDOG_vect) { + #else +ISR(WDT_vect) { + #endif + wdcounter++; + if (reset_indicator==1) reset_indicator++; + else if (reset_indicator==2) mode=0; +} + +int testSW(void) { + uint8_t r; + DDRB&=~(1< bit=1 else bit=0 + sensor_byte |= 1; + if (am_wait(45,1)) return 6;// 30us - 75us = 45us + } + } + sensor_data[i] = sensor_byte; + } + + // checksum + if ( ((sensor_data[0]+sensor_data[1]+sensor_data[2]+sensor_data[3]) & 0xff ) != sensor_data[4]) + { + PORTB&=~(1< 5V also all *5 + config_info[5]=7; + } + else { + + lam2302_hum=(sensor_data[0]*10); + config_info[5]=12; + } + lam2302_temp=lam2302_temp*25.6; + rSREG=SREG; + cli(); + am2302_hum=lam2302_hum; + am2302_temp=lam2302_temp; + SREG=rSREG; + return 0; +} + + + + + + + + + int main(void){ + PRR|=(1<2) { + wdcounter=0; + SENSON + } + gcontrol=0; + } + if (wdcounter==2) { + err=am2302(); + if (err!=0) { + pack.page3[pn]=err; + pn=pn+1;if (pn>31) pn=1; + } + //SENSOFF + wdcounter=3; + } + if (wdcounter>=16) { + wdcounter=0; + SENSON + } + + + + if (((TIMSK0 & (1< + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS2438_DHT22 + DS2438_DHT22 + DS2438_DHT22 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + J41800000789 + 0x1E930C + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + debugWIRE + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Default (-Wa,-g) + + + + + + compile + OWDS2438.S + + + compile + + + + \ No newline at end of file diff --git a/DS2438_DHT22/DS2438_DHT22.cproj b/DS2438_DHT22/DS2438_DHT22.cproj index 3dc3802..4986240 100644 --- a/DS2438_DHT22/DS2438_DHT22.cproj +++ b/DS2438_DHT22/DS2438_DHT22.cproj @@ -29,15 +29,15 @@ - - - - - - - - - + + + + + + + + + com.atmel.avrdbg.tool.atmelice J41800000789 diff --git a/DS2438_Fenster_Kontakt/DS2438_Fenster_Kontakt.atsln b/DS2438_Fenster_Kontakt/DS2438_Fenster_Kontakt.atsln new file mode 100644 index 0000000..a43f92a --- /dev/null +++ b/DS2438_Fenster_Kontakt/DS2438_Fenster_Kontakt.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2438_Fenster_Kontakt", "DS2438_Fenster_Kontakt.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2438_Fenster_Kontakt/DS2438_Fenster_Kontakt.c b/DS2438_Fenster_Kontakt/DS2438_Fenster_Kontakt.c new file mode 100644 index 0000000..7a7418c --- /dev/null +++ b/DS2438_Fenster_Kontakt/DS2438_Fenster_Kontakt.c @@ -0,0 +1,208 @@ +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include + + +extern void OWINIT(); +extern void EXTERN_SLEEP(); + +uint8_t owid[8]={0x26, 0xA3, 0xD9, 0x89, 0xDD, 0xDD, 0x05, 0x64};/**/ +uint8_t config_info[26]={0x01,0x06, 0x05,0x08, 0x06,0x08, 0x00,0x00, 0x02,0x09,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + + + +extern uint8_t mode; +extern uint8_t gcontrol; +extern uint8_t reset_indicator; +extern uint8_t alarmflag; + +volatile uint8_t wdcounter; + + +typedef union { + + volatile uint8_t bytes[64]; + struct { + uint8_t status; //1 + int16_t temp; //2 + uint16_t voltage; //4 + uint16_t current; //6 + uint8_t threshold; //8 + + uint8_t page1[8]; //9 + uint8_t page2[8]; //17 + uint8_t page3[8]; //25 + uint8_t page4[8]; //33 + uint8_t page5[8]; //41 + uint8_t page6[8]; //49 + uint8_t page7[8]; //57 + //uint8_t crc; //65 + }; +} pack_t; +volatile pack_t pack; + + +volatile int16_t ds_temp; +volatile uint16_t ds_vad; +volatile uint16_t ds_vdd; + +#define CH1 (1<1) ch1++; + if (ch2>1) ch2++; + if (ch3>1) ch3++; + if (reset_indicator==1) reset_indicator++; + else if (reset_indicator==2) mode=0; + +} + +ISR(PCINT0_vect) { + + if ((PIN_CH1&CH1)==0) {if (ch1==0) ch1=1;} else {ds_temp=25600;ch1=0;} + if ((PIN_CH2&CH2)==0) {if (ch2==0) ch2=1;} else {ds_vdd=0x1f4;ch2=0;} + if ((PIN_CH3&CH3)==0) {if (ch3==0) ch3=1;} else {ds_vad=0x1f4;ch3=0;} + + wdcounter=10; +} + +int testSW(void) { + uint8_t r; + DDRB&=~(1< + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS2438_DHT22 + DS2438_Fenster_Kontakt + DS2438_DHT22 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + J41800000789 + 0x1E930C + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + debugWIRE + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Default (-Wa,-g) + + + + + + compile + + + compile + + + + \ No newline at end of file diff --git a/DS2438_Fenster_Kontakt/OWDS2438.S b/DS2438_Fenster_Kontakt/OWDS2438.S new file mode 100644 index 0000000..eff1ad7 --- /dev/null +++ b/DS2438_Fenster_Kontakt/OWDS2438.S @@ -0,0 +1,196 @@ +// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define _CHANGEABLE_ID_ +//#define _DIS_FLASH_ +#define _ZERO_POLLING_ +//#define _DB_ +//#define __4MHZ__ + +#include "../common/OWConfig.s" +#include "../common/OWCRC8.s" + +#if defined(__AVR_ATtiny25__) +.extern pack,16 +#else +.extern pack,64 +#endif +.extern ds_temp,2 +.extern ds_vdd,2 +.extern ds_vad,2 + +.comm block,1 ; Block der augegeben, geschrieben wird (Parameter von READ/WRITE Scratchpad) + + +.macro CHIP_INIT +.endm + +; Ab hier Geraeteabhaenging +#define OW_READ_SCRATCHPAD_ADR OW_FIRST_COMMAND+0 +#define OW_READ_SCRATCHPAD OW_FIRST_COMMAND+1 +#define OW_WRITE_SCRATCHPAD_ADR OW_FIRST_COMMAND+2 +#define OW_WRITE_SCRATCHPAD OW_FIRST_COMMAND+3 + + + +.macro COMMAND_TABLE + rjmp h_readscratchpad_adr + rjmp h_readscratchpad + rjmp h_writescratchpad_adr + rjmp h_writescratchpad +.endm + +#include "../common/OWRomFunctions.s" +#include "../common/OWTimerInterrupt.s" + + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + + +h_readcommand: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cset 0xBE,OW_READ_SCRATCHPAD_ADR + cset 0x4E,OW_WRITE_SCRATCHPAD_ADR + cjmp 0x44,hrc_set_convertT + cjmp 0xB4,hrc_set_convertV + FW_CONFIG_INFO +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + rjmp handle_end_sleep + + +hrc_set_convertT: + ldi r_temp,1 + sts gcontrol,r_temp + lds r_temp,ds_temp + sts pack+1,r_temp + lds r_temp,ds_temp+1 + sts pack+2,r_temp + rjmp handle_end_sleep +hrc_set_convertV: + lds r_temp,pack + sbrs r_temp,3 + rjmp hrc_set_convertVV + ldi r_temp,2 + sts gcontrol,r_temp + //ldi r_temp,0xF4# + lds r_temp,ds_vdd + sts pack+3,r_temp + //ldi r_temp,0x01 + lds r_temp,ds_vdd+1 + sts pack+4,r_temp + rjmp hrc_set_convertend +hrc_set_convertVV: + ldi r_temp,4 + sts gcontrol,r_temp + lds r_temp,ds_vad + sts pack+3,r_temp + lds r_temp,ds_vad+1 + sts pack+4,r_temp +hrc_set_convertend: + rjmp handle_end_sleep + + + +;--------------------------------------------------- +; READ SCRATCHPAD +;--------------------------------------------------- + +h_readscratchpad_adr: + lsl r_rwbyte + lsl r_rwbyte + lsl r_rwbyte +#if defined(__AVR_ATtiny25__) + andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen +#endif + sts block,r_rwbyte + ldi r_sendflag,1 + ldi r_mode,OW_READ_SCRATCHPAD + ldi r_temp,8 + sts gcontrol,r_temp + CRCInit2 +h_readscratchpad: + cpi r_bytep,8 + breq h_readscratchpad_crc + cpi r_bytep,9 + breq h_readscratchpad_all + lds r_temp,block + add r_temp,r_bytep + configZ pack,r_temp + ld r_rwbyte,Z + rjmp handle_end_inc +h_readscratchpad_crc: + lds r_rwbyte,crc + rjmp handle_end_inc +h_readscratchpad_all: + rjmp handle_end_sleep + + + + +;--------------------------------------------------- +; WRITE SCRATCHPAD +;--------------------------------------------------- +h_writescratchpad_adr: + lsl r_rwbyte + lsl r_rwbyte + lsl r_rwbyte +#if defined(__AVR_ATtiny25__) + andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen +#endif + sts block,r_rwbyte + ldi r_mode,OW_WRITE_SCRATCHPAD + ldi r_bcount,1 + rjmp handle_end +h_writescratchpad: + cpi r_bytep,8 + breq h_writescratchpad_all + lds r_temp,block + add r_temp,r_bytep + configZ pack,r_temp + st Z,r_rwbyte + rjmp handle_end_inc +h_writescratchpad_all: + rjmp handle_end_sleep + + + + + +#include "../common/OWPinInterrupt.s" +.end \ No newline at end of file diff --git a/DS2438_HDC1080/DS2438_HDC1080.atsln b/DS2438_HDC1080/DS2438_HDC1080.atsln index da1d586..4812b38 100644 --- a/DS2438_HDC1080/DS2438_HDC1080.atsln +++ b/DS2438_HDC1080/DS2438_HDC1080.atsln @@ -1,22 +1,22 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Atmel Studio Solution File, Format Version 11.00 -VisualStudioVersion = 14.0.23107.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2438_HDC1080", "DS2438_HDC1080.cproj", "{91468D4F-8AE2-4C59-8A35-549C49E00934}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|AVR = Debug|AVR - Release|AVR = Release|AVR - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {91468D4F-8AE2-4C59-8A35-549C49E00934}.Debug|AVR.ActiveCfg = Debug|AVR - {91468D4F-8AE2-4C59-8A35-549C49E00934}.Debug|AVR.Build.0 = Debug|AVR - {91468D4F-8AE2-4C59-8A35-549C49E00934}.Release|AVR.ActiveCfg = Release|AVR - {91468D4F-8AE2-4C59-8A35-549C49E00934}.Release|AVR.Build.0 = Release|AVR - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2438_HDC1080", "DS2438_HDC1080.cproj", "{91468D4F-8AE2-4C59-8A35-549C49E00934}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {91468D4F-8AE2-4C59-8A35-549C49E00934}.Debug|AVR.ActiveCfg = Debug|AVR + {91468D4F-8AE2-4C59-8A35-549C49E00934}.Debug|AVR.Build.0 = Debug|AVR + {91468D4F-8AE2-4C59-8A35-549C49E00934}.Release|AVR.ActiveCfg = Release|AVR + {91468D4F-8AE2-4C59-8A35-549C49E00934}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2438_HDC2010/DS2438_HDC2010.atsln b/DS2438_HDC2010/DS2438_HDC2010.atsln new file mode 100644 index 0000000..92feefd --- /dev/null +++ b/DS2438_HDC2010/DS2438_HDC2010.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2438_HDC2010", "DS2438_HDC2010.cproj", "{91468D4F-8AE2-4C59-8A35-549C49E00934}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {91468D4F-8AE2-4C59-8A35-549C49E00934}.Debug|AVR.ActiveCfg = Debug|AVR + {91468D4F-8AE2-4C59-8A35-549C49E00934}.Debug|AVR.Build.0 = Debug|AVR + {91468D4F-8AE2-4C59-8A35-549C49E00934}.Release|AVR.ActiveCfg = Release|AVR + {91468D4F-8AE2-4C59-8A35-549C49E00934}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2438_HDC2010/DS2438_HDC2010.c b/DS2438_HDC2010/DS2438_HDC2010.c new file mode 100644 index 0000000..d47fd90 --- /dev/null +++ b/DS2438_HDC2010/DS2438_HDC2010.c @@ -0,0 +1,199 @@ +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/USI_TWI_Master.h" +#include "../common/I2C/HDC1080.h" +#include "../common/calibr.h" + +extern void OWINIT(); +extern void EXTERN_SLEEP(); + +uint8_t owid[8]={0x26, 0xA2, 0xD9, 0x84, 0x00, 0x00, 0x05, 0x16};/**/ +uint8_t config_info[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0x00,0x00, 0x02,11,0x00,11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + + +extern uint8_t mode; +extern uint8_t gcontrol; +extern uint8_t reset_indicator; +extern uint8_t alarmflag; + +volatile uint8_t wdcounter=5; + + +typedef union { + + volatile uint8_t bytes[64]; + struct { + uint8_t status; //1 + int16_t temp; //2 + uint16_t voltage; //4 + uint16_t current; //6 + uint8_t threshold; //8 + + uint8_t page1[8]; //9 + uint8_t page2[8]; //17 + uint8_t page3[8]; //25 + uint8_t page4[8]; //33 + uint8_t page5[8]; //41 + uint8_t page6[8]; //49 + uint8_t page7[8]; //57 + //uint8_t crc; //65 + }; +} pack_t; +volatile pack_t pack; + + + +volatile int16_t am2302_temp; +volatile uint16_t am2302_hum; + +uint8_t userRegister[1]; +int16_t sRH,sT; +double temperatureC,humidityRH; +volatile double l; + +#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) +ISR(WATCHDOG_vect) { +#else +ISR(WDT_vect) { +#endif + wdcounter++; + if (reset_indicator==1) reset_indicator++; + else if (reset_indicator==2) mode=0; + + +} + +int testSW(void) { + uint8_t r; + DDRB&=~(1<2) { + //PORTB|=(1< + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + {91468d4f-8ae2-4c59-8a35-549c49e00934} + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS2438_SHT2X + DS2438_HDC2010 + DS2438_SHT2X + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + debugWIRE + + J41800000789 + 0x1E930C + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + -std=gnu99 -D__4MHZ__ + + + libm + + + -D__4MHZ__ + Default (-Wa,-g) + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + + + + + + compile + calibr.c + + + compile + HDC2010.c + + + compile + USI_TWI_Master.c + + + compile + OWDS2438.S + + + compile + + + + \ No newline at end of file diff --git a/DS2438_MAX44009_VOC_DS2438_HDC_direct/DS2438_DS2438.c b/DS2438_MAX44009_VOC_DS2438_HDC_direct/DS2438_DS2438.c new file mode 100644 index 0000000..f4aef4a --- /dev/null +++ b/DS2438_MAX44009_VOC_DS2438_HDC_direct/DS2438_DS2438.c @@ -0,0 +1,444 @@ +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +//!!!!!Max Program size 7551 Byte +//#define __4MHZ__ +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/TWI_Master.h" +#include "../common/I2C/HDC2010.h" +#include "../common/I2C/MAX44009.h" +#include "../common/owSlave_tools.h" + +OWST_EXTERN_VARS + + + +volatile uint8_t owid1[8]={0x26, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x50};/**/ +volatile uint8_t owid2[8]={0x26, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x67};/**/ + //18 +volatile uint8_t config_info1[26]={3,28, 0x05,0x08, 8,27, 0x00,0x00, 0x02,17,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +volatile uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 11,0x08, 0x02,0x07,0x00,0x07,17,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + +#if (owid>128) +#error "Variable not correct" +#endif + +extern uint8_t cpsp2; + +OWST_WDT_ISR + +/* + + + typedef union { + volatile uint8_t bytes[8]; + struct { + uint16_t temp; //0 + uint8_t TH; //2 + uint8_t TL; //3 + uint8_t config; //4 + uint8_t rrFF; //5 + uint8_t rr00; //6 + uint8_t rr10; //7 + }; + } pack1_t; + volatile pack1_t pack1; +*/ + + + typedef union { + #if defined(__AVR_ATtiny25__) + uint8_t bytes[16]; + #else + uint8_t bytes[64]; + #endif + struct { + uint8_t status; //1 + int16_t temp; //2 + uint16_t voltage; //4 + int16_t current; //6 + uint8_t threshold; //8 + + uint8_t page1[8]; //9 + #if defined(__AVR_ATtiny25__) + #else + uint8_t page2[8]; //17 + union{ + uint8_t page3[8]; //25 + struct { + uint8_t free; + uint16_t R0; + uint16_t VS; + uint8_t cmode; + int16_t ip; + + }; + }; + union{ + uint8_t page4[8]; //33 + struct { + uint16_t tol_s8; + uint16_t tol_d; + uint16_t r_day_max; + uint16_t r_week_max; + }; + }; + union{ + uint8_t page5[8]; //41 + struct { + uint8_t codeVOC; // immer 0x37 nach Neustart + uint8_t days_of_r0; //Anzahl der Tage fuer die r0 ermittelt wird + int8_t corr_VOC_mult; //r0 corr + int8_t corr_VOC_div; + uint16_t vv3; + uint8_t time_corr; //Wiregate; + uint8_t reset_code; + }; + uint16_t page5d[4]; + }; + uint8_t page6[8]; //49 + uint8_t page7[8]; //57 + + #endif + }; + } pack2_t; + volatile pack2_t pack2,pack1; + + + + + volatile int16_t DS2438_2_TEMP; + volatile uint16_t DS2438_2_VAD; + volatile uint16_t DS2438_2_VDD=0x01F4; + volatile int16_t DS2438_1_TEMP; + volatile uint16_t DS2438_1_VAD; + volatile uint16_t DS2438_1_VDD=0x01F4; + + OWST_TESTSW + + + double temperatureC,humidityRH,hhum; + double l; + + + uint16_t weekmaxarr[33]; + + //Kompensieren der Abhänigkeit von RS/RO von Temperatur und Luftfeuchte + inline double interp(double t, double h) { + double h2; + double t2; + h2=h*h; + t2=t*t; + return 4.76111e-9*h2*t2-3.96956e-7*h2*t+0.0000408889*h2-1.07132e-6*h*t2+0.000115968*h*t-0.0101333*h+0.000163806*t2-0.0241179*t+1.80591; + } + inline double calibr_hum05(double t,double hum) { + double y=-0.0006*t*t-0.2455*t-28.5902; + return -(hum/y)+hum; + } + inline double calibr_hum075(double t,double hum) { + double y=-0.0004*t*t-0.1636*t-18.9173; + return -(hum/y)+hum; + } + inline double calibr_hum1(double t,double hum) { + double y=-0.0003*t*t-0.1228*t-14.0808; + return -(hum/y)+hum; + } + + double R0; + uint16_t mr; + uint8_t startup=10; + double ip; + double la[4]; + uint8_t lainit=1; + + + + #define EEPROM_R0 0 + #define EEPROM_R0d 2 + #define EEPROM_R0w 4 + #define EEPROM_dol 6 + #define EEPROM_CODE_DAYOFR0 8 + #define EEPROM_CORR 10 + #define EEPROM_FREE 12 + #define EEPROM_TCORR_RESET 14 + + uint16_t readEEPROM(uint8_t addr,uint16_t def) { + uint16_t hr; + while(EECR & (1<>8; + EECR |= (1<0) { //8s + pack2.tol_s8++; + if (pack2.tol_s8>(10000)) {//10800 ist theortisch der Tag aber meistens zu lang + pack2.tol_s8=0; + pack2.tol_d++; //rund 180 Jahre :-) + pack2.r_week_max=0; + weekmaxarr[pack2.days_of_r0]=pack2.r_day_max; + for(uint8_t i=0;ipack2.r_week_max) pack2.r_week_max=weekmaxarr[i]; + } + if (pack2.tol_d>7) { + pack2.R0=pack2.r_week_max; + } else { + pack2.R0=pack2.r_day_max; + } + //R0=//R0-0.5*(pack2.R0/100-R0); + R0=R0-(R0-pack2.R0/100.0)*0.5 ; + pack2.R0=R0*100; + writeEEPROM(EEPROM_R0,pack2.R0); + writeEEPROM(EEPROM_R0d,pack2.r_day_max); //Maximum des Tages + writeEEPROM(EEPROM_R0w,pack2.r_week_max); //Maximum der Letzten 7 Tage + writeEEPROM(EEPROM_dol,pack2.tol_d); //Anzahl der Betriebstage + pack2.r_day_max=0; + } + if (startup!=0) startup--; + //getSHT2xHumTemp(&temperatureC,&humidityRH); + HDC2010_Readf(&temperatureC,&humidityRH); + ip=interp(temperatureC,humidityRH); + pack2.ip=ip*1000; + //double RH=calibr_hum(temperatureC,-0.2,humidityRH)*10.0; + //double TC =temperatureC *10.0-2; + double RH=calibr_hum075(temperatureC,humidityRH)*10.0; + //double RH=humidityRH*10.0; + double TC=temperatureC*10.0-7.5; + + + if (testSW()) { + DS2438_2_VAD=RH; + DS2438_2_TEMP=TC*25.6; + config_info2[5]=12; //10V = 100% + }else{ + hhum=(1.0546-0.000216*TC)*(RH); + DS2438_2_VAD=0.31*hhum +80; + DS2438_2_TEMP=TC*25.6; + config_info2[5]=7; + } + mr=0; + //Kritische Sektion !___Ein Breakpoint in dieser Section kann den TGS8100 zerstoeren!___________________________ + PORTB&=~(1< Nur zum Debug .... Speicher reicht sonst nicht.... + l=mr*1.8/32768.0; //Spannung in v + l=( 1.8/l- 1) *30; //l is resistance + if (lainit) { + la[0]=la[1]=la[2]=la[3]=l; //smaller code + lainit=0; + } else { + //for (uint8_t i=0;i<3;i++) { + // la[i]=la[i+1]; + //} + la[0]=la[1]; + la[1]=la[2]; + la[2]=la[3]; + la[3]=l; + } + double lasum=la[0]+la[1]+la[2]+la[3]; + l=lasum/4.0; + + pack2.current=l*100; + + l=l/ip; + + if (startup==0){ + if (l>R0) { + R0=l; + pack2.R0=R0*100; + writeEEPROM(EEPROM_R0,pack2.R0); + + } + if (l*100>pack2.r_day_max) { + pack2.r_day_max=l*100; + } + } else if (l + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + {7a5672fe-8226-4158-b931-e1f36b9a8858} + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS18B20_DS2438 + DS2438_MAX44009_VOC_DS2438_HDC + DS18B20_DS2438 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + debugWIRE + + + + + + + + com.atmel.avrdbg.tool.simulator + + + Simulator + + + J41800000789 + 0x1E930C + 0 + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + __4MHZ__ + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + True + + + libm + + + -D__4MHZ__ + Default (-Wa,-g) + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + __4MHZ__ + + + + + _CHANGEABLE_ID_ + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + -D__4MHZ__ + Default (-Wa,-g) + + + + + + compile + HDC2010.c + + + compile + MAX44009.c + + + compile + TWI_Master.c + + + compile + OWDS2438_DS2438.S + + + compile + + + + \ No newline at end of file diff --git a/DS2438_MAX44009_VOC_DS2438_SHT_direct/DS2438_DS2438.c b/DS2438_MAX44009_VOC_DS2438_SHT_direct/DS2438_DS2438.c new file mode 100644 index 0000000..e4e3bbc --- /dev/null +++ b/DS2438_MAX44009_VOC_DS2438_SHT_direct/DS2438_DS2438.c @@ -0,0 +1,442 @@ +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +//!!!!!Max Program size 7551 Byte + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/TWI_Master.h" +#include "../common/I2C/SHT2xV2.h" +#include "../common/I2C/MAX44009.h" +#include "../common/owSlave_tools.h" + +OWST_EXTERN_VARS + + + +volatile uint8_t owid1[8]={0x26, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x50};/**/ +volatile uint8_t owid2[8]={0x26, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x67};/**/ + //18 +volatile uint8_t config_info1[26]={3,28, 0x05,0x08, 8,27, 0x00,0x00, 0x02,17,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +volatile uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 11,0x08, 0x02,0x07,0x00,0x07,17,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + +#if (owid>128) +#error "Variable not correct" +#endif + +extern uint8_t cpsp2; + +OWST_WDT_ISR + +/* + + + typedef union { + volatile uint8_t bytes[8]; + struct { + uint16_t temp; //0 + uint8_t TH; //2 + uint8_t TL; //3 + uint8_t config; //4 + uint8_t rrFF; //5 + uint8_t rr00; //6 + uint8_t rr10; //7 + }; + } pack1_t; + volatile pack1_t pack1; +*/ + + + typedef union { + #if defined(__AVR_ATtiny25__) + uint8_t bytes[16]; + #else + uint8_t bytes[64]; + #endif + struct { + uint8_t status; //1 + int16_t temp; //2 + uint16_t voltage; //4 + int16_t current; //6 + uint8_t threshold; //8 + + uint8_t page1[8]; //9 + #if defined(__AVR_ATtiny25__) + #else + uint8_t page2[8]; //17 + union{ + uint8_t page3[8]; //25 + struct { + uint8_t free; + uint16_t R0; + uint16_t VS; + uint8_t cmode; + int16_t ip; + + }; + }; + union{ + uint8_t page4[8]; //33 + struct { + uint16_t tol_s8; + uint16_t tol_d; + uint16_t r_day_max; + uint16_t r_week_max; + }; + }; + union{ + uint8_t page5[8]; //41 + struct { + uint8_t codeVOC; // immer 0x37 nach Neustart + uint8_t days_of_r0; //Anzahl der Tage fuer die r0 ermittelt wird + int8_t corr_VOC_mult; //r0 corr + int8_t corr_VOC_div; + uint16_t vv3; + uint8_t time_corr; //Wiregate; + uint8_t reset_code; + }; + uint16_t page5d[4]; + }; + uint8_t page6[8]; //49 + uint8_t page7[8]; //57 + + #endif + }; + } pack2_t; + volatile pack2_t pack2,pack1; + + + + + volatile int16_t DS2438_2_TEMP; + volatile uint16_t DS2438_2_VAD; + volatile uint16_t DS2438_2_VDD=0x01F4; + volatile int16_t DS2438_1_TEMP; + volatile uint16_t DS2438_1_VAD; + volatile uint16_t DS2438_1_VDD=0x01F4; + + OWST_TESTSW + + + double temperatureC,humidityRH,hhum; + double l; + + + uint16_t weekmaxarr[33]; + + //Kompensieren der Abhänigkeit von RS/RO von Temperatur und Luftfeuchte + inline double interp(double t, double h) { + double h2; + double t2; + h2=h*h; + t2=t*t; + return 4.76111e-9*h2*t2-3.96956e-7*h2*t+0.0000408889*h2-1.07132e-6*h*t2+0.000115968*h*t-0.0101333*h+0.000163806*t2-0.0241179*t+1.80591; + } + inline double calibr_hum05(double t,double hum) { + double y=-0.0006*t*t-0.2455*t-28.5902; + return -(hum/y)+hum; + } + inline double calibr_hum075(double t,double hum) { + double y=-0.0004*t*t-0.1636*t-18.9173; + return -(hum/y)+hum; + } + inline double calibr_hum1(double t,double hum) { + double y=-0.0003*t*t-0.1228*t-14.0808; + return -(hum/y)+hum; + } + + double R0; + uint16_t mr; + uint8_t startup=10; + double ip; + double la[4]; + uint8_t lainit=1; + + + + #define EEPROM_R0 0 + #define EEPROM_R0d 2 + #define EEPROM_R0w 4 + #define EEPROM_dol 6 + #define EEPROM_CODE_DAYOFR0 8 + #define EEPROM_CORR 10 + #define EEPROM_FREE 12 + #define EEPROM_TCORR_RESET 14 + + uint16_t readEEPROM(uint8_t addr,uint16_t def) { + uint16_t hr; + while(EECR & (1<>8; + EECR |= (1<0) { //8s + pack2.tol_s8++; + if (pack2.tol_s8>(10000)) {//10800 ist theortisch der Tag aber meistens zu lang + pack2.tol_s8=0; + pack2.tol_d++; //rund 180 Jahre :-) + pack2.r_week_max=0; + weekmaxarr[pack2.days_of_r0]=pack2.r_day_max; + for(uint8_t i=0;ipack2.r_week_max) pack2.r_week_max=weekmaxarr[i]; + } + if (pack2.tol_d>7) { + pack2.R0=pack2.r_week_max; + } else { + pack2.R0=pack2.r_day_max; + } + //R0=//R0-0.5*(pack2.R0/100-R0); + R0=R0-(R0-pack2.R0/100.0)*0.5 ; + pack2.R0=R0*100; + writeEEPROM(EEPROM_R0,pack2.R0); + writeEEPROM(EEPROM_R0d,pack2.r_day_max); //Maximum des Tages + writeEEPROM(EEPROM_R0w,pack2.r_week_max); //Maximum der Letzten 7 Tage + writeEEPROM(EEPROM_dol,pack2.tol_d); //Anzahl der Betriebstage + pack2.r_day_max=0; + } + if (startup!=0) startup--; + getSHT2xHumTemp(&temperatureC,&humidityRH); + ip=interp(temperatureC,humidityRH); + pack2.ip=ip*1000; + //double RH=calibr_hum(temperatureC,-0.2,humidityRH)*10.0; + //double TC =temperatureC *10.0-2; + double RH=calibr_hum075(temperatureC,humidityRH)*10.0; + //double RH=humidityRH*10.0; + double TC=temperatureC*10.0-7.5; + + + if (testSW()) { + DS2438_2_VAD=RH; + DS2438_2_TEMP=TC*25.6; + config_info2[5]=12; //10V = 100% + }else{ + hhum=(1.0546-0.000216*TC)*(RH); + DS2438_2_VAD=0.31*hhum +80; + DS2438_2_TEMP=TC*25.6; + config_info2[5]=7; + } + mr=0; + //Kritische Sektion !___Ein Breakpoint in dieser Section kann den TGS8100 zerstoeren!___________________________ + PORTB&=~(1< Nur zum Debug .... Speicher reicht sonst nicht.... + l=mr*3.0/32768.0; //Spannung in v + l=( 3/l- 1) *30; //l is resistance + if (lainit) { + la[0]=la[1]=la[2]=la[3]=l; //smaller code + lainit=0; + } else { + //for (uint8_t i=0;i<3;i++) { + // la[i]=la[i+1]; + //} + la[0]=la[1]; + la[1]=la[2]; + la[2]=la[3]; + la[3]=l; + } + double lasum=la[0]+la[1]+la[2]+la[3]; + l=lasum/4.0; + + pack2.current=l*100; + + l=l/ip; + + if (startup==0){ + if (l>R0) { + R0=l; + pack2.R0=R0*100; + writeEEPROM(EEPROM_R0,pack2.R0); + + } + if (l*100>pack2.r_day_max) { + pack2.r_day_max=l*100; + } + } else if (l + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + {7a5672fe-8226-4158-b931-e1f36b9a8858} + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS18B20_DS2438 + DS2438_MAX44009_VOC_DS2438_SHT + DS18B20_DS2438 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + debugWIRE + + + + + + + + com.atmel.avrdbg.tool.simulator + + + Simulator + + + J41800000789 + 0x1E930C + 0 + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + True + + + libm + + + Default (-Wa,-g) + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + _CHANGEABLE_ID_ + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + -U_CHANGEABLE_ID_ + Default (-Wa,-g) + + + + + + compile + MAX44009.c + + + compile + SHT2xV2.c + + + compile + TWI_Master.c + + + compile + OWDS2438_DS2438.S + + + compile + + + + \ No newline at end of file diff --git a/DS2438_SHT2X_DS2438_BMP280_MAX44009/DS2438_DS2438.c b/DS2438_SHT2X_DS2438_BMP280_MAX44009/DS2438_DS2438.c new file mode 100644 index 0000000..eb3ad1e --- /dev/null +++ b/DS2438_SHT2X_DS2438_BMP280_MAX44009/DS2438_DS2438.c @@ -0,0 +1,189 @@ +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +//!!!!!Max Program size 7551 Byte + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/USI_TWI_Master.h" +#include "../common/I2C/SHT2xV2.h" +#include "../common/calibr.h" +#include "../common/I2C/BMP280.h" +#include "../common/I2C/MAX44009.h" +#include "../common/owSlave_tools.h" + + +OWST_EXTERN_VARS + + + +volatile uint8_t owid1[8]={0x26, 0x01, 0x01, 0x01, 0x00, 0x00, 0x03, 0xF6};/**/ +volatile uint8_t owid2[8]={0x26, 0x02, 0x01, 0x01, 0x00, 0x00, 0x03, 0xAF};/**/ +volatile uint8_t config_info1[26]={0x01,0x06, 0x05,0x08, 4,7, 0x00,0x00, 0x02,7,0x00,7,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +volatile uint8_t config_info2[26]={3,4, 0x05,0x08, 2,20, 0,0 , 0x02,15,0x00,14,0,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + + + +typedef union { + volatile uint8_t bytes[64]; + struct { + uint8_t status; //1 + int16_t temp; //2 + uint16_t voltage; //4 + int16_t current; //6 + uint8_t threshold; //8 + uint8_t page1[8]; //9 + uint8_t page2[8]; //17 + + uint8_t page3[8]; //25 + + uint8_t page4[8]; //33 + uint8_t page5[8]; //41 + uint8_t page6[8]; //49 + uint8_t page7[8]; //57 + + }; +} pack1_t; +volatile pack1_t pack1; + + + + +typedef union { + volatile uint8_t bytes[64]; + struct { + uint8_t status; //1 + int16_t temp; //2 + uint16_t voltage; //4 + int16_t current; //6 + uint8_t threshold; //8 + + uint8_t page1[8]; //9 + + uint8_t page2[8]; //17 + uint8_t page3[8]; //25 + + uint8_t page4[8]; //33 + uint8_t page5[8]; //41 + uint8_t page6[8]; //25 + uint8_t page7[8]; //57 + + }; +} pack2_t; +volatile pack2_t pack2; + +OWST_WDT_ISR +OWST_TESTSW + + + + + +volatile int16_t DS2438_1_TEMP; +volatile uint16_t DS2438_1_VAD; +volatile int16_t DS2438_2_TEMP; +volatile uint16_t DS2438_2_VAD; + + + +double temperatureC,humidityRH,hhum; +double l; +uint32_t P; +int32_t t; +uint8_t max_adr=0; + + +int main(void){ + OWST_INIT_USI_ON + OWINIT(); + OWST_WDR_CONFIG8 + OWST_EN_PULLUP + + pack1.page3[0]=0xF1; + pack2.page3[0]=0xF4; + + + USI_TWI_Master_Initialise(); + _delay_ms(10); + bmp280Init(); + _delay_ms(10); + initSHT2x(); + _delay_ms(100); + if (checkMAX44009(0)) max_adr=0; else max_adr=1 ; + gcontrol=1; + sei(); + + while(1) { + if (gcontrol) wdcounter=1; + if (wdcounter>0) { //8s + getSHT2xHumTemp(&temperatureC,&humidityRH); + double RH=humidityRH*10.0; + double TC =temperatureC *10.0; + if (testSW()) { + DS2438_1_VAD=RH; + DS2438_1_TEMP=TC*25.6; + config_info1[5]=12; //10V = 100% + }else{ + hhum=(1.0546-0.000216*TC)*(RH); + //am2302_hum=0.318*hhum +76.0; + DS2438_1_VAD=0.31*hhum +80; + DS2438_1_TEMP=TC*25.6; + config_info1[5]=7; + } + wdcounter=0; + bmp280ConvertInt(&t,&P,1); + uint16_t Pu=P/50; + Pu=Pu-1400; + DS2438_2_VAD=Pu; + l=MAX44009getlux(max_adr); + if (l<0.030) l=0.030; //Darf nicht 0 sein. minimum -35°C Sensor minimum 0.045 + //double l=1000; + l=log(l)*10*16; + DS2438_2_TEMP=l; + + } + + if (gcontrol) { + gcontrol=0; + } + + + OWST_MAIN_END + } + + +} diff --git a/DS2438_SHT2X_DS2438_BMP280_MAX44009/DS2438_SHT2X_DS2438_BMP280_MAX44009.atsln b/DS2438_SHT2X_DS2438_BMP280_MAX44009/DS2438_SHT2X_DS2438_BMP280_MAX44009.atsln new file mode 100644 index 0000000..5103429 --- /dev/null +++ b/DS2438_SHT2X_DS2438_BMP280_MAX44009/DS2438_SHT2X_DS2438_BMP280_MAX44009.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2438_SHT2X_DS2438_BMP280_MAX44009", "DS2438_SHT2X_DS2438_BMP280_MAX44009.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.ActiveCfg = Debug|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.Build.0 = Debug|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.ActiveCfg = Release|AVR + {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2438_SHT2X_DS2438_BMP280_MAX44009/DS2438_SHT2X_DS2438_BMP280_MAX44009.cproj b/DS2438_SHT2X_DS2438_BMP280_MAX44009/DS2438_SHT2X_DS2438_BMP280_MAX44009.cproj new file mode 100644 index 0000000..d3b09b1 --- /dev/null +++ b/DS2438_SHT2X_DS2438_BMP280_MAX44009/DS2438_SHT2X_DS2438_BMP280_MAX44009.cproj @@ -0,0 +1,163 @@ + + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + {7a5672fe-8226-4158-b931-e1f36b9a8858} + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS18B20_DS2438 + DS2438_SHT2X_DS2438_BMP280_MAX44009 + DS18B20_DS2438 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + debugWIRE + + + + + + + + com.atmel.avrdbg.tool.simulator + + + Simulator + + + J41800000789 + 0x1E930C + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + True + + + libm + + + Default (-Wa,-g) + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + + + + + + compile + calibr.c + + + compile + BMP280.c + + + compile + MAX44009.c + + + compile + SHT2xV2.c + + + compile + USI_TWI_Master.c + + + compile + OWDS2438_DS2438.S + + + compile + + + + \ No newline at end of file diff --git a/DS2438_SHT2X_DS2438_LPS225HB/DS2438_DS2438.c b/DS2438_SHT2X_DS2438_LPS225HB/DS2438_DS2438.c new file mode 100644 index 0000000..3e71e92 --- /dev/null +++ b/DS2438_SHT2X_DS2438_LPS225HB/DS2438_DS2438.c @@ -0,0 +1,282 @@ +// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +//!!!!!Max Program size 7551 Byte + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/USI_TWI_Master.h" +#include "../common/I2C/LPS225HB.h" +#include "../common/I2C/SHT2xV2.h" +#include "../common/calibr.h" + +extern void OWINIT(void); +extern void EXTERN_SLEEP(void); + + + +volatile uint8_t owid1[8]={0x26, 0x3B, 0xDA, 0x84, 0x00, 0x00, 0x03, 0xA2};/**/ +volatile uint8_t owid2[8]={0x26, 0x3C, 0xDA, 0x84, 0x00, 0x00, 0x03, 0x27};/**/ +volatile uint8_t config_info1[26]={0x02,23, 0x05,0x08, 0x2,20, 0x00,0x00, 0x02,29,0x00,29,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +volatile uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0,0, 0x02,0x07,0x00,0x07,0,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + +#if (owid>128) +#error "Variable not correct" +#endif + +extern uint8_t mode; +extern uint8_t gcontrol; +extern uint8_t reset_indicator; +extern uint8_t alarmflag; +volatile uint8_t wdcounter=1; + + +typedef union { + #if defined(__AVR_ATtiny25__) + volatile uint8_t bytes[16]; + #else + volatile uint8_t bytes[64]; + #endif + struct { + uint8_t status; //1 + int16_t temp; //2 + uint16_t voltage; //4 + int16_t current; //6 + uint8_t threshold; //8 + union { + uint8_t page1[8]; //9 + struct { + uint32_t etm; + uint8_t ica; + uint16_t offset; + uint8_t f1; + }; + }; + #if defined(__AVR_ATtiny25__) + #else + union { + uint8_t page2[8]; //17 + struct { + uint32_t dis; + uint32_t eoc; + }; + }; + + uint8_t page3[8]; //25 + + uint8_t page4[8]; //33 + uint8_t page5[8]; //41 + uint8_t page6[8]; //49 + uint8_t page7[8]; //57 + + #endif + }; +} pack1_t; +volatile pack1_t pack1; + + + + +typedef union { + #if defined(__AVR_ATtiny25__) + volatile uint8_t bytes[16]; + #else + volatile uint8_t bytes[64]; + #endif + struct { + uint8_t status; //1 + int16_t temp; //2 + uint16_t voltage; //4 + int16_t current; //6 + uint8_t threshold; //8 + + uint8_t page1[8]; //9 + #if defined(__AVR_ATtiny25__) + #else + uint8_t page2[8]; //17 + uint8_t page3[8]; //25 + + uint8_t page4[8]; //33 + uint8_t page5[8]; //41 + uint8_t page6[8]; //49 + uint8_t page7[8]; //57 + + #endif + }; +} pack2_t; +volatile pack2_t pack2; + + +#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) +ISR(WATCHDOG_vect) { +#else +ISR(WDT_vect) { +#endif + wdcounter++; + if (reset_indicator==1) reset_indicator++; + else if (reset_indicator==2) mode=0; +} + + + +volatile int16_t DS2438_1_TEMP; +volatile uint16_t DS2438_1_VAD; +volatile int16_t DS2438_2_TEMP; +volatile uint16_t DS2438_2_VAD; + + +uint8_t userRegister[1]; +int16_t sRH,sT; +double temperatureC,humidityRH,hhum; +double l; +uint32_t P; +int16_t t; + +int testSW(void) { + uint8_t r; + DDRB&=~(1<3) { + getSHT2xHumTemp(&temperatureC,&humidityRH); + double RH=calibr_hum(temperatureC,-0.2,humidityRH)*10.0; + double TC =temperatureC *10.0-2; + + + if (testSW()) { + DS2438_2_VAD=RH; + DS2438_2_TEMP=TC*25.6; + + config_info2[5]=12; //10V = 100% + }else{ + hhum=(1.0546-0.000216*TC)*(RH); + //am2302_hum=0.318*hhum +76.0; + DS2438_2_VAD=0.31*hhum +80; + DS2438_2_TEMP=TC*25.6; + config_info2[5]=7; + } + //DS2438_1_TEMP=DS2438_2_TEMP; + + LPS225HB_Readi(&t,&P) ; + P=P-700*(uint32_t)(4096); + P=((double)P/102.4); + //cli();pack.A=ADC;sei(); + //cli();DS2438_1_TEMP=P;sei(); + DS2438_1_TEMP=P; + P=P/20; + DS2438_1_VAD=P; + + // gcontrol=1; + wdcounter=0; + + } + + + + +#if defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) + if (((TIMSK & (1< + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + {7a5672fe-8226-4158-b931-e1f36b9a8858} + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS18B20_DS2438 + DS2438_SHT2X_DS2438_LPS225HB + DS18B20_DS2438 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + debugWIRE + + + + + + + + com.atmel.avrdbg.tool.simulator + + + Simulator + + + J41800000789 + 0x1E930C + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + True + + + libm + + + Default (-Wa,-g) + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + + + + + + compile + calibr.c + + + compile + LPS225HB.c + + + compile + SHT2xV2.c + + + compile + USI_TWI_Master.c + + + compile + OWDS2438_DS2438.S + + + compile + + + + \ No newline at end of file diff --git a/DS2438_SHT3X/DS2438_SHT3X.c b/DS2438_SHT3X/DS2438_SHT3X.c index d283508..a5b53e1 100644 --- a/DS2438_SHT3X/DS2438_SHT3X.c +++ b/DS2438_SHT3X/DS2438_SHT3X.c @@ -150,7 +150,8 @@ int main(void){ MCUSR=0; USI_TWI_Master_Initialise(); - + pack.page3[0]=0xF1; + initSHT3x(0); _delay_ms(100); @@ -188,6 +189,7 @@ int main(void){ if (((TIMSK0 & (1<true exception_table 2 - 1 + 0 @@ -42,87 +42,89 @@ + 125000 - debugWIRE + ISP com.atmel.avrdbg.tool.atmelice J41800000789 Atmel-ICE - debugWIRE + ISP J41800000789 0x1E930C + 125000 - -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" - True - True - True - True - False - True - True - - - __4MHZ__ - - - - - %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include - - - Optimize (-O1) - True - True - Default (-g2) - True - - - libm - - - Default (-Wa,-g) - + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + __4MHZ__ + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + - -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" - True - True - True - True - False - True - True - - - DEBUG - __4MHZ__ - - - - - %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include - - - Optimize (-O1) - True - True - Default (-g2) - True - - - libm - - - Default (-Wa,-g) - + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + __4MHZ__ + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + diff --git a/DS2450/DS2450.c b/DS2450/DS2450.c index e2fb6c3..0e92255 100644 --- a/DS2450/DS2450.c +++ b/DS2450/DS2450.c @@ -38,6 +38,7 @@ #include #include #include +#include "../common/I2C/TWI_Master.h" extern void OWINIT(); extern void EXTERN_SLEEP(); @@ -49,12 +50,25 @@ uint8_t config_info[26]={0x06,0x09,0x06,0x09,0x06,0x09,0x06,0x09,0x02,20,20,20,2 #error "Variable not correct" #endif -extern uint8_t mode; +extern volatile uint8_t mode; extern uint8_t gcontrol; extern uint8_t reset_indicator; extern uint8_t alarmflag; + +#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) +ISR(WATCHDOG_vect) { + #else + ISR(WDT_vect) { + // mode=0; + #endif + //wdcounter++; + if (reset_indicator==1) reset_indicator++; + else if (reset_indicator==2) mode=0; + } + + typedef union { volatile uint8_t bytes[0x20]; struct { @@ -99,8 +113,15 @@ typedef union { volatile pack_t pack; +#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) +#define AD_PORT PORTA +#define AD_DDR DDRA +#endif - +#if defined(__AVR_ATmega168__)||defined(__AVR_ATmega168A__) ||defined(__AVR_ATmega328__) ||defined(__AVR_ATmega328P__) ||defined(__AVR_ATmega328PB__) +#define AD_PORT PORTC +#define AD_DDR DDRC +#endif int main(void){ @@ -125,20 +146,31 @@ int main(void){ pack.HD=0xFF; pack.LD=0x00; pack.VCCP=0; + MCUCR &=~(1<7.0 com.Atmel.AVRGCC8.C dce6c7e3-ee26-4d79-826b-08594b9ad897 - ATtiny84A + ATmega328P none Executable C @@ -25,7 +25,7 @@ true exception_table 2 - 1 + 0 @@ -39,87 +39,106 @@ - + com.atmel.avrdbg.tool.atmelice + ISP + J41800000789 + 0x1E950F + + + + 125000 + + ISP + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + 125000 - -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" - True - True - True - True - False - True - True - - - NDEBUG - - - - - %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include - - - Optimize for size (-Os) - True - True - True - - - libm - - - - - %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include - - - + -mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\gcc\dev\atmega328p" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\include + + + - -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" - True - True - True - True - False - True - True - - - DEBUG - - - - - %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include - - - Optimize (-O1) - True - True - Default (-g2) - True - - - libm - - - - - %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include - - - Default (-Wa,-g) - + -mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\gcc\dev\atmega328p" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\include + + + Default (-Wa,-g) + + + compile + TWI_Master.c + compile diff --git a/DS2450/OWDS2450.S b/DS2450/OWDS2450.S index 61a1dad..a3381b4 100644 --- a/DS2450/OWDS2450.S +++ b/DS2450/OWDS2450.S @@ -33,8 +33,8 @@ #define _CHANGEABLE_ID_ #define _ZERO_POLLING_ -#define __4MHZ__ - +//#define __4MHZ__ +//#define _DB_ #include "../common/OWConfig.s" #include "../common/OWCRC16.s" @@ -140,9 +140,9 @@ h_readmemory_init_crc:; init erstes CRC byte ;ldi r_bcount,1 rjmp handle_end h_readmemory_end: - ldi r_mode,OW_SLEEP - clr r_sendflag - rjmp handle_end + //ldi r_mode,OW_SLEEP + //clr r_sendflag + rjmp handle_end_sleep h_readmemorycrc1:;init zweites CRC Byte lds r_rwbyte,crcsave ;ldi r_bcount,1 diff --git a/DS2450_ADC/DS2450.c b/DS2450_ADC/DS2450.c new file mode 100644 index 0000000..2dc7006 --- /dev/null +++ b/DS2450_ADC/DS2450.c @@ -0,0 +1,305 @@ + +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/owSlave_tools.h" + + +OWST_EXTERN_VARS + +uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/ +uint8_t config_info[26]={0x06,0x09,0x06,9,0x06,9,0x06,9,0x02,20,20,20,20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + +OWST_WDT_ISR + + +typedef union { + volatile uint8_t bytes[0x20]; + struct { + //Page0 + uint16_t A; //0 + uint16_t B; //2 + uint16_t C; //4 + uint16_t D; //6 + //Page1 + uint8_t CSA1; + uint8_t CSA2; + uint8_t CSB1; + uint8_t CSB2; + uint8_t CSC1; + uint8_t CSC2; + uint8_t CSD1; + uint8_t CSD2; + //Page2 + uint8_t LA; + uint8_t HA; + uint8_t LB; + uint8_t HB; + uint8_t LC; + uint8_t HC; + uint8_t LD; + uint8_t HD; + //Page3 + uint8_t FC1; + uint8_t FC2; + uint8_t FC3; + uint8_t FC4; + uint8_t VCCP; + uint8_t FC5; + uint8_t FC6; + uint8_t FC7; + uint8_t convc1; + uint8_t convc2; + + + }; +} pack_t; +volatile pack_t pack; + +OWST_ADC_CONF16_FUNC +OWST_ADC_CONF16_OSS_FUNC +OWST_TESTSW + +#define LPIN_CH2 (1<3) { + LED2_ON + wdcounter=0; + ADMUX=OWST_ADCIN_REFINT; + _delay_us(100); + VCC=owst_ADC_runf(); + VCC=(1.079*65472.0)/VCC; + //if (VCC>5.1) VCC=5.1; + //VAD=VCC*65535.0/5.1; + //if (VAD>65535) VAD=65535; + if (testSW()) { //Zwei differential Eingaenge + VAD_C=0; + ADMUX=0b001000; //ADC0 + ADC1 - Gain 1 + _delay_us(100); + VAD_A=owst_ADC_runf(); + if (VAD_A<3100) { + ADMUX=0b001001; //ADC0 + ADC1 - Gain 20 + _delay_us(100); + VAD_A=owst_ADC_runf(); + VAD_A=VCC/20.0*VAD_A/65472.0; + //VAD_A=VCC/20.0; + VAD_C+=12850; + } else { + VAD_A=owst_ADC_OSS_runf(); + VAD_A=VCC*VAD_A/65472.0; + VAD_C+=0; + } + if (pack.CSA2&0x01) VAD_A=VAD_A*65535.0/5.1; else VAD_A=VAD_A*65535.0/2.55; + if (VAD_A>65535) VAD_A=65535; + ///_------------------------ B--------------------- + ADMUX=0b011000; //ADC3 + ADC7 - Gain 1 + _delay_us(100); + VAD_B=owst_ADC_runf(); + if (VAD_B<3100) { + ADMUX=0b011001; //ADC3 + ADC7 - Gain 20 + _delay_us(100); + VAD_B=owst_ADC_runf(); + VAD_B=VCC/20.0*VAD_B/65472.0; + //VAD_B=VAD_B20.0; + VAD_C+=12850*2; + } else { + VAD_B=owst_ADC_OSS_runf(); + VAD_B=VCC*VAD_B/65472.0; + VAD_C+=0; + } + if (pack.CSB2&0x01) VAD_B=VAD_B*65535.0/5.1; else VAD_B=VAD_B*65535.0/2.55; + //VAD_B=VAD_B*65535.0/5.1; + if (VAD_B>65535) VAD_B=65535; + VAD_D=VCC*65535.0/5.1; + if (VAD_D>65535) VAD_D=65535; + + } else { // 4 Eingaenge gegen Masse + ADMUX=OWST_ADCIN_PA0; + _delay_us(100); + VAD_A=owst_ADC_OSS_runf(); + VAD_A=VCC*VAD_A/65472.0; + if (pack.CSA2&0x01) VAD_A=VAD_A*65535.0/5.1; else VAD_A=VAD_A*65535.0/2.55; + if (VAD_A>65535) VAD_A=65535; + + ADMUX=OWST_ADCIN_PA1; + _delay_us(100); + VAD_B=owst_ADC_OSS_runf(); + VAD_B=VCC*VAD_B/65472.0; + if (pack.CSB2&0x01) VAD_B=VAD_B*65535.0/5.1; else VAD_B=VAD_B*65535.0/2.55; + if (VAD_B>65535) VAD_B=65535; + + ADMUX=OWST_ADCIN_PA3; + _delay_us(100); + VAD_C=owst_ADC_OSS_runf(); + VAD_C=VCC*VAD_C/65472.0; + if (pack.CSC2&0x01) VAD_C=VAD_C*65535.0/5.1; else VAD_C=VAD_C*65535.0/2.55; + if (VAD_C>65535) VAD_C=65535; + + ADMUX=OWST_ADCIN_PA7; + _delay_us(100); + VAD_D=owst_ADC_OSS_runf(); + VAD_D=VCC*VAD_D/65472.0; + if (pack.CSD2&0x01) VAD_D=VAD_D*65535.0/5.1; else VAD_D=VAD_D*65535.0/2.55; + if (VAD_D>65535) VAD_D=65535; + } + LED2_OFF + + + } + + if (gcontrol) { + //PORTB|=(1<pack.HA) {alarmflag=1;pack.CSA2|=0x20;} + if (pack.CSA2&0x04) //AEL + if (pack.bytes[1]pack.HB) {alarmflag=1;pack.CSB2|=0x20;} + if (pack.CSB2&0x04) //AEL + if (pack.bytes[1]pack.HC) {alarmflag=1;pack.CSC2|=0x20;} + if (pack.CSC2&0x04) //AEL + if (pack.bytes[1]pack.HD) {alarmflag=1;pack.CSD2|=0x20;} + if (pack.CSD2&0x04) //AEL + if (pack.bytes[1] + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS2450 + DS2450_ADC + DS2450 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + debugWIRE + J41800000789 + 0x1E930C + + + + 125000 + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + 125000 + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include + + + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include + + + Default (-Wa,-g) + + + + + + compile + + + compile + + + + \ No newline at end of file diff --git a/DS2450_ADC/OWDS2450.S b/DS2450_ADC/OWDS2450.S new file mode 100644 index 0000000..a3381b4 --- /dev/null +++ b/DS2450_ADC/OWDS2450.S @@ -0,0 +1,248 @@ + +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define _CHANGEABLE_ID_ +#define _ZERO_POLLING_ +//#define __4MHZ__ +//#define _DB_ +#include "../common/OWConfig.s" +#include "../common/OWCRC16.s" + +.extern pack,8 +.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....) +.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte.... +//.extern am2302_temp,2 + + + +.macro CHIP_INIT +.endm + +.macro COMMAND_TABLE + rjmp h_readmemoryaddr + rjmp h_readmemory + rjmp h_readmemorycrc1 + rjmp h_readmemorycrc2 + rjmp h_writememoryaddr + rjmp h_writememory + rjmp h_writememorycrc1 + rjmp h_writememorycrc2 + rjmp h_writememoryreadback + rjmp h_convert + rjmp h_convertcrc1 + rjmp h_convertcrc2 + rjmp h_convert_conv +.endm + +#include "../common/OWRomFunctions.s" +#include "../common/OWTimerInterrupt.s" + + + +; Ab hier Geraeteabhaenging +#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0 +#define OW_READ_MEMORY OW_FIRST_COMMAND+1 +#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2 +#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3 +#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4 +#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5 +#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6 +#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7 +#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8 +#define OW_CONVERT OW_FIRST_COMMAND+9 +#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10 +#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11 +#define OW_CONVERT_CONV OW_FIRST_COMMAND+12 + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + + +h_readcommand: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cset 0xAA,OW_READ_MEMORY_ADDR + cset 0x55,OW_WRITE_MEMORY_ADDR + cset 0x3C,OW_CONVERT + FW_CONFIG_INFO +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + ldi r_mode,OW_SLEEP + rjmp handle_end + + +h_readmemoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_readmemory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + rjmp handle_end_inc +h_readmemory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory + ;;ldi r_bcount,1 ;ist unten + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + clr r_bytep + rjmp h_readmemory2 +h_readmemory: + lds r_bytep,addr + inc r_bytep + sts addr,r_bytep + andi r_bytep,0x07 + breq h_readmemory_init_crc +h_readmemory2: + lds r_bytep,addr + ;andi r_bytep,0x1F ist oben + configZ pack,r_bytep + ld r_rwbyte,Z + ;ldi r_bcount,1 + rjmp handle_end ;sendet das Byte und geht zu h_readmemory +h_readmemory_init_crc:; init erstes CRC byte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_READ_MEMORY_CRC1 + ;ldi r_bcount,1 + rjmp handle_end +h_readmemory_end: + //ldi r_mode,OW_SLEEP + //clr r_sendflag + rjmp handle_end_sleep +h_readmemorycrc1:;init zweites CRC Byte + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_READ_MEMORY_CRC2 + rjmp handle_end +h_readmemorycrc2:;weiteres senden..... nach zweitem Byte + lds r_temp,addr + andi r_temp,0xE0 + brne h_readmemory_end; ende des speichers + ldi r_mode,OW_READ_MEMORY + CRCInit1 ;Start with new CRC + rjmp h_readmemory2 + +h_writememoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_writememory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + inc r_bytep + ;ldi r_bcount,1 + rjmp handle_end +h_writememory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory + ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren..... + lds r_bytep,addr + rjmp handle_end ;read Memory Byte +h_writememory: + lds r_bytep,addr + configZ pack,r_bytep + st Z,r_rwbyte + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC1 + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + rjmp handle_end +h_writememorycrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC2 + rjmp handle_end +h_writememorycrc2: + lds r_temp,addr + configZ pack,r_temp + ld r_rwbyte,Z + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_READBACK + rjmp handle_end +h_writememoryreadback: + ldi r_temp,0x00 + sts crc+1,r_temp + lds r_temp,addr + inc r_temp + sts addr,r_temp + sts crc,r_temp + ldi r_sendflag,0 + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY + rjmp handle_end + +h_convert: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_convert_byte1 ;nein dann weiter + inc r_bytep + sts pack+0x20,r_rwbyte + ;ldi r_bcount,1 + rjmp handle_end +h_convert_byte1: ;zweies byte glesen go crc# + sts pack+0x21,r_rwbyte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_CONVERT_CRC1 + ;ldi r_bcount,1 + ldi r_sendflag,1 + rjmp handle_end +h_convertcrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CRC2 + rjmp handle_end +h_convertcrc2: + ldi r_temp,1 + sts gcontrol,r_temp + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CONV + ;clr r_sendflag + ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling +h_convert_conv: + ldi r_bcount,0 + ldi r_rwbyte,0 + rjmp handle_end_no_bcount + + + + +#include "../common/OWPinInterrupt.s" +.end \ No newline at end of file diff --git a/DS2450_ADC_JOE2/DS2450.c b/DS2450_ADC_JOE2/DS2450.c new file mode 100644 index 0000000..edf3076 --- /dev/null +++ b/DS2450_ADC_JOE2/DS2450.c @@ -0,0 +1,305 @@ + +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/owSlave_tools.h" + + +OWST_EXTERN_VARS + +uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/ +uint8_t config_info[26]={0x06,0x09,0x06,9,0x06,9,0x06,9,0x02,20,20,20,20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + +OWST_WDT_ISR + + +typedef union { + volatile uint8_t bytes[0x20]; + struct { + //Page0 + uint16_t A; //0 + uint16_t B; //2 + uint16_t C; //4 + uint16_t D; //6 + //Page1 + uint8_t CSA1; + uint8_t CSA2; + uint8_t CSB1; + uint8_t CSB2; + uint8_t CSC1; + uint8_t CSC2; + uint8_t CSD1; + uint8_t CSD2; + //Page2 + uint8_t LA; + uint8_t HA; + uint8_t LB; + uint8_t HB; + uint8_t LC; + uint8_t HC; + uint8_t LD; + uint8_t HD; + //Page3 + uint8_t FC1; + uint8_t FC2; + uint8_t FC3; + uint8_t FC4; + uint8_t VCCP; + uint8_t FC5; + uint8_t FC6; + uint8_t FC7; + uint8_t convc1; + uint8_t convc2; + + + }; +} pack_t; +volatile pack_t pack; + +OWST_ADC_CONF16_FUNC +OWST_ADC_CONF16_OSS_FUNC +OWST_TESTSW + +#define LPIN_CH2 (1<3) { + LED2_ON + wdcounter=0; + ADMUX=OWST_ADCIN_REFINT; + _delay_us(100); + VCC=owst_ADC_runf(); + VCC=(1.079*65472.0)/VCC; + //if (VCC>5.1) VCC=5.1; + //VAD=VCC*65535.0/5.1; + //if (VAD>65535) VAD=65535; + if (testSW()) { //Zwei differential Eingaenge + VAD_C=0; + ADMUX=0b0011010; //ADC4 + ADC5 - Gain 1 + _delay_us(100); + VAD_A=owst_ADC_runf(); + if (VAD_A<3100) { + ADMUX=0b0011011; //ADC0 + ADC1 - Gain 20 + _delay_us(100); + VAD_A=owst_ADC_runf(); + VAD_A=VCC/20.0*VAD_A/65472.0; + //VAD_A=VCC/20.0; + VAD_C+=12850; + } else { + VAD_A=owst_ADC_OSS_runf(); + VAD_A=VCC*VAD_A/65472.0; + VAD_C+=0; + } + if (pack.CSA2&0x01) VAD_A=VAD_A*65535.0/5.1; else VAD_A=VAD_A*65535.0/2.55; + if (VAD_A>65535) VAD_A=65535; + ///_------------------------ B--------------------- + ADMUX=0b011110; //ADC6 + ADC7 - Gain 1 + _delay_us(100); + VAD_B=owst_ADC_runf(); + if (VAD_B<3100) { + ADMUX=0b011111; //ADC6 + ADC7 - Gain 20 + _delay_us(100); + VAD_B=owst_ADC_runf(); + VAD_B=VCC/20.0*VAD_B/65472.0; + //VAD_B=VAD_B20.0; + VAD_C+=12850*2; + } else { + VAD_B=owst_ADC_OSS_runf(); + VAD_B=VCC*VAD_B/65472.0; + VAD_C+=0; + } + if (pack.CSB2&0x01) VAD_B=VAD_B*65535.0/5.1; else VAD_B=VAD_B*65535.0/2.55; + //VAD_B=VAD_B*65535.0/5.1; + if (VAD_B>65535) VAD_B=65535; + VAD_D=VCC*65535.0/5.1; + if (VAD_D>65535) VAD_D=65535; + + } else { // 4 Eingaenge gegen Masse + ADMUX=OWST_ADCIN_PA4; + _delay_us(100); + VAD_A=owst_ADC_OSS_runf(); + VAD_A=VCC*VAD_A/65472.0; + if (pack.CSA2&0x01) VAD_A=VAD_A*65535.0/5.1; else VAD_A=VAD_A*65535.0/2.55; + if (VAD_A>65535) VAD_A=65535; + + ADMUX=OWST_ADCIN_PA5; + _delay_us(100); + VAD_B=owst_ADC_OSS_runf(); + VAD_B=VCC*VAD_B/65472.0; + if (pack.CSB2&0x01) VAD_B=VAD_B*65535.0/5.1; else VAD_B=VAD_B*65535.0/2.55; + if (VAD_B>65535) VAD_B=65535; + + ADMUX=OWST_ADCIN_PA6; + _delay_us(100); + VAD_C=owst_ADC_OSS_runf(); + VAD_C=VCC*VAD_C/65472.0; + if (pack.CSC2&0x01) VAD_C=VAD_C*65535.0/5.1; else VAD_C=VAD_C*65535.0/2.55; + if (VAD_C>65535) VAD_C=65535; + + ADMUX=OWST_ADCIN_PA7; + _delay_us(100); + VAD_D=owst_ADC_OSS_runf(); + VAD_D=VCC*VAD_D/65472.0; + if (pack.CSD2&0x01) VAD_D=VAD_D*65535.0/5.1; else VAD_D=VAD_D*65535.0/2.55; + if (VAD_D>65535) VAD_D=65535; + } + LED2_OFF + + + } + + if (gcontrol) { + //PORTB|=(1<pack.HA) {alarmflag=1;pack.CSA2|=0x20;} + if (pack.CSA2&0x04) //AEL + if (pack.bytes[1]pack.HB) {alarmflag=1;pack.CSB2|=0x20;} + if (pack.CSB2&0x04) //AEL + if (pack.bytes[1]pack.HC) {alarmflag=1;pack.CSC2|=0x20;} + if (pack.CSC2&0x04) //AEL + if (pack.bytes[1]pack.HD) {alarmflag=1;pack.CSD2|=0x20;} + if (pack.CSD2&0x04) //AEL + if (pack.bytes[1] + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS2450 + DS2450_ADC_JOE2 + DS2450 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + debugWIRE + J41800000789 + 0x1E930C + + + + 125000 + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + 125000 + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include + + + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include + + + Default (-Wa,-g) + + + + + + compile + + + compile + + + + \ No newline at end of file diff --git a/DS2450_ADC_JOE2/OWDS2450.S b/DS2450_ADC_JOE2/OWDS2450.S new file mode 100644 index 0000000..a3381b4 --- /dev/null +++ b/DS2450_ADC_JOE2/OWDS2450.S @@ -0,0 +1,248 @@ + +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define _CHANGEABLE_ID_ +#define _ZERO_POLLING_ +//#define __4MHZ__ +//#define _DB_ +#include "../common/OWConfig.s" +#include "../common/OWCRC16.s" + +.extern pack,8 +.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....) +.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte.... +//.extern am2302_temp,2 + + + +.macro CHIP_INIT +.endm + +.macro COMMAND_TABLE + rjmp h_readmemoryaddr + rjmp h_readmemory + rjmp h_readmemorycrc1 + rjmp h_readmemorycrc2 + rjmp h_writememoryaddr + rjmp h_writememory + rjmp h_writememorycrc1 + rjmp h_writememorycrc2 + rjmp h_writememoryreadback + rjmp h_convert + rjmp h_convertcrc1 + rjmp h_convertcrc2 + rjmp h_convert_conv +.endm + +#include "../common/OWRomFunctions.s" +#include "../common/OWTimerInterrupt.s" + + + +; Ab hier Geraeteabhaenging +#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0 +#define OW_READ_MEMORY OW_FIRST_COMMAND+1 +#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2 +#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3 +#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4 +#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5 +#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6 +#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7 +#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8 +#define OW_CONVERT OW_FIRST_COMMAND+9 +#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10 +#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11 +#define OW_CONVERT_CONV OW_FIRST_COMMAND+12 + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + + +h_readcommand: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cset 0xAA,OW_READ_MEMORY_ADDR + cset 0x55,OW_WRITE_MEMORY_ADDR + cset 0x3C,OW_CONVERT + FW_CONFIG_INFO +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + ldi r_mode,OW_SLEEP + rjmp handle_end + + +h_readmemoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_readmemory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + rjmp handle_end_inc +h_readmemory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory + ;;ldi r_bcount,1 ;ist unten + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + clr r_bytep + rjmp h_readmemory2 +h_readmemory: + lds r_bytep,addr + inc r_bytep + sts addr,r_bytep + andi r_bytep,0x07 + breq h_readmemory_init_crc +h_readmemory2: + lds r_bytep,addr + ;andi r_bytep,0x1F ist oben + configZ pack,r_bytep + ld r_rwbyte,Z + ;ldi r_bcount,1 + rjmp handle_end ;sendet das Byte und geht zu h_readmemory +h_readmemory_init_crc:; init erstes CRC byte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_READ_MEMORY_CRC1 + ;ldi r_bcount,1 + rjmp handle_end +h_readmemory_end: + //ldi r_mode,OW_SLEEP + //clr r_sendflag + rjmp handle_end_sleep +h_readmemorycrc1:;init zweites CRC Byte + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_READ_MEMORY_CRC2 + rjmp handle_end +h_readmemorycrc2:;weiteres senden..... nach zweitem Byte + lds r_temp,addr + andi r_temp,0xE0 + brne h_readmemory_end; ende des speichers + ldi r_mode,OW_READ_MEMORY + CRCInit1 ;Start with new CRC + rjmp h_readmemory2 + +h_writememoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_writememory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + inc r_bytep + ;ldi r_bcount,1 + rjmp handle_end +h_writememory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory + ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren..... + lds r_bytep,addr + rjmp handle_end ;read Memory Byte +h_writememory: + lds r_bytep,addr + configZ pack,r_bytep + st Z,r_rwbyte + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC1 + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + rjmp handle_end +h_writememorycrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC2 + rjmp handle_end +h_writememorycrc2: + lds r_temp,addr + configZ pack,r_temp + ld r_rwbyte,Z + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_READBACK + rjmp handle_end +h_writememoryreadback: + ldi r_temp,0x00 + sts crc+1,r_temp + lds r_temp,addr + inc r_temp + sts addr,r_temp + sts crc,r_temp + ldi r_sendflag,0 + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY + rjmp handle_end + +h_convert: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_convert_byte1 ;nein dann weiter + inc r_bytep + sts pack+0x20,r_rwbyte + ;ldi r_bcount,1 + rjmp handle_end +h_convert_byte1: ;zweies byte glesen go crc# + sts pack+0x21,r_rwbyte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_CONVERT_CRC1 + ;ldi r_bcount,1 + ldi r_sendflag,1 + rjmp handle_end +h_convertcrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CRC2 + rjmp handle_end +h_convertcrc2: + ldi r_temp,1 + sts gcontrol,r_temp + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CONV + ;clr r_sendflag + ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling +h_convert_conv: + ldi r_bcount,0 + ldi r_rwbyte,0 + rjmp handle_end_no_bcount + + + + +#include "../common/OWPinInterrupt.s" +.end \ No newline at end of file diff --git a/DS2450_APDS9960/DS2450_APDS9960.atsln b/DS2450_APDS9960/DS2450_APDS9960.atsln index 06d2247..d6e53d6 100644 --- a/DS2450_APDS9960/DS2450_APDS9960.atsln +++ b/DS2450_APDS9960/DS2450_APDS9960.atsln @@ -1,22 +1,22 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Atmel Studio Solution File, Format Version 11.00 -VisualStudioVersion = 14.0.23107.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_APDS9960", "DS2450_APDS9960.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|AVR = Debug|AVR - Release|AVR = Release|AVR - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR - {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR - {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR - {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_APDS9960", "DS2450_APDS9960.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2450_APDS9960/DS2450_APDS9960.cproj b/DS2450_APDS9960/DS2450_APDS9960.cproj index 43e905b..aadfa77 100644 --- a/DS2450_APDS9960/DS2450_APDS9960.cproj +++ b/DS2450_APDS9960/DS2450_APDS9960.cproj @@ -1,152 +1,152 @@ - - - - 2.0 - 7.0 - com.Atmel.AVRGCC8.C - dce6c7e3-ee26-4d79-826b-08594b9ad897 - ATtiny84A - none - Executable - C - $(MSBuildProjectName) - .elf - $(MSBuildProjectDirectory)\$(Configuration) - DS2450 - DS2450_APDS9960 - DS2450 - Native - true - false - true - true - 0x20000000 - - true - exception_table - 2 - 1 - - - - - - - - - - - - - - com.atmel.avrdbg.tool.atmelice - J41800000789 - 0x1E930C - - - - - debugWIRE - - com.atmel.avrdbg.tool.atmelice - J41800000789 - Atmel-ICE - - debugWIRE - - - - - -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" - True - True - True - True - False - True - True - - - NDEBUG - - - - - %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include - - - Optimize for size (-Os) - True - True - True - - - libm - - - - - %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include - - - - - - - - - -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" - True - True - True - True - False - True - True - - - DEBUG - - - - - %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include - - - Optimize (-O1) - True - True - Default (-g2) - True - - - libm - - - - - %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include - - - Default (-Wa,-g) - - - - - - compile - APDS9960.c - - - compile - USI_TWI_Master.c - - - compile - - - compile - - - + + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS2450 + DS2450_APDS9960 + DS2450 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + J41800000789 + 0x1E930C + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + debugWIRE + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Default (-Wa,-g) + + + + + + compile + APDS9960.c + + + compile + USI_TWI_Master.c + + + compile + + + compile + + + \ No newline at end of file diff --git a/DS2450_APDS9960/OWDS2450.S b/DS2450_APDS9960/OWDS2450.S new file mode 100644 index 0000000..61a1dad --- /dev/null +++ b/DS2450_APDS9960/OWDS2450.S @@ -0,0 +1,248 @@ + +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define _CHANGEABLE_ID_ +#define _ZERO_POLLING_ +#define __4MHZ__ + +#include "../common/OWConfig.s" +#include "../common/OWCRC16.s" + +.extern pack,8 +.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....) +.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte.... +//.extern am2302_temp,2 + + + +.macro CHIP_INIT +.endm + +.macro COMMAND_TABLE + rjmp h_readmemoryaddr + rjmp h_readmemory + rjmp h_readmemorycrc1 + rjmp h_readmemorycrc2 + rjmp h_writememoryaddr + rjmp h_writememory + rjmp h_writememorycrc1 + rjmp h_writememorycrc2 + rjmp h_writememoryreadback + rjmp h_convert + rjmp h_convertcrc1 + rjmp h_convertcrc2 + rjmp h_convert_conv +.endm + +#include "../common/OWRomFunctions.s" +#include "../common/OWTimerInterrupt.s" + + + +; Ab hier Geraeteabhaenging +#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0 +#define OW_READ_MEMORY OW_FIRST_COMMAND+1 +#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2 +#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3 +#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4 +#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5 +#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6 +#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7 +#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8 +#define OW_CONVERT OW_FIRST_COMMAND+9 +#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10 +#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11 +#define OW_CONVERT_CONV OW_FIRST_COMMAND+12 + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + + +h_readcommand: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cset 0xAA,OW_READ_MEMORY_ADDR + cset 0x55,OW_WRITE_MEMORY_ADDR + cset 0x3C,OW_CONVERT + FW_CONFIG_INFO +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + ldi r_mode,OW_SLEEP + rjmp handle_end + + +h_readmemoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_readmemory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + rjmp handle_end_inc +h_readmemory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory + ;;ldi r_bcount,1 ;ist unten + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + clr r_bytep + rjmp h_readmemory2 +h_readmemory: + lds r_bytep,addr + inc r_bytep + sts addr,r_bytep + andi r_bytep,0x07 + breq h_readmemory_init_crc +h_readmemory2: + lds r_bytep,addr + ;andi r_bytep,0x1F ist oben + configZ pack,r_bytep + ld r_rwbyte,Z + ;ldi r_bcount,1 + rjmp handle_end ;sendet das Byte und geht zu h_readmemory +h_readmemory_init_crc:; init erstes CRC byte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_READ_MEMORY_CRC1 + ;ldi r_bcount,1 + rjmp handle_end +h_readmemory_end: + ldi r_mode,OW_SLEEP + clr r_sendflag + rjmp handle_end +h_readmemorycrc1:;init zweites CRC Byte + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_READ_MEMORY_CRC2 + rjmp handle_end +h_readmemorycrc2:;weiteres senden..... nach zweitem Byte + lds r_temp,addr + andi r_temp,0xE0 + brne h_readmemory_end; ende des speichers + ldi r_mode,OW_READ_MEMORY + CRCInit1 ;Start with new CRC + rjmp h_readmemory2 + +h_writememoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_writememory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + inc r_bytep + ;ldi r_bcount,1 + rjmp handle_end +h_writememory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory + ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren..... + lds r_bytep,addr + rjmp handle_end ;read Memory Byte +h_writememory: + lds r_bytep,addr + configZ pack,r_bytep + st Z,r_rwbyte + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC1 + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + rjmp handle_end +h_writememorycrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC2 + rjmp handle_end +h_writememorycrc2: + lds r_temp,addr + configZ pack,r_temp + ld r_rwbyte,Z + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_READBACK + rjmp handle_end +h_writememoryreadback: + ldi r_temp,0x00 + sts crc+1,r_temp + lds r_temp,addr + inc r_temp + sts addr,r_temp + sts crc,r_temp + ldi r_sendflag,0 + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY + rjmp handle_end + +h_convert: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_convert_byte1 ;nein dann weiter + inc r_bytep + sts pack+0x20,r_rwbyte + ;ldi r_bcount,1 + rjmp handle_end +h_convert_byte1: ;zweies byte glesen go crc# + sts pack+0x21,r_rwbyte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_CONVERT_CRC1 + ;ldi r_bcount,1 + ldi r_sendflag,1 + rjmp handle_end +h_convertcrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CRC2 + rjmp handle_end +h_convertcrc2: + ldi r_temp,1 + sts gcontrol,r_temp + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CONV + ;clr r_sendflag + ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling +h_convert_conv: + ldi r_bcount,0 + ldi r_rwbyte,0 + rjmp handle_end_no_bcount + + + + +#include "../common/OWPinInterrupt.s" +.end \ No newline at end of file diff --git a/DS2450_BME680/DS2450_BME680.atsln b/DS2450_BME680/DS2450_BME680.atsln new file mode 100644 index 0000000..0c0f0c7 --- /dev/null +++ b/DS2450_BME680/DS2450_BME680.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_BME680", "DS2450_BME680.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2450_BME680/DS2450_BME680.c b/DS2450_BME680/DS2450_BME680.c new file mode 100644 index 0000000..c93bd56 --- /dev/null +++ b/DS2450_BME680/DS2450_BME680.c @@ -0,0 +1,272 @@ + +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/TWI_Master.h" +#include "../common/I2C/BME680.h" + +extern void OWINIT(); +extern void EXTERN_SLEEP(); + +uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x23, 0x20};/**/ +//uint8_t config_info[26]={0x03,13,0x03,13,0x03,13,0x3,15,0x02,20,20,20,20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +//uint8_t config_info[26]={1,14,4,8,2,8,11,18,0x02,24,24,24,24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +uint8_t config_info[26]={1,13,4,13,2,8,11,8,0x02,24,24,24,24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + + +#if (owid>128) +#error "Variable not correct" +#endif + +extern uint8_t mode; +extern uint8_t gcontrol; +extern uint8_t reset_indicator; +extern uint8_t alarmflag; +volatile uint8_t wdcounter=10; + + +#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) +ISR(WATCHDOG_vect) { + #else + ISR(WDT_vect) { + #endif + wdcounter++; + // if (reset_indicator==1) reset_indicator++; + //else if (reset_indicator==2) mode=0; + } + +typedef union { + volatile uint8_t bytes[0x22]; + struct { + //Page0 + uint16_t A; //0 + uint16_t B; //2 + uint16_t C; //4 + uint16_t D; //6 + //Page1 + uint8_t CSA1; + uint8_t CSA2; + uint8_t CSB1; + uint8_t CSB2; + uint8_t CSC1; + uint8_t CSC2; + uint8_t CSD1; + uint8_t CSD2; + //Page2 + uint8_t LA; + uint8_t HA; + uint8_t LB; + uint8_t HB; + uint8_t LC; + uint8_t HC; + uint8_t LD; + uint8_t HD; + //Page3 + uint8_t FC1; + uint8_t FC2; + uint8_t FC3; + uint8_t FC4; + uint8_t VCCP; + uint8_t FC5; + uint8_t FC6; + uint8_t FC7; + uint8_t convc1; + uint8_t convc2; + + + }; +} pack_t; +volatile pack_t pack; + + +int16_t T; +uint16_t H; +uint32_t P; +uint16_t G; + + +int main(void){ + pack.A=0; + pack.B=0; + pack.C=0; + pack.D=0; + pack.CSA1=0x08; + pack.CSA2=0x8C; + pack.CSB1=0x08; + pack.CSB2=0x8C; + pack.CSC1=0x08; + pack.CSC2=0x8C; + pack.CSD1=0x08; + pack.CSD2=0x8C; + pack.HA=0xFF; + pack.LA=0x00; + pack.HB=0xFF; + pack.LB=0x00; + pack.HC=0xFF; + pack.LC=0x00; + pack.HD=0xFF; + pack.LD=0x00; + pack.VCCP=0; + + PORTA=0xFF; + //PORTB=0xFF; + //PORTC=0xFF; +// PORTD=0xFF; + + OWINIT(); + + MCUCR &=~(1<1) { + readBMP680(&T,&H,&P,&G); + wdcounter=0; + } + + if (gcontrol) { + //PORTB|=(1<pack.HA) {alarmflag=1;pack.CSA2|=0x20;} + if (pack.CSA2&0x04) //AEL + if (pack.bytes[1]pack.HB) {alarmflag=1;pack.CSB2|=0x20;} + if (pack.CSB2&0x04) //AEL + if (pack.bytes[1]pack.HC) {alarmflag=1;pack.CSC2|=0x20;} + if (pack.CSC2&0x04) //AEL + if (pack.bytes[1]pack.HD) {alarmflag=1;pack.CSD2|=0x20;} + if (pack.CSD2&0x04) //AEL + if (pack.bytes[1] + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS2450 + DS2450_BME680 + DS2450 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 0 + + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + J41800000789 + 0x1E930C + + + + 125000 + + ISP + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + ISP + 125000 + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include + + + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include + + + Default (-Wa,-g) + + + + + + compile + BME680.c + + + compile + TWI_Master.c + + + compile + + + compile + + + + \ No newline at end of file diff --git a/DS2450_BME680/OWDS2450.S b/DS2450_BME680/OWDS2450.S new file mode 100644 index 0000000..61a1dad --- /dev/null +++ b/DS2450_BME680/OWDS2450.S @@ -0,0 +1,248 @@ + +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define _CHANGEABLE_ID_ +#define _ZERO_POLLING_ +#define __4MHZ__ + +#include "../common/OWConfig.s" +#include "../common/OWCRC16.s" + +.extern pack,8 +.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....) +.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte.... +//.extern am2302_temp,2 + + + +.macro CHIP_INIT +.endm + +.macro COMMAND_TABLE + rjmp h_readmemoryaddr + rjmp h_readmemory + rjmp h_readmemorycrc1 + rjmp h_readmemorycrc2 + rjmp h_writememoryaddr + rjmp h_writememory + rjmp h_writememorycrc1 + rjmp h_writememorycrc2 + rjmp h_writememoryreadback + rjmp h_convert + rjmp h_convertcrc1 + rjmp h_convertcrc2 + rjmp h_convert_conv +.endm + +#include "../common/OWRomFunctions.s" +#include "../common/OWTimerInterrupt.s" + + + +; Ab hier Geraeteabhaenging +#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0 +#define OW_READ_MEMORY OW_FIRST_COMMAND+1 +#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2 +#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3 +#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4 +#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5 +#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6 +#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7 +#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8 +#define OW_CONVERT OW_FIRST_COMMAND+9 +#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10 +#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11 +#define OW_CONVERT_CONV OW_FIRST_COMMAND+12 + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + + +h_readcommand: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cset 0xAA,OW_READ_MEMORY_ADDR + cset 0x55,OW_WRITE_MEMORY_ADDR + cset 0x3C,OW_CONVERT + FW_CONFIG_INFO +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + ldi r_mode,OW_SLEEP + rjmp handle_end + + +h_readmemoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_readmemory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + rjmp handle_end_inc +h_readmemory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory + ;;ldi r_bcount,1 ;ist unten + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + clr r_bytep + rjmp h_readmemory2 +h_readmemory: + lds r_bytep,addr + inc r_bytep + sts addr,r_bytep + andi r_bytep,0x07 + breq h_readmemory_init_crc +h_readmemory2: + lds r_bytep,addr + ;andi r_bytep,0x1F ist oben + configZ pack,r_bytep + ld r_rwbyte,Z + ;ldi r_bcount,1 + rjmp handle_end ;sendet das Byte und geht zu h_readmemory +h_readmemory_init_crc:; init erstes CRC byte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_READ_MEMORY_CRC1 + ;ldi r_bcount,1 + rjmp handle_end +h_readmemory_end: + ldi r_mode,OW_SLEEP + clr r_sendflag + rjmp handle_end +h_readmemorycrc1:;init zweites CRC Byte + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_READ_MEMORY_CRC2 + rjmp handle_end +h_readmemorycrc2:;weiteres senden..... nach zweitem Byte + lds r_temp,addr + andi r_temp,0xE0 + brne h_readmemory_end; ende des speichers + ldi r_mode,OW_READ_MEMORY + CRCInit1 ;Start with new CRC + rjmp h_readmemory2 + +h_writememoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_writememory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + inc r_bytep + ;ldi r_bcount,1 + rjmp handle_end +h_writememory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory + ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren..... + lds r_bytep,addr + rjmp handle_end ;read Memory Byte +h_writememory: + lds r_bytep,addr + configZ pack,r_bytep + st Z,r_rwbyte + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC1 + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + rjmp handle_end +h_writememorycrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC2 + rjmp handle_end +h_writememorycrc2: + lds r_temp,addr + configZ pack,r_temp + ld r_rwbyte,Z + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_READBACK + rjmp handle_end +h_writememoryreadback: + ldi r_temp,0x00 + sts crc+1,r_temp + lds r_temp,addr + inc r_temp + sts addr,r_temp + sts crc,r_temp + ldi r_sendflag,0 + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY + rjmp handle_end + +h_convert: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_convert_byte1 ;nein dann weiter + inc r_bytep + sts pack+0x20,r_rwbyte + ;ldi r_bcount,1 + rjmp handle_end +h_convert_byte1: ;zweies byte glesen go crc# + sts pack+0x21,r_rwbyte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_CONVERT_CRC1 + ;ldi r_bcount,1 + ldi r_sendflag,1 + rjmp handle_end +h_convertcrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CRC2 + rjmp handle_end +h_convertcrc2: + ldi r_temp,1 + sts gcontrol,r_temp + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CONV + ;clr r_sendflag + ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling +h_convert_conv: + ldi r_bcount,0 + ldi r_rwbyte,0 + rjmp handle_end_no_bcount + + + + +#include "../common/OWPinInterrupt.s" +.end \ No newline at end of file diff --git a/DS2450_BMP280/OWDS2450.S b/DS2450_BMP280/OWDS2450.S new file mode 100644 index 0000000..1d81abd --- /dev/null +++ b/DS2450_BMP280/OWDS2450.S @@ -0,0 +1,247 @@ + +// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define _CHANGEABLE_ID_ +#define _ZERO_POLLING_ + +#include "../common/OWConfig.s" +#include "../common/OWCRC16.s" + +.extern pack,8 +.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....) +.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte.... +//.extern am2302_temp,2 + + + +.macro CHIP_INIT +.endm + +.macro COMMAND_TABLE + rjmp h_readmemoryaddr + rjmp h_readmemory + rjmp h_readmemorycrc1 + rjmp h_readmemorycrc2 + rjmp h_writememoryaddr + rjmp h_writememory + rjmp h_writememorycrc1 + rjmp h_writememorycrc2 + rjmp h_writememoryreadback + rjmp h_convert + rjmp h_convertcrc1 + rjmp h_convertcrc2 + rjmp h_convert_conv +.endm + +#include "../common/OWRomFunctions.s" +#include "../common/OWTimerInterrupt.s" + + + +; Ab hier Geraeteabhaenging +#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0 +#define OW_READ_MEMORY OW_FIRST_COMMAND+1 +#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2 +#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3 +#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4 +#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5 +#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6 +#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7 +#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8 +#define OW_CONVERT OW_FIRST_COMMAND+9 +#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10 +#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11 +#define OW_CONVERT_CONV OW_FIRST_COMMAND+12 + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + + +h_readcommand: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cset 0xAA,OW_READ_MEMORY_ADDR + cset 0x55,OW_WRITE_MEMORY_ADDR + cset 0x3C,OW_CONVERT + FW_CONFIG_INFO +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + ldi r_mode,OW_SLEEP + rjmp handle_end + + +h_readmemoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_readmemory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + rjmp handle_end_inc +h_readmemory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory + ;;ldi r_bcount,1 ;ist unten + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + clr r_bytep + rjmp h_readmemory2 +h_readmemory: + lds r_bytep,addr + inc r_bytep + sts addr,r_bytep + andi r_bytep,0x07 + breq h_readmemory_init_crc +h_readmemory2: + lds r_bytep,addr + ;andi r_bytep,0x1F ist oben + configZ pack,r_bytep + ld r_rwbyte,Z + ;ldi r_bcount,1 + rjmp handle_end ;sendet das Byte und geht zu h_readmemory +h_readmemory_init_crc:; init erstes CRC byte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_READ_MEMORY_CRC1 + ;ldi r_bcount,1 + rjmp handle_end +h_readmemory_end: + ldi r_mode,OW_SLEEP + clr r_sendflag + rjmp handle_end +h_readmemorycrc1:;init zweites CRC Byte + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_READ_MEMORY_CRC2 + rjmp handle_end +h_readmemorycrc2:;weiteres senden..... nach zweitem Byte + lds r_temp,addr + andi r_temp,0xE0 + brne h_readmemory_end; ende des speichers + ldi r_mode,OW_READ_MEMORY + CRCInit1 ;Start with new CRC + rjmp h_readmemory2 + +h_writememoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_writememory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + inc r_bytep + ;ldi r_bcount,1 + rjmp handle_end +h_writememory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory + ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren..... + lds r_bytep,addr + rjmp handle_end ;read Memory Byte +h_writememory: + lds r_bytep,addr + configZ pack,r_bytep + st Z,r_rwbyte + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC1 + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + rjmp handle_end +h_writememorycrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC2 + rjmp handle_end +h_writememorycrc2: + lds r_temp,addr + configZ pack,r_temp + ld r_rwbyte,Z + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_READBACK + rjmp handle_end +h_writememoryreadback: + ldi r_temp,0x00 + sts crc+1,r_temp + lds r_temp,addr + inc r_temp + sts addr,r_temp + sts crc,r_temp + ldi r_sendflag,0 + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY + rjmp handle_end + +h_convert: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_convert_byte1 ;nein dann weiter + inc r_bytep + sts pack+0x20,r_rwbyte + ;ldi r_bcount,1 + rjmp handle_end +h_convert_byte1: ;zweies byte glesen go crc# + sts pack+0x21,r_rwbyte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_CONVERT_CRC1 + ;ldi r_bcount,1 + ldi r_sendflag,1 + rjmp handle_end +h_convertcrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CRC2 + rjmp handle_end +h_convertcrc2: + ldi r_temp,1 + sts gcontrol,r_temp + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CONV + ;clr r_sendflag + ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling +h_convert_conv: + ldi r_bcount,0 + ldi r_rwbyte,0 + rjmp handle_end_no_bcount + + + + +#include "../common/OWPinInterrupt.s" +.end \ No newline at end of file diff --git a/DS2450_CDM7160/DS2450_CDM7160.atsln b/DS2450_CDM7160/DS2450_CDM7160.atsln new file mode 100644 index 0000000..6ee8119 --- /dev/null +++ b/DS2450_CDM7160/DS2450_CDM7160.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_CDM7160", "DS2450_CDM7160.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2450_CDM7160/DS2450_CDM7160.c b/DS2450_CDM7160/DS2450_CDM7160.c new file mode 100644 index 0000000..f69e8b4 --- /dev/null +++ b/DS2450_CDM7160/DS2450_CDM7160.c @@ -0,0 +1,280 @@ +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/USI_TWI_Master.h" +#include "../common/I2C/CDM7160.h" +extern void OWINIT(); +extern void EXTERN_SLEEP(); +//6A02160084D9A320 +//uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/ +uint8_t owid[8]={0x20, 0xB3, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x31};/**/ +uint8_t config_info[26]={0x10,13,0x0,0x0, 0,0, 0,0,0x02,16,0,0x00,0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +#if (owid>128) +#error "Variable not correct" +#endif + +extern uint8_t mode; +extern uint8_t gcontrol; +extern uint8_t reset_indicator; +extern uint8_t alarmflag; +volatile uint8_t wdcounter=10; + + +#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) +ISR(WATCHDOG_vect) { +#else +ISR(WDT_vect) { +#endif + wdcounter++; + if (reset_indicator==1) reset_indicator++; + else if (reset_indicator==2) mode=0; +} + +typedef union { + volatile uint8_t bytes[0x20]; + struct { + //Page0 + uint16_t A; //0 + uint16_t B; //2 + uint16_t C; //4 + uint16_t D; //6 + //Page1 + uint8_t CSA1; + uint8_t CSA2; + uint8_t CSB1; + uint8_t CSB2; + uint8_t CSC1; + uint8_t CSC2; + uint8_t CSD1; + uint8_t CSD2; + //Page2 + uint8_t LA; + uint8_t HA; + uint8_t LB; + uint8_t HB; + uint8_t LC; + uint8_t HC; + uint8_t LD; + uint8_t HD; + //Page3 + uint8_t FC1; + uint8_t FC2; + uint8_t FC3; + uint8_t FC4; + uint8_t VCCP; + uint8_t FC5; + uint8_t FC6; + uint8_t FC7; + uint8_t convc1; + uint8_t convc2; + + + }; +} pack_t; +volatile pack_t pack; + + + + +uint16_t CO2; + + + + + +int main(void){ + pack.A=0; + pack.B=0; + pack.C=0; + pack.D=0; + pack.CSA1=0x08; + pack.CSA2=0x8C; + pack.CSB1=0x08; + pack.CSB2=0x8C; + pack.CSC1=0x08; + pack.CSC2=0x8C; + pack.CSD1=0x08; + pack.CSD2=0x8C; + pack.HA=0xFF; + pack.LA=0x00; + pack.HB=0xFF; + pack.LB=0x00; + pack.HC=0xFF; + pack.LC=0x00; + pack.HD=0xFF; + pack.LD=0x00; + pack.VCCP=0; + PORTB=0xFF-(1<2) { + + CO2=CDM7160getCO2(); + + wdcounter=0; + } + + + + + + + if (gcontrol) { + //PORTB|=(1<pack.HA) {alarmflag=1;pack.CSA2|=0x20;} + if (pack.CSA2&0x04) //AEL + if (pack.bytes[1]pack.HB) {alarmflag=1;pack.CSB2|=0x20;} + if (pack.CSB2&0x04) //AEL + if (pack.bytes[1]pack.HC) {alarmflag=1;pack.CSC2|=0x20;} + if (pack.CSC2&0x04) //AEL + if (pack.bytes[1]pack.HD) {alarmflag=1;pack.CSD2|=0x20;} + if (pack.CSD2&0x04) //AEL + if (pack.bytes[1] + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS2450 + DS2450_CDM7160 + DS2450 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + J41800000779 + 0x1E930C + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000779 + Atmel-ICE + + debugWIRE + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize for size (-Os) + True + True + True + -std=gnu99 -D__4MHZ__ + + + libm + + + -D__4MHZ__ + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + + + + + + compile + CDM7160.c + + + compile + USI_TWI_Master.c + + + compile + OWDS2450.S + + + compile + + + + \ No newline at end of file diff --git a/DS2450_CDM7160/OWDS2450.S b/DS2450_CDM7160/OWDS2450.S new file mode 100644 index 0000000..1d81abd --- /dev/null +++ b/DS2450_CDM7160/OWDS2450.S @@ -0,0 +1,247 @@ + +// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define _CHANGEABLE_ID_ +#define _ZERO_POLLING_ + +#include "../common/OWConfig.s" +#include "../common/OWCRC16.s" + +.extern pack,8 +.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....) +.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte.... +//.extern am2302_temp,2 + + + +.macro CHIP_INIT +.endm + +.macro COMMAND_TABLE + rjmp h_readmemoryaddr + rjmp h_readmemory + rjmp h_readmemorycrc1 + rjmp h_readmemorycrc2 + rjmp h_writememoryaddr + rjmp h_writememory + rjmp h_writememorycrc1 + rjmp h_writememorycrc2 + rjmp h_writememoryreadback + rjmp h_convert + rjmp h_convertcrc1 + rjmp h_convertcrc2 + rjmp h_convert_conv +.endm + +#include "../common/OWRomFunctions.s" +#include "../common/OWTimerInterrupt.s" + + + +; Ab hier Geraeteabhaenging +#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0 +#define OW_READ_MEMORY OW_FIRST_COMMAND+1 +#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2 +#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3 +#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4 +#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5 +#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6 +#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7 +#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8 +#define OW_CONVERT OW_FIRST_COMMAND+9 +#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10 +#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11 +#define OW_CONVERT_CONV OW_FIRST_COMMAND+12 + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + + +h_readcommand: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cset 0xAA,OW_READ_MEMORY_ADDR + cset 0x55,OW_WRITE_MEMORY_ADDR + cset 0x3C,OW_CONVERT + FW_CONFIG_INFO +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + ldi r_mode,OW_SLEEP + rjmp handle_end + + +h_readmemoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_readmemory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + rjmp handle_end_inc +h_readmemory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory + ;;ldi r_bcount,1 ;ist unten + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + clr r_bytep + rjmp h_readmemory2 +h_readmemory: + lds r_bytep,addr + inc r_bytep + sts addr,r_bytep + andi r_bytep,0x07 + breq h_readmemory_init_crc +h_readmemory2: + lds r_bytep,addr + ;andi r_bytep,0x1F ist oben + configZ pack,r_bytep + ld r_rwbyte,Z + ;ldi r_bcount,1 + rjmp handle_end ;sendet das Byte und geht zu h_readmemory +h_readmemory_init_crc:; init erstes CRC byte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_READ_MEMORY_CRC1 + ;ldi r_bcount,1 + rjmp handle_end +h_readmemory_end: + ldi r_mode,OW_SLEEP + clr r_sendflag + rjmp handle_end +h_readmemorycrc1:;init zweites CRC Byte + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_READ_MEMORY_CRC2 + rjmp handle_end +h_readmemorycrc2:;weiteres senden..... nach zweitem Byte + lds r_temp,addr + andi r_temp,0xE0 + brne h_readmemory_end; ende des speichers + ldi r_mode,OW_READ_MEMORY + CRCInit1 ;Start with new CRC + rjmp h_readmemory2 + +h_writememoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_writememory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + inc r_bytep + ;ldi r_bcount,1 + rjmp handle_end +h_writememory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory + ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren..... + lds r_bytep,addr + rjmp handle_end ;read Memory Byte +h_writememory: + lds r_bytep,addr + configZ pack,r_bytep + st Z,r_rwbyte + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC1 + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + rjmp handle_end +h_writememorycrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC2 + rjmp handle_end +h_writememorycrc2: + lds r_temp,addr + configZ pack,r_temp + ld r_rwbyte,Z + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_READBACK + rjmp handle_end +h_writememoryreadback: + ldi r_temp,0x00 + sts crc+1,r_temp + lds r_temp,addr + inc r_temp + sts addr,r_temp + sts crc,r_temp + ldi r_sendflag,0 + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY + rjmp handle_end + +h_convert: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_convert_byte1 ;nein dann weiter + inc r_bytep + sts pack+0x20,r_rwbyte + ;ldi r_bcount,1 + rjmp handle_end +h_convert_byte1: ;zweies byte glesen go crc# + sts pack+0x21,r_rwbyte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_CONVERT_CRC1 + ;ldi r_bcount,1 + ldi r_sendflag,1 + rjmp handle_end +h_convertcrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CRC2 + rjmp handle_end +h_convertcrc2: + ldi r_temp,1 + sts gcontrol,r_temp + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CONV + ;clr r_sendflag + ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling +h_convert_conv: + ldi r_bcount,0 + ldi r_rwbyte,0 + rjmp handle_end_no_bcount + + + + +#include "../common/OWPinInterrupt.s" +.end \ No newline at end of file diff --git a/DS2450_CDM7160_BMP280/DS2450_CDM7160_BMP280.atsln b/DS2450_CDM7160_BMP280/DS2450_CDM7160_BMP280.atsln new file mode 100644 index 0000000..8e5ac3e --- /dev/null +++ b/DS2450_CDM7160_BMP280/DS2450_CDM7160_BMP280.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_CDM7160_BMP280", "DS2450_CDM7160_BMP280.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2450_CDM7160_BMP280/DS2450_CDM7160_BMP280.c b/DS2450_CDM7160_BMP280/DS2450_CDM7160_BMP280.c new file mode 100644 index 0000000..204aa20 --- /dev/null +++ b/DS2450_CDM7160_BMP280/DS2450_CDM7160_BMP280.c @@ -0,0 +1,272 @@ + +// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/TWI_Master.h" +#include "../common/I2C/CDM7160.h" +#include "../common/I2C/BMP280.h" +#include "../common/owSlave_tools.h" + +OWST_EXTERN_VARS + +uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/ +uint8_t config_info[26]={10,13,10,13, 2,16, 1,14,0x02,16,16,14,14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + +#if (owid>128) +#error "Variable not correct" +#endif + +OWST_WDT_ISR + + +typedef union { + volatile uint8_t bytes[0x20]; + struct { + //Page0 + uint16_t A; //0 + uint16_t B; //2 + uint16_t C; //4 + uint16_t D; //6 + //Page1 + uint8_t CSA1; + uint8_t CSA2; + uint8_t CSB1; + uint8_t CSB2; + uint8_t CSC1; + uint8_t CSC2; + uint8_t CSD1; + uint8_t CSD2; + //Page2 + uint8_t LA; + uint8_t HA; + uint8_t LB; + uint8_t HB; + uint8_t LC; + uint8_t HC; + uint8_t LD; + uint8_t HD; + //Page3 + uint8_t FC1; + uint8_t FC2; + uint8_t FC3; + uint8_t FC4; + uint8_t VCCP; + uint8_t FC5; + uint8_t FC6; + uint8_t FC7; + uint8_t convc1; + uint8_t convc2; + + + }; +} pack_t; +volatile pack_t pack; + + + + + + double temperatureC,humidityRH; + double l; +uint32_t P; +int32_t t; +int16_t CO2; +uint8_t max_adr=0; + + + +int main(void){ + OWST_INIT_USI_ON + pack.A=0; + pack.B=0; + pack.C=0; + pack.D=0; + pack.CSA1=0x08; + pack.CSA2=0x8C; + pack.CSB1=0x08; + pack.CSB2=0x8C; + pack.CSC1=0x08; + pack.CSC2=0x8C; + pack.CSD1=0x08; + pack.CSD2=0x8C; + pack.HA=0xFF; + pack.LA=0x00; + pack.HB=0xFF; + pack.LB=0x00; + pack.HC=0xFF; + pack.LC=0x00; + pack.HD=0xFF; + pack.LD=0x00; + pack.VCCP=0; + + OWINIT(); + + OWST_WDR_CONFIG8 + OWST_EN_PULLUP + + gcontrol=1; + TWI_Master_Initialise(); + CDM7160softReset(); + _delay_ms(200); + + CDM7160setMode(0); //Power Down Mode + _delay_ms(200); + CDM7160setAvCount(0x3F); + CDM7160setFMode(1); + CO2=CDM7160getCO2(); + CDM7160setMode(1); + _delay_ms(200); + + bmp280Init(); + + sei(); + + //DDRB|=(1<3) { + + bmp280ConvertInt(&t,&P,1); + CO2=CDM7160getCO2(); + wdcounter=0; + } + + + + + + + if (gcontrol) { + //PORTB|=(1<pack.HA) {alarmflag=1;pack.CSA2|=0x20;} + if (pack.CSA2&0x04) //AEL + if (pack.bytes[1]pack.HB) {alarmflag=1;pack.CSB2|=0x20;} + if (pack.CSB2&0x04) //AEL + if (pack.bytes[1]pack.HC) {alarmflag=1;pack.CSC2|=0x20;} + if (pack.CSC2&0x04) //AEL + if (pack.bytes[1]pack.HD) {alarmflag=1;pack.CSD2|=0x20;} + if (pack.CSD2&0x04) //AEL + if (pack.bytes[1] + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS2450 + DS2450_CDM7160_BMP280 + DS2450 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + J41800000779 + 0x1E930C + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000779 + Atmel-ICE + + debugWIRE + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + + + + + + compile + BMP280.c + + + compile + CDM7160.c + + + compile + TWI_Master.c + + + compile + + + compile + + + + \ No newline at end of file diff --git a/DS2450_DSM501A/DS2450_DSM501A.atsln b/DS2450_DSM501A/DS2450_DSM501A.atsln new file mode 100644 index 0000000..b65d9ec --- /dev/null +++ b/DS2450_DSM501A/DS2450_DSM501A.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_DSM501A", "DS2450_DSM501A.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2450_DSM501A/DS2450_DSM501A.c b/DS2450_DSM501A/DS2450_DSM501A.c new file mode 100644 index 0000000..710e9ae --- /dev/null +++ b/DS2450_DSM501A/DS2450_DSM501A.c @@ -0,0 +1,312 @@ + +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include + +extern void OWINIT(); +extern void EXTERN_SLEEP(); + +uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/ +uint8_t config_info[26]={0x9,13,0x06,0x09,0x06,0x013,0x06,0x013,0x02,20,20,20,20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +#if (owid>128) +#error "Variable not correct" +#endif + +extern uint8_t mode; +extern uint8_t gcontrol; +extern uint8_t reset_indicator; +extern uint8_t alarmflag; + +volatile uint16_t ltime_list[32]; +volatile uint16_t pcount_list[32]; +volatile uint8_t wsp=0; +volatile uint16_t max_count; +volatile uint16_t max_ptime=0; +volatile uint16_t min_ptime=0; + +uint16_t ds; + + + +typedef union { + volatile uint8_t bytes[0x20]; + struct { + //Page0 + uint16_t A; //0 + uint16_t B; //2 + uint16_t C; //4 + uint16_t D; //6 + //Page1 + uint8_t CSA1; + uint8_t CSA2; + uint8_t CSB1; + uint8_t CSB2; + uint8_t CSC1; + uint8_t CSC2; + uint8_t CSD1; + uint8_t CSD2; + //Page2 + uint8_t LA; + uint8_t HA; + uint8_t LB; + uint8_t HB; + uint8_t LC; + uint8_t HC; + uint8_t LD; + uint8_t HD; + //Page3 + uint8_t FC1; + uint8_t FC2; + uint8_t FC3; + uint8_t FC4; + uint8_t VCCP; + uint8_t FC5; + uint8_t FC6; + uint8_t FC7; + uint8_t convc1; + uint8_t convc2; + + + }; +} pack_t; +volatile pack_t pack; + +volatile uint16_t count; +volatile uint16_t ltime; +volatile uint16_t startt; + +#define SEC_TIME 31250+300 + +ISR(TIM1_OVF_vect){ + TCNT1=~(SEC_TIME); + ltime_list[wsp]=ltime; + pcount_list[wsp]=count; + wsp++; + if (wsp>=32) wsp=0; + //if (count>max) max=count; + //if (mess) + //count=(SEC_TIME) + startt=~(SEC_TIME); + count=0; + ltime=0; + +} +#define PIN_WIND (1<max_ptime)max_ptime=duration; + if (durationds) ds=wspeed[i]; + } + cli();pack.A=ds;sei(); + alarmflag=0; + if (pack.CSA2&0x08) //AEH + if (pack.bytes[1]>pack.HA) {alarmflag=1;pack.CSA2|=0x20;} + if (pack.CSA2&0x04) //AEL + if (pack.bytes[1]ds) ds=wspeed[i]; + } + double lr=(fds/32.0)/(SEC_TIME)*65535/5.1; + cli();pack.B=lr;sei(); + //max=0; + if (pack.CSB2&0x08) //AEH + if (pack.bytes[1]>pack.HB) {alarmflag=1;pack.CSB2|=0x20;} + if (pack.CSB2&0x04) //AEL + if (pack.bytes[1]pack.HC) {alarmflag=1;pack.CSC2|=0x20;} + if (pack.CSC2&0x04) //AEL + if (pack.bytes[1]pack.HD) {alarmflag=1;pack.CSD2|=0x20;} + if (pack.CSD2&0x04) //AEL + if (pack.bytes[1] + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS2450 + DS2450_DSM501A + DS2450 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + J41800000789 + 0x1E930C + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + debugWIRE + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Default (-Wa,-g) + + + + + + compile + OWDS2450.S + + + compile + + + + \ No newline at end of file diff --git a/DS2450_IAQCORE/DS2450_IAQCORE.atsln b/DS2450_IAQCORE/DS2450_IAQCORE.atsln index cd34225..37cfa07 100644 --- a/DS2450_IAQCORE/DS2450_IAQCORE.atsln +++ b/DS2450_IAQCORE/DS2450_IAQCORE.atsln @@ -1,22 +1,22 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Atmel Studio Solution File, Format Version 11.00 -VisualStudioVersion = 14.0.23107.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_IAQCORE", "DS2450_IAQCORE.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|AVR = Debug|AVR - Release|AVR = Release|AVR - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR - {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR - {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR - {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_IAQCORE", "DS2450_IAQCORE.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2450_IAQCORE/DS2450_IAQCORE.c b/DS2450_IAQCORE/DS2450_IAQCORE.c index 750cb9b..006c9b8 100644 --- a/DS2450_IAQCORE/DS2450_IAQCORE.c +++ b/DS2450_IAQCORE/DS2450_IAQCORE.c @@ -45,7 +45,7 @@ extern void OWINIT(); extern void EXTERN_SLEEP(); uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/ -uint8_t config_info[26]={0x06,13,0x06,13,0x06,13,0x06,13,0x02,20,20,20,20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +uint8_t config_info[26]={10,13,8,13,11,13,5,13,0x02,27,27,27,27,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; #if (owid>128) #error "Variable not correct" diff --git a/DS2450_IAQCORE/DS2450_IAQCORE.cproj b/DS2450_IAQCORE/DS2450_IAQCORE.cproj index 5bb475f..e17cbba 100644 --- a/DS2450_IAQCORE/DS2450_IAQCORE.cproj +++ b/DS2450_IAQCORE/DS2450_IAQCORE.cproj @@ -1,139 +1,139 @@ - - - - 2.0 - 7.0 - com.Atmel.AVRGCC8.C - dce6c7e3-ee26-4d79-826b-08594b9ad897 - ATtiny84A - none - Executable - C - $(MSBuildProjectName) - .elf - $(MSBuildProjectDirectory)\$(Configuration) - DS2450 - DS2450_IAQCORE - DS2450 - Native - true - false - true - true - 0x20000000 - - true - exception_table - 2 - 1 - - - - - - - - - - - - - - - - - - - -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" - True - True - True - True - False - True - True - - - NDEBUG - - - - - %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include - - - Optimize for size (-Os) - True - True - True - - - libm - - - - - %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include - - - - - - - - - -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" - True - True - True - True - False - True - True - - - DEBUG - - - - - %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include - - - Optimize (-O1) - True - True - Default (-g2) - True - - - libm - - - - - %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include - - - Default (-Wa,-g) - - - - - - compile - IAQCORE.c - - - compile - USI_TWI_Master.c - - - compile - - - compile - - - + + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS2450 + DS2450_IAQCORE + DS2450 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Default (-Wa,-g) + + + + + + compile + IAQCORE.c + + + compile + USI_TWI_Master.c + + + compile + + + compile + + + \ No newline at end of file diff --git a/DS2450_LPS225HB/DS2450_LPS225HB.atsln b/DS2450_LPS225HB/DS2450_LPS225HB.atsln new file mode 100644 index 0000000..73505ee --- /dev/null +++ b/DS2450_LPS225HB/DS2450_LPS225HB.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_LPS225HB", "DS2450_LPS225HB.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2450_LPS225HB/DS2450_LPS225HB.c b/DS2450_LPS225HB/DS2450_LPS225HB.c new file mode 100644 index 0000000..75dbbad --- /dev/null +++ b/DS2450_LPS225HB/DS2450_LPS225HB.c @@ -0,0 +1,292 @@ +// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/USI_TWI_Master.h" +#include "../common/I2C/LPS225HB.h" +extern void OWINIT(); +extern void EXTERN_SLEEP(); + +uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/ +uint8_t config_info[26]={0x02,16,0x01,14, 0,0, 0x0,0,0x02,14,14,0x00,0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +#if (owid>128) +#error "Variable not correct" +#endif + +extern uint8_t mode; +extern uint8_t gcontrol; +extern uint8_t reset_indicator; +extern uint8_t alarmflag; +volatile uint8_t wdcounter=10; + + +#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) +ISR(WATCHDOG_vect) { +#else +ISR(WDT_vect) { +#endif + wdcounter++; + if (reset_indicator==1) reset_indicator++; + else if (reset_indicator==2) mode=0; +} + +typedef union { + volatile uint8_t bytes[0x20]; + struct { + //Page0 + uint16_t A; //0 + uint16_t B; //2 + uint16_t C; //4 + uint16_t D; //6 + //Page1 + uint8_t CSA1; + uint8_t CSA2; + uint8_t CSB1; + uint8_t CSB2; + uint8_t CSC1; + uint8_t CSC2; + uint8_t CSD1; + uint8_t CSD2; + //Page2 + uint8_t LA; + uint8_t HA; + uint8_t LB; + uint8_t HB; + uint8_t LC; + uint8_t HC; + uint8_t LD; + uint8_t HD; + //Page3 + uint8_t FC1; + uint8_t FC2; + uint8_t FC3; + uint8_t FC4; + uint8_t VCCP; + uint8_t FC5; + uint8_t FC6; + uint8_t FC7; + uint8_t convc1; + uint8_t convc2; + + + }; +} pack_t; +volatile pack_t pack; + + + +volatile int16_t am2302_temp; +volatile uint16_t am2302_hum; + + +uint8_t userRegister[1]; +int16_t sRH,sT; +volatile double temperatureC,humidityRH; +uint32_t P; +int16_t t; + + + + +int main(void){ + pack.A=0; + pack.B=0; + pack.C=0; + pack.D=0; + pack.CSA1=0x08; + pack.CSA2=0x8C; + pack.CSB1=0x08; + pack.CSB2=0x8C; + pack.CSC1=0x08; + pack.CSC2=0x8C; + pack.CSD1=0x08; + pack.CSD2=0x8C; + pack.HA=0xFF; + pack.LA=0x00; + pack.HB=0xFF; + pack.LB=0x00; + pack.HC=0xFF; + pack.LC=0x00; + pack.HD=0xFF; + pack.LD=0x00; + pack.VCCP=0; + PORTB=0xFF-(1<3) { + LPS225HB_Readi(&t,&P); + + + wdcounter=0; + } + + + + + + + if (gcontrol) { + //PORTB|=(1<pack.HA) {alarmflag=1;pack.CSA2|=0x20;} + if (pack.CSA2&0x04) //AEL + if (pack.bytes[1]pack.HB) {alarmflag=1;pack.CSB2|=0x20;} + if (pack.CSB2&0x04) //AEL + if (pack.bytes[1]pack.HC) {alarmflag=1;pack.CSC2|=0x20;} + if (pack.CSC2&0x04) //AEL + if (pack.bytes[1]pack.HD) {alarmflag=1;pack.CSD2|=0x20;} + if (pack.CSD2&0x04) //AEL + if (pack.bytes[1] + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS2450 + DS2450_LPS225HB + DS2450 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + J41800000779 + 0x1E930C + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000779 + Atmel-ICE + + debugWIRE + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + + + + + + compile + LPS225HB.c + + + compile + USI_TWI_Master.c + + + compile + + + compile + + + + \ No newline at end of file diff --git a/DS2450_LPS225HB/OWDS2450.S b/DS2450_LPS225HB/OWDS2450.S new file mode 100644 index 0000000..1d81abd --- /dev/null +++ b/DS2450_LPS225HB/OWDS2450.S @@ -0,0 +1,247 @@ + +// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define _CHANGEABLE_ID_ +#define _ZERO_POLLING_ + +#include "../common/OWConfig.s" +#include "../common/OWCRC16.s" + +.extern pack,8 +.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....) +.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte.... +//.extern am2302_temp,2 + + + +.macro CHIP_INIT +.endm + +.macro COMMAND_TABLE + rjmp h_readmemoryaddr + rjmp h_readmemory + rjmp h_readmemorycrc1 + rjmp h_readmemorycrc2 + rjmp h_writememoryaddr + rjmp h_writememory + rjmp h_writememorycrc1 + rjmp h_writememorycrc2 + rjmp h_writememoryreadback + rjmp h_convert + rjmp h_convertcrc1 + rjmp h_convertcrc2 + rjmp h_convert_conv +.endm + +#include "../common/OWRomFunctions.s" +#include "../common/OWTimerInterrupt.s" + + + +; Ab hier Geraeteabhaenging +#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0 +#define OW_READ_MEMORY OW_FIRST_COMMAND+1 +#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2 +#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3 +#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4 +#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5 +#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6 +#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7 +#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8 +#define OW_CONVERT OW_FIRST_COMMAND+9 +#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10 +#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11 +#define OW_CONVERT_CONV OW_FIRST_COMMAND+12 + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + + +h_readcommand: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cset 0xAA,OW_READ_MEMORY_ADDR + cset 0x55,OW_WRITE_MEMORY_ADDR + cset 0x3C,OW_CONVERT + FW_CONFIG_INFO +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + ldi r_mode,OW_SLEEP + rjmp handle_end + + +h_readmemoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_readmemory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + rjmp handle_end_inc +h_readmemory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory + ;;ldi r_bcount,1 ;ist unten + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + clr r_bytep + rjmp h_readmemory2 +h_readmemory: + lds r_bytep,addr + inc r_bytep + sts addr,r_bytep + andi r_bytep,0x07 + breq h_readmemory_init_crc +h_readmemory2: + lds r_bytep,addr + ;andi r_bytep,0x1F ist oben + configZ pack,r_bytep + ld r_rwbyte,Z + ;ldi r_bcount,1 + rjmp handle_end ;sendet das Byte und geht zu h_readmemory +h_readmemory_init_crc:; init erstes CRC byte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_READ_MEMORY_CRC1 + ;ldi r_bcount,1 + rjmp handle_end +h_readmemory_end: + ldi r_mode,OW_SLEEP + clr r_sendflag + rjmp handle_end +h_readmemorycrc1:;init zweites CRC Byte + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_READ_MEMORY_CRC2 + rjmp handle_end +h_readmemorycrc2:;weiteres senden..... nach zweitem Byte + lds r_temp,addr + andi r_temp,0xE0 + brne h_readmemory_end; ende des speichers + ldi r_mode,OW_READ_MEMORY + CRCInit1 ;Start with new CRC + rjmp h_readmemory2 + +h_writememoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_writememory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + inc r_bytep + ;ldi r_bcount,1 + rjmp handle_end +h_writememory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory + ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren..... + lds r_bytep,addr + rjmp handle_end ;read Memory Byte +h_writememory: + lds r_bytep,addr + configZ pack,r_bytep + st Z,r_rwbyte + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC1 + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + rjmp handle_end +h_writememorycrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC2 + rjmp handle_end +h_writememorycrc2: + lds r_temp,addr + configZ pack,r_temp + ld r_rwbyte,Z + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_READBACK + rjmp handle_end +h_writememoryreadback: + ldi r_temp,0x00 + sts crc+1,r_temp + lds r_temp,addr + inc r_temp + sts addr,r_temp + sts crc,r_temp + ldi r_sendflag,0 + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY + rjmp handle_end + +h_convert: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_convert_byte1 ;nein dann weiter + inc r_bytep + sts pack+0x20,r_rwbyte + ;ldi r_bcount,1 + rjmp handle_end +h_convert_byte1: ;zweies byte glesen go crc# + sts pack+0x21,r_rwbyte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_CONVERT_CRC1 + ;ldi r_bcount,1 + ldi r_sendflag,1 + rjmp handle_end +h_convertcrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CRC2 + rjmp handle_end +h_convertcrc2: + ldi r_temp,1 + sts gcontrol,r_temp + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CONV + ;clr r_sendflag + ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling +h_convert_conv: + ldi r_bcount,0 + ldi r_rwbyte,0 + rjmp handle_end_no_bcount + + + + +#include "../common/OWPinInterrupt.s" +.end \ No newline at end of file diff --git a/DS2450_MAX44008/DS2450_MAX44008.atsln b/DS2450_MAX44008/DS2450_MAX44008.atsln new file mode 100644 index 0000000..71471d5 --- /dev/null +++ b/DS2450_MAX44008/DS2450_MAX44008.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_MAX44008", "DS2450_MAX44008.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2450_MAX44008/DS2450_MAX44008.c b/DS2450_MAX44008/DS2450_MAX44008.c new file mode 100644 index 0000000..2741d88 --- /dev/null +++ b/DS2450_MAX44008/DS2450_MAX44008.c @@ -0,0 +1,270 @@ + +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/USI_TWI_Master.h" + +extern void OWINIT(); +extern void EXTERN_SLEEP(); + +uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/ +uint8_t config_info[26]={0x06,0x09,0x06,0x09,0x06,0x09,0x06,0x09,0x02,20,20,20,20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + +#if (owid>128) +#error "Variable not correct" +#endif + +extern uint8_t mode; +extern uint8_t gcontrol; +extern uint8_t reset_indicator; +extern uint8_t alarmflag; + + +typedef union { + volatile uint8_t bytes[0x20]; + struct { + //Page0 + uint16_t A; //0 + uint16_t B; //2 + uint16_t C; //4 + uint16_t D; //6 + //Page1 + uint8_t CSA1; + uint8_t CSA2; + uint8_t CSB1; + uint8_t CSB2; + uint8_t CSC1; + uint8_t CSC2; + uint8_t CSD1; + uint8_t CSD2; + //Page2 + uint8_t LA; + uint8_t HA; + uint8_t LB; + uint8_t HB; + uint8_t LC; + uint8_t HC; + uint8_t LD; + uint8_t HD; + //Page3 + uint8_t FC1; + uint8_t FC2; + uint8_t FC3; + uint8_t FC4; + uint8_t VCCP; + uint8_t FC5; + uint8_t FC6; + uint8_t FC7; + uint8_t convc1; + uint8_t convc2; + + + }; +} pack_t; +volatile pack_t pack; + + + uint8_t checkMAX44008(uint8_t nr) { + volatile uint8_t b1; + nr=(nr<<1)&0x02f; + + I2c_StartCondition(); + I2c_WriteByte(0b10000000|nr); + I2c_WriteByte(0x00); + I2c_StartCondition(); + I2c_WriteByte (0b10000001|nr); + b1 =I2c_ReadByte(NO_ACK); + I2c_StopCondition(); + return b1!=0xFF; + + } + + + +int main(void){ + pack.A=0; + pack.B=0; + pack.C=0; + pack.D=0; + pack.CSA1=0x08; + pack.CSA2=0x8C; + pack.CSB1=0x08; + pack.CSB2=0x8C; + pack.CSC1=0x08; + pack.CSC2=0x8C; + pack.CSD1=0x08; + pack.CSD2=0x8C; + pack.HA=0xFF; + pack.LA=0x00; + pack.HB=0xFF; + pack.LB=0x00; + pack.HC=0xFF; + pack.LC=0x00; + pack.HD=0xFF; + pack.LD=0x00; + pack.VCCP=0; + + PORTA=0xFF; + PORTB=0xFF; + + OWINIT(); + + MCUCR &=~(1<pack.HA) {alarmflag=1;pack.CSA2|=0x20;} + if (pack.CSA2&0x04) //AEL + if (pack.bytes[1]pack.HB) {alarmflag=1;pack.CSB2|=0x20;} + if (pack.CSB2&0x04) //AEL + if (pack.bytes[1]pack.HC) {alarmflag=1;pack.CSC2|=0x20;} + if (pack.CSC2&0x04) //AEL + if (pack.bytes[1]pack.HD) {alarmflag=1;pack.CSD2|=0x20;} + if (pack.CSD2&0x04) //AEL + if (pack.bytes[1] + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS2450 + DS2450_MAX44008 + DS2450 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Default (-Wa,-g) + + + + + + compile + USI_TWI_Master.c + + + compile + + + compile + + + + \ No newline at end of file diff --git a/DS2450_MAX44008/OWDS2450.S b/DS2450_MAX44008/OWDS2450.S new file mode 100644 index 0000000..61a1dad --- /dev/null +++ b/DS2450_MAX44008/OWDS2450.S @@ -0,0 +1,248 @@ + +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define _CHANGEABLE_ID_ +#define _ZERO_POLLING_ +#define __4MHZ__ + +#include "../common/OWConfig.s" +#include "../common/OWCRC16.s" + +.extern pack,8 +.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....) +.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte.... +//.extern am2302_temp,2 + + + +.macro CHIP_INIT +.endm + +.macro COMMAND_TABLE + rjmp h_readmemoryaddr + rjmp h_readmemory + rjmp h_readmemorycrc1 + rjmp h_readmemorycrc2 + rjmp h_writememoryaddr + rjmp h_writememory + rjmp h_writememorycrc1 + rjmp h_writememorycrc2 + rjmp h_writememoryreadback + rjmp h_convert + rjmp h_convertcrc1 + rjmp h_convertcrc2 + rjmp h_convert_conv +.endm + +#include "../common/OWRomFunctions.s" +#include "../common/OWTimerInterrupt.s" + + + +; Ab hier Geraeteabhaenging +#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0 +#define OW_READ_MEMORY OW_FIRST_COMMAND+1 +#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2 +#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3 +#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4 +#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5 +#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6 +#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7 +#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8 +#define OW_CONVERT OW_FIRST_COMMAND+9 +#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10 +#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11 +#define OW_CONVERT_CONV OW_FIRST_COMMAND+12 + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + + +h_readcommand: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cset 0xAA,OW_READ_MEMORY_ADDR + cset 0x55,OW_WRITE_MEMORY_ADDR + cset 0x3C,OW_CONVERT + FW_CONFIG_INFO +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + ldi r_mode,OW_SLEEP + rjmp handle_end + + +h_readmemoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_readmemory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + rjmp handle_end_inc +h_readmemory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory + ;;ldi r_bcount,1 ;ist unten + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + clr r_bytep + rjmp h_readmemory2 +h_readmemory: + lds r_bytep,addr + inc r_bytep + sts addr,r_bytep + andi r_bytep,0x07 + breq h_readmemory_init_crc +h_readmemory2: + lds r_bytep,addr + ;andi r_bytep,0x1F ist oben + configZ pack,r_bytep + ld r_rwbyte,Z + ;ldi r_bcount,1 + rjmp handle_end ;sendet das Byte und geht zu h_readmemory +h_readmemory_init_crc:; init erstes CRC byte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_READ_MEMORY_CRC1 + ;ldi r_bcount,1 + rjmp handle_end +h_readmemory_end: + ldi r_mode,OW_SLEEP + clr r_sendflag + rjmp handle_end +h_readmemorycrc1:;init zweites CRC Byte + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_READ_MEMORY_CRC2 + rjmp handle_end +h_readmemorycrc2:;weiteres senden..... nach zweitem Byte + lds r_temp,addr + andi r_temp,0xE0 + brne h_readmemory_end; ende des speichers + ldi r_mode,OW_READ_MEMORY + CRCInit1 ;Start with new CRC + rjmp h_readmemory2 + +h_writememoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_writememory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + inc r_bytep + ;ldi r_bcount,1 + rjmp handle_end +h_writememory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory + ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren..... + lds r_bytep,addr + rjmp handle_end ;read Memory Byte +h_writememory: + lds r_bytep,addr + configZ pack,r_bytep + st Z,r_rwbyte + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC1 + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + rjmp handle_end +h_writememorycrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC2 + rjmp handle_end +h_writememorycrc2: + lds r_temp,addr + configZ pack,r_temp + ld r_rwbyte,Z + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_READBACK + rjmp handle_end +h_writememoryreadback: + ldi r_temp,0x00 + sts crc+1,r_temp + lds r_temp,addr + inc r_temp + sts addr,r_temp + sts crc,r_temp + ldi r_sendflag,0 + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY + rjmp handle_end + +h_convert: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_convert_byte1 ;nein dann weiter + inc r_bytep + sts pack+0x20,r_rwbyte + ;ldi r_bcount,1 + rjmp handle_end +h_convert_byte1: ;zweies byte glesen go crc# + sts pack+0x21,r_rwbyte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_CONVERT_CRC1 + ;ldi r_bcount,1 + ldi r_sendflag,1 + rjmp handle_end +h_convertcrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CRC2 + rjmp handle_end +h_convertcrc2: + ldi r_temp,1 + sts gcontrol,r_temp + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CONV + ;clr r_sendflag + ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling +h_convert_conv: + ldi r_bcount,0 + ldi r_rwbyte,0 + rjmp handle_end_no_bcount + + + + +#include "../common/OWPinInterrupt.s" +.end \ No newline at end of file diff --git a/DS2450_SGP30/DS2450_SGP30.atsln b/DS2450_SGP30/DS2450_SGP30.atsln new file mode 100644 index 0000000..5f82c4f --- /dev/null +++ b/DS2450_SGP30/DS2450_SGP30.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_SGP30", "DS2450_SGP30.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2450_SGP30/DS2450_SGP30.c b/DS2450_SGP30/DS2450_SGP30.c new file mode 100644 index 0000000..f0b881c --- /dev/null +++ b/DS2450_SGP30/DS2450_SGP30.c @@ -0,0 +1,265 @@ + +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/USI_TWI_Master.h" +#include "../common/I2C/SGP30.h" + +extern void OWINIT(); +extern void EXTERN_SLEEP(); + +uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x23, 0x20};/**/ +//uint8_t config_info[26]={0x03,13,0x03,13,0x03,13,0x3,15,0x02,20,20,20,20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +uint8_t config_info[26]={10,13,8,13,8,13,8,13,0x02,25,25,25,25,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + +#if (owid>128) +#error "Variable not correct" +#endif + +extern uint8_t mode; +extern uint8_t gcontrol; +extern uint8_t reset_indicator; +extern uint8_t alarmflag; +volatile uint8_t wdcounter=10; + + +#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) +ISR(WATCHDOG_vect) { + #else + ISR(WDT_vect) { + #endif + wdcounter++; + if (reset_indicator==1) reset_indicator++; + else if (reset_indicator==2) mode=0; + } + +typedef union { + volatile uint8_t bytes[0x20]; + struct { + //Page0 + uint16_t A; //0 + uint16_t B; //2 + uint16_t C; //4 + uint16_t D; //6 + //Page1 + uint8_t CSA1; + uint8_t CSA2; + uint8_t CSB1; + uint8_t CSB2; + uint8_t CSC1; + uint8_t CSC2; + uint8_t CSD1; + uint8_t CSD2; + //Page2 + uint8_t LA; + uint8_t HA; + uint8_t LB; + uint8_t HB; + uint8_t LC; + uint8_t HC; + uint8_t LD; + uint8_t HD; + //Page3 + uint8_t FC1; + uint8_t FC2; + uint8_t FC3; + uint8_t FC4; + uint8_t VCCP; + uint8_t FC5; + uint8_t FC6; + uint8_t FC7; + uint8_t convc1; + uint8_t convc2; + + + }; +} pack_t; +volatile pack_t pack; + + +uint16_t CO2; +uint16_t VOC; +uint16_t ETH; +uint16_t H2; + + +int main(void){ + pack.A=0; + pack.B=0; + pack.C=0; + pack.D=0; + pack.CSA1=0x08; + pack.CSA2=0x8C; + pack.CSB1=0x08; + pack.CSB2=0x8C; + pack.CSC1=0x08; + pack.CSC2=0x8C; + pack.CSD1=0x08; + pack.CSD2=0x8C; + pack.HA=0xFF; + pack.LA=0x00; + pack.HB=0xFF; + pack.LB=0x00; + pack.HC=0xFF; + pack.LC=0x00; + pack.HD=0xFF; + pack.LD=0x00; + pack.VCCP=0; + + PORTA=0xFF; + PORTB=0xFF; + + OWINIT(); + + MCUCR &=~(1<1) { + runSGP30(&CO2,&VOC,Ð,&H2); + wdcounter=0; + } + + if (gcontrol) { + //PORTB|=(1<pack.HA) {alarmflag=1;pack.CSA2|=0x20;} + if (pack.CSA2&0x04) //AEL + if (pack.bytes[1]pack.HB) {alarmflag=1;pack.CSB2|=0x20;} + if (pack.CSB2&0x04) //AEL + if (pack.bytes[1]pack.HC) {alarmflag=1;pack.CSC2|=0x20;} + if (pack.CSC2&0x04) //AEL + if (pack.bytes[1]pack.HD) {alarmflag=1;pack.CSD2|=0x20;} + if (pack.CSD2&0x04) //AEL + if (pack.bytes[1] + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS2450 + DS2450_SGP30 + DS2450 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + J41800000789 + 0x1E930C + + + + 125000 + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + debugWIRE + 125000 + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + NDEBUG + __4MHZ__ + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + -D __4MHZ__ + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + __4MHZ__ + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + -D __4MHZ__ + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Default (-Wa,-g) + + + + + + compile + SGP30.c + + + compile + USI_TWI_Master.c + + + compile + + + compile + + + + \ No newline at end of file diff --git a/DS2450_SGP30/OWDS2450.S b/DS2450_SGP30/OWDS2450.S new file mode 100644 index 0000000..0b56d13 --- /dev/null +++ b/DS2450_SGP30/OWDS2450.S @@ -0,0 +1,250 @@ + +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define _CHANGEABLE_ID_ +#define _ZERO_POLLING_ +//#define __4MHZ__ + + + +#include "../common/OWConfig.s" +#include "../common/OWCRC16.s" + +.extern pack,8 +.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....) +.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte.... +//.extern am2302_temp,2 + + + +.macro CHIP_INIT +.endm + +.macro COMMAND_TABLE + rjmp h_readmemoryaddr + rjmp h_readmemory + rjmp h_readmemorycrc1 + rjmp h_readmemorycrc2 + rjmp h_writememoryaddr + rjmp h_writememory + rjmp h_writememorycrc1 + rjmp h_writememorycrc2 + rjmp h_writememoryreadback + rjmp h_convert + rjmp h_convertcrc1 + rjmp h_convertcrc2 + rjmp h_convert_conv +.endm + +#include "../common/OWRomFunctions.s" +#include "../common/OWTimerInterrupt.s" + + + +; Ab hier Geraeteabhaenging +#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0 +#define OW_READ_MEMORY OW_FIRST_COMMAND+1 +#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2 +#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3 +#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4 +#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5 +#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6 +#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7 +#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8 +#define OW_CONVERT OW_FIRST_COMMAND+9 +#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10 +#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11 +#define OW_CONVERT_CONV OW_FIRST_COMMAND+12 + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + + +h_readcommand: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cset 0xAA,OW_READ_MEMORY_ADDR + cset 0x55,OW_WRITE_MEMORY_ADDR + cset 0x3C,OW_CONVERT + FW_CONFIG_INFO +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + ldi r_mode,OW_SLEEP + rjmp handle_end + + +h_readmemoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_readmemory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + rjmp handle_end_inc +h_readmemory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory + ;;ldi r_bcount,1 ;ist unten + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + clr r_bytep + rjmp h_readmemory2 +h_readmemory: + lds r_bytep,addr + inc r_bytep + sts addr,r_bytep + andi r_bytep,0x07 + breq h_readmemory_init_crc +h_readmemory2: + lds r_bytep,addr + ;andi r_bytep,0x1F ist oben + configZ pack,r_bytep + ld r_rwbyte,Z + ;ldi r_bcount,1 + rjmp handle_end ;sendet das Byte und geht zu h_readmemory +h_readmemory_init_crc:; init erstes CRC byte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_READ_MEMORY_CRC1 + ;ldi r_bcount,1 + rjmp handle_end +h_readmemory_end: + ldi r_mode,OW_SLEEP + clr r_sendflag + rjmp handle_end +h_readmemorycrc1:;init zweites CRC Byte + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_READ_MEMORY_CRC2 + rjmp handle_end +h_readmemorycrc2:;weiteres senden..... nach zweitem Byte + lds r_temp,addr + andi r_temp,0xE0 + brne h_readmemory_end; ende des speichers + ldi r_mode,OW_READ_MEMORY + CRCInit1 ;Start with new CRC + rjmp h_readmemory2 + +h_writememoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_writememory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + inc r_bytep + ;ldi r_bcount,1 + rjmp handle_end +h_writememory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory + ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren..... + lds r_bytep,addr + rjmp handle_end ;read Memory Byte +h_writememory: + lds r_bytep,addr + configZ pack,r_bytep + st Z,r_rwbyte + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC1 + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + rjmp handle_end +h_writememorycrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC2 + rjmp handle_end +h_writememorycrc2: + lds r_temp,addr + configZ pack,r_temp + ld r_rwbyte,Z + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_READBACK + rjmp handle_end +h_writememoryreadback: + ldi r_temp,0x00 + sts crc+1,r_temp + lds r_temp,addr + inc r_temp + sts addr,r_temp + sts crc,r_temp + ldi r_sendflag,0 + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY + rjmp handle_end + +h_convert: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_convert_byte1 ;nein dann weiter + inc r_bytep + sts pack+0x20,r_rwbyte + ;ldi r_bcount,1 + rjmp handle_end +h_convert_byte1: ;zweies byte glesen go crc# + sts pack+0x21,r_rwbyte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_CONVERT_CRC1 + ;ldi r_bcount,1 + ldi r_sendflag,1 + rjmp handle_end +h_convertcrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CRC2 + rjmp handle_end +h_convertcrc2: + ldi r_temp,1 + sts gcontrol,r_temp + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CONV + ;clr r_sendflag + ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling +h_convert_conv: + ldi r_bcount,0 + ldi r_rwbyte,0 + rjmp handle_end_no_bcount + + + + +#include "../common/OWPinInterrupt.s" +.end \ No newline at end of file diff --git a/DS2450_SHT2X_BMP280/DS2450_SHT2X_BMP280.atsln b/DS2450_SHT2X_BMP280/DS2450_SHT2X_BMP280.atsln index c9b2ef7..526fac6 100644 --- a/DS2450_SHT2X_BMP280/DS2450_SHT2X_BMP280.atsln +++ b/DS2450_SHT2X_BMP280/DS2450_SHT2X_BMP280.atsln @@ -1,22 +1,22 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Atmel Studio Solution File, Format Version 11.00 -VisualStudioVersion = 14.0.23107.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_SHT2X_BMP280", "DS2450_SHT2X_BMP280.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|AVR = Debug|AVR - Release|AVR = Release|AVR - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR - {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR - {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR - {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_SHT2X_BMP280", "DS2450_SHT2X_BMP280.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2450_SHT2X_BMP280_MAX44009/DS2450_SHT2X_BMP280_MAX44009.c b/DS2450_SHT2X_BMP280_MAX44009/DS2450_SHT2X_BMP280_MAX44009.c index 683b765..2d10504 100644 --- a/DS2450_SHT2X_BMP280_MAX44009/DS2450_SHT2X_BMP280_MAX44009.c +++ b/DS2450_SHT2X_BMP280_MAX44009/DS2450_SHT2X_BMP280_MAX44009.c @@ -39,11 +39,13 @@ #include #include #include "../common/I2C/USI_TWI_Master.h" -#include "../common/I2C/SHT2x.h" +#include "../common/I2C/SHT2xV2.h" #include "../common/I2C/BMP280.h" #include "../common/I2C/MAX44009.h" -extern void OWINIT(); -extern void EXTERN_SLEEP(); +#include "../common/owSlave_tools.h" +#include "../common/calibr.h" + +OWST_EXTERN_VARS uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/ uint8_t config_info[26]={0x01,14,0x04,0x08, 0x03,15, 0x02,16,0x02,7,7,15,14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; @@ -52,22 +54,8 @@ uint8_t config_info[26]={0x01,14,0x04,0x08, 0x03,15, 0x02,16,0x02,7,7,15,14,0x00 #error "Variable not correct" #endif -extern uint8_t mode; -extern uint8_t gcontrol; -extern uint8_t reset_indicator; -extern uint8_t alarmflag; -volatile uint8_t wdcounter=10; - +OWST_WDT_ISR -#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) -ISR(WATCHDOG_vect) { -#else -ISR(WDT_vect) { -#endif - wdcounter++; - if (reset_indicator==1) reset_indicator++; - else if (reset_indicator==2) mode=0; -} typedef union { volatile uint8_t bytes[0x20]; @@ -114,14 +102,10 @@ volatile pack_t pack; -volatile int16_t am2302_temp; -volatile uint16_t am2302_hum; -uint8_t userRegister[1]; -int16_t sRH,sT; -volatile double temperatureC,humidityRH; -volatile double l; + double temperatureC,humidityRH; + double l; uint32_t P; int32_t t; uint8_t max_adr=0; @@ -129,6 +113,7 @@ uint8_t max_adr=0; int main(void){ + OWST_INIT_USI_ON pack.A=0; pack.B=0; pack.C=0; @@ -150,35 +135,17 @@ int main(void){ pack.HD=0xFF; pack.LD=0x00; pack.VCCP=0; - PORTB=0xFF-(1<3) { - SHT2x_MeasurePoll(HUMIDITY, &sRH); - // --- measure temperature with "Polling Mode" (no hold master) --- - SHT2x_MeasurePoll(TEMP, &sT); - //-- calculate humidity and temperature -- - temperatureC = SHT2x_CalcTemperatureC(sT); - humidityRH = SHT2x_CalcRH(sRH); + getSHT2xHumTemp(&temperatureC,&humidityRH); + humidityRH=calibr_hum(temperatureC,-0.2,humidityRH); + temperatureC =temperatureC -0.2; bmp280ConvertInt(&t,&P,1); l=MAX44009getlux(max_adr); if (l<0.030) l=0.030; //Darf nicht 0 sein. minimum -35°C Sensor minimum 0.045 @@ -245,7 +209,8 @@ int main(void){ while ((ADCSRA&(1<pack.HB) {alarmflag=1;pack.CSB2|=0x20;} if (pack.CSB2&0x04) //AEL @@ -272,7 +237,8 @@ int main(void){ while ((ADCSRA&(1<pack.HD) {alarmflag=1;pack.CSD2|=0x20;} if (pack.CSD2&0x04) //AEL @@ -297,21 +263,7 @@ int main(void){ bb=bb*2; }*/ -#if defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) - if (((TIMSK & (1<1 - + - + @@ -123,6 +123,10 @@ + + compile + calibr.c + compile BMP280.c @@ -131,13 +135,9 @@ compile MAX44009.c - - compile - SHT2x.c - - + compile - TSL256x.c + SHT2xV2.c compile diff --git a/DS2450_SHT2X_MAX44009/DS2450_SHT2X_MAX44009.atsln b/DS2450_SHT2X_MAX44009/DS2450_SHT2X_MAX44009.atsln index 542967c..5739ec3 100644 --- a/DS2450_SHT2X_MAX44009/DS2450_SHT2X_MAX44009.atsln +++ b/DS2450_SHT2X_MAX44009/DS2450_SHT2X_MAX44009.atsln @@ -1,22 +1,22 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Atmel Studio Solution File, Format Version 11.00 -VisualStudioVersion = 14.0.23107.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_SHT2X_MAX44009", "DS2450_SHT2X_MAX44009.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|AVR = Debug|AVR - Release|AVR = Release|AVR - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR - {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR - {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR - {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_SHT2X_MAX44009", "DS2450_SHT2X_MAX44009.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2450_SHT2X_MAX44009/DS2450_SHT2X_MAX44009.c b/DS2450_SHT2X_MAX44009/DS2450_SHT2X_MAX44009.c index 8f5d4f9..b5ed22b 100644 --- a/DS2450_SHT2X_MAX44009/DS2450_SHT2X_MAX44009.c +++ b/DS2450_SHT2X_MAX44009/DS2450_SHT2X_MAX44009.c @@ -38,7 +38,7 @@ #include #include #include -#include "../common/I2C/USI_TWI_Master.h" +#include "../common/I2C/TWI_Master.h" #include "../common/I2C/SHT2x.h" #include "../common/I2C/MAX44009.h" extern void OWINIT(); @@ -165,7 +165,7 @@ int main(void){ gcontrol=1; - USI_TWI_Master_Initialise(); + TWI_Master_Initialise(); SHT2x_SoftReset(); SHT2x_ReadUserRegister(userRegister); //(userRegister & ~SHT2x_RES_MASK) | SHT2x_RES_10_13BIT; @@ -309,7 +309,7 @@ int main(void){ MCUCR|=(1<1 - - - - - - - - - - + + + + + + + + + + com.atmel.avrdbg.tool.atmelice J41800000779 @@ -135,9 +135,9 @@ compile TSL256x.c - + compile - USI_TWI_Master.c + TWI_Master.c compile diff --git a/DS2450_SHT3X/DS2450_SHT3X.atsln b/DS2450_SHT3X/DS2450_SHT3X.atsln new file mode 100644 index 0000000..c8f5c00 --- /dev/null +++ b/DS2450_SHT3X/DS2450_SHT3X.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_SHT3X", "DS2450_SHT3X.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2450_SHT3X/DS2450_SHT3X.c b/DS2450_SHT3X/DS2450_SHT3X.c new file mode 100644 index 0000000..26d723b --- /dev/null +++ b/DS2450_SHT3X/DS2450_SHT3X.c @@ -0,0 +1,298 @@ +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/USI_TWI_Master.h" +#include "../common/I2C/SHT3x.h" +#include "../common/calibr.h" +extern void OWINIT(); +extern void EXTERN_SLEEP(); +//6A02160084D9A320 +//uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/ +uint8_t owid[8]={0x20, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x6A};/**/ +uint8_t config_info[26]={0x01,14,0x04,0x08, 0,0, 0,0,0x02,21,21,0x00,0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +#if (owid>128) +#error "Variable not correct" +#endif + +extern uint8_t mode; +extern uint8_t gcontrol; +extern uint8_t reset_indicator; +extern uint8_t alarmflag; +volatile uint8_t wdcounter=10; + + +#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) +ISR(WATCHDOG_vect) { +#else +ISR(WDT_vect) { +#endif + wdcounter++; + if (reset_indicator==1) reset_indicator++; + else if (reset_indicator==2) mode=0; +} + +typedef union { + volatile uint8_t bytes[0x20]; + struct { + //Page0 + uint16_t A; //0 + uint16_t B; //2 + uint16_t C; //4 + uint16_t D; //6 + //Page1 + uint8_t CSA1; + uint8_t CSA2; + uint8_t CSB1; + uint8_t CSB2; + uint8_t CSC1; + uint8_t CSC2; + uint8_t CSD1; + uint8_t CSD2; + //Page2 + uint8_t LA; + uint8_t HA; + uint8_t LB; + uint8_t HB; + uint8_t LC; + uint8_t HC; + uint8_t LD; + uint8_t HD; + //Page3 + uint8_t FC1; + uint8_t FC2; + uint8_t FC3; + uint8_t FC4; + uint8_t VCCP; + uint8_t FC5; + uint8_t FC6; + uint8_t FC7; + uint8_t convc1; + uint8_t convc2; + + + }; +} pack_t; +volatile pack_t pack; + + + +volatile int16_t am2302_temp; +volatile uint16_t am2302_hum; + + +uint8_t userRegister[1]; +int16_t sRH,sT; + double temperatureC,humidityRH; +uint32_t P; +int32_t t; + + + + +int main(void){ + pack.A=0; + pack.B=0; + pack.C=0; + pack.D=0; + pack.CSA1=0x08; + pack.CSA2=0x8C; + pack.CSB1=0x08; + pack.CSB2=0x8C; + pack.CSC1=0x08; + pack.CSC2=0x8C; + pack.CSD1=0x08; + pack.CSD2=0x8C; + pack.HA=0xFF; + pack.LA=0x00; + pack.HB=0xFF; + pack.LB=0x00; + pack.HC=0xFF; + pack.LC=0x00; + pack.HD=0xFF; + pack.LD=0x00; + pack.VCCP=0; + PORTB=0xFF-(1<3) { + + getSHT3xHumTemp(0,&temperatureC,&humidityRH); + + wdcounter=0; + } + + + + + + + if (gcontrol) { + //PORTB|=(1<pack.HA) {alarmflag=1;pack.CSA2|=0x20;} + if (pack.CSA2&0x04) //AEL + if (pack.bytes[1]pack.HB) {alarmflag=1;pack.CSB2|=0x20;} + if (pack.CSB2&0x04) //AEL + if (pack.bytes[1]pack.HC) {alarmflag=1;pack.CSC2|=0x20;} + if (pack.CSC2&0x04) //AEL + if (pack.bytes[1]pack.HD) {alarmflag=1;pack.CSD2|=0x20;} + if (pack.CSD2&0x04) //AEL + if (pack.bytes[1] + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS2450 + DS2450_SHT3X + DS2450 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + J41800000779 + 0x1E930C + + + + + debugWIRE + + com.atmel.avrdbg.tool.atmelice + J41800000779 + Atmel-ICE + + debugWIRE + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize for size (-Os) + True + True + True + -std=gnu99 -D__4MHZ__ + + + libm + + + -D__4MHZ__ + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + + + + + + compile + calibr.c + + + compile + SHT3x.c + + + compile + USI_TWI_Master.c + + + compile + + + compile + + + + \ No newline at end of file diff --git a/DS2450_SHT3X/OWDS2450.S b/DS2450_SHT3X/OWDS2450.S new file mode 100644 index 0000000..1d81abd --- /dev/null +++ b/DS2450_SHT3X/OWDS2450.S @@ -0,0 +1,247 @@ + +// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define _CHANGEABLE_ID_ +#define _ZERO_POLLING_ + +#include "../common/OWConfig.s" +#include "../common/OWCRC16.s" + +.extern pack,8 +.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....) +.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte.... +//.extern am2302_temp,2 + + + +.macro CHIP_INIT +.endm + +.macro COMMAND_TABLE + rjmp h_readmemoryaddr + rjmp h_readmemory + rjmp h_readmemorycrc1 + rjmp h_readmemorycrc2 + rjmp h_writememoryaddr + rjmp h_writememory + rjmp h_writememorycrc1 + rjmp h_writememorycrc2 + rjmp h_writememoryreadback + rjmp h_convert + rjmp h_convertcrc1 + rjmp h_convertcrc2 + rjmp h_convert_conv +.endm + +#include "../common/OWRomFunctions.s" +#include "../common/OWTimerInterrupt.s" + + + +; Ab hier Geraeteabhaenging +#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0 +#define OW_READ_MEMORY OW_FIRST_COMMAND+1 +#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2 +#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3 +#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4 +#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5 +#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6 +#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7 +#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8 +#define OW_CONVERT OW_FIRST_COMMAND+9 +#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10 +#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11 +#define OW_CONVERT_CONV OW_FIRST_COMMAND+12 + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + + +h_readcommand: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cset 0xAA,OW_READ_MEMORY_ADDR + cset 0x55,OW_WRITE_MEMORY_ADDR + cset 0x3C,OW_CONVERT + FW_CONFIG_INFO +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + ldi r_mode,OW_SLEEP + rjmp handle_end + + +h_readmemoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_readmemory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + rjmp handle_end_inc +h_readmemory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory + ;;ldi r_bcount,1 ;ist unten + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + clr r_bytep + rjmp h_readmemory2 +h_readmemory: + lds r_bytep,addr + inc r_bytep + sts addr,r_bytep + andi r_bytep,0x07 + breq h_readmemory_init_crc +h_readmemory2: + lds r_bytep,addr + ;andi r_bytep,0x1F ist oben + configZ pack,r_bytep + ld r_rwbyte,Z + ;ldi r_bcount,1 + rjmp handle_end ;sendet das Byte und geht zu h_readmemory +h_readmemory_init_crc:; init erstes CRC byte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_READ_MEMORY_CRC1 + ;ldi r_bcount,1 + rjmp handle_end +h_readmemory_end: + ldi r_mode,OW_SLEEP + clr r_sendflag + rjmp handle_end +h_readmemorycrc1:;init zweites CRC Byte + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_READ_MEMORY_CRC2 + rjmp handle_end +h_readmemorycrc2:;weiteres senden..... nach zweitem Byte + lds r_temp,addr + andi r_temp,0xE0 + brne h_readmemory_end; ende des speichers + ldi r_mode,OW_READ_MEMORY + CRCInit1 ;Start with new CRC + rjmp h_readmemory2 + +h_writememoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_writememory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + inc r_bytep + ;ldi r_bcount,1 + rjmp handle_end +h_writememory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory + ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren..... + lds r_bytep,addr + rjmp handle_end ;read Memory Byte +h_writememory: + lds r_bytep,addr + configZ pack,r_bytep + st Z,r_rwbyte + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC1 + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + rjmp handle_end +h_writememorycrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC2 + rjmp handle_end +h_writememorycrc2: + lds r_temp,addr + configZ pack,r_temp + ld r_rwbyte,Z + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_READBACK + rjmp handle_end +h_writememoryreadback: + ldi r_temp,0x00 + sts crc+1,r_temp + lds r_temp,addr + inc r_temp + sts addr,r_temp + sts crc,r_temp + ldi r_sendflag,0 + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY + rjmp handle_end + +h_convert: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_convert_byte1 ;nein dann weiter + inc r_bytep + sts pack+0x20,r_rwbyte + ;ldi r_bcount,1 + rjmp handle_end +h_convert_byte1: ;zweies byte glesen go crc# + sts pack+0x21,r_rwbyte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_CONVERT_CRC1 + ;ldi r_bcount,1 + ldi r_sendflag,1 + rjmp handle_end +h_convertcrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CRC2 + rjmp handle_end +h_convertcrc2: + ldi r_temp,1 + sts gcontrol,r_temp + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CONV + ;clr r_sendflag + ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling +h_convert_conv: + ldi r_bcount,0 + ldi r_rwbyte,0 + rjmp handle_end_no_bcount + + + + +#include "../common/OWPinInterrupt.s" +.end \ No newline at end of file diff --git a/DS2450_VOC_SHT/DS2450_VOC_SHT.atsln b/DS2450_VOC_SHT/DS2450_VOC_SHT.atsln new file mode 100644 index 0000000..97e522a --- /dev/null +++ b/DS2450_VOC_SHT/DS2450_VOC_SHT.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_VOC_SHT", "DS2450_VOC_SHT.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DS2450_VOC_SHT/DS2450_VOC_SHT.c b/DS2450_VOC_SHT/DS2450_VOC_SHT.c new file mode 100644 index 0000000..80c06a1 --- /dev/null +++ b/DS2450_VOC_SHT/DS2450_VOC_SHT.c @@ -0,0 +1,519 @@ + +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +//!!!!!Max Program size 7551 Byte + + + + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/USI_TWI_Master.h" +#include "../common/I2C/MAX1164x.h" +#include "../common/I2C/SHT2xV2.h" +#include "../common/calibr.h" + +extern void OWINIT(); +extern void EXTERN_SLEEP(); + +uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/ +uint8_t config_info[26]={0x01,14,0x04,0x08, 8,8,11,0x08,0x02,7,7,17,17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + +#if (owid>128) +#error "Variable not correct" +#endif + +extern uint8_t mode; +extern uint8_t gcontrol; +extern uint8_t reset_indicator; +extern uint8_t alarmflag; +volatile uint8_t wdcounter=1; + +#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) +ISR(WATCHDOG_vect) { +#else +ISR(WDT_vect) { +#endif + wdcounter++; + if (reset_indicator==1) reset_indicator++; + else if (reset_indicator==2) mode=0; +} + + +typedef union { + volatile uint8_t bytes[0x20]; + struct { + //Page0 + uint16_t A; //0 + uint16_t B; //2 + uint16_t C; //4 + uint16_t D; //6 + //Page1 + uint8_t CSA1; + uint8_t CSA2; + uint8_t CSB1; + uint8_t CSB2; + uint8_t CSC1; + uint8_t CSC2; + uint8_t CSD1; + uint8_t CSD2; + //Page2 + uint8_t LA; + uint8_t HA; + uint8_t LB; + uint8_t HB; + uint8_t LC; + uint8_t HC; + uint8_t LD; + uint8_t HD; + //Page3 + uint8_t FC1; + uint8_t FC2; + uint8_t FC3; + uint8_t FC4; + uint8_t VCCP; + uint8_t FC5; + uint8_t FC6; + uint8_t FC7; + uint8_t convc1; + uint8_t convc2; + + + }; +} pack_t; +volatile pack_t pack; + + + + + +volatile int16_t am2302_temp; +volatile uint16_t am2302_hum; + + +uint8_t userRegister[1]; +int16_t sRH,sT; +double temperatureC,humidityRH,hhum; +double l; +double RH; +double TC; + + +uint8_t max_adr=0; +#define CH0_M MAX1164x_C_SCAN0|MAX1164x_C_SGL +#define CH1_M MAX1164x_C_SCAN0|MAX1164x_C_SGL|MAX1164x_C_CS0 +#define CH0_CH1 MAX1164x_C_SCAN0 +//|MAX1164x_C_CS0 + +uint16_t weekmaxarr[8]; + +//Kompensieren der Abhänigkeit von RS/RO von Temperatur und Luftfeuchte +inline double interp(double t, double h) { + double h2; + double t2; + h2=h*h; + t2=t*t; + return 4.76111e-9*h2*t2-3.96956e-7*h2*t+0.0000408889*h2-1.07132e-6*h*t2+0.000115968*h*t-0.0101333*h+0.000163806*t2-0.0241179*t+1.80591; +} + +double R0; +uint16_t mr; +uint8_t startup=10; +double ip; + + +int testSW(void) { + uint8_t r; + DDRB&=~(1<>8; + EECR |= (1< 1,5V + gcontrol=1; + + sei(); + + //DDRB|=(1<0) { //8s + ptol_s8++; + if (ptol_s8>(10000)) {//10800 ist theortisch der Tag aber meistens zu lang + ptol_s8=0; + ptol_d++; //rund 180 Jahre :-) + pr_week_max=0; + weekmaxarr[7]=pr_day_max; + for(uint8_t i=0;i<7;i++) { + weekmaxarr[i]=weekmaxarr[i+1]; + //maximum of week + if (weekmaxarr[i]>pr_week_max) pr_week_max=weekmaxarr[i]; + } + if (ptol_d>7) { + pR0=pr_week_max; + } else { + pR0=pr_day_max; + } + //R0=//R0-0.5*(pack2.R0/100-R0); + R0=R0-(R0-pR0/100.0)*0.5 ; + pR0=R0*100; + writeEEPROM(EEPROM_R0,pR0); + writeEEPROM(EEPROM_R0d,pr_day_max); //Maximum des Tages + writeEEPROM(EEPROM_R0w,pr_week_max); //Maximum der Letzten 7 Tage + writeEEPROM(EEPROM_dol,ptol_d); //Anzahl der Betriebstage + pr_day_max=0; + } + if (startup!=0) startup--; + getSHT2xHumTemp(&temperatureC,&humidityRH); + ip=interp(temperatureC,humidityRH); + pip=ip*1000; + RH=calibr_hum(temperatureC,-0.2,humidityRH); + TC =temperatureC -0.2; + mr=0; + //Kritische Sektion !___Ein Breakpoint in dieser Section kann den TGS8100 zerstoeren!___________________________ + PORTB&=~(1<1.8) { + if (mr>7200) { + if (pcmode==0) { + MAX1164x_config(MAX1164x_S_SEL2|MAX1164x_S_SEL0,CH0_CH1); + pcmode=1; + } + } + //if (l<1.6) { + if (mr<6400) { + if (pcmode==1) { + MAX1164x_config(MAX1164x_S_SEL2|MAX1164x_S_SEL0,CH0_M); + pcmode=0; + } + + + } + pVS=mr*5/2; + l=mr/4000.0; + l=( 3/l- 1) *30; + RA=l*100; + + l=l/ip; + + if (startup==0){ + if (l>R0) { + R0=l; + pR0=R0*100; + writeEEPROM(EEPROM_R0,pR0); + + } + if (l*100>pr_day_max) { + pr_day_max=l*100; + } + l=exp((1-(l/R0))*6.05)-1;// exp((1-($val)/55)*5.75); (5.75 geht über 125 6.05 geht bis 240... mittlere Linie im Datenblatt) + //l=(l/R0*100.0); + l=l*100; //fuer DS2450 + + } + else l=0; //negative Werte am Anfang verhintern + wdcounter=0; + + } + + + if (gcontrol) { + //PORTB|=(1<pack.HA) {alarmflag=1;pack.CSA2|=0x20;} + if (pack.CSA2&0x04) //AEL + if (pack.bytes[1]pack.HB) {alarmflag=1;pack.CSB2|=0x20;} + if (pack.CSB2&0x04) //AEL + if (pack.bytes[1]pack.HC) {alarmflag=1;pack.CSC2|=0x20;} + if (pack.CSC2&0x04) //AEL + if (pack.bytes[1]pack.HD) {alarmflag=1;pack.CSD2|=0x20;} + if (pack.CSD2&0x04) //AEL + if (pack.bytes[1] + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS2450 + DS2450_VOC_SHT + DS2450 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + + + + + + + -mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include + + + Default (-Wa,-g) + + + + + + compile + calibr.c + + + compile + MAX1164x.c + + + compile + SHT2xV2.c + + + compile + USI_TWI_Master.c + + + compile + + + compile + + + + \ No newline at end of file diff --git a/DS2450_VOC_SHT/OWDS2450.S b/DS2450_VOC_SHT/OWDS2450.S new file mode 100644 index 0000000..1d81abd --- /dev/null +++ b/DS2450_VOC_SHT/OWDS2450.S @@ -0,0 +1,247 @@ + +// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define _CHANGEABLE_ID_ +#define _ZERO_POLLING_ + +#include "../common/OWConfig.s" +#include "../common/OWCRC16.s" + +.extern pack,8 +.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....) +.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte.... +//.extern am2302_temp,2 + + + +.macro CHIP_INIT +.endm + +.macro COMMAND_TABLE + rjmp h_readmemoryaddr + rjmp h_readmemory + rjmp h_readmemorycrc1 + rjmp h_readmemorycrc2 + rjmp h_writememoryaddr + rjmp h_writememory + rjmp h_writememorycrc1 + rjmp h_writememorycrc2 + rjmp h_writememoryreadback + rjmp h_convert + rjmp h_convertcrc1 + rjmp h_convertcrc2 + rjmp h_convert_conv +.endm + +#include "../common/OWRomFunctions.s" +#include "../common/OWTimerInterrupt.s" + + + +; Ab hier Geraeteabhaenging +#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0 +#define OW_READ_MEMORY OW_FIRST_COMMAND+1 +#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2 +#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3 +#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4 +#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5 +#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6 +#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7 +#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8 +#define OW_CONVERT OW_FIRST_COMMAND+9 +#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10 +#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11 +#define OW_CONVERT_CONV OW_FIRST_COMMAND+12 + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + + +h_readcommand: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cset 0xAA,OW_READ_MEMORY_ADDR + cset 0x55,OW_WRITE_MEMORY_ADDR + cset 0x3C,OW_CONVERT + FW_CONFIG_INFO +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + ldi r_mode,OW_SLEEP + rjmp handle_end + + +h_readmemoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_readmemory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + rjmp handle_end_inc +h_readmemory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory + ;;ldi r_bcount,1 ;ist unten + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + clr r_bytep + rjmp h_readmemory2 +h_readmemory: + lds r_bytep,addr + inc r_bytep + sts addr,r_bytep + andi r_bytep,0x07 + breq h_readmemory_init_crc +h_readmemory2: + lds r_bytep,addr + ;andi r_bytep,0x1F ist oben + configZ pack,r_bytep + ld r_rwbyte,Z + ;ldi r_bcount,1 + rjmp handle_end ;sendet das Byte und geht zu h_readmemory +h_readmemory_init_crc:; init erstes CRC byte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_READ_MEMORY_CRC1 + ;ldi r_bcount,1 + rjmp handle_end +h_readmemory_end: + ldi r_mode,OW_SLEEP + clr r_sendflag + rjmp handle_end +h_readmemorycrc1:;init zweites CRC Byte + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_READ_MEMORY_CRC2 + rjmp handle_end +h_readmemorycrc2:;weiteres senden..... nach zweitem Byte + lds r_temp,addr + andi r_temp,0xE0 + brne h_readmemory_end; ende des speichers + ldi r_mode,OW_READ_MEMORY + CRCInit1 ;Start with new CRC + rjmp h_readmemory2 + +h_writememoryaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_writememory_addr_byte1 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + inc r_bytep + ;ldi r_bcount,1 + rjmp handle_end +h_writememory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory + ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren..... + lds r_bytep,addr + rjmp handle_end ;read Memory Byte +h_writememory: + lds r_bytep,addr + configZ pack,r_bytep + st Z,r_rwbyte + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC1 + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + rjmp handle_end +h_writememorycrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC2 + rjmp handle_end +h_writememorycrc2: + lds r_temp,addr + configZ pack,r_temp + ld r_rwbyte,Z + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_READBACK + rjmp handle_end +h_writememoryreadback: + ldi r_temp,0x00 + sts crc+1,r_temp + lds r_temp,addr + inc r_temp + sts addr,r_temp + sts crc,r_temp + ldi r_sendflag,0 + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY + rjmp handle_end + +h_convert: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_convert_byte1 ;nein dann weiter + inc r_bytep + sts pack+0x20,r_rwbyte + ;ldi r_bcount,1 + rjmp handle_end +h_convert_byte1: ;zweies byte glesen go crc# + sts pack+0x21,r_rwbyte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_CONVERT_CRC1 + ;ldi r_bcount,1 + ldi r_sendflag,1 + rjmp handle_end +h_convertcrc1: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CRC2 + rjmp handle_end +h_convertcrc2: + ldi r_temp,1 + sts gcontrol,r_temp + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CONV + ;clr r_sendflag + ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling +h_convert_conv: + ldi r_bcount,0 + ldi r_rwbyte,0 + rjmp handle_end_no_bcount + + + + +#include "../common/OWPinInterrupt.s" +.end \ No newline at end of file diff --git a/common/I2C/BME680.c b/common/I2C/BME680.c index 9907867..3d2bec7 100644 --- a/common/I2C/BME680.c +++ b/common/I2C/BME680.c @@ -76,8 +76,9 @@ #include #include +#include -#include "USI_TWI_Master.h" +#include "TWI_Master.h" #include "BME680.h" #define WC 0b11101100 @@ -237,6 +238,14 @@ const float lookup_k2_range[16] PROGMEM = { 8e6, 4e6, 2e6, 1e6,499500.4995, 248262.1648, 125000, 63004.03226, 31281.28128, 15625, 7812.5, 3906.25,1953.125,976.5625, 488.28125, 244.140625}; +const float lookup_k1_range1[16] = { + 1, 1, 1, 1, 1,0.99, 1, 0.992, +1, 1, 0.998, 0.995, 1, 0.99, 1, 1}; +const float lookup_k2_range1[16] = { + 8e6, 4e6, 2e6, 1e6,499500.4995, 248262.1648, 125000, 63004.03226, +31281.28128, 15625, 7812.5, 3906.25,1953.125,976.5625, 488.28125, 244.140625}; + + double bme680_compensate_gas_double(uint16_t gas_adc_u16, uint8_t gas_range_u8) { double gas_res_d = 0; @@ -248,11 +257,14 @@ double bme680_compensate_gas_double(uint16_t gas_adc_u16, uint8_t gas_range_u8) double var1 = 0; float a1= pgm_read_float(&(lookup_k1_range[gas_range_u8])); float a2= pgm_read_float(&(lookup_k2_range[gas_range_u8])); + //float a1=lookup_k1_range1[gas_range_u8]; + //float a2=lookup_k2_range1[gas_range_u8]; range_switching_error_val = calib.range_switching_error; var1 = (1340.0 + (5.0 * range_switching_error_val))*a1; + gas_res_d = var1*a2/(gas_adc_u16-512.0+var1); return gas_res_d; } @@ -345,6 +357,7 @@ void readBMP680(int16_t *T,uint16_t *H,uint32_t *P,uint16_t *G){ I2c_StopCondition(); *G=(((uint16_t)g1)<<2)|(g2>>6); *P=*G; + *G= bme680_compensate_gas_double(*G,g2&0xF)/10.0; int32_t temp_comp = 0; @@ -431,6 +444,5 @@ void readBMP680(int16_t *T,uint16_t *H,uint32_t *P,uint16_t *G){ *H=g2; //*P= - } diff --git a/common/I2C/BMP280.c b/common/I2C/BMP280.c index 97ab51d..9fb4319 100644 --- a/common/I2C/BMP280.c +++ b/common/I2C/BMP280.c @@ -4,7 +4,7 @@ #include #include #include -#include "USI_TWI_Master.h" +#include "TWI_Master.h" uint16_t dig_T1; int16_t dig_T2; @@ -45,6 +45,12 @@ short bmp280ReadShort(unsigned char address) } void bmp280Init(void) { + I2c_StartCondition(); + I2c_WriteByte(0xEC); + I2c_WriteByte(0xF4); + I2c_WriteByte(0b01010111); //2x Temp over 16x Press over Normal mode + I2c_WriteByte(0b11100000); //4s time / no IIfilter + I2c_StopCondition(); dig_T1=bmp280ReadShort(0x88); dig_T2=bmp280ReadShort(0x8A); dig_T3=bmp280ReadShort(0x8C); @@ -57,12 +63,7 @@ void bmp280Init(void) { dig_P7=bmp280ReadShort(0x9A); dig_P8=bmp280ReadShort(0x9C); dig_P9=bmp280ReadShort(0x9E); - I2c_StartCondition(); - I2c_WriteByte(0xEC); - I2c_WriteByte(0xF4); - I2c_WriteByte(0b01010111); //2x Temp over 16x Press over Normal mode - I2c_WriteByte(0b11100000); //4s time / no IIfilter - I2c_StopCondition(); + } @@ -133,11 +134,78 @@ int32_t bmp280ReadPressure_simple() { } +#define BMP280_S32_t int32_t +// Returns temperature in DegC, double precision. Output value of “51.23” equals 51.23 DegC. +// t_fine carries fine temperature as global value +BMP280_S32_t t_fine; +double bmp280_compensate_T_double(BMP280_S32_t adc_T) +{ + double var1, var2, T; + var1 = (((double)adc_T)/16384.0 - ((double)dig_T1)/1024.0) * ((double)dig_T2); + var2 = ((((double)adc_T)/131072.0 - ((double)dig_T1)/8192.0) * + (((double)adc_T)/131072.0 - ((double) dig_T1)/8192.0)) * ((double)dig_T3); + t_fine = (BMP280_S32_t)(var1 + var2); + T = (var1 + var2) / 5120.0; + return T; +} +// Returns pressure in Pa as double. Output value of “96386.2” equals 96386.2 Pa = 963.862 hPa +double bmp280_compensate_P_double(BMP280_S32_t adc_P) +{ + double var1, var2, p; + var1 = ((double)t_fine/2.0) - 64000.0; + var2 = var1 * var1 * ((double)dig_P6) / 32768.0; + var2 = var2 + var1 * ((double)dig_P5) * 2.0; + var2 = (var2/4.0)+(((double)dig_P4) * 65536.0); + var1 = (((double)dig_P3) * var1 * var1 / 524288.0 + ((double)dig_P2) * var1) / 524288.0; + var1 = (1.0 + var1 / 32768.0)*((double)dig_P1); + if (var1 == 0.0) + { + return 0; // avoid exception caused by division by zero + } + p = 1048576.0 - (double)adc_P; + p = (p - (var2 / 4096.0)) * 6250.0 / var1; + var1 = ((double)dig_P9) * p * p / 2147483648.0; + var2 = p * ((double)dig_P8) / 32768.0; + p = p + (var1 + var2 + ((double)dig_P7)) / 16.0; + return p; +} + +void bmp280ConvertInt_df(int32_t * temperature,uint32_t *pressure,uint8_t oss) { + //bmp280Init(); + double var1, var2, T; + int32_t adc_T=bmp280ReadTemp(); + var1 = (((double)adc_T)/16384.0 - ((double)dig_T1)/1024.0) * ((double)dig_T2); + var2 = ((((double)adc_T)/131072.0 - ((double)dig_T1)/8192.0) * + (((double)adc_T)/131072.0 - ((double) dig_T1)/8192.0)) * ((double)dig_T3); + t_fine = (BMP280_S32_t)(var1 + var2); + T = (var1 + var2) / 5120.0; + + int32_t adc_P= bmp280ReadPressure(oss); + double p; + var1 = ((double)t_fine/2.0) - 64000.0; + var2 = var1 * var1 * ((double)dig_P6) / 32768.0; + var2 = var2 + var1 * ((double)dig_P5) * 2.0; + var2 = (var2/4.0)+(((double)dig_P4) * 65536.0); + var1 = (((double)dig_P3) * var1 * var1 / 524288.0 + ((double)dig_P2) * var1) / 524288.0; + var1 = (1.0 + var1 / 32768.0)*((double)dig_P1); + if (var1 == 0.0) + { + return ; // avoid exception caused by division by zero + } + p = 1048576.0 - (double)adc_P; + p = (p - (var2 / 4096.0)) * 6250.0 / var1; + var1 = ((double)dig_P9) * p * p / 2147483648.0; + var2 = p * ((double)dig_P8) / 32768.0; + p = p + (var1 + var2 + ((double)dig_P7)) / 16.0; + *temperature=(int32_t) (T*100.0); + *pressure=(uint32_t) p; + return; +} + + void bmp280ConvertInt(int32_t * temperature,uint32_t *pressure,uint8_t oss) { int32_t var1,var2,T,t_fine; - - int32_t adc_T=bmp280ReadTemp(); var1 = ((((adc_T>>3) - ((int32_t)dig_T1<<1))) * ((int32_t)dig_T2)) >> 11; var2 = ((((((adc_T>>4) - ((int32_t)dig_T1)) * ((adc_T>>4) - (int32_t)dig_T1))) >> 12) *((int32_t)dig_T3)) >> 14; @@ -145,7 +213,7 @@ void bmp280ConvertInt(int32_t * temperature,uint32_t *pressure,uint8_t oss) { T = (t_fine * 5 + 128) >> 8; *temperature=T; int32_t adc_P= bmp280ReadPressure(oss); - uint32_t p; + int32_t p; var1 = (((int32_t)t_fine)>>1) - (int32_t)64000; var2 = (((var1>>2) * (var1>>2)) >> 11 ) * ((int32_t)dig_P6); var2 = var2 + ((var1*((int32_t)dig_P5))<<1); @@ -164,7 +232,8 @@ void bmp280ConvertInt(int32_t * temperature,uint32_t *pressure,uint8_t oss) { var1 = (((int32_t)dig_P9) * ((int32_t)(((p>>3) * (p>>3))>>13)))>>12; var2 = (((int32_t)(p>>2)) * ((int32_t)dig_P8))>>13; p = (uint32_t)((int32_t)p + ((var1 + var2 + dig_P7) >> 4)); - *pressure=p; + + *pressure=(uint32_t)(p); } diff --git a/common/I2C/BMP280.h b/common/I2C/BMP280.h index 5c9f86d..330eccd 100644 --- a/common/I2C/BMP280.h +++ b/common/I2C/BMP280.h @@ -9,6 +9,7 @@ int32_t bmp280ReadPressure(uint8_t oss); int32_t bmp280ReadPressure_simple(); void bmp280Convert(double * temperature, double * pressure,uint8_t oss); void bmp280ConvertInt(int32_t * temperature,uint32_t *pressure,uint8_t oss); +void bmp280ConvertInt_df(int32_t * temperature,uint32_t *pressure,uint8_t oss); void bmp280ConvertIntP(int32_t temp256,uint32_t *pressure) ; void bmp280ConvertIntP1(uint32_t *pressure) ; diff --git a/common/I2C/CDM7160.c b/common/I2C/CDM7160.c index e82a138..868f344 100644 --- a/common/I2C/CDM7160.c +++ b/common/I2C/CDM7160.c @@ -35,7 +35,7 @@ #include -#include "USI_TWI_Master.h" +#include "TWI_Master.h" #include "CDM7160.h" diff --git a/common/I2C/HDC2010.c b/common/I2C/HDC2010.c new file mode 100644 index 0000000..03036a3 --- /dev/null +++ b/common/I2C/HDC2010.c @@ -0,0 +1,291 @@ +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +//---------- Includes ---------------------------------------------------------- +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include "TWI_Master.h" +#include "HDC2010.h" +typedef enum{ + I2C_ADR_W = 130, // sensor I2C address + write bit //ADR=VDD + I2C_ADR_R = 131 // sensor I2C address + read bit +}etI2cHeader; + +uint8_t HDC2010_Init() { + volatile uint8_t error=0; + /*I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr + error |= I2c_WriteByte (0x02); // Config + error |= I2c_WriteByte (0x0); // 14 bit + error |= I2c_WriteByte (0x0); // + I2c_StopCondition();*/ + return error; + +} + +uint8_t HDC2010_Readf(double * temperature, double * hum) { + int16_t t; + uint16_t h; + uint8_t error=0; + error=HDC2010_Readi(&t,&h); + *temperature=(double)t/65536.0*165.0-40.0; + *hum=(double)h/65536.0*100; + return error; + +} +uint8_t HDC2010_Readi(int16_t * temperature, uint16_t * hum) { + volatile uint8_t error=0; + I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr + error |= I2c_WriteByte (0x0F); // + error |= I2c_WriteByte (0x01); // + I2c_StopCondition(); + _delay_ms(10); + I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr + error |= I2c_WriteByte (0x0); // + I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_R); //I2C address + *temperature=0; + *temperature |= I2c_ReadByte(ACK); + *temperature |= I2c_ReadByte(ACK)<<8; + *hum=0; + *hum|= I2c_ReadByte(ACK); + *hum|= I2c_ReadByte(NO_ACK)<<8; + I2c_StopCondition(); + + return error; + } + +/* + +const uint16_t POLYNOMIAL = 0x131; //P(x)=x^8+x^5+x^4+1 = 100110001 + + +//============================================================================== +uint8_t SHT2x_CheckCrc(uint8_t data[], uint8_t nbrOfBytes, uint8_t checksum) +//============================================================================== +{ + uint8_t crc = 0; + uint8_t byteCtr; + //calculates 8-Bit checksum with given polynomial + for (byteCtr = 0; byteCtr < nbrOfBytes; ++byteCtr) + { crc ^= (data[byteCtr]); + for (uint8_t bit = 8; bit > 0; --bit) + { if (crc & 0x80) crc = (crc << 1) ^ POLYNOMIAL; + else crc = (crc << 1); + } + } + if (crc != checksum) return CHECKSUM_ERROR; + else return 0; +} +//=========================================================================== +uint8_t SHT2x_ReadUserRegister(uint8_t *pRegisterValue) +//=========================================================================== +{ + uint8_t checksum; //variable for checksum byte + uint8_t error=0; //variable for error code + I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_W); + error |= I2c_WriteByte (USER_REG_R); + I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_R); + *pRegisterValue = I2c_ReadByte(ACK); + checksum=I2c_ReadByte(NO_ACK); + error |= SHT2x_CheckCrc (pRegisterValue,1,checksum); + I2c_StopCondition(); + return error; +} +//=========================================================================== +uint8_t SHT2x_WriteUserRegister(uint8_t *pRegisterValue) +//=========================================================================== +{ + uint8_t error=0; //variable for error code + I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_W); + error |= I2c_WriteByte (USER_REG_W); + error |= I2c_WriteByte (*pRegisterValue); + I2c_StopCondition(); + return error; +} +//=========================================================================== +uint8_t SHT2x_MeasureHM(etSHT2xMeasureType eSHT2xMeasureType, int16_t *pMeasurand) +//=========================================================================== +{ + uint8_t checksum; //checksum + uint8_t data[2]; //data array for checksum verification + uint8_t error=0; //error variable + uint16_t i; //counting variable + //-- write I2C sensor address and command -- + I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr + switch(eSHT2xMeasureType) + { case HUMIDITY: error |= I2c_WriteByte (TRIG_RH_MEASUREMENT_HM); break; + case TEMP : error |= I2c_WriteByte (TRIG_T_MEASUREMENT_HM); break; + //default: assert(0); + } + //-- wait until hold master is released -- + I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_R); + //SCL=HIGH; // set SCL I/O port as input + DDR_USI&=~(1<>8) & 0xFF; + *pMeasurand|=0xFF & (data[1] = I2c_ReadByte(ACK)); +// pMeasurand->s16.u8H = data[0] = I2c_ReadByte(ACK); +// pMeasurand->s16.u8L = data[1] = I2c_ReadByte(ACK); + + checksum=I2c_ReadByte(NO_ACK); + //-- verify checksum -- + error |= SHT2x_CheckCrc (data,2,checksum); + I2c_StopCondition(); + return error; +} +//=========================================================================== +uint8_t SHT2x_MeasurePoll(etSHT2xMeasureType eSHT2xMeasureType, int16_t *pMeasurand) +//=========================================================================== +{ + uint8_t checksum; //checksum + uint8_t data[2]; //data array for checksum verification + uint8_t error=0; //error variable + uint16_t i=0; //counting variable + //-- write I2C sensor address and command -- + I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr + switch(eSHT2xMeasureType) + { case HUMIDITY: error |= I2c_WriteByte (TRIG_RH_MEASUREMENT_POLL); break; + case TEMP : error |= I2c_WriteByte (TRIG_T_MEASUREMENT_POLL); break; + //default: assert(0); + } + //-- poll every 10ms for measurement ready. Timeout after 20 retries (200ms)-- + do + { I2c_StartCondition(); + _delay_ms(200); //delay 10ms + if(i++ >= 20) break; + } while(I2c_WriteByte (I2C_ADR_R) == ACK_ERROR); + if (i>=20) error |= TIME_OUT_ERROR; + //-- read two data bytes and one checksum byte -- + data[0]=I2c_ReadByte(ACK); + data[1]=I2c_ReadByte(ACK); + *pMeasurand=(data[0]<<8)|data[1]; + +// pMeasurand->s16.u8H = data[0] = I2c_ReadByte(ACK); +// pMeasurand->s16.u8L = data[1] = I2c_ReadByte(ACK); + checksum=I2c_ReadByte(NO_ACK); + //-- verify checksum -- + error |= SHT2x_CheckCrc (data,2,checksum); + I2c_StopCondition(); + return error; +} +//=========================================================================== +uint8_t SHT2x_SoftReset(void) +//=========================================================================== +{ + uint8_t error=0; //error variable + I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr + error |= I2c_WriteByte (SOFT_RESET); // Command + I2c_StopCondition(); + _delay_ms(15); // wait till sensor has restarted + return error; +} +//============================================================================== +float SHT2x_CalcRH(uint16_t u16sRH) +//============================================================================== +{ + double humidityRH; // variable for result + u16sRH &= ~0x0003; // clear bits [1..0] (status bits) + //-- calculate relative humidity [%RH] -- + humidityRH = -6.0 + 125.0/65536 * (double)u16sRH; // RH= -6 + 125 * SRH/2^16 + return humidityRH; +} +//============================================================================== +float SHT2x_CalcTemperatureC(uint16_t u16sT) +//============================================================================== +{ + double temperatureC; // variable for result + u16sT &= ~0x0003; // clear bits [1..0] (status bits) + //-- calculate temperature [°C] -- + temperatureC= -46.85 + 175.72/65536 *(double)u16sT; //T= -46.85 + 175.72 * ST/2^16 + return temperatureC; +} +//============================================================================== +uint8_t SHT2x_GetSerialNumber(uint8_t u8SerialNumber[]) +//============================================================================== +{ + uint8_t error=0; //error variable + //Read from memory location 1 + I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_W); //I2C address + error |= I2c_WriteByte (0xFA); //Command for readout on-chip memory + error |= I2c_WriteByte (0x0F); //on-chip memory address + I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_R); //I2C address + u8SerialNumber[5] = I2c_ReadByte(ACK); //Read SNB_3 + I2c_ReadByte(ACK); //Read CRC SNB_3 (CRC is not analyzed) + u8SerialNumber[4] = I2c_ReadByte(ACK); //Read SNB_2 + I2c_ReadByte(ACK); //Read CRC SNB_2 (CRC is not analyzed) + u8SerialNumber[3] = I2c_ReadByte(ACK); //Read SNB_1 + I2c_ReadByte(ACK); //Read CRC SNB_1 (CRC is not analyzed) + u8SerialNumber[2] = I2c_ReadByte(ACK); //Read SNB_0 + I2c_ReadByte(NO_ACK); //Read CRC SNB_0 (CRC is not analyzed) + I2c_StopCondition(); + //Read from memory location 2 + I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_W); //I2C address + error |= I2c_WriteByte (0xFC); //Command for readout on-chip memory + error |= I2c_WriteByte (0xC9); //on-chip memory address + I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_R); //I2C address + u8SerialNumber[1] = I2c_ReadByte(ACK); //Read SNC_1 + u8SerialNumber[0] = I2c_ReadByte(ACK); //Read SNC_0 + I2c_ReadByte(ACK); //Read CRC SNC0/1 (CRC is not analyzed) + u8SerialNumber[7] = I2c_ReadByte(ACK); //Read SNA_1 + u8SerialNumber[6] = I2c_ReadByte(ACK); //Read SNA_0 + I2c_ReadByte(NO_ACK); //Read CRC SNA0/1 (CRC is not analyzed) + I2c_StopCondition(); + return error; +} +*/ \ No newline at end of file diff --git a/common/I2C/HDC2010.h b/common/I2C/HDC2010.h new file mode 100644 index 0000000..84f133e --- /dev/null +++ b/common/I2C/HDC2010.h @@ -0,0 +1,42 @@ +#ifndef HDC2010_H +#define HDC2010_H +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +uint8_t HDC2010_Init(); + +uint8_t HDC2010_Readf(double * temperature, double * hum); +uint8_t HDC2010_Readi(int16_t * temperature, uint16_t * hum); + + +#endif diff --git a/common/I2C/LPS225HB.c b/common/I2C/LPS225HB.c new file mode 100644 index 0000000..eafb35c --- /dev/null +++ b/common/I2C/LPS225HB.c @@ -0,0 +1,129 @@ +// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +//---------- Includes ---------------------------------------------------------- +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include "USI_TWI_Master.h" +#include "LPS225HB.h" +typedef enum{ + I2C_ADR_W = 0b10111000, // sensor I2C address + write bit //ADR=VDD + I2C_ADR_R = 0b10111001 // sensor I2C address + read bit +}etI2cHeader; + +uint8_t LPS225HB_Init() { + volatile uint8_t error=0; + /*I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr + error |= I2c_WriteByte (0x02); // Config + error |= I2c_WriteByte (0x0); // 14 bit + error |= I2c_WriteByte (0x0); // + I2c_StopCondition();*/ + + + I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr + error |= I2c_WriteByte (0x11); // + //error |= I2c_WriteByte (0b01110001); // + error |= I2c_WriteByte (0b00010100); // + I2c_StopCondition(); + return error; + +} + +uint8_t LPS225HB_Readf(double * temperature, double * pressure) { + int16_t t; + uint32_t p; + uint8_t error=0; + error= LPS225HB_Readi(&t,&p); + *temperature=(double)t/100.0; + *pressure=(double)p/4096.0; + return error; + +} +uint8_t readReg(uint8_t reg) { + volatile uint8_t error=0; + uint8_t ret; + I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr + error |= I2c_WriteByte (reg); // + I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_R); //I2C address + ret= I2c_ReadByte(NO_ACK); + I2c_StopCondition(); + return ret; +} + +uint8_t LPS225HB_Readi(int16_t * temperature, uint32_t * pressure) { + volatile uint8_t error=0; + I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr + error |= I2c_WriteByte (0x11); // + //error |= I2c_WriteByte (0b00000001); // + error |= I2c_WriteByte (0b01010001); // + I2c_StopCondition(); + _delay_ms(1000); +// uint16_t status=0; +// status=readReg(0x27); +// status|=readReg(0x26)<<8; +// *pressure=0; +// *pressure|= readReg(0x28); +// *pressure|= ((uint32_t)readReg(0x29))<<8; +// *pressure|= ((uint32_t)readReg(0x2A))<<16; + + + I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr + error |= I2c_WriteByte (0x28); // + I2c_StartCondition(); + error |= I2c_WriteByte (I2C_ADR_R); //I2C address +// status= I2c_ReadByte(ACK)<<8; +// status|= I2c_ReadByte(ACK); + + + *pressure=0; + *pressure|= I2c_ReadByte(ACK); + *pressure|= ((uint32_t)I2c_ReadByte(ACK))<<8; + *pressure|= ((uint32_t)I2c_ReadByte(ACK))<<16; + *temperature=0; + *temperature |= I2c_ReadByte(ACK); + *temperature |= ((int16_t)I2c_ReadByte(NO_ACK)<<8); + I2c_StopCondition(); + //*temperature=status; + + return error; + } + diff --git a/common/I2C/LPS225HB.h b/common/I2C/LPS225HB.h new file mode 100644 index 0000000..c69f90c --- /dev/null +++ b/common/I2C/LPS225HB.h @@ -0,0 +1,42 @@ +#ifndef LPS225HB_H +#define LPS225HB_H +// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +uint8_t LPS225HB_Init(); + +uint8_t LPS225HB_Readf(double * temperature, double * pressure); +uint8_t LPS225HB_Readi(int16_t * temperature, uint32_t * pressure); + + +#endif diff --git a/common/I2C/MAX44009.c b/common/I2C/MAX44009.c index 212524b..3340dbb 100644 --- a/common/I2C/MAX44009.c +++ b/common/I2C/MAX44009.c @@ -35,7 +35,7 @@ #include -#include "USI_TWI_Master.h" +#include "TWI_Master.h" #include "MAX44009.h" uint8_t checkMAX44009(uint8_t nr) { diff --git a/common/I2C/SGP30.c b/common/I2C/SGP30.c index 62841c4..00b24cd 100644 --- a/common/I2C/SGP30.c +++ b/common/I2C/SGP30.c @@ -162,6 +162,8 @@ void save_baseline(uint16_t b1,uint16_t b2 ) { void read_baseline(uint16_t *b1,uint16_t *b2) { *b1=readEEPROM(0,0xFFFF); *b2=readEEPROM(2,0xFFFF); + *b1=0xFFFF; + *b2=0xFFFF; } void set_baseline(uint16_t b1,uint16_t b2) { diff --git a/common/I2C/SHT2x.c b/common/I2C/SHT2x.c index ae9f352..bc5b662 100644 --- a/common/I2C/SHT2x.c +++ b/common/I2C/SHT2x.c @@ -15,7 +15,7 @@ #include #include #include -#include "USI_TWI_Master.h" +#include "TWI_Master.h" #include "SHT2x.h" const uint16_t POLYNOMIAL = 0x131; //P(x)=x^8+x^5+x^4+1 = 100110001 diff --git a/common/I2C/SHT2xV2.c b/common/I2C/SHT2xV2.c index 130e85b..adbaf06 100644 --- a/common/I2C/SHT2xV2.c +++ b/common/I2C/SHT2xV2.c @@ -34,7 +34,7 @@ #define F_CPU 8000000UL #include #include -#include "USI_TWI_Master.h" +#include "TWI_Master.h" #include "SHT2xV2.h" uint8_t initSHT2x(){ @@ -97,9 +97,13 @@ uint8_t getSHT2xHumTemp(double *temp,double *hum) { if (calcCRCSHT2x(t1,t2)==tc) *temp=-46.85 + 175.72/65536 *(double)(((uint16_t)t1<<8)|(t2&0xF8)); else ret=0; - if (calcCRCSHT2x(f1,f2)==fc) + if (calcCRCSHT2x(f1,f2)==fc) { *hum=-6.0+125.0/65536*(double)(((uint16_t)f1<<8)|(f2&0xF8)); + *hum=(*hum)-((100.0/(*hum)*2.5)-2.5); + } else ret=0; + //*temp=20; + //*hum=10; return ret; } diff --git a/common/I2C/SHT3x.c b/common/I2C/SHT3x.c index b20de79..8246a32 100644 --- a/common/I2C/SHT3x.c +++ b/common/I2C/SHT3x.c @@ -12,7 +12,7 @@ #define F_CPU 8000000UL #include #include -#include "USI_TWI_Master.h" +#include "TWI_Master.h" #include "SHT3x.h" uint8_t initSHT3x(uint8_t adrline){ diff --git a/common/I2C/TSL256x.c b/common/I2C/TSL256x.c index d32ab0f..979a903 100644 --- a/common/I2C/TSL256x.c +++ b/common/I2C/TSL256x.c @@ -4,7 +4,7 @@ #include #include #include -#include "USI_TWI_Master.h" +#include "TWI_Master.h" void TSL256x_init() { I2c_StartCondition(); diff --git a/common/I2C/TWI_Master.c b/common/I2C/TWI_Master.c new file mode 100644 index 0000000..ed125ec --- /dev/null +++ b/common/I2C/TWI_Master.c @@ -0,0 +1,367 @@ + +#ifdef __4MHZ__ +#define F_CPU 4000000UL +#else +#define F_CPU 8000000UL +#endif +#include +#include "TWI_Master.h" +#include + +#if defined(__AVR_AT90Mega169__) | defined(__AVR_ATmega169PA__) | \ +defined(__AVR_AT90Mega165__) | defined(__AVR_ATmega165__) | \ +defined(__AVR_ATmega325__) | defined(__AVR_ATmega3250__) | \ +defined(__AVR_ATmega645__) | defined(__AVR_ATmega6450__) | \ +defined(__AVR_ATmega329__) | defined(__AVR_ATmega3290__) | \ +defined(__AVR_ATmega649__) | defined(__AVR_ATmega6490__) |\ +defined(__AVR_ATtiny25__) | defined(__AVR_ATtiny45__) | defined(__AVR_ATtiny85__) | \ +defined(__AVR_AT90Tiny26__) | defined(__AVR_ATtiny26__) |\ +defined(__AVR_AT90Tiny2313__) | defined(__AVR_ATtiny2313__) |\ +defined(__AVR_ATtiny84__) | defined(__AVR_ATtiny84A__) + +unsigned char USI_TWI_Master_Transfer( unsigned char ); +unsigned char USI_TWI_Master_Stop( void ); + +union USI_TWI_state +{ + unsigned char errorState; // Can reuse the TWI_state for error states due to that it will not be need if there exists an error. + struct + { + unsigned char addressMode : 1; + unsigned char masterWriteDataMode : 1; + unsigned char unused : 6; + }; +} USI_TWI_state; + +/*--------------------------------------------------------------- + USI TWI single master initialization function +---------------------------------------------------------------*/ +void TWI_Master_Initialise( void ) +{ + PORT_USI |= (1< (unsigned char*)RAMEND) // Test if address is outside SRAM space + { + USI_TWI_state.errorState = USI_TWI_DATA_OUT_OF_BOUND; + return (FALSE); + } + if(msgSize <= 1) // Test if the transmission buffer is empty + { + USI_TWI_state.errorState = USI_TWI_NO_DATA; + return (FALSE); + } +#endif + +#ifdef NOISE_TESTING // Test if any unexpected conditions have arrived prior to this execution. + if( USISR & (1< + +void TWI_Wait_Busy() { + _delay_us(100); + while (!( TWCR & (1< +//********** Defines **********// + +// Defines controlling timing limits +#define TWI_FAST_MODE +#ifdef __4MHZ__ +#define SYS_CLK 4000.0 // [kHz] +#else +#define SYS_CLK 8000.0 // [kHz] +#endif + + + +#ifdef TWI_FAST_MODE // TWI FAST mode timing limits. SCL = 100-400kHz + #define T2_TWI ((SYS_CLK *1300) /1000000) +1 // >1,3us + #define T4_TWI ((SYS_CLK * 600) /1000000) +1 // >0,6us + +#else // TWI STANDARD mode timing limits. SCL <= 100kHz + #define T2_TWI ((SYS_CLK *4700) /1000000) +1 // >4,7us + #define T4_TWI ((SYS_CLK *4000) /1000000) +1 // >4,0us +#endif + +// Defines controling code generating +//#define PARAM_VERIFICATION +//#define NOISE_TESTING +//#define SIGNAL_VERIFY + +//USI_TWI messages and flags and bit masks +//#define SUCCESS 7 +//#define MSG 0 +/**************************************************************************** + Bit and byte definitions +****************************************************************************/ +#define TWI_READ_BIT 0 // Bit position for R/W bit in "address byte". +#define TWI_ADR_BITS 1 // Bit position for LSB of the slave address bits in the init byte. +#define TWI_NACK_BIT 0 // Bit position for (N)ACK bit. + +#define USI_TWI_NO_DATA 0x00 // Transmission buffer is empty +#define USI_TWI_DATA_OUT_OF_BOUND 0x01 // Transmission buffer is outside SRAM space +#define USI_TWI_UE_START_CON 0x02 // Unexpected Start Condition +#define USI_TWI_UE_STOP_CON 0x03 // Unexpected Stop Condition +#define USI_TWI_UE_DATA_COL 0x04 // Unexpected Data Collision (arbitration) +#define USI_TWI_NO_ACK_ON_DATA 0x05 // The slave did not acknowledge all data +#define USI_TWI_NO_ACK_ON_ADDRESS 0x06 // The slave did not acknowledge the address +#define USI_TWI_MISSING_START_CON 0x07 // Generated Start Condition not detected on bus +#define USI_TWI_MISSING_STOP_CON 0x08 // Generated Stop Condition not detected on bus + +// Device dependant defines + +#if defined(__AVR_AT90Mega169__) | defined(__AVR_ATmega169PA__) | \ + defined(__AVR_AT90Mega165__) | defined(__AVR_ATmega165__) | \ + defined(__AVR_ATmega325__) | defined(__AVR_ATmega3250__) | \ + defined(__AVR_ATmega645__) | defined(__AVR_ATmega6450__) | \ + defined(__AVR_ATmega329__) | defined(__AVR_ATmega3290__) | \ + defined(__AVR_ATmega649__) | defined(__AVR_ATmega6490__) + #define DDR_USI DDRE + #define PORT_USI PORTE + #define PIN_USI PINE + #define PORT_USI_SDA PORTE5 + #define PORT_USI_SCL PORTE4 + #define PIN_USI_SDA PINE5 + #define PIN_USI_SCL PINE4 +#endif + +#if defined(__AVR_ATtiny25__) | defined(__AVR_ATtiny45__) | defined(__AVR_ATtiny85__) | \ + defined(__AVR_AT90Tiny26__) | defined(__AVR_ATtiny26__) + #define DDR_USI DDRB + #define PORT_USI PORTB + #define PIN_USI PINB + #define PORT_USI_SDA PORTB0 + #define PORT_USI_SCL PORTB2 + #define PIN_USI_SDA PINB0 + #define PIN_USI_SCL PINB2 +#endif + +#if defined(__AVR_AT90Tiny2313__) | defined(__AVR_ATtiny2313__) + #define DDR_USI DDRB + #define PORT_USI PORTB + #define PIN_USI PINB + #define PORT_USI_SDA PORTB5 + #define PORT_USI_SCL PORTB7 + #define PIN_USI_SDA PINB5 + #define PIN_USI_SCL PINB7 +#endif + +#if defined(__AVR_ATtiny84__) | defined(__AVR_ATtiny84A__) +#define DDR_USI DDRA +#define PORT_USI PORTA +#define PIN_USI PINA +#define PORT_USI_SDA PORTA6 +#define PORT_USI_SCL PORTA4 +#define PIN_USI_SDA PINA6 +#define PIN_USI_SCL PINA4 +#endif + + +//****************** ATMEGA TWI without USI +#define TWI_BUFFER_SIZE 4 // Set this to the largest message size that will be sent including address byte. +#define TWI_TWBR 0x4C; // 0x0C // TWI Bit rate Register setting. // Se Application note for detailed // information on setting this value. + + + +#define ACK (1< -#include "USI_TWI_Master.h" +#include "TWI_Master.h" #include unsigned char USI_TWI_Master_Transfer( unsigned char ); diff --git a/common/I2C/USI_TWI_Master.h b/common/I2C/USI_TWI_Master.h index d6b1f85..19f3e88 100644 --- a/common/I2C/USI_TWI_Master.h +++ b/common/I2C/USI_TWI_Master.h @@ -121,12 +121,23 @@ #define PIN_USI_SCL PINA4 #endif + +#if defined(__AVR_ATmega328__) | defined(__AVR_ATmega328P__) | defined(__AVR_ATmega328PB__) +#define DDR_USI DDRC +#define PORT_USI PORTC +#define PIN_USI PINC +#define PORT_USI_SDA PORTC4 +#define PORT_USI_SCL PORTC5 +#define PIN_USI_SDA PINC4 +#define PIN_USI_SCL PINC5 +#endif + // General defines #define TRUE 1 #define FALSE 0 -#define ACK (1<VOC use different + st Z,r_rwbyte + rjmp handle_end_sleep + +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** + + + +h_readcommand2: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cjmp 0xBE,hrc_set_readscratchpad2 + cjmp 0x4E,hrc_set_writescratchpad2 + cjmp 0x44,hrc_set_convertT2 + cjmp 0x48,hrc_copy_scratchpad2 + cjmp 0xB8,hrc_recall_eeprom2 + FW_CONFIG_INFO2 +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + ldi r_mode,OW_SLEEP + rjmp handle_end + +hrc_set_readscratchpad2: + ldi r_mode,OW_READ_SCRATCHPAD2 + ldi r_sendflag,1 + CRCInit2 + rjmp h_readscratchpad2 + +hrc_set_writescratchpad2: + ldi r_mode,OW_WRITE_SCRATCHPAD2 + ldi r_bytep,2 ;start to write in 2 + rjmp handle_end + +hrc_recall_eeprom2: + rcall hrc_recall_eeprom_func2 + rjmp handle_end + +hrc_set_convertT2: + ldi r_temp,1 + sts gcontrol,r_temp +hrc_set_convertT22b: + ldi r_mode,OW_CONVERT_RUN2 + ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling +h_convert_run2: + ldi r_bcount,0 + ldi r_rwbyte,0 + rjmp handle_end_no_bcount + + + +hrc_copy_scratchpad2: + ldi r_bytep,2 + configZ pack2,r_bytep + clr r_bytep +hrc_copy_scratchpad_EEPROM_write2: + sbic _SFR_IO_ADDR(EECR), EEPE + rjmp hrc_copy_scratchpad_EEPROM_write2 + ldi r_temp, (0<VOC use different + st Z,r_rwbyte + rjmp handle_end_sleep + + + + + +#include "../common/OWPinInterrupt.s" +.end diff --git a/common/OWDS18B20_DS2408.S b/common/OWDS18B20_DS2408.S new file mode 100644 index 0000000..3b7802a --- /dev/null +++ b/common/OWDS18B20_DS2408.S @@ -0,0 +1,456 @@ + +// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define _CHANGEABLE_ID_ +#define _ZERO_POLLING_ +#define _HANDLE_CC_COMMAND_ +#include "../common/OWConfig.s" +#include "../common/OWCRC8_16.s" + +.extern pack1,8 + +.extern pack2,8 +.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....) +.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte.... +//.extern am2302_temp,2 +.comm stat_to_sample,1 + +.comm block,1 ; Block der augegeben, geschrieben wird (Parameter von READ/WRITE Scratchpad) +.comm cpsp,1 ; Copy Scratchpad marker + +.macro CHIP_INIT ;r_temp is pushed other Registers should be saved + ldi r_temp,0 + sts cpsp,r_temp +Init_EEPROM_read: + push r_bytep + push r_rwbyte + sbic _SFR_IO_ADDR(EECR), EEPE + rjmp Init_EEPROM_read + ldi r_temp,0 + out _SFR_IO_ADDR(EEARH), r_temp + ldi r_temp,2 + out _SFR_IO_ADDR(EEARL), r_temp + sbi _SFR_IO_ADDR(EECR), EERE + in r_temp,_SFR_IO_ADDR(EEDR) + sbrs r_temp,7 + rcall hrc_recall_eeprom_func1 + pop r_rwbyte + pop r_bytep +.endm + + +.macro COMMAND_TABLE + rjmp h_readscratchpad1 + rjmp h_writescratchpad1 + rjmp h_convert_run1 + rjmp h_readpioregaddr2 + rjmp h_readpioreg2 + rjmp h_readpioregcrc12 + rjmp h_readpioregcrc22 + rjmp h_readchanel2 + rjmp h_readchanel_crc2 + rjmp h_writechanel2 + rjmp h_writecomchanel2 + rjmp h_writesendaa2 + rjmp h_writesendchanel2 + rjmp h_resetactivity2 + rjmp h_writeregaddr2 + rjmp h_writereg2 +.endm + +#include "../common/OWRomFunctionsDual.s" +#include "../common/OWTimerInterrupt.s" + + + +; Ab hier Geraeteabhaenging + +#define OW_READ_SCRATCHPAD1 OW_FIRST_COMMAND+0 +#define OW_WRITE_SCRATCHPAD1 OW_FIRST_COMMAND+1 +#define OW_CONVERT_RUN1 OW_FIRST_COMMAND+2 + +#define OW_READ_PIO_REG_ADDR2 OW_FIRST_COMMAND+3 +#define OW_READ_PIO_REG2 OW_FIRST_COMMAND+4 +#define OW_READ_PIO_REG_CRC12 OW_FIRST_COMMAND+5 +#define OW_READ_PIO_REG_CRC22 OW_FIRST_COMMAND+6 +#define OW_READ_CHANEL2 OW_FIRST_COMMAND+7 +#define OW_READ_CHANEL_CRC2 OW_FIRST_COMMAND+8 +#define OW_WRITE_CHANEL2 OW_FIRST_COMMAND+9 +#define OW_WRITE_COMCHANEL2 OW_FIRST_COMMAND+10 +#define OW_WRITE_SENDAA2 OW_FIRST_COMMAND+11 +#define OW_WRITE_SEND_CHANEL2 OW_FIRST_COMMAND+12 +#define OW_RESET_ACTIVITY2 OW_FIRST_COMMAND+13 +#define OW_WRITE_REG_ADDR2 OW_FIRST_COMMAND+14 +#define OW_WRITE_REG2 OW_FIRST_COMMAND+15 + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + +#ifdef _HANDLE_CC_COMMAND_ +h_readcommand12: + clr r_bytep + cjmp 0x44,hrc_set_convertT12 + ldi r_mode,OW_SLEEP + rjmp handle_end +#endif + + +h_readcommand1: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cjmp 0xBE,hrc_set_readscratchpad1 + cjmp 0x4E,hrc_set_writescratchpad1 + cjmp 0x44,hrc_set_convertT1 + cjmp 0x48,hrc_copy_scratchpad1 + cjmp 0xB8,hrc_recall_eeprom1 + FW_CONFIG_INFO1 +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + ldi r_mode,OW_SLEEP + rjmp handle_end + +hrc_set_readscratchpad1: + ldi r_mode,OW_READ_SCRATCHPAD1 + ldi r_sendflag,1 + CRCInit2 + rjmp h_readscratchpad1 + +hrc_set_writescratchpad1: + ldi r_mode,OW_WRITE_SCRATCHPAD1 + ldi r_bytep,2 ;start to write in 2 + rjmp handle_end + +hrc_recall_eeprom1: + rcall hrc_recall_eeprom_func1 + rjmp handle_end + +#ifdef _HANDLE_CC_COMMAND_ +hrc_set_convertT12: + rjmp hrc_set_convertT1 +#endif + +hrc_set_convertT1: + ldi r_temp,16 + sts gcontrol,r_temp +hrc_set_convertT12b: + ldi r_mode,OW_CONVERT_RUN1 + ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling +h_convert_run1: + ldi r_bcount,0 + ldi r_rwbyte,0 + rjmp handle_end_no_bcount + + + +hrc_copy_scratchpad1: + ldi r_bytep,2 + configZ pack1,r_bytep + clr r_bytep +hrc_copy_scratchpad_EEPROM_write1: + sbic _SFR_IO_ADDR(EECR), EEPE + rjmp hrc_copy_scratchpad_EEPROM_write1 + ldi r_temp, (0<VOC use different + st Z,r_rwbyte + rjmp handle_end_sleep + +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** + + + + + + + + + + + + + + + + + + + + + + + +h_readcommand2: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cset 0xF0,OW_READ_PIO_REG_ADDR2 + cljmp 0xF5,hrc_readchanel2 + cset 0x5A,OW_WRITE_CHANEL2 + cljmp 0xC3,hrc_reset_activity2 + cset 0xCC,OW_WRITE_REG_ADDR2 + FW_CONFIG_INFO2 +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + ldi r_mode,OW_SLEEP + rjmp handle_end + + +h_readpioregaddr2: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_readpioreg_addr_byte12 ;nein dann weiter + //andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + subi r_rwbyte,0x89 ;beim lesen von 0x88 --> 0xFF inc addr -> 0x00 + sts addr,r_rwbyte ;speichern des ersten bytes + rjmp handle_end_inc +h_readpioreg_addr_byte12: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_READ_PIO_REG2 ;weiter zu read Memory + ;;ldi r_bcount,1 ;ist unten + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + clr r_bytep +h_readpioreg2: + lds r_bytep,addr + inc r_bytep + sts addr,r_bytep + cpi r_bytep,0x08 + breq h_readpioreg_init_crc2 + brge h_readpioreg_end2 ; groeser dann nix senden + configZ pack2,r_bytep + ld r_rwbyte,Z + ;ldi r_bcount,1 + rjmp handle_end ;sendet das Byte und geht zu h_readmemory +h_readpioreg_init_crc2:; init erstes CRC byte + lds r_rwbyte,crc16 + com r_rwbyte + lds r_temp,crc16+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_READ_PIO_REG_CRC12 + ;ldi r_bcount,1 + rjmp handle_end +h_readpioreg_end2: + ldi r_mode,OW_SLEEP + clr r_sendflag + rjmp handle_end +h_readpioregcrc12:;init zweites CRC Byte + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_READ_PIO_REG_CRC22 + rjmp handle_end +h_readpioregcrc22: ; 2. CRC Byte gesendet + rjmp h_readpioreg_end2 + + +hrc_readchanel2: + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + ldi r_mode,OW_READ_CHANEL2 + ldi r_temp,8 + sts gcontrol,r_temp + rjmp h_readchanel12 +h_readchanel2: + ldi r_temp,4 + sts gcontrol,r_temp +h_readchanel12: + cpi r_bytep,31 + brge h_readchanelcrc12 + lds r_rwbyte,stat_to_sample + sts pack2,r_rwbyte //sample + rjmp handle_end_inc +h_readchanelcrc12: + lds r_rwbyte,crc16 + com r_rwbyte + lds r_temp,crc16+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_READ_CHANEL_CRC2 + ;ldi r_bcount,1 + rjmp handle_end +h_readchanel_crc2: + clr r_bytep + ldi r_mode,OW_READ_CHANEL2 + lds r_rwbyte,crcsave + rjmp handle_end + +h_writechanel2: + sts crcsave,r_rwbyte + ldi r_mode,OW_WRITE_COMCHANEL2 + rjmp handle_end +h_writecomchanel2: + com r_rwbyte + lds r_temp,crcsave + cp r_rwbyte,r_temp + breq h_writeok2 + rjmp handle_end_sleep +h_writeok2: + sts pack2+1,r_rwbyte + ldi r_temp2,1 + sts gcontrol,r_temp2 + clr r_sendflag + ldi r_rwbyte,0xAA + ldi r_mode,OW_WRITE_SENDAA2 + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + rjmp handle_end +h_writesendaa2: + lds r_rwbyte,pack2 + ldi r_mode,OW_WRITE_SEND_CHANEL2 + rjmp handle_end +h_writesendchanel2: + rjmp handle_end_sleep + + + +hrc_reset_activity2: + ldi r_temp,2 + sts gcontrol,r_temp + ldi r_rwbyte,0xAA + ldi r_mode,OW_RESET_ACTIVITY2 + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + rjmp handle_end +h_resetactivity2: + rjmp handle_end_sleep + + +h_writeregaddr2: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_writeregddr_byte12 ;nein dann weiter + //andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + subi r_rwbyte,0x8B + brmi h_writereg_end2 + sts addr,r_rwbyte ;speichern des ersten bytes + rjmp handle_end_inc +h_writeregddr_byte12: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_WRITE_REG2 ;weiter zu write Memory + ;;ldi r_bcount,1 ;ist unten + clr r_bytep + rjmp handle_end +h_writereg2: + lds r_temp,addr + configZ pack2+3,r_temp + st Z,r_rwbyte + cpi r_temp,5 + brge h_writereg_end2 + inc r_temp + sts addr,r_temp + rjmp handle_end_sleep + +h_writereg_end2: + rjmp handle_end_sleep + + + + + +#include "../common/OWPinInterrupt.s" +.end \ No newline at end of file diff --git a/common/OWDS18B20_DS2438.S b/common/OWDS18B20_DS2438.S index 73fd42e..a95559e 100644 --- a/common/OWDS18B20_DS2438.S +++ b/common/OWDS18B20_DS2438.S @@ -34,7 +34,8 @@ #define _CHANGEABLE_ID_ #define _ZERO_POLLING_ #define _HANDLE_CC_COMMAND_ - +#define _NO_BOOTLOADER_PIN_ +//#define __4MHZ__ //#define _DB_ #include "../common/OWConfig.s" @@ -42,15 +43,14 @@ .extern pack1,8 -//.extern am2302_temp,2 - #if defined(__AVR_ATtiny25__) .extern pack2,16 #else .extern pack2,64 #endif -//.extern am2302_temp,2 -//.extern am2302_hum,2 + + + .comm block,1 ; Block der augegeben, geschrieben wird (Parameter von READ/WRITE Scratchpad) .comm cpsp,1 ; Copy Scratchpad marker @@ -110,8 +110,9 @@ Init_EEPROM_read: h_readcommand12: clr r_bytep cjmp 0x44,hrc_set_convertT12 - ldi r_mode,OW_SLEEP - rjmp handle_end + rjmp h_readcccommand ;fuehre DS2438 commands aus... + //ldi r_mode,OW_SLEEP + //rjmp handle_end #endif @@ -120,9 +121,10 @@ h_readcommand1: #ifndef _DIS_FLASH_ FLASH_COMMANDS ; muss zu erst sein.... #endif + cjmp 0x44,hrc_set_convertT1 +h_readcccommand: cjmp 0xBE,hrc_set_readscratchpad1 cjmp 0x4E,hrc_set_writescratchpad1 - cjmp 0x44,hrc_set_convertT1 cjmp 0x48,hrc_copy_scratchpad1 cjmp 0xB8,hrc_recall_eeprom1 FW_CONFIG_INFO1 @@ -151,9 +153,9 @@ hrc_recall_eeprom1: hrc_set_convertT12: ldi r_temp,3 sts gcontrol,r_temp - lds r_temp,am2302_temp + lds r_temp,DS2438_2_TEMP sts pack2+1,r_temp - lds r_temp,am2302_temp+1 + lds r_temp,DS2438_2_TEMP+1 sts pack2+2,r_temp rjmp hrc_set_convertT12b #endif @@ -288,26 +290,28 @@ h_readcommand2: hrc_set_convertT2: ldi r_temp,2 sts gcontrol,r_temp - lds r_temp,am2302_temp + lds r_temp,DS2438_2_TEMP sts pack2+1,r_temp - lds r_temp,am2302_temp+1 + lds r_temp,DS2438_2_TEMP+1 sts pack2+2,r_temp rjmp handle_end_sleep hrc_set_convertV2: + ldi r_temp,4 + sts gcontrol,r_temp lds r_temp,pack2 sbrs r_temp,3 rjmp hrc_set_convertVV2 - ldi r_temp,0xF4 + lds r_temp,DS2438_2_VDD sts pack2+3,r_temp - ldi r_temp,0x01 + lds r_temp,DS2438_2_VDD+1 sts pack2+4,r_temp rjmp hrc_set_convertend2 hrc_set_convertVV2: - ldi r_temp,3 + ldi r_temp,8 sts gcontrol,r_temp - lds r_temp,am2302_hum + lds r_temp,DS2438_2_VAD sts pack2+3,r_temp - lds r_temp,am2302_hum+1 + lds r_temp,DS2438_2_VAD+1 sts pack2+4,r_temp hrc_set_convertend2: rjmp handle_end_sleep diff --git a/common/OWDS2408.S b/common/OWDS2408.S new file mode 100644 index 0000000..1bad722 --- /dev/null +++ b/common/OWDS2408.S @@ -0,0 +1,255 @@ + +// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define _CHANGEABLE_ID_ +#define _ZERO_POLLING_ + +#include "../common/OWConfig.s" +#include "../common/OWCRC16.s" + +.extern pack,8 +.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....) +.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte.... +//.extern am2302_temp,2 +.comm stat_to_sample,1 + + + +.macro CHIP_INIT +.endm + +.macro COMMAND_TABLE + rjmp h_readpioregaddr + rjmp h_readpioreg + rjmp h_readpioregcrc1 + rjmp h_readpioregcrc2 + rjmp h_readchanel + rjmp h_readchanel_crc + rjmp h_writechanel + rjmp h_writecomchanel + rjmp h_writesendaa + rjmp h_writesendchanel + rjmp h_resetactivity + rjmp h_writeregaddr + rjmp h_writereg +.endm + +#include "../common/OWRomFunctions.s" +#include "../common/OWTimerInterrupt.s" + + + +; Ab hier Geraeteabhaenging +#define OW_READ_PIO_REG_ADDR OW_FIRST_COMMAND+0 +#define OW_READ_PIO_REG OW_FIRST_COMMAND+1 +#define OW_READ_PIO_REG_CRC1 OW_FIRST_COMMAND+2 +#define OW_READ_PIO_REG_CRC2 OW_FIRST_COMMAND+3 +#define OW_READ_CHANEL OW_FIRST_COMMAND+4 +#define OW_READ_CHANEL_CRC OW_FIRST_COMMAND+5 +#define OW_WRITE_CHANEL OW_FIRST_COMMAND+6 +#define OW_WRITE_COMCHANEL OW_FIRST_COMMAND+7 +#define OW_WRITE_SENDAA OW_FIRST_COMMAND+8 +#define OW_WRITE_SEND_CHANEL OW_FIRST_COMMAND+9 +#define OW_RESET_ACTIVITY OW_FIRST_COMMAND+10 +#define OW_WRITE_REG_ADDR OW_FIRST_COMMAND+11 +#define OW_WRITE_REG OW_FIRST_COMMAND+12 + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + + +h_readcommand: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cset 0xF0,OW_READ_PIO_REG_ADDR + cljmp 0xF5,hrc_readchanel + cset 0x5A,OW_WRITE_CHANEL + cljmp 0xC3,hrc_reset_activity + cset 0xCC,OW_WRITE_REG_ADDR + FW_CONFIG_INFO +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + ldi r_mode,OW_SLEEP + rjmp handle_end + + +h_readpioregaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_readpioreg_addr_byte1 ;nein dann weiter + //andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + subi r_rwbyte,0x89 ;beim lesen von 0x88 --> 0xFF inc addr -> 0x00 + sts addr,r_rwbyte ;speichern des ersten bytes + rjmp handle_end_inc +h_readpioreg_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_READ_PIO_REG ;weiter zu read Memory + ;;ldi r_bcount,1 ;ist unten + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + clr r_bytep +h_readpioreg: + lds r_bytep,addr + inc r_bytep + sts addr,r_bytep + cpi r_bytep,0x08 + breq h_readpioreg_init_crc + brge h_readpioreg_end ; groeser dann nix senden + configZ pack,r_bytep + ld r_rwbyte,Z + ;ldi r_bcount,1 + rjmp handle_end ;sendet das Byte und geht zu h_readmemory +h_readpioreg_init_crc:; init erstes CRC byte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_READ_PIO_REG_CRC1 + ;ldi r_bcount,1 + rjmp handle_end +h_readpioreg_end: + ldi r_mode,OW_SLEEP + clr r_sendflag + rjmp handle_end +h_readpioregcrc1:;init zweites CRC Byte + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_READ_PIO_REG_CRC2 + rjmp handle_end +h_readpioregcrc2: ; 2. CRC Byte gesendet + rjmp h_readpioreg_end + + +hrc_readchanel: + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + ldi r_mode,OW_READ_CHANEL + ldi r_temp,8 + sts gcontrol,r_temp + rjmp h_readchanel1 +h_readchanel: + ldi r_temp,4 + sts gcontrol,r_temp +h_readchanel1: + cpi r_bytep,31 + brge h_readchanelcrc1 + lds r_rwbyte,stat_to_sample + sts pack,r_rwbyte //sample + rjmp handle_end_inc +h_readchanelcrc1: + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_READ_CHANEL_CRC + ;ldi r_bcount,1 + rjmp handle_end +h_readchanel_crc: + clr r_bytep + ldi r_mode,OW_READ_CHANEL + lds r_rwbyte,crcsave + rjmp handle_end + +h_writechanel: + sts crcsave,r_rwbyte + ldi r_mode,OW_WRITE_COMCHANEL + rjmp handle_end +h_writecomchanel: + com r_rwbyte + lds r_temp,crcsave + cp r_rwbyte,r_temp + breq h_writeok + rjmp handle_end_sleep +h_writeok: + sts pack+1,r_rwbyte + ldi r_temp2,1 + sts gcontrol,r_temp2 + clr r_sendflag + ldi r_rwbyte,0xAA + ldi r_mode,OW_WRITE_SENDAA + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + rjmp handle_end +h_writesendaa: + lds r_rwbyte,pack + ldi r_mode,OW_WRITE_SEND_CHANEL + rjmp handle_end +h_writesendchanel: + rjmp handle_end_sleep + + + +hrc_reset_activity: + ldi r_temp,2 + sts gcontrol,r_temp + ldi r_rwbyte,0xAA + ldi r_mode,OW_RESET_ACTIVITY + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + rjmp handle_end +h_resetactivity: + rjmp handle_end_sleep + + +h_writeregaddr: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_writeregddr_byte1 ;nein dann weiter + //andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + subi r_rwbyte,0x8B + brmi h_writereg_end + sts addr,r_rwbyte ;speichern des ersten bytes + rjmp handle_end_inc +h_writeregddr_byte1: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_WRITE_REG ;weiter zu write Memory + ;;ldi r_bcount,1 ;ist unten + clr r_bytep + rjmp handle_end +h_writereg: + lds r_temp,addr + configZ pack+3,r_temp + st Z,r_rwbyte + cpi r_temp,5 + brge h_writereg_end + inc r_temp + sts addr,r_temp + rjmp handle_end_sleep + +h_writereg_end: + rjmp handle_end_sleep + + + + + +#include "../common/OWPinInterrupt.s" +.end \ No newline at end of file diff --git a/common/OWDS2413_DS2413.S b/common/OWDS2413_DS2413.S new file mode 100644 index 0000000..df6d04b --- /dev/null +++ b/common/OWDS2413_DS2413.S @@ -0,0 +1,248 @@ + +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define _CHANGEABLE_ID_ +#define _ZERO_POLLING_ +//#define _HANDLE_CC_COMMAND_ +//#define _DB_ +//#define __4MHZ__ + + +#include "../common/OWConfig.s" +#include "../common/OWCRC16.s" + +.extern pin_state1,1 +.extern pin_state1,1 +.extern pin_state2,1 +.extern pin_set2,1 +.comm resv1,1 +.comm resv2,1 +.macro CHIP_INIT ;r_temp is pushed other Registers should be saved +.endm + +.macro COMMAND_TABLE + + rjmp h_accessread1 + rjmp h_accesswrite1 + rjmp h_accesswrite_read1 + + rjmp h_accessread2 + rjmp h_accesswrite2 + rjmp h_accesswrite_read2 +.endm + +#include "../common/OWRomFunctionsDual.s" +#include "../common/OWTimerInterrupt.s" + + + +; Ab hier Geraeteabhaenging +#define OW_ACCESSREAD1 OW_FIRST_COMMAND+0 +#define OW_ACCESSWRITE1 OW_FIRST_COMMAND+1 +#define OW_ACCESSWRITE_READ1 OW_FIRST_COMMAND+2 + + +#define OW_ACCESSREAD2 OW_FIRST_COMMAND+3 +#define OW_ACCESSWRITE2 OW_FIRST_COMMAND+4 +#define OW_ACCESSWRITE_READ2 OW_FIRST_COMMAND+5 + + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + +h_readcommand1: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cjmp 0xF5,hrc_accessread1 + cset 0x5A,OW_ACCESSWRITE1 +/* cset 0xBE,OW_READ_SCRATCHPAD_ADR2 + cset 0x4E,OW_WRITE_SCRATCHPAD_ADR2 + cjmp 0x44,hrc_set_convertT2 + cjmp 0xB4,hrc_set_convertV2*/ + FW_CONFIG_INFO1 + //cljmp 0x85,hrc_fw_configinfo2 +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + rjmp handle_end_sleep + + +hrc_accessread1: + ldi r_sendflag,1 + ldi r_mode,OW_ACCESSREAD1 +h_accessread1: + lds r_temp,pin_state1 + andi r_temp,0x0F + mov r_rwbyte,r_temp + com r_rwbyte + swap r_rwbyte + andi r_rwbyte,0xF0 + or r_rwbyte,r_temp + rjmp handle_end + + + + +h_accesswrite_read1: + //lds r_rwbyte,pin_state1 + rjmp handle_end_sleep + + + +h_accesswrite1: + cpi r_bytep,1 + breq h_accesswrite_compl1 + sts resv1,r_rwbyte + rjmp handle_end_inc +h_accesswrite_compl1: + com r_rwbyte + lds r_temp,resv1 + cp r_temp,r_rwbyte + brne h_accesswrite_error1 + sts pin_set1,r_rwbyte + ldi r_mode,OW_ACCESSWRITE_READ1 + ldi r_rwbyte,0xAA + ldi r_sendflag,1 + rjmp handle_end_inc +h_accesswrite_error1: + rjmp handle_end_sleep + + + + + + +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** + + +h_readcommand2: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cjmp 0xF5,hrc_accessread2 + cset 0x5A,OW_ACCESSWRITE2 +/* cset 0xBE,OW_READ_SCRATCHPAD_ADR2 + cset 0x4E,OW_WRITE_SCRATCHPAD_ADR2 + cjmp 0x44,hrc_set_convertT2 + cjmp 0xB4,hrc_set_convertV2*/ + FW_CONFIG_INFO2 + //cljmp 0x85,hrc_fw_configinfo2 +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + rjmp handle_end_sleep + + +hrc_accessread2: + ldi r_sendflag,1 + ldi r_mode,OW_ACCESSREAD2 +h_accessread2: + lds r_temp,pin_state2 + andi r_temp,0x0F + mov r_rwbyte,r_temp + com r_rwbyte + swap r_rwbyte + andi r_rwbyte,0xF0 + or r_rwbyte,r_temp + rjmp handle_end + + + + +h_accesswrite_read2: + //lds r_rwbyte,pin_state2 + rjmp handle_end_sleep + + + +h_accesswrite2: + cpi r_bytep,1 + breq h_accesswrite_compl2 + sts resv2,r_rwbyte + rjmp handle_end_inc +h_accesswrite_compl2: + com r_rwbyte + lds r_temp,resv2 + cp r_temp,r_rwbyte + brne h_accesswrite_error2 + sts pin_set2,r_rwbyte + ldi r_mode,OW_ACCESSWRITE_READ2 + ldi r_rwbyte,0xAA + ldi r_sendflag,1 + rjmp handle_end_inc +h_accesswrite_error2: + rjmp handle_end_sleep +/* +;--------------------------------------------------- +; WRITE SCRATCHPAD +;--------------------------------------------------- +h_writescratchpad_adr2: + lsl r_rwbyte + lsl r_rwbyte + lsl r_rwbyte +#if defined(__AVR_ATtiny25__) + andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen +#endif + sts block,r_rwbyte + ldi r_mode,OW_WRITE_SCRATCHPAD2 + ldi r_bcount,1 + rjmp handle_end +h_writescratchpad2: + cpi r_bytep,8 + breq h_writescratchpad_all2 + lds r_temp,block + add r_temp,r_bytep + configZ pack2,r_temp + st Z,r_rwbyte + rjmp handle_end_inc +h_writescratchpad_all2: + rjmp handle_end_sleep + + + + + + + */ + + +#include "../common/OWPinInterrupt.s" +.end diff --git a/common/OWDS2438_DS2438.S b/common/OWDS2438_DS2438.S index 2d2c891..78b51c1 100644 --- a/common/OWDS2438_DS2438.S +++ b/common/OWDS2438_DS2438.S @@ -31,9 +31,14 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#ifndef _NOCHANGEABLE_ID_ #define _CHANGEABLE_ID_ +#endif #define _ZERO_POLLING_ #define _HANDLE_CC_COMMAND_ +#define _NO_BOOTLOADER_PIN_ +//#define __4MHZ__ + //#define _DB_ #include "../common/OWConfig.s" @@ -139,9 +144,9 @@ chrc_set_convertV1: lds r_temp,pack1 sbrs r_temp,3 rjmp hrc_set_convertVV1 - ldi r_temp,0xF4 //5V + lds r_temp,DS2438_1_VDD sts pack1+3,r_temp - ldi r_temp,0x01 + lds r_temp,DS2438_1_VDD+1 sts pack1+4,r_temp rjmp hrc_set_convertend1 hrc_set_convertVV1: @@ -284,9 +289,9 @@ chrc_set_convertV2: lds r_temp,pack2 sbrs r_temp,3 rjmp hrc_set_convertVV2 - ldi r_temp,0xF4 + lds r_temp,DS2438_2_VDD sts pack2+3,r_temp - ldi r_temp,0x01 + lds r_temp,DS2438_2_VDD+1 sts pack2+4,r_temp rjmp hrc_set_convertend2 hrc_set_convertVV2: diff --git a/common/OWDS2450_DS2423.S b/common/OWDS2450_DS2423.S new file mode 100644 index 0000000..f4ca4f5 --- /dev/null +++ b/common/OWDS2450_DS2423.S @@ -0,0 +1,548 @@ + +// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define _CHANGEABLE_ID_ +#define _ZERO_POLLING_ + +#include "../common/OWConfig.s" +#include "../common/OWCRC16.s" + +.extern pack1,20 +.extern pack2,45 +.extern counters2,16 +//Bleiben gleich denn es werden nicht beide gleichzeitig abgefragt +.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....) +.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte.... +//.extern am2302_temp,2 + +.comm gcontrol1,1 +.comm gcontrol2,1 + +.macro CHIP_INIT +.endm + +.macro COMMAND_TABLE + rjmp h_readmemoryaddr1 + rjmp h_readmemory1 + rjmp h_readmemorycrc11 + rjmp h_readmemorycrc21 + rjmp h_writememoryaddr1 + rjmp h_writememory1 + rjmp h_writememorycrc11 + rjmp h_writememorycrc21 + rjmp h_writememoryreadback1 + rjmp h_convert1 + rjmp h_convertcrc11 + rjmp h_convertcrc21 + rjmp h_convert_conv1 + + rjmp h_writescratchpad2 + rjmp h_writescratchpad_crc2 + rjmp h_readscratchpad2 + rjmp h_copyscratchpad2 + rjmp h_readmemory_addr2 + rjmp h_readmemory2 + rjmp h_readmemorycounter_addr2 + rjmp h_readmemorycounter2 + rjmp h_readmemorycounter_ex2 +.endm + +#include "../common/OWRomFunctionsDual.s" +#include "../common/OWTimerInterrupt.s" + + + +; Ab hier Geraeteabhaenging +#define OW_READ_MEMORY_ADDR1 OW_FIRST_COMMAND+0 +#define OW_READ_MEMORY1 OW_FIRST_COMMAND+1 +#define OW_READ_MEMORY_CRC11 OW_FIRST_COMMAND+2 +#define OW_READ_MEMORY_CRC21 OW_FIRST_COMMAND+3 +#define OW_WRITE_MEMORY_ADDR1 OW_FIRST_COMMAND+4 +#define OW_WRITE_MEMORY1 OW_FIRST_COMMAND+5 +#define OW_WRITE_MEMORY_CRC11 OW_FIRST_COMMAND+6 +#define OW_WRITE_MEMORY_CRC21 OW_FIRST_COMMAND+7 +#define OW_WRITE_MEMORY_READBACK1 OW_FIRST_COMMAND+8 +#define OW_CONVERT1 OW_FIRST_COMMAND+9 +#define OW_CONVERT_CRC11 OW_FIRST_COMMAND+10 +#define OW_CONVERT_CRC21 OW_FIRST_COMMAND+11 +#define OW_CONVERT_CONV1 OW_FIRST_COMMAND+12 + +#define OW_WRITE_SCRATCHPAD2 OW_FIRST_COMMAND+13 +#define OW_WRITE_SCRATCHPAD_CRC2 OW_FIRST_COMMAND+14 +#define OW_READ_SCRATCHPAD2 OW_FIRST_COMMAND+15 +#define OW_COPY_SCRATCHPAD2 OW_FIRST_COMMAND+16 +#define OW_READ_MEMORY_ADDR2 OW_FIRST_COMMAND+17 +#define OW_READ_MEMORY2 OW_FIRST_COMMAND+18 +#define OW_READ_MEMORYCOUNTER_ADDR2 OW_FIRST_COMMAND+19 +#define OW_READ_MEMORYCOUNTER2 OW_FIRST_COMMAND+20 +#define OW_READ_MEMORYCOUNTER_EX2 OW_FIRST_COMMAND+21 + + + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + + +h_readcommand1: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cset 0xAA,OW_READ_MEMORY_ADDR1 + cset 0x55,OW_WRITE_MEMORY_ADDR1 + cset 0x3C,OW_CONVERT1 + FW_CONFIG_INFO1 +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + ldi r_mode,OW_SLEEP + rjmp handle_end + + +h_readmemoryaddr1: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_readmemory_addr_byte11 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + rjmp handle_end_inc +h_readmemory_addr_byte11: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_READ_MEMORY1 ;weiter zu read Memory + ;;ldi r_bcount,1 ;ist unten + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + clr r_bytep + rjmp h_readmemory21 +h_readmemory1: + lds r_bytep,addr + inc r_bytep + sts addr,r_bytep + andi r_bytep,0x07 + breq h_readmemory_init_crc1 +h_readmemory21: + lds r_bytep,addr + ;andi r_bytep,0x1F ist oben + configZ pack1,r_bytep + ld r_rwbyte,Z + ;ldi r_bcount,1 + rjmp handle_end ;sendet das Byte und geht zu h_readmemory +h_readmemory_init_crc1:; init erstes CRC byte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_READ_MEMORY_CRC11 + ;ldi r_bcount,1 + rjmp handle_end +h_readmemory_end1: + ldi r_mode,OW_SLEEP + clr r_sendflag + rjmp handle_end +h_readmemorycrc11:;init zweites CRC Byte + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_READ_MEMORY_CRC21 + rjmp handle_end +h_readmemorycrc21:;weiteres senden..... nach zweitem Byte + lds r_temp,addr + andi r_temp,0xE0 + brne h_readmemory_end1; ende des speichers + ldi r_mode,OW_READ_MEMORY1 + CRCInit1 ;Start with new CRC + rjmp h_readmemory21 + +h_writememoryaddr1: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_writememory_addr_byte11 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + inc r_bytep + ;ldi r_bcount,1 + rjmp handle_end +h_writememory_addr_byte11: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_WRITE_MEMORY1 ;weiter zu read Memory + ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren..... + lds r_bytep,addr + rjmp handle_end ;read Memory Byte +h_writememory1: + lds r_bytep,addr + configZ pack1,r_bytep + st Z,r_rwbyte + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC11 + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + rjmp handle_end +h_writememorycrc11: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC21 + rjmp handle_end +h_writememorycrc21: + lds r_temp,addr + configZ pack1,r_temp + ld r_rwbyte,Z + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_READBACK1 + rjmp handle_end +h_writememoryreadback1: + ldi r_temp,0x00 + sts crc+1,r_temp + lds r_temp,addr + inc r_temp + sts addr,r_temp + sts crc,r_temp + ldi r_sendflag,0 + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY1 + rjmp handle_end + +h_convert1: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_convert_byte11 ;nein dann weiter + inc r_bytep + sts pack1+0x20,r_rwbyte + ;ldi r_bcount,1 + rjmp handle_end +h_convert_byte11: ;zweies byte glesen go crc# + sts pack1+0x21,r_rwbyte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_CONVERT_CRC11 + ;ldi r_bcount,1 + ldi r_sendflag,1 + rjmp handle_end +h_convertcrc11: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CRC21 + rjmp handle_end +h_convertcrc21: + ldi r_temp,1 + sts gcontrol1,r_temp + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CONV1 + ;clr r_sendflag + ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling +h_convert_conv1: + ldi r_bcount,0 + ldi r_rwbyte,0 + rjmp handle_end_no_bcount + +///////////////////////////////////////////////////////////////////// + + + +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** + + + + +h_readcommand2: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cset 0x0F,OW_WRITE_SCRATCHPAD2 + cjmp 0xAA,hrc_set_readscratchpad2 + cset 0x5A,OW_COPY_SCRATCHPAD2 + cset 0xF0,OW_READ_MEMORY_ADDR2 + cset 0xA5,OW_READ_MEMORYCOUNTER_ADDR2 + FW_CONFIG_INFO2 +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + ldi r_mode,OW_SLEEP + rjmp handle_end + +hrc_set_readscratchpad2: + ldi r_mode,OW_READ_SCRATCHPAD2 + ldi r_sendflag,1 + rjmp h_readscratchpad2 + +h_writescratchpad2: + configZ pack2,r_bytep + inc r_bytep + st Z,r_rwbyte + cpi r_bytep,2 + breq h_writescratchpad_block2 + brsh h_writescratchpad_set_eoffset2 ;;33 + rjmp handle_end ;handle_end zu weit entfernt fuer br... +h_writescratchpad_set_eoffset2: + cpi r_bytep,35 + breq h_writescratchpad_setcrc2 + mov r_temp,r_bytep + subi r_temp,4 + sts pack2+2,r_temp ;AA und PF cleared + rjmp handle_end +;Start writeing to 32 Byte Block ; skip status byte +h_writescratchpad_block2: + lds r_temp,pack2 ; Adresse low byte + andi r_temp,0x1F ;32 byte + add r_bytep,r_temp ;Zur angegebenen Startadresse springen + ;ori r_temp,0x20 ; Set PF flag + sts pack2+2,r_temp ;E4:E0 vorher setzen + ; Byte 3 ueberspringen + rjmp handle_end_inc + +h_writescratchpad_setcrc2: + ;copy crc to pack2 + lds r_temp,crc + com r_temp + sts pack2+43,r_temp + lds r_temp,crc+1 + com r_temp ; invertieren , komischer name..... + sts pack2+44,r_temp + ldi r_mode,OW_WRITE_SCRATCHPAD_CRC2 + ldi r_sendflag,1 + ldi r_bytep,43 +h_writescratchpad_crc2: + cpi r_bytep,45 + breq h_writescratchpad_crc_end2 + configZ pack2,r_bytep + ld r_rwbyte,Z + rjmp handle_end_inc +h_writescratchpad_crc_end2: + rjmp handle_end_sleep + + +h_readscratchpad2: + cpi r_bytep,35 + breq h_readscratchpad_end2 + cpi r_bytep,3 + brne h_readscratchpad_read_byte2 +h_readscratchpad_set_offset2: + lds r_temp,pack2 + andi r_temp,0x1F + ldi r_temp2,3 + add r_temp,r_temp2 + mov r_bytep,r_temp +h_readscratchpad_read_byte2: + configZ pack2,r_bytep + ld r_rwbyte,Z + rjmp handle_end_inc +h_readscratchpad_end2: + rjmp handle_end_sleep + + + +h_copyscratchpad2: + cpi r_bytep,3 + brsh h_copyscratchpad_ok2 + configZ pack2,r_bytep + inc r_bytep + ld r_temp,Z + cp r_temp,r_rwbyte + brne h_copyscratchpad_nok2 + cpi r_bytep,3 + breq h_copyscratchpad_ok2 + ldi r_bcount,1 + rjmp handle_end +h_copyscratchpad_ok2: + ldi r_rwbyte,0xAA + ldi r_sendflag,1 + ldi r_temp,1 + sts gcontrol2,r_temp + rjmp handle_end +h_copyscratchpad_nok2: + lds r_temp,pack2+3 + andi r_temp,~0x80 + sts pack2+3,r_temp + rjmp handle_end_sleep + + +h_readmemory_addr2: + cpi r_bytep,0 + brne h_readmrmory_addr_byte12 + sts pack2,r_rwbyte + rjmp handle_end_inc +h_readmrmory_addr_byte12: + sts pack2+1,r_rwbyte + ldi r_mode,OW_READ_MEMORY2 + ldi r_sendflag,1 + clr r_bytep + rjmp h_readmemory22 +h_readmemory2: + lds r_bytep,pack2 + lds r_temp2,pack2+1 + inc r_bytep + clr r_temp + adc r_temp2,r_temp + sbrc r_temp2,1 + rjmp h_readmemory_end2 + sts pack2+1,r_temp2 + sts pack2,r_bytep +h_readmemory22: + ldi zl,lo8(pack2+45) + ldi zh,hi8(pack2+45) + lds r_bytep,pack2 + add zl,r_bytep + lds r_bytep,pack2+1 + adc zh,r_bytep + //configZ pack2+3,r_bytep + ld r_rwbyte,Z + rjmp handle_end +h_readmemory_end2: + rjmp handle_end_sleep + + + + + + + + +h_readmemorycounter_addr2: + cpi r_bytep,0 + brne h_readmrmorycounter_addr_byte12 + sts pack2,r_rwbyte + inc r_bytep + ;ldi r_bcount,1 + rjmp handle_end +h_readmrmorycounter_addr_byte12: + sts pack2+1,r_rwbyte + ldi r_mode,OW_READ_MEMORYCOUNTER2 + ;ldi r_bcount,1 + ldi r_sendflag,1 + clr r_bytep + rjmp h_readmemorycounter22 +h_readmemorycounter2: + lds r_bytep,pack2 + lds r_temp2,pack2+1 + ldi r_temp,1 ;inc leider kein c flag + add r_bytep,r_temp + clr r_temp + adc r_temp2,r_temp + mov r_temp,r_bytep + andi r_temp,0x1F + breq h_readmemorycounter_next2 + sts pack2+1,r_temp2 + sts pack2,r_bytep +h_readmemorycounter22: ;Lesen von dem worauf die erstenzwei bytes zeigen + lds r_bytep,pack2 + andi r_bytep,0x1F + configZ pack2+3,r_bytep + ld r_rwbyte,Z + ;ldi r_bcount,1 + rjmp handle_end +//h_readmemorycounter_end: +// ldi r_mode,OW_SLEEP +// clr r_sendflag +// rjmp handle_end +h_readmemorycounter_next2: ; rest lesen + ldi r_mode,OW_READ_MEMORYCOUNTER_EX2 + ldi r_bytep,34 + lds r_temp2,pack2 + lds r_temp,pack2+1 + //lsr r_temp + //ror r_temp2 + + lsl r_temp2 + rol r_temp + cpi r_temp,3 + brne h_readmemorycounter_cFF2 + andi r_temp2,0xC0 + swap r_temp2 + + ;cpi r_temp,0xE0 + + configZ counters2,r_temp2 + ld r_temp,Z+ + sts pack2+35,r_temp + ld r_temp,Z+ + sts pack2+36,r_temp + ld r_temp,Z+ + sts pack2+37,r_temp + ld r_temp,Z+ + sts pack2+38,r_temp + rjmp h_readmemorycounter_ex2 +h_readmemorycounter_cFF2: + ldi r_temp,0xFF + sts pack2+35,r_temp + sts pack2+36,r_temp + sts pack2+37,r_temp + sts pack2+38,r_temp + +h_readmemorycounter_ex2: + inc r_bytep + cpi r_bytep,45 + breq h_readmemorycounter_ex_end2 + cpi r_bytep,43 + brne h_readmemorycounter_ex22 + lds r_temp,crc + com r_temp + sts pack2+43,r_temp + lds r_temp,crc+1 + com r_temp + sts pack2+44,r_temp +h_readmemorycounter_ex22: + ;ldi r_bcount,1 + configZ pack2,r_bytep + ld r_rwbyte,Z + rjmp handle_end +h_readmemorycounter_ex_end2: + lds r_bytep,pack2 + lds r_temp2,pack2+1 + ldi r_temp,1 ;inc leider kein c flag + add r_bytep,r_temp + clr r_temp + adc r_temp2,r_temp + sbrc r_temp2,1 ;am ene von allem + rjmp h_readmemorycounter_ex_sleep2 + CRCInit1 + ldi r_mode,OW_READ_MEMORYCOUNTER2 + sts pack2+1,r_temp2 + sts pack2,r_bytep + rjmp h_readmemorycounter22 +h_readmemorycounter_ex_sleep2: + ldi r_mode,OW_SLEEP + clr r_sendflag + rjmp handle_end + + + + + +#include "../common/OWPinInterrupt.s" +.end \ No newline at end of file diff --git a/common/OWDS2450_DS2450.S b/common/OWDS2450_DS2450.S new file mode 100644 index 0000000..bdf354f --- /dev/null +++ b/common/OWDS2450_DS2450.S @@ -0,0 +1,440 @@ + +// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * All advertising materials mentioning features or use of this +// software must display the following acknowledgement: This product +// includes software developed by tm3d.de and its contributors. +// * Neither the name of tm3d.de nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define _CHANGEABLE_ID_ +#define _ZERO_POLLING_ + +#include "../common/OWConfig.s" +#include "../common/OWCRC16.s" + +.extern pack1,20 +.extern pack2,20 + +//Bleiben gleich denn es werden nicht beide gleichzeitig abgefragt +.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....) +.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte.... +//.extern am2302_temp,2 + +.comm gcontrol1,1 +.comm gcontrol2,1 + +.macro CHIP_INIT +.endm + +.macro COMMAND_TABLE + rjmp h_readmemoryaddr1 + rjmp h_readmemory1 + rjmp h_readmemorycrc11 + rjmp h_readmemorycrc21 + rjmp h_writememoryaddr1 + rjmp h_writememory1 + rjmp h_writememorycrc11 + rjmp h_writememorycrc21 + rjmp h_writememoryreadback1 + rjmp h_convert1 + rjmp h_convertcrc11 + rjmp h_convertcrc21 + rjmp h_convert_conv1 + + rjmp h_readmemoryaddr2 + rjmp h_readmemory2 + rjmp h_readmemorycrc12 + rjmp h_readmemorycrc22 + rjmp h_writememoryaddr2 + rjmp h_writememory2 + rjmp h_writememorycrc12 + rjmp h_writememorycrc22 + rjmp h_writememoryreadback2 + rjmp h_convert2 + rjmp h_convertcrc12 + rjmp h_convertcrc22 + rjmp h_convert_conv2 +.endm + +#include "../common/OWRomFunctionsDual.s" +#include "../common/OWTimerInterrupt.s" + + + +; Ab hier Geraeteabhaenging +#define OW_READ_MEMORY_ADDR1 OW_FIRST_COMMAND+0 +#define OW_READ_MEMORY1 OW_FIRST_COMMAND+1 +#define OW_READ_MEMORY_CRC11 OW_FIRST_COMMAND+2 +#define OW_READ_MEMORY_CRC21 OW_FIRST_COMMAND+3 +#define OW_WRITE_MEMORY_ADDR1 OW_FIRST_COMMAND+4 +#define OW_WRITE_MEMORY1 OW_FIRST_COMMAND+5 +#define OW_WRITE_MEMORY_CRC11 OW_FIRST_COMMAND+6 +#define OW_WRITE_MEMORY_CRC21 OW_FIRST_COMMAND+7 +#define OW_WRITE_MEMORY_READBACK1 OW_FIRST_COMMAND+8 +#define OW_CONVERT1 OW_FIRST_COMMAND+9 +#define OW_CONVERT_CRC11 OW_FIRST_COMMAND+10 +#define OW_CONVERT_CRC21 OW_FIRST_COMMAND+11 +#define OW_CONVERT_CONV1 OW_FIRST_COMMAND+12 + +#define OW_READ_MEMORY_ADDR2 OW_FIRST_COMMAND+13 +#define OW_READ_MEMORY2 OW_FIRST_COMMAND+14 +#define OW_READ_MEMORY_CRC12 OW_FIRST_COMMAND+15 +#define OW_READ_MEMORY_CRC22 OW_FIRST_COMMAND+16 +#define OW_WRITE_MEMORY_ADDR2 OW_FIRST_COMMAND+17 +#define OW_WRITE_MEMORY2 OW_FIRST_COMMAND+18 +#define OW_WRITE_MEMORY_CRC12 OW_FIRST_COMMAND+19 +#define OW_WRITE_MEMORY_CRC22 OW_FIRST_COMMAND+20 +#define OW_WRITE_MEMORY_READBACK2 OW_FIRST_COMMAND+21 +#define OW_CONVERT2 OW_FIRST_COMMAND+22 +#define OW_CONVERT_CRC12 OW_FIRST_COMMAND+23 +#define OW_CONVERT_CRC22 OW_FIRST_COMMAND+24 +#define OW_CONVERT_CONV2 OW_FIRST_COMMAND+25 + + + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + + +h_readcommand1: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cset 0xAA,OW_READ_MEMORY_ADDR1 + cset 0x55,OW_WRITE_MEMORY_ADDR1 + cset 0x3C,OW_CONVERT1 + FW_CONFIG_INFO1 +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + ldi r_mode,OW_SLEEP + rjmp handle_end + + +h_readmemoryaddr1: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_readmemory_addr_byte11 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + rjmp handle_end_inc +h_readmemory_addr_byte11: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_READ_MEMORY1 ;weiter zu read Memory + ;;ldi r_bcount,1 ;ist unten + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + clr r_bytep + rjmp h_readmemory21 +h_readmemory1: + lds r_bytep,addr + inc r_bytep + sts addr,r_bytep + andi r_bytep,0x07 + breq h_readmemory_init_crc1 +h_readmemory21: + lds r_bytep,addr + ;andi r_bytep,0x1F ist oben + configZ pack1,r_bytep + ld r_rwbyte,Z + ;ldi r_bcount,1 + rjmp handle_end ;sendet das Byte und geht zu h_readmemory +h_readmemory_init_crc1:; init erstes CRC byte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_READ_MEMORY_CRC11 + ;ldi r_bcount,1 + rjmp handle_end +h_readmemory_end1: + ldi r_mode,OW_SLEEP + clr r_sendflag + rjmp handle_end +h_readmemorycrc11:;init zweites CRC Byte + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_READ_MEMORY_CRC21 + rjmp handle_end +h_readmemorycrc21:;weiteres senden..... nach zweitem Byte + lds r_temp,addr + andi r_temp,0xE0 + brne h_readmemory_end1; ende des speichers + ldi r_mode,OW_READ_MEMORY1 + CRCInit1 ;Start with new CRC + rjmp h_readmemory21 + +h_writememoryaddr1: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_writememory_addr_byte11 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + inc r_bytep + ;ldi r_bcount,1 + rjmp handle_end +h_writememory_addr_byte11: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_WRITE_MEMORY1 ;weiter zu read Memory + ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren..... + lds r_bytep,addr + rjmp handle_end ;read Memory Byte +h_writememory1: + lds r_bytep,addr + configZ pack1,r_bytep + st Z,r_rwbyte + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC11 + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + rjmp handle_end +h_writememorycrc11: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC21 + rjmp handle_end +h_writememorycrc21: + lds r_temp,addr + configZ pack1,r_temp + ld r_rwbyte,Z + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_READBACK1 + rjmp handle_end +h_writememoryreadback1: + ldi r_temp,0x00 + sts crc+1,r_temp + lds r_temp,addr + inc r_temp + sts addr,r_temp + sts crc,r_temp + ldi r_sendflag,0 + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY1 + rjmp handle_end + +h_convert1: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_convert_byte11 ;nein dann weiter + inc r_bytep + sts pack1+0x20,r_rwbyte + ;ldi r_bcount,1 + rjmp handle_end +h_convert_byte11: ;zweies byte glesen go crc# + sts pack1+0x21,r_rwbyte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_CONVERT_CRC11 + ;ldi r_bcount,1 + ldi r_sendflag,1 + rjmp handle_end +h_convertcrc11: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CRC21 + rjmp handle_end +h_convertcrc21: + ldi r_temp,1 + sts gcontrol1,r_temp + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CONV1 + ;clr r_sendflag + ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling +h_convert_conv1: + ldi r_bcount,0 + ldi r_rwbyte,0 + rjmp handle_end_no_bcount + +///////////////////////////////////////////////////////////////////// + + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + + +h_readcommand2: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cset 0xAA,OW_READ_MEMORY_ADDR2 + cset 0x55,OW_WRITE_MEMORY_ADDR2 + cset 0x3C,OW_CONVERT2 + FW_CONFIG_INFO2 +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + ldi r_mode,OW_SLEEP + rjmp handle_end + + +h_readmemoryaddr2: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_readmemory_addr_byte12 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + rjmp handle_end_inc +h_readmemory_addr_byte12: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_READ_MEMORY2 ;weiter zu read Memory + ;;ldi r_bcount,1 ;ist unten + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + clr r_bytep + rjmp h_readmemory22 +h_readmemory2: + lds r_bytep,addr + inc r_bytep + sts addr,r_bytep + andi r_bytep,0x07 + breq h_readmemory_init_crc2 +h_readmemory22: + lds r_bytep,addr + ;andi r_bytep,0x1F ist oben + configZ pack2,r_bytep + ld r_rwbyte,Z + ;ldi r_bcount,1 + rjmp handle_end ;sendet das Byte und geht zu h_readmemory +h_readmemory_init_crc2:; init erstes CRC byte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_READ_MEMORY_CRC12 + ;ldi r_bcount,1 + rjmp handle_end +h_readmemory_end2: + ldi r_mode,OW_SLEEP + clr r_sendflag + rjmp handle_end +h_readmemorycrc12:;init zweites CRC Byte + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_READ_MEMORY_CRC22 + rjmp handle_end +h_readmemorycrc22:;weiteres senden..... nach zweitem Byte + lds r_temp,addr + andi r_temp,0xE0 + brne h_readmemory_end2; ende des speichers + ldi r_mode,OW_READ_MEMORY2 + CRCInit1 ;Start with new CRC + rjmp h_readmemory22 + +h_writememoryaddr2: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_writememory_addr_byte12 ;nein dann weiter + andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen + sts addr,r_rwbyte ;speichern des ersten bytes + inc r_bytep + ;ldi r_bcount,1 + rjmp handle_end +h_writememory_addr_byte12: ;zweiters Addressbyte wird nicht gespeichert! + ldi r_mode,OW_WRITE_MEMORY2 ;weiter zu read Memory + ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren..... + lds r_bytep,addr + rjmp handle_end ;read Memory Byte +h_writememory2: + lds r_bytep,addr + configZ pack2,r_bytep + st Z,r_rwbyte + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC12 + ldi r_sendflag,1 ;jetzt sendet der Slave zum Master + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + rjmp handle_end +h_writememorycrc12: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_CRC22 + rjmp handle_end +h_writememorycrc22: + lds r_temp,addr + configZ pack2,r_temp + ld r_rwbyte,Z + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY_READBACK2 + rjmp handle_end +h_writememoryreadback2: + ldi r_temp,0x00 + sts crc+1,r_temp + lds r_temp,addr + inc r_temp + sts addr,r_temp + sts crc,r_temp + ldi r_sendflag,0 + ;ldi r_bcount,1 + ldi r_mode,OW_WRITE_MEMORY2 + rjmp handle_end + +h_convert2: + cpi r_bytep,0 ;erstes Adressbyte ? + brne h_convert_byte12 ;nein dann weiter + inc r_bytep + sts pack2+0x20,r_rwbyte + ;ldi r_bcount,1 + rjmp handle_end +h_convert_byte12: ;zweies byte glesen go crc# + sts pack2+0x21,r_rwbyte + lds r_rwbyte,crc + com r_rwbyte + lds r_temp,crc+1 + com r_temp + sts crcsave,r_temp + ldi r_mode,OW_CONVERT_CRC12 + ;ldi r_bcount,1 + ldi r_sendflag,1 + rjmp handle_end +h_convertcrc12: + lds r_rwbyte,crcsave + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CRC22 + rjmp handle_end +h_convertcrc22: + ldi r_temp,1 + sts gcontrol2,r_temp + ;ldi r_bcount,1 + ldi r_mode,OW_CONVERT_CONV2 + ;clr r_sendflag + ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling +h_convert_conv2: + ldi r_bcount,0 + ldi r_rwbyte,0 + rjmp handle_end_no_bcount + + + +#include "../common/OWPinInterrupt.s" +.end \ No newline at end of file diff --git a/common/OWPinInterrupt.s b/common/OWPinInterrupt.s index 69f84f3..7d8a711 100644 --- a/common/OWPinInterrupt.s +++ b/common/OWPinInterrupt.s @@ -31,8 +31,8 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.global PIN_INTERRIPT -PIN_INTERRIPT: +.global PIN_INTERRUPT +PIN_INTERRUPT: ;leitung auf Low ziehen TESTZEROMARKER ; ueberspringe wenn zeromarker=0 ;sbic und cbi/sbi andern SREG nicht sbi OW_DDR,OW_PINN diff --git a/common/OWRomFunctions.s b/common/OWRomFunctions.s index fb1d85b..6abeffc 100644 --- a/common/OWRomFunctions.s +++ b/common/OWRomFunctions.s @@ -169,11 +169,7 @@ hrc_jmp_flasher: lds r_temp,flashmarker cpi r_temp,2 brne hrc_jmp_flasher_inc - ldi r_temp,0xC0 - push r_temp - ldi r_temp,0x0E - push r_temp - ret ; Direkter Sprung zum Bootloader + JMP_FLASHER hrc_jmp_flasher_inc: inc r_temp sts flashmarker,r_temp @@ -276,7 +272,7 @@ h_searchroms_next: ; Setup next bit configZ owid,r_bcount ld r_rwbyte,Z - sts srbyte,r_rwbyte + sts srbyte,r_rwbyte ;#################### Doppelung ist schon in h_searchrom_next_bit rjmp h_searchrom_next_bit h_searchroms_next_bit: ;next Bit lesen @@ -316,7 +312,7 @@ h_readrom_all: h_fwconfiginfo: cpi r_bytep,24 breq h_fwconfiginfo_crc -#ifdef _CRC8_ +#if defined(_CRC8_) || defined( _CRC8_16_) cpi r_bytep,25 breq h_fwconfiginfo_all #elif defined _CRC16_ @@ -446,31 +442,9 @@ spause: .global OWINIT OWINIT: -#ifndef _DIS_FLASH_ -; check for bootloader jumper - ;vor allen anderen Registerconfigs push r_temp - ldi r_temp,(1< ID vom EEPROM lesen auch wenn sie sich nicht ändern laesst ; lesen der ID aus dem EEPROM beim Start read_EEPROM_ID1: ldi r_temp2,lo8(E2END) @@ -139,7 +139,7 @@ read_EEPROM_ID_loop: brne read_EEPROM_ID_loop read_EEPROM_ID_end: ret -#endif +//#endif @@ -187,11 +187,7 @@ hrc_jmp_flasher: lds r_temp,flashmarker cpi r_temp,2 brne hrc_jmp_flasher_inc - ldi r_temp,0xC0 - push r_temp - ldi r_temp,0x0E - push r_temp - ret ; Direkter Sprung zum Bootloader + JMP_FLASHER hrc_jmp_flasher_inc: inc r_temp sts flashmarker,r_temp @@ -426,7 +422,7 @@ h_fwconfiginfo2: h_fwconfiginfo_go: cpi r_bytep,24 breq h_fwconfiginfo_crc -#ifdef _CRC8_ +#if defined(_CRC8_) || defined( _CRC8_16_) cpi r_bytep,25 breq h_fwconfiginfo_all #elif defined _CRC16_ @@ -587,27 +583,7 @@ OWINIT: ;vor allen anderen Registerconfigs push r_temp #ifndef _DIS_FLASH_ - ldi r_temp,(1<100) return 100.0; return r; +} + +inline double calibr_hum05(double t,double hum) { + double y=-0.0006*t*t-0.2455*t-28.5902; + return -(hum/y)+hum; } \ No newline at end of file diff --git a/common/calibr.h b/common/calibr.h index 2ba627c..bef35d8 100644 --- a/common/calibr.h +++ b/common/calibr.h @@ -5,5 +5,4 @@ double calibr_hum(double temp,double tempdiv,double hum); - #endif \ No newline at end of file diff --git a/common/owSlave_tools.h b/common/owSlave_tools.h new file mode 100644 index 0000000..3dbba63 --- /dev/null +++ b/common/owSlave_tools.h @@ -0,0 +1,187 @@ +#ifndef OWSLAVE_TOOLS_H +#define OWSLAVE_TOOLS_H + +#if defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) +#define OWST_INIT_ALL_OFF \ + PRR|=(1<>6;\ +} \ +double owst_ADC_OSS_runf() {/*964ms*/\ + double r=0;\ + for(uint16_t i=0;i<4096;i++) {\ + OWST_ADC_CONF \ + r+=ADC;\ + }\ + r+=5150;\ + r*=0.9993;\ + return r/64.0;\ +} + + +#endif \ No newline at end of file diff --git a/programmer/programmer/programmer.asmproj b/programmer/programmer/programmer.asmproj index 2f55cc1..5a5c1e2 100644 --- a/programmer/programmer/programmer.asmproj +++ b/programmer/programmer/programmer.asmproj @@ -25,7 +25,7 @@ true exception_table 2 - 0 + 1 @@ -38,11 +38,11 @@ - com.atmel.avrdbg.tool.avrdragon + com.atmel.avrdbg.tool.atmelice - 100000 + 125000 0 debugWIRE @@ -51,14 +51,14 @@ J41800000789 Atmel-ICE - ISP + debugWIRE - 00A200054127 + J41800000789 0x1E930C - 125000 + 0 ISP diff --git a/programmer/programmer/programmer_8MHz_2017.asm b/programmer/programmer/programmer_8MHz_2017.asm new file mode 100644 index 0000000..5a51e4e --- /dev/null +++ b/programmer/programmer/programmer_8MHz_2017.asm @@ -0,0 +1,489 @@ +.def srbyte = r12 ;byty for search rom algorithm +.def writelow = r13; marker for send low +.def zero =r14; always zero +.def smode=r15; if 1 then send +.def temp = r16 ; +.def temp2 = r17; +.def mode = r18 ; +.def bitp = r19 ; bit counter ... shift... +.def rwbyte = r21; +.def param = r22; +.def bytep = r23 ;byte counter +#define spmcrval param + + +.equ OWM_READ_ROM_COMMAND=0 ; 0 wegen schnellen test ist dieser wert 0! Daturch wird die Sprungdabelle nicht verwendet +.equ OWM_SLEEP=1 ; Warten auf Reset +.equ OWM_MATCH_ROM=2 +.equ OWM_SEARCH_ROM_S=3 ;send bit +.equ OWM_SEARCH_ROM_R=4 ;resive master +.equ OWM_READ_COMMAND=5 +.equ OWM_WRITE_SCRATCHPAD=6 +.equ OWM_READ_SCRATCHPAD=7 +.equ OWM_PROGRAMM_PAGE=8 +.equ OWM_RECALL_FLASH=9 + + +.equ OW_DDR = DDRB +.equ OW_PIN = PORTB2 +.equ OW_PORT = PORTB +.equ OW_PINN = PINB + +;.equ SRAM_START = 0x60 + +.macro set_clock + ldi temp,0x80; + out CLKPR,temp + ldi temp,@0 + out CLKPR,temp +.endmacro + +.macro owwl + sbic OW_PINN,OW_PIN + rjmp pc-1 +.endmacro + +.macro owwh + sbis OW_PINN,OW_PIN + rjmp pc-1 +.endmacro + + + + + ;--------------------------------------------------- +; START of PROG +;--------------------------------------------------- + + +.CSEG +.ORG 0x000 +jreset: + rjmp start ; Reset-Vector + reti ; + reti ; + reti ; + reti ; + reti ; + reti ; + reti ; + reti ; + reti ; + reti ; + reti ; + reti ; + reti ; + reti ; + reti ; + reti ; + reti ; + reti ; + reti ; + reti ; + + +.ORG 0x0EC0 +//7552 Byte +start: + cli + ldi temp,0 + mov zero,temp + set_clock 0x00 ;8mhz + ldi mode,OWM_SLEEP + ldi temp,(1< + + + 2.0 + 7.0 + com.Atmel.AVRAssembler + 59B1D629-9DCC-43ed-A0FD-8AB0E4D622AB + none + ATmega328PB + $(MSBuildProjectName) + .obj + $(MSBuildProjectDirectory)\$(Configuration) + ASSEMBLY + programmer_atmega328 + programmer_atmega328 + programmer_atmega328 + Native + $(MSBuildProjectDirectory)\programmer_atmega328.asm + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 0 + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + J41800000789 + 0x1E9516 + + + + 125000 + + ISP + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + ISP + 125000 + + + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\avrasm\inc + + + m328PBdef.inc + + + Executable + + + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\avrasm\inc + + + m328PBdef.inc + + + + + + Code + + + + \ No newline at end of file diff --git a/programmer_atmega328/programmer_atmega328/programmer_atmega328.atsln b/programmer_atmega328/programmer_atmega328/programmer_atmega328.atsln new file mode 100644 index 0000000..ac4179e --- /dev/null +++ b/programmer_atmega328/programmer_atmega328/programmer_atmega328.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{18226A42-8477-4023-8AD2-40C49DA407C9}") = "programmer_atmega328", "programmer_atmega328.asmproj", "{59B1D629-9DCC-43ED-A0FD-8AB0E4D622AB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {59B1D629-9DCC-43ED-A0FD-8AB0E4D622AB}.Debug|AVR.ActiveCfg = Debug|AVR + {59B1D629-9DCC-43ED-A0FD-8AB0E4D622AB}.Debug|AVR.Build.0 = Debug|AVR + {59B1D629-9DCC-43ED-A0FD-8AB0E4D622AB}.Release|AVR.ActiveCfg = Release|AVR + {59B1D629-9DCC-43ED-A0FD-8AB0E4D622AB}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal -- 2.34.1