From: Tobias Date: Fri, 7 Apr 2017 07:26:18 +0000 (+0200) Subject: 4MHz - Some New double Double Devices X-Git-Url: https://git.smho.de/?a=commitdiff_plain;h=485bc58764a5b2a1296dee25aadb42316e8defe0;p=owSlave2.git 4MHz - Some New double Double Devices --- diff --git a/DS18B20_BMP280_DS2438_SHT/DS18B20_BMP280_DS2438_SHT.cproj b/DS18B20_BMP280_DS2438_SHT/DS18B20_BMP280_DS2438_SHT.cproj index 2594168..68c6f87 100644 --- a/DS18B20_BMP280_DS2438_SHT/DS18B20_BMP280_DS2438_SHT.cproj +++ b/DS18B20_BMP280_DS2438_SHT/DS18B20_BMP280_DS2438_SHT.cproj @@ -28,15 +28,15 @@ 1 - - - - - - - - - + + + + + + + + + custom @@ -173,4 +173,4 @@ - + \ No newline at end of file diff --git a/DS18B20_BMP280_DS2438_SHT/DS18B20_DS2438.c b/DS18B20_BMP280_DS2438_SHT/DS18B20_DS2438.c index 191de8f..e379db8 100644 --- a/DS18B20_BMP280_DS2438_SHT/DS18B20_DS2438.c +++ b/DS18B20_BMP280_DS2438_SHT/DS18B20_DS2438.c @@ -194,7 +194,7 @@ int main(void){ }else{ config_info2[5]=7; } - + pack2.page3[0]=0xF1; MCUSR=0; USI_TWI_Master_Initialise(); diff --git a/DS18B20_MAX44009_DS2438_SHT/DS18B20_MAX44009_DS2438_SHT.cproj b/DS18B20_MAX44009_DS2438_SHT/DS18B20_MAX44009_DS2438_SHT.cproj index 1c7737c..f17ec23 100644 --- a/DS18B20_MAX44009_DS2438_SHT/DS18B20_MAX44009_DS2438_SHT.cproj +++ b/DS18B20_MAX44009_DS2438_SHT/DS18B20_MAX44009_DS2438_SHT.cproj @@ -28,15 +28,15 @@ 1 - - - - - - - - - + + + + + + + + + com.atmel.avrdbg.tool.atmelice diff --git a/DS18B20_VOC_DS2438_SHT direct/DS18B20_DS2438.c b/DS18B20_VOC_DS2438_SHT direct/DS18B20_DS2438.c index 06e2fdd..4448c39 100644 --- a/DS18B20_VOC_DS2438_SHT direct/DS18B20_DS2438.c +++ b/DS18B20_VOC_DS2438_SHT direct/DS18B20_DS2438.c @@ -35,12 +35,12 @@ #define F_CPU 8000000UL #include #include -#include +#include #include #include #include #include "../common/I2C/USI_TWI_Master.h" -#include "../common/I2C/SHT2x.h" +#include "../common/I2C/SHT2xV2.h" #include "../common/calibr.h" extern void OWINIT(void); @@ -50,10 +50,11 @@ extern void EXTERN_SLEEP(void); volatile uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x18};/**/ volatile uint8_t owid2[8]={0x26, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x67};/**/ -volatile uint8_t config_info1[26]={0x08,0x01, 0x00,0x00, 0x00,0x00, 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) + //18 +volatile uint8_t config_info1[26]={0x08,18, 0x00,0x00, 0x00,0x00, 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 @@ -66,383 +67,367 @@ 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; + #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[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[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 - int16_t current; //6 - uint8_t threshold; //8 - - uint8_t page1[8]; //9 + typedef union { #if defined(__AVR_ATtiny25__) + volatile uint8_t bytes[16]; #else - uint8_t page2[8]; //17 - union{ - uint8_t page3[8]; //25 - struct { - uint16_t R0; - uint16_t VS; - uint8_t cmode; - int16_t ip; - uint8_t free; + 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 + union{ + uint8_t page3[8]; //25 + struct { + uint16_t R0; + uint16_t VS; + uint8_t cmode; + int16_t ip; + uint8_t free; + }; }; - }; - 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 page4[8]; //33 + struct { + uint16_t tol_s8; + uint16_t tol_d; + uint16_t r_day_max; + uint16_t r_week_max; + }; }; + uint8_t page5[8]; //41 + uint8_t page6[8]; //49 + uint8_t page7[8]; //57 + + #endif }; - uint8_t page5[8]; //41 - uint8_t page6[8]; //49 - uint8_t page7[8]; //57 + } 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,hhum; + volatile double l; + + + 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; + double la[4]; + uint8_t lainit=1; + + int testSW(void) { + uint8_t r; + DDRB&=~(1<>8; - EECR |= (1<>8; + EECR |= (1<0) { - 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[7]=pack2.r_day_max; - for(uint8_t i=0;i<7;i++) { - weekmaxarr[i]=weekmaxarr[i+1]; - //maximum of week - if (weekmaxarr[i]>pack2.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--; - 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); - ip=interp(temperatureC,humidityRH); - pack2.ip=ip*1000; - humidityRH=calibr_hum(temperatureC,-0.2,humidityRH)*10.0; - //humidityRH=humidityRH*10.0; - temperatureC =temperatureC *10.0-2; - - - if (testSW()) { - am2302_hum= humidityRH*10.0; - am2302_temp=temperatureC*25.6; - //am2302_temp=am2302_temp-45; - config_info2[5]=8; + int main(void){ + PORTA=0xFF-(1<1.8) { - if (mr>7200) { - if (pack2.cmode==0) { -// MAX1164x_config(MAX1164x_S_SEL2|MAX1164x_S_SEL0,CH0_CH1); - pack2.cmode=1; + if (pack1.config==0x05) { //Reset all Data + pack1.config=0x7F; + pack2.r_day_max=1; + pack2.r_week_max=1; + pack2.tol_d=0; + pack2.tol_s8=0; //Tag faengt mit Einschalten an + R0=1; + writeEEPROM(EEPROM_R0,0xFF); + writeEEPROM(EEPROM_R0d,0xFF); //Maximum des Tages + writeEEPROM(EEPROM_R0w,0xFF); //Maximum der Letzten 7 Tage + writeEEPROM(EEPROM_dol,0xFF); //Anzahl der Betriebstage + for(uint8_t i=0;i<7;i++) { + weekmaxarr[i]=1; } } - //if (l<1.6) { - if (mr<6400) { - if (pack2.cmode==1) { - // MAX1164x_config(MAX1164x_S_SEL2|MAX1164x_S_SEL0,CH0_M); - pack2.cmode=0; + if (wdcounter>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[7]=pack2.r_day_max; + for(uint8_t i=0;i<7;i++) { + weekmaxarr[i]=weekmaxarr[i+1]; + //maximum of week + if (weekmaxarr[i]>pack2.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; + + + if (testSW()) { + am2302_hum=RH; + am2302_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; + am2302_hum=0.31*hhum +80; + am2302_temp=TC*25.6; + config_info2[5]=7; } + mr=0; + //Kritische Sektion !___Ein Breakpoint in dieser Section kann den TGS8100 zerstoeren!___________________________ + PORTB&=~(1<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 (lR0) { - R0=l; - pack2.R0=R0*100; - writeEEPROM(EEPROM_R0,pack2.R0); + if (gcontrol==1) { + uint16_t w=l; + 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(); + EXTERN_SLEEP(); + } + if ((gcontrol==2)||(gcontrol==3)) { + gcontrol=0; + + } - } - if (l*100>pack2.r_day_max) { - pack2.r_day_max=l*100; - } - } else if (l>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(); - EXTERN_SLEEP(); - } - if ((gcontrol==2)||(gcontrol==3)) { - gcontrol=0; - } - - -#if defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) + #if defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) if (((TIMSK & (1<0) { + if (wdcounter>0) { //8s pack2.tol_s8++; if (pack2.tol_s8>(10000)) {//10800 ist theortisch der Tag aber meistens zu lang pack2.tol_s8=0; @@ -337,15 +337,13 @@ int main(void){ ip=interp(temperatureC,humidityRH); pack2.ip=ip*1000; double RH=calibr_hum(temperatureC,-0.2,humidityRH)*10.0; - //humidityRH=humidityRH*10.0; double TC =temperatureC *10.0-2; if (testSW()) { - am2302_hum=RH*10.0; + am2302_hum=RH; am2302_temp=TC*25.6; - //am2302_temp=am2302_temp-45; - config_info2[5]=8; + config_info2[5]=12; //10V = 100% }else{ hhum=(1.0546-0.000216*TC)*(RH); //am2302_hum=0.318*hhum +76.0; @@ -353,7 +351,6 @@ int main(void){ am2302_temp=TC*25.6; config_info2[5]=7; } - //PORTB&=~(1< +#include +#include +#include +#include +#include + +extern void OWINIT(void); +extern void EXTERN_SLEEP(void); +#define FHEM_PLATINE + +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};/**/ +uint8_t config_info1[26]={9,13,9,13,9,13,9,13,0x02,19,19,19,19,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 + +extern uint8_t mode; +extern uint8_t gcontrol; +extern uint8_t reset_indicator; + + +uint8_t pin_state; +uint8_t pin_set; + + +typedef union { + volatile uint8_t bytes[45]; + struct { + uint16_t addr; + uint8_t status; + uint8_t scratch[32];//3 + uint32_t counter; //35 + uint32_t zero; //39 + uint16_t crc; //43 + }; +} counterpack_t; +counterpack_t pack1; + + + +volatile uint8_t lastcps; +typedef union { + uint32_t c32[4]; + uint8_t c8[16]; +} counters_t; + +volatile counters_t counters1; + + +volatile uint8_t istat; +volatile uint8_t changefromeeprom; + +#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_CH3 (1< minus of Comperator falls down -> output of Comperator rises +#ifdef FHEM_PLATINE + //Switch std AIN1 to A0 + ADCSRA&=~(1<Ruecksetzen + for (uint8_t i=2;i<4;i++) { + counters1.c32[i]=0; + } + //count Resets counters1.c32[0]++; changefromeeprom=1; + } +#endif + MCUCR|=(1< + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + {7a5672fe-8226-4158-b931-e1f36b9a8858} + ATtiny84A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS18B20_DS2438 + DS2423_DS2413 + 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 + OWDS2423_DS2413.S + + + compile + + + + \ No newline at end of file diff --git a/DS2423_DS2413/Makefile b/DS2423_DS2413/Makefile new file mode 100644 index 0000000..a8708ea --- /dev/null +++ b/DS2423_DS2413/Makefile @@ -0,0 +1,202 @@ +# Hey Emacs, this is a -*- makefile -*- + +# AVR-GCC Makefile template, derived from the WinAVR template (which +# is public domain), believed to be neutral to any flavor of "make" +# (GNU make, BSD make, SysV make) + + +MCU = attiny84 +FORMAT = ihex +TARGET =DS2423_DS2423 +SRC = DS2423_DS2423.c +ASRC = ../common/OWDS2423_DS2423.S + +# Name of this Makefile (used for "make depend"). +MAKEFILE = Makefile + + +CFLAGS = -x c -funsigned-char -funsigned-bitfields -I. -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -std=gnu99 -MD -MP + +#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs + + +#Additional libraries. + +# Minimalistic printf version +PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min + +# Floating point printf version (requires MATH_LIB = -lm below) +PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt + +PRINTF_LIB = + +# Minimalistic scanf version +SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min + +# Floating point + %[ scanf version (requires MATH_LIB = -lm below) +SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt + +SCANF_LIB = + +MATH_LIB = -lm + +# External memory options + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# used for variables (.data/.bss) and heap (malloc()). +#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# only used for heap (malloc()). +#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff + +EXTMEMOPTS = + +#LDMAP = $(LDFLAGS) -Wl,-Map=$(TARGET).map,--cref +#LDFLAGS = $(EXTMEMOPTS) $(LDMAP) $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) +LDFLAGS = -Wl,--start-group -Wl,-lm -Wl,--end-group -Wl,--gc-sections -mmcu=$(MCU) + +# Programming support using avrdude. Settings and variables. + +#AVRDUDE_PROGRAMMER = stk500 +#AVRDUDE_PORT = /dev/term/a + +#AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex +#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep + + +# Uncomment the following if you want avrdude's erase cycle counter. +# Note that this counter needs to be initialized first using -Yn, +# see avrdude manual. +#AVRDUDE_ERASE_COUNTER = -y + +# Uncomment the following if you do /not/ wish a verification to be +# performed after programming the device. +#AVRDUDE_NO_VERIFY = -V + +# Increase verbosity level. Please use this when submitting bug +# reports about avrdude. See +# to submit bug reports. +#AVRDUDE_VERBOSE = -v -v + +#AVRDUDE_BASIC = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +#AVRDUDE_FLAGS = $(AVRDUDE_BASIC) $(AVRDUDE_NO_VERIFY) $(AVRDUDE_VERBOSE) $(AVRDUDE_ERASE_COUNTER) + + +CC = avr-gcc +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump +SIZE = avr-size +NM = avr-nm +#AVRDUDE = avrdude +REMOVE = rm -f +MV = mv -f + +# Define all object files. +OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) + +# Define all listing files. +LST = $(ASRC:.S=.lst) $(SRC:.c=.lst) + +# Combine all necessary flags and optional flags. +# Add target processor to flags. +ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) +ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) + + +# Default target. +all: build + +build: elf hex eep + +elf: $(TARGET).elf +hex: $(TARGET).hex +#eep: $(TARGET).eep +lss: $(TARGET).lss +sym: $(TARGET).sym + + +# Program the device. +program: $(TARGET).hex $(TARGET).eep + $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) + + + + +# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. +COFFCONVERT=$(OBJCOPY) --debugging \ +--change-section-address .data-0x800000 \ +--change-section-address .bss-0x800000 \ +--change-section-address .noinit-0x800000 \ +--change-section-address .eeprom-0x810000 + + +coff: $(TARGET).elf + $(COFFCONVERT) -O coff-avr $(TARGET).elf $(TARGET).cof + + +extcoff: $(TARGET).elf + $(COFFCONVERT) -O coff-ext-avr $(TARGET).elf $(TARGET).cof + + +.SUFFIXES: .elf .hex .eep .lss .sym + +.elf.hex: + $(OBJCOPY) -O $(FORMAT) $< $@ +# $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ + +.elf.eep: + -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ + +# Create extended listing file from ELF output file. +.elf.lss: + $(OBJDUMP) -h -S $< > $@ + +# Create a symbol table from ELF output file. +.elf.sym: + $(NM) -n $< > $@ + + + +# Link: create ELF output file from object files. +$(TARGET).elf: $(OBJ) + $(CC) $(OBJ) --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +.c.o: + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C source files. +.c.s: + $(CC) -S $(ALL_CFLAGS) $< -o $@ + + +# Assemble: create object files from assembler source files. +.S.o: + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + + + +# Target: clean project. +clean: + $(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).cof $(TARGET).elf \ + $(TARGET).map $(TARGET).sym $(TARGET).lss \ + $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) + +depend: + if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \ + then \ + sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \ + $(MAKEFILE).$$$$ && \ + $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \ + fi + echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \ + >> $(MAKEFILE); \ + $(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE) + +.PHONY: all build elf hex eep lss sym program coff extcoff clean depend + + diff --git a/DS2423_DS2423/DS2423_DS2423.atsln b/DS2423_DS2423/DS2423_DS2423.atsln new file mode 100644 index 0000000..c3fc382 --- /dev/null +++ b/DS2423_DS2423/DS2423_DS2423.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}") = "DS2423_DS2423", "DS2423_DS2423.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/DS2423_DS2423/DS2423_DS2423.c b/DS2423_DS2423/DS2423_DS2423.c new file mode 100644 index 0000000..68fb010 --- /dev/null +++ b/DS2423_DS2423/DS2423_DS2423.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 acknowledgment: 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 + +extern void OWINIT(void); +extern void EXTERN_SLEEP(void); + +//#define FHEM_PLATINE + +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};/**/ +#if RAMEND>260 //defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny84A__) +uint8_t config_info1[26]={9,13,9,13,9,13,9,13,0x02,19,19,19,19,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //+2 for CRC +uint8_t config_info2[26]={9,13,9,13,9,13,9,13,0x02,19,19,19,19,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //+2 for CRC +#endif +#if (owid>128) +#error "Variable not correct" +#endif + +extern uint8_t mode; +extern uint8_t gcontrol; +extern uint8_t reset_indicator; + + + +typedef union { + volatile uint8_t bytes[45]; + struct { + uint16_t addr; + uint8_t status; + uint8_t scratch[32];//3 + uint32_t counter; //35 + uint32_t zero; //39 + uint16_t crc; //43 + }; +} counterpack_t; +counterpack_t pack1; + +//The Memory of both Chips is the same, beause of the small memory of ATTiny44 +#define pack2 pack1 + +volatile uint8_t lastcps; +typedef union { + uint32_t c32[4]; + uint8_t c8[16]; +} counters_t; + +volatile counters_t counters1,counters2; + + +volatile uint8_t istat; +volatile uint8_t changefromeeprom; + +#if defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) +#define PCINT_VECTOR PCINT0_vect +#define PIN_REG PINA +#define PIN_DDR DDRA + +#ifdef FHEM_PLATINE +#define PIN_CH3 (1< minus of Comperator falls down -> output of Comperator rises +#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++) { + counters1.c32[i]=0; + counters2.c32[i]=0; + } + //count Resets changefromeeprom=1; + } + } +#endif + MCUCR|=(1< + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + {7a5672fe-8226-4158-b931-e1f36b9a8858} + ATtiny44A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + DS18B20_DS2438 + DS2423_DS2423 + DS18B20_DS2438 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 1 + + + + + + + + + + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + J41800000789 + Atmel-ICE + + + + + + + + + + + com.atmel.avrdbg.tool.simulator + + + Simulator + + + J41800000789 + 0x1E930D + + + + + -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 + OWDS2423_DS2423.S + + + compile + + + + \ No newline at end of file diff --git a/DS2423_DS2423/Makefile b/DS2423_DS2423/Makefile new file mode 100644 index 0000000..a8708ea --- /dev/null +++ b/DS2423_DS2423/Makefile @@ -0,0 +1,202 @@ +# Hey Emacs, this is a -*- makefile -*- + +# AVR-GCC Makefile template, derived from the WinAVR template (which +# is public domain), believed to be neutral to any flavor of "make" +# (GNU make, BSD make, SysV make) + + +MCU = attiny84 +FORMAT = ihex +TARGET =DS2423_DS2423 +SRC = DS2423_DS2423.c +ASRC = ../common/OWDS2423_DS2423.S + +# Name of this Makefile (used for "make depend"). +MAKEFILE = Makefile + + +CFLAGS = -x c -funsigned-char -funsigned-bitfields -I. -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -std=gnu99 -MD -MP + +#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs + + +#Additional libraries. + +# Minimalistic printf version +PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min + +# Floating point printf version (requires MATH_LIB = -lm below) +PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt + +PRINTF_LIB = + +# Minimalistic scanf version +SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min + +# Floating point + %[ scanf version (requires MATH_LIB = -lm below) +SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt + +SCANF_LIB = + +MATH_LIB = -lm + +# External memory options + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# used for variables (.data/.bss) and heap (malloc()). +#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# only used for heap (malloc()). +#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff + +EXTMEMOPTS = + +#LDMAP = $(LDFLAGS) -Wl,-Map=$(TARGET).map,--cref +#LDFLAGS = $(EXTMEMOPTS) $(LDMAP) $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) +LDFLAGS = -Wl,--start-group -Wl,-lm -Wl,--end-group -Wl,--gc-sections -mmcu=$(MCU) + +# Programming support using avrdude. Settings and variables. + +#AVRDUDE_PROGRAMMER = stk500 +#AVRDUDE_PORT = /dev/term/a + +#AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex +#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep + + +# Uncomment the following if you want avrdude's erase cycle counter. +# Note that this counter needs to be initialized first using -Yn, +# see avrdude manual. +#AVRDUDE_ERASE_COUNTER = -y + +# Uncomment the following if you do /not/ wish a verification to be +# performed after programming the device. +#AVRDUDE_NO_VERIFY = -V + +# Increase verbosity level. Please use this when submitting bug +# reports about avrdude. See +# to submit bug reports. +#AVRDUDE_VERBOSE = -v -v + +#AVRDUDE_BASIC = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +#AVRDUDE_FLAGS = $(AVRDUDE_BASIC) $(AVRDUDE_NO_VERIFY) $(AVRDUDE_VERBOSE) $(AVRDUDE_ERASE_COUNTER) + + +CC = avr-gcc +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump +SIZE = avr-size +NM = avr-nm +#AVRDUDE = avrdude +REMOVE = rm -f +MV = mv -f + +# Define all object files. +OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) + +# Define all listing files. +LST = $(ASRC:.S=.lst) $(SRC:.c=.lst) + +# Combine all necessary flags and optional flags. +# Add target processor to flags. +ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) +ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) + + +# Default target. +all: build + +build: elf hex eep + +elf: $(TARGET).elf +hex: $(TARGET).hex +#eep: $(TARGET).eep +lss: $(TARGET).lss +sym: $(TARGET).sym + + +# Program the device. +program: $(TARGET).hex $(TARGET).eep + $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) + + + + +# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. +COFFCONVERT=$(OBJCOPY) --debugging \ +--change-section-address .data-0x800000 \ +--change-section-address .bss-0x800000 \ +--change-section-address .noinit-0x800000 \ +--change-section-address .eeprom-0x810000 + + +coff: $(TARGET).elf + $(COFFCONVERT) -O coff-avr $(TARGET).elf $(TARGET).cof + + +extcoff: $(TARGET).elf + $(COFFCONVERT) -O coff-ext-avr $(TARGET).elf $(TARGET).cof + + +.SUFFIXES: .elf .hex .eep .lss .sym + +.elf.hex: + $(OBJCOPY) -O $(FORMAT) $< $@ +# $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ + +.elf.eep: + -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ + +# Create extended listing file from ELF output file. +.elf.lss: + $(OBJDUMP) -h -S $< > $@ + +# Create a symbol table from ELF output file. +.elf.sym: + $(NM) -n $< > $@ + + + +# Link: create ELF output file from object files. +$(TARGET).elf: $(OBJ) + $(CC) $(OBJ) --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +.c.o: + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C source files. +.c.s: + $(CC) -S $(ALL_CFLAGS) $< -o $@ + + +# Assemble: create object files from assembler source files. +.S.o: + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + + + +# Target: clean project. +clean: + $(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).cof $(TARGET).elf \ + $(TARGET).map $(TARGET).sym $(TARGET).lss \ + $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) + +depend: + if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \ + then \ + sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \ + $(MAKEFILE).$$$$ && \ + $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \ + fi + echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \ + >> $(MAKEFILE); \ + $(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE) + +.PHONY: all build elf hex eep lss sym program coff extcoff clean depend + + diff --git a/DS2423_komische platine/DS2423.c b/DS2423_komische platine/DS2423.c index 13b33dc..11f51db 100644 --- a/DS2423_komische platine/DS2423.c +++ b/DS2423_komische platine/DS2423.c @@ -54,7 +54,7 @@ extern uint8_t gcontrol; extern uint8_t reset_indicator; -volatile uint8_t wdcounter; + @@ -80,7 +80,7 @@ typedef union { volatile counters_t counters; volatile uint8_t istat; - +volatile uint8_t changefromeeprom; #define PCINT_VECTOR PCINT0_vect #define PIN_REG PINA #define PIN_DDR DDRA @@ -111,8 +111,8 @@ ISR(PCINT0_vect) { if (((PIN_REG&PIN_CH1)==0)&&((istat&PIN_CH1)==PIN_CH1)) { counters.c32[1]++; LPORT_CH2|=LPIN_CH2;} if (((PIN_REG&PIN_CH2)==0)&&((istat&PIN_CH2)==PIN_CH2)) { counters.c32[2]++; LPORT_CH2|=LPIN_CH2;} if (((PIN_REG&PIN_CH3)==0)&&((istat&PIN_CH3)==PIN_CH3)) { counters.c32[3]++; LPORT_CH2|=LPIN_CH2;} - - if (((PORT_EE&PIN_EE)==0)&&((istat&PIN_EE)==PIN_EE)) { + changefromeeprom=1; +/* if (((PORT_EE&PIN_EE)==0)&&((istat&PIN_EE)==PIN_EE)) { _delay_ms(50); if (((PORT_EE&PIN_EE)==0)) { @@ -135,7 +135,7 @@ ISR(PCINT0_vect) { } GIFR|=(1<7.0 com.Atmel.AVRGCC8.C {26106a5a-6618-4774-943f-65c46ddb610b} - ATtiny84A + ATtiny44 none Executable C @@ -27,14 +27,14 @@ 2 1 - + - + @@ -53,87 +53,87 @@ debugWIRE J41800000789 - 0x1E930C + 0x1E9207 125000 - -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=attiny44 -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\gcc\dev\attiny44" + 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) + - -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=attiny44 -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\gcc\dev\attiny44" + 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) + diff --git a/DS2438_DHT22/DS2438_DHT22.c b/DS2438_DHT22/DS2438_DHT22.c index d928313..e850887 100644 --- a/DS2438_DHT22/DS2438_DHT22.c +++ b/DS2438_DHT22/DS2438_DHT22.c @@ -253,6 +253,7 @@ uint8_t am2302() { uint8_t i; for(i=0;i<64;i++) pack.bytes[i]=0; + pack.page3[0]=0xF1; //Wiregate Code MCUSR=0; uint8_t err; diff --git a/DS2438_DHT22/DS2438_DHT22.cproj b/DS2438_DHT22/DS2438_DHT22.cproj index 8631da1..3dc3802 100644 --- a/DS2438_DHT22/DS2438_DHT22.cproj +++ b/DS2438_DHT22/DS2438_DHT22.cproj @@ -28,16 +28,16 @@ 1 - - - - - - - - - - + + + + + + + + + + com.atmel.avrdbg.tool.atmelice J41800000789 @@ -57,79 +57,79 @@ - -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 + + + 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) - + -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/DS2438_SHT2X/DS2438_SHT2X.c b/DS2438_SHT2X/DS2438_SHT2X.c index 632a112..349736e 100644 --- a/DS2438_SHT2X/DS2438_SHT2X.c +++ b/DS2438_SHT2X/DS2438_SHT2X.c @@ -146,6 +146,7 @@ int main(void){ uint8_t i; for(i=0;i<64;i++) pack.bytes[i]=0; + pack.page3[0]=0xF1; MCUSR=0; USI_TWI_Master_Initialise(); initSHT2x(); diff --git a/DS2438_VOC_DS2438_SHT_Wiregate/DS2438_DS2438.c b/DS2438_VOC_DS2438_SHT_Wiregate/DS2438_DS2438.c new file mode 100644 index 0000000..00a58ef --- /dev/null +++ b/DS2438_VOC_DS2438_SHT_Wiregate/DS2438_DS2438.c @@ -0,0 +1,486 @@ +// 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(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]={0x01,0x06, 0x05,0x08, 0x8,19, 0x00,0x00, 0x02,7,0x00,17,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 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; + +#define TIME_CORR 5 +volatile int8_t time_corr_count=TIME_CORR; + +#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 + pack1.etm++; + time_corr_count--; + if ((pack1.page1[0]&0x7)==0) { + wdcounter++; + } + if (time_corr_count<=0) { + //wdcounter++; + pack1.etm+=1; + time_corr_count=TIME_CORR; + } + /* if ((pack1.page1[0]&0x0F)==0) { + pack1.etm+=2; + + }*/ +/* if ((pack1.page1[0]&0x1F)==0) { + pack1.etm--; + }*/ + + if (reset_indicator==1) reset_indicator++; + else if (reset_indicator==2) mode=0; + + + } + + + +uint16_t pR0; +uint16_t pVS; +uint8_t pcmode; +int16_t pip; + +uint16_t ptol_s8; +uint16_t ptol_d; +uint16_t pr_day_max; +uint16_t pr_week_max; + + +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; + +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++; + + //pack1.dis+=8; + //pack1.eoc+=8; + 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; + 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; + 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; + pack2.current=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; + } + } 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_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 + + + + + -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 + MAX1164x.c + + + compile + SHT2xV2.c + + + compile + USI_TWI_Master.c + + + compile + OWDS2438_DS2438.S + + + compile + + + + \ No newline at end of file diff --git a/DS2438_VOC_DS2438_SHT_Wiregate/Makefile b/DS2438_VOC_DS2438_SHT_Wiregate/Makefile new file mode 100644 index 0000000..9aa6429 --- /dev/null +++ b/DS2438_VOC_DS2438_SHT_Wiregate/Makefile @@ -0,0 +1,202 @@ +# Hey Emacs, this is a -*- makefile -*- + +# AVR-GCC Makefile template, derived from the WinAVR template (which +# is public domain), believed to be neutral to any flavor of "make" +# (GNU make, BSD make, SysV make) + + +MCU = attiny84 +FORMAT = ihex +TARGET =DS2438_VOC_DS2438_SHT +SRC = ../common/calibr.c ../common/I2C/MAX1164x.c ../common/I2C/SHT2xV2.c ../common/I2C/USI_TWI_Master.c DS2438_DS2438.c +ASRC = ../common/OWDS2438_DS2438.S + +# Name of this Makefile (used for "make depend"). +MAKEFILE = Makefile + + +CFLAGS = -x c -funsigned-char -funsigned-bitfields -I. -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -std=gnu99 -MD -MP + +#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs + + +#Additional libraries. + +# Minimalistic printf version +PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min + +# Floating point printf version (requires MATH_LIB = -lm below) +PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt + +PRINTF_LIB = + +# Minimalistic scanf version +SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min + +# Floating point + %[ scanf version (requires MATH_LIB = -lm below) +SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt + +SCANF_LIB = + +MATH_LIB = -lm + +# External memory options + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# used for variables (.data/.bss) and heap (malloc()). +#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# only used for heap (malloc()). +#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff + +EXTMEMOPTS = + +#LDMAP = $(LDFLAGS) -Wl,-Map=$(TARGET).map,--cref +#LDFLAGS = $(EXTMEMOPTS) $(LDMAP) $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) +LDFLAGS = -Wl,--start-group -Wl,-lm -Wl,--end-group -Wl,--gc-sections -mmcu=$(MCU) + +# Programming support using avrdude. Settings and variables. + +#AVRDUDE_PROGRAMMER = stk500 +#AVRDUDE_PORT = /dev/term/a + +#AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex +#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep + + +# Uncomment the following if you want avrdude's erase cycle counter. +# Note that this counter needs to be initialized first using -Yn, +# see avrdude manual. +#AVRDUDE_ERASE_COUNTER = -y + +# Uncomment the following if you do /not/ wish a verification to be +# performed after programming the device. +#AVRDUDE_NO_VERIFY = -V + +# Increase verbosity level. Please use this when submitting bug +# reports about avrdude. See +# to submit bug reports. +#AVRDUDE_VERBOSE = -v -v + +#AVRDUDE_BASIC = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +#AVRDUDE_FLAGS = $(AVRDUDE_BASIC) $(AVRDUDE_NO_VERIFY) $(AVRDUDE_VERBOSE) $(AVRDUDE_ERASE_COUNTER) + + +CC = avr-gcc +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump +SIZE = avr-size +NM = avr-nm +#AVRDUDE = avrdude +REMOVE = rm -f +MV = mv -f + +# Define all object files. +OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) + +# Define all listing files. +LST = $(ASRC:.S=.lst) $(SRC:.c=.lst) + +# Combine all necessary flags and optional flags. +# Add target processor to flags. +ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) +ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) + + +# Default target. +all: build + +build: elf hex eep + +elf: $(TARGET).elf +hex: $(TARGET).hex +#eep: $(TARGET).eep +lss: $(TARGET).lss +sym: $(TARGET).sym + + +# Program the device. +program: $(TARGET).hex $(TARGET).eep + $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) + + + + +# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. +COFFCONVERT=$(OBJCOPY) --debugging \ +--change-section-address .data-0x800000 \ +--change-section-address .bss-0x800000 \ +--change-section-address .noinit-0x800000 \ +--change-section-address .eeprom-0x810000 + + +coff: $(TARGET).elf + $(COFFCONVERT) -O coff-avr $(TARGET).elf $(TARGET).cof + + +extcoff: $(TARGET).elf + $(COFFCONVERT) -O coff-ext-avr $(TARGET).elf $(TARGET).cof + + +.SUFFIXES: .elf .hex .eep .lss .sym + +.elf.hex: + $(OBJCOPY) -O $(FORMAT) $< $@ +# $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ + +.elf.eep: + -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ + +# Create extended listing file from ELF output file. +.elf.lss: + $(OBJDUMP) -h -S $< > $@ + +# Create a symbol table from ELF output file. +.elf.sym: + $(NM) -n $< > $@ + + + +# Link: create ELF output file from object files. +$(TARGET).elf: $(OBJ) + $(CC) $(OBJ) --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +.c.o: + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C source files. +.c.s: + $(CC) -S $(ALL_CFLAGS) $< -o $@ + + +# Assemble: create object files from assembler source files. +.S.o: + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + + + +# Target: clean project. +clean: + $(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).cof $(TARGET).elf \ + $(TARGET).map $(TARGET).sym $(TARGET).lss \ + $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) + +depend: + if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \ + then \ + sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \ + $(MAKEFILE).$$$$ && \ + $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \ + fi + echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \ + >> $(MAKEFILE); \ + $(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE) + +.PHONY: all build elf hex eep lss sym program coff extcoff clean depend + + diff --git a/DS2450_BMP280/DS2450_BMP280.atsln b/DS2450_BMP280/DS2450_BMP280.atsln new file mode 100644 index 0000000..2ab645d --- /dev/null +++ b/DS2450_BMP280/DS2450_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.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_BMP280", "DS2450_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_BMP280/DS2450_BMP280.c b/DS2450_BMP280/DS2450_BMP280.c new file mode 100644 index 0000000..420d789 --- /dev/null +++ b/DS2450_BMP280/DS2450_BMP280.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. + +#define F_CPU 8000000UL +#include +#include +#include +#include +#include +#include +#include "../common/I2C/USI_TWI_Master.h" +#include "../common/I2C/BMP280.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; +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) { + bmp280ConvertInt(&t,&P,1); + + 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_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 + USI_TWI_Master.c + + + compile + + + compile + + + + \ No newline at end of file diff --git a/DS2450_BMP280/Makefile b/DS2450_BMP280/Makefile new file mode 100644 index 0000000..fbcebe4 --- /dev/null +++ b/DS2450_BMP280/Makefile @@ -0,0 +1,202 @@ +# Hey Emacs, this is a -*- makefile -*- + +# AVR-GCC Makefile template, derived from the WinAVR template (which +# is public domain), believed to be neutral to any flavor of "make" +# (GNU make, BSD make, SysV make) + + +MCU = attiny84 +FORMAT = ihex +TARGET =DS2450_BMP280 +SRC = ../common/I2C/BMP280.c ../common/I2C/USI_TWI_Master.c DS2450_BMP280.c +ASRC = OWDS2450.S + +# Name of this Makefile (used for "make depend"). +MAKEFILE = Makefile + + +CFLAGS = -x c -funsigned-char -funsigned-bitfields -I. -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -std=gnu99 -MD -MP + +#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs + + +#Additional libraries. + +# Minimalistic printf version +PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min + +# Floating point printf version (requires MATH_LIB = -lm below) +PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt + +PRINTF_LIB = + +# Minimalistic scanf version +SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min + +# Floating point + %[ scanf version (requires MATH_LIB = -lm below) +SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt + +SCANF_LIB = + +MATH_LIB = -lm + +# External memory options + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# used for variables (.data/.bss) and heap (malloc()). +#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# only used for heap (malloc()). +#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff + +EXTMEMOPTS = + +#LDMAP = $(LDFLAGS) -Wl,-Map=$(TARGET).map,--cref +#LDFLAGS = $(EXTMEMOPTS) $(LDMAP) $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) +LDFLAGS = -Wl,--start-group -Wl,-lm -Wl,--end-group -Wl,--gc-sections -mmcu=$(MCU) + +# Programming support using avrdude. Settings and variables. + +#AVRDUDE_PROGRAMMER = stk500 +#AVRDUDE_PORT = /dev/term/a + +#AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex +#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep + + +# Uncomment the following if you want avrdude's erase cycle counter. +# Note that this counter needs to be initialized first using -Yn, +# see avrdude manual. +#AVRDUDE_ERASE_COUNTER = -y + +# Uncomment the following if you do /not/ wish a verification to be +# performed after programming the device. +#AVRDUDE_NO_VERIFY = -V + +# Increase verbosity level. Please use this when submitting bug +# reports about avrdude. See +# to submit bug reports. +#AVRDUDE_VERBOSE = -v -v + +#AVRDUDE_BASIC = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +#AVRDUDE_FLAGS = $(AVRDUDE_BASIC) $(AVRDUDE_NO_VERIFY) $(AVRDUDE_VERBOSE) $(AVRDUDE_ERASE_COUNTER) + + +CC = avr-gcc +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump +SIZE = avr-size +NM = avr-nm +#AVRDUDE = avrdude +REMOVE = rm -f +MV = mv -f + +# Define all object files. +OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) + +# Define all listing files. +LST = $(ASRC:.S=.lst) $(SRC:.c=.lst) + +# Combine all necessary flags and optional flags. +# Add target processor to flags. +ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) +ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) + + +# Default target. +all: build + +build: elf hex eep + +elf: $(TARGET).elf +hex: $(TARGET).hex +#eep: $(TARGET).eep +lss: $(TARGET).lss +sym: $(TARGET).sym + + +# Program the device. +program: $(TARGET).hex $(TARGET).eep + $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) + + + + +# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. +COFFCONVERT=$(OBJCOPY) --debugging \ +--change-section-address .data-0x800000 \ +--change-section-address .bss-0x800000 \ +--change-section-address .noinit-0x800000 \ +--change-section-address .eeprom-0x810000 + + +coff: $(TARGET).elf + $(COFFCONVERT) -O coff-avr $(TARGET).elf $(TARGET).cof + + +extcoff: $(TARGET).elf + $(COFFCONVERT) -O coff-ext-avr $(TARGET).elf $(TARGET).cof + + +.SUFFIXES: .elf .hex .eep .lss .sym + +.elf.hex: + $(OBJCOPY) -O $(FORMAT) $< $@ +# $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ + +.elf.eep: + -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ + +# Create extended listing file from ELF output file. +.elf.lss: + $(OBJDUMP) -h -S $< > $@ + +# Create a symbol table from ELF output file. +.elf.sym: + $(NM) -n $< > $@ + + + +# Link: create ELF output file from object files. +$(TARGET).elf: $(OBJ) + $(CC) $(OBJ) --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +.c.o: + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C source files. +.c.s: + $(CC) -S $(ALL_CFLAGS) $< -o $@ + + +# Assemble: create object files from assembler source files. +.S.o: + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + + + +# Target: clean project. +clean: + $(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).cof $(TARGET).elf \ + $(TARGET).map $(TARGET).sym $(TARGET).lss \ + $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) + +depend: + if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \ + then \ + sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \ + $(MAKEFILE).$$$$ && \ + $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \ + fi + echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \ + >> $(MAKEFILE); \ + $(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE) + +.PHONY: all build elf hex eep lss sym program coff extcoff clean depend + + diff --git a/DS2450_SHT2X_BMP280/DS2450_SHT2X_BMP280.cproj b/DS2450_SHT2X_BMP280/DS2450_SHT2X_BMP280.cproj index 54ca3e6..3a27365 100644 --- a/DS2450_SHT2X_BMP280/DS2450_SHT2X_BMP280.cproj +++ b/DS2450_SHT2X_BMP280/DS2450_SHT2X_BMP280.cproj @@ -28,16 +28,16 @@ 1 - - - - - - - - - - + + + + + + + + + + com.atmel.avrdbg.tool.atmelice J41800000779 diff --git a/common/OWConfig.s b/common/OWConfig.s index 9fd65c7..8b8928f 100644 --- a/common/OWConfig.s +++ b/common/OWConfig.s @@ -57,7 +57,7 @@ #define zh 31 .extern owid,8 -.extern config_info,16 +.extern config_info,26 .comm mode,1 ; Aktueller Zustand nach dem die Unterprogramme aufgerufen werden .comm srbyte,1 ; aktuelles Byte fuer Searchrom diff --git a/common/OWDS2401_DS2413.S b/common/OWDS2401_DS2413.S new file mode 100644 index 0000000..ba48f60 --- /dev/null +++ b/common/OWDS2401_DS2413.S @@ -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 _CHANGEABLE_ID_ +#define _ZERO_POLLING_ +//#define _HANDLE_CC_COMMAND_ +//#define _DB_ + +#include "../common/OWConfig.s" +#include "../common/OWCRC8.s" + +.extern pin_state,1 +.extern pin_set,1 +.comm resv1,1 + + +.macro CHIP_INIT ;r_temp is pushed other Registers should be saved +.endm + +.macro COMMAND_TABLE + rjmp h_accessread + rjmp h_accesswrite + rjmp h_accesswrite_read +.endm + +#include "../common/OWRomFunctionsDual.s" +#include "../common/OWTimerInterrupt.s" + + + +; Ab hier Geraeteabhaenging +#define OW_ACCESSREAD OW_FIRST_COMMAND+0 +#define OW_ACCESSWRITE OW_FIRST_COMMAND+1 +#define OW_ACCESSWRITE_READ OW_FIRST_COMMAND+2 + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + +#ifdef _HANDLE_CC_COMMAND_ +/*h_readcommand12: + clr r_bytep + cset 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 + +/* cset 0xBE,OW_READ_SCRATCHPAD_ADR1 + cset 0x4E,OW_WRITE_SCRATCHPAD_ADR1 + cjmp 0x44,hrc_set_convertT1 + cjmp 0xB4,hrc_set_convertV1*/ + FW_CONFIG_INFO1 +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + rjmp handle_end_sleep + + + +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** + + + + + +h_readcommand2: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cjmp 0xF5,hrc_accessread + cset 0x5A,OW_ACCESSWRITE +/* 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_accessread: + ldi r_sendflag,1 + ldi r_mode,OW_ACCESSREAD +h_accessread: + lds r_temp,pin_state + 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_read: + rjmp handle_end_sleep + + + +h_accesswrite: + cpi r_bytep,1 + breq h_accesswrite_compl + sts resv1,r_rwbyte + rjmp handle_end_inc +h_accesswrite_compl: + com r_rwbyte + lds r_temp,resv1 + cp r_temp,r_rwbyte + brne h_accesswrite_error + sts pin_set,r_rwbyte + ldi r_mode,OW_ACCESSWRITE_READ + ldi r_rwbyte,0xAA + ldi r_sendflag,1 + rjmp handle_end_inc +h_accesswrite_error: + 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/OWDS2423.S b/common/OWDS2423.S index 1abee6a..32be7dc 100644 --- a/common/OWDS2423.S +++ b/common/OWDS2423.S @@ -30,9 +30,10 @@ // (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 __4MHZ__ #define _CHANGEABLE_ID_ #define _ZERO_POLLING_ +//#define _DB_ #include "../common/OWConfig.s" #include "../common/OWCRC16.s" diff --git a/common/OWDS2423_DS2413.S b/common/OWDS2423_DS2413.S new file mode 100644 index 0000000..c0370a4 --- /dev/null +++ b/common/OWDS2423_DS2413.S @@ -0,0 +1,451 @@ + +// 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_ + +#include "../common/OWConfig.s" +#include "../common/OWCRC16.s" + +.extern pack1,45 +.extern counters1,16 + +//.extern pack2,45 +.extern counters2,16 + +#define pack2 pack1 +;same EEPROM for Attiny44 +.extern pin_state,1 +.extern pin_set,1 +.comm resv1,1 +.macro CHIP_INIT ;r_temp is pushed other Registers should be saved +.endm + +.macro COMMAND_TABLE + rjmp h_writescratchpad1 + rjmp h_writescratchpad_crc1 + rjmp h_readscratchpad1 + rjmp h_copyscratchpad1 + rjmp h_readmemory_addr1 + rjmp h_readmemory1 + rjmp h_readmemorycounter_addr1 + rjmp h_readmemorycounter1 + rjmp h_readmemorycounter_ex1 + + rjmp h_accessread2 + rjmp h_accesswrite2 + rjmp h_accesswrite_read2 +.endm + +#include "../common/OWRomFunctionsDual.s" +#include "../common/OWTimerInterrupt.s" + + + +; Ab hier Geraeteabhaenging +#define OW_WRITE_SCRATCHPAD1 OW_FIRST_COMMAND+0 +#define OW_WRITE_SCRATCHPAD_CRC1 OW_FIRST_COMMAND+1 +#define OW_READ_SCRATCHPAD1 OW_FIRST_COMMAND+2 +#define OW_COPY_SCRATCHPAD1 OW_FIRST_COMMAND+3 +#define OW_READ_MEMORY_ADDR1 OW_FIRST_COMMAND+4 +#define OW_READ_MEMORY1 OW_FIRST_COMMAND+5 +#define OW_READ_MEMORYCOUNTER_ADDR1 OW_FIRST_COMMAND+6 +#define OW_READ_MEMORYCOUNTER1 OW_FIRST_COMMAND+7 +#define OW_READ_MEMORYCOUNTER_EX1 OW_FIRST_COMMAND+8 + +#define OW_ACCESSREAD2 OW_FIRST_COMMAND+9 +#define OW_ACCESSWRITE2 OW_FIRST_COMMAND+10 +#define OW_ACCESSWRITE_READ2 OW_FIRST_COMMAND+11 + + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + +h_readcommand1: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cset 0x0F,OW_WRITE_SCRATCHPAD1 + cjmp 0xAA,hrc_set_readscratchpad1 + cset 0x5A,OW_COPY_SCRATCHPAD1 + cset 0xF0,OW_READ_MEMORY_ADDR1 + cset 0xA5,OW_READ_MEMORYCOUNTER_ADDR1 + 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 + rjmp h_readscratchpad1 + +h_writescratchpad1: + configZ pack1,r_bytep + inc r_bytep + st Z,r_rwbyte + cpi r_bytep,2 + breq h_writescratchpad_block1 + brsh h_writescratchpad_set_eoffset1 ;;33 + rjmp handle_end ;handle_end zu weit entfernt fuer br... +h_writescratchpad_set_eoffset1: + cpi r_bytep,35 + breq h_writescratchpad_setcrc1 + mov r_temp,r_bytep + subi r_temp,4 + sts pack1+2,r_temp ;AA und PF cleared + rjmp handle_end +;Start writeing to 32 Byte Block ; skip status byte +h_writescratchpad_block1: + lds r_temp,pack1 ; 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 pack1+2,r_temp ;E4:E0 vorher setzen + ; Byte 3 ueberspringen + rjmp handle_end_inc + +h_writescratchpad_setcrc1: + ;copy crc to pack + lds r_temp,crc + com r_temp + sts pack1+43,r_temp + lds r_temp,crc+1 + com r_temp ; invertieren , komischer name..... + sts pack1+44,r_temp + ldi r_mode,OW_WRITE_SCRATCHPAD_CRC1 + ldi r_sendflag,1 + ldi r_bytep,43 +h_writescratchpad_crc1: + cpi r_bytep,45 + breq h_writescratchpad_crc_end1 + configZ pack1,r_bytep + ld r_rwbyte,Z + rjmp handle_end_inc +h_writescratchpad_crc_end1: + rjmp handle_end_sleep + + +h_readscratchpad1: + cpi r_bytep,35 + breq h_readscratchpad_end1 + cpi r_bytep,3 + brne h_readscratchpad_read_byte1 +h_readscratchpad_set_offset1: + lds r_temp,pack1 + andi r_temp,0x1F + ldi r_temp2,3 + add r_temp,r_temp2 + mov r_bytep,r_temp +h_readscratchpad_read_byte1: + configZ pack1,r_bytep + ld r_rwbyte,Z + rjmp handle_end_inc +h_readscratchpad_end1: + rjmp handle_end_sleep + + + +h_copyscratchpad1: + cpi r_bytep,3 + brsh h_copyscratchpad_ok1 + configZ pack1,r_bytep + inc r_bytep + ld r_temp,Z + cp r_temp,r_rwbyte + brne h_copyscratchpad_nok1 + cpi r_bytep,3 + breq h_copyscratchpad_ok1 + ldi r_bcount,1 + rjmp handle_end +h_copyscratchpad_ok1: + ldi r_rwbyte,0xAA + ldi r_sendflag,1 + rjmp handle_end +h_copyscratchpad_nok1: + lds r_temp,pack1+3 + andi r_temp,~0x80 + sts pack1+3,r_temp + rjmp handle_end_sleep + + +h_readmemory_addr1: + cpi r_bytep,0 + brne h_readmrmory_addr_byte11 + sts pack1,r_rwbyte + rjmp handle_end_inc +h_readmrmory_addr_byte11: + sts pack1+1,r_rwbyte + ldi r_mode,OW_READ_MEMORY1 + ldi r_sendflag,1 + clr r_bytep + rjmp h_readmemory21 +h_readmemory1: + lds r_bytep,pack1 + lds r_temp2,pack1+1 + inc r_bytep + clr r_temp + adc r_temp2,r_temp + sbrc r_temp2,1 + rjmp h_readmemory_end1 + sts pack1+1,r_temp + sts pack1,r_bytep +h_readmemory21: + lds r_bytep,pack1 + andi r_bytep,0x1F + configZ pack1+3,r_bytep + ld r_rwbyte,Z + rjmp handle_end +h_readmemory_end1: + rjmp handle_end_sleep + + + + + + + + +h_readmemorycounter_addr1: + cpi r_bytep,0 + brne h_readmrmorycounter_addr_byte11 + sts pack1,r_rwbyte + inc r_bytep + ;ldi r_bcount,1 + rjmp handle_end +h_readmrmorycounter_addr_byte11: + sts pack1+1,r_rwbyte + ldi r_mode,OW_READ_MEMORYCOUNTER1 + ;ldi r_bcount,1 + ldi r_sendflag,1 + clr r_bytep + rjmp h_readmemorycounter21 +h_readmemorycounter1: + lds r_bytep,pack1 + lds r_temp2,pack1+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_next1 + sts pack1+1,r_temp2 + sts pack1,r_bytep +h_readmemorycounter21: ;Lesen von dem worauf die erstenzwei bytes zeigen + lds r_bytep,pack1 + andi r_bytep,0x1F + configZ pack1+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_next1: ; rest lesen + ldi r_mode,OW_READ_MEMORYCOUNTER_EX1 + ldi r_bytep,34 + lds r_temp2,pack1 + lds r_temp,pack1+1 + lsl r_temp2 + rol r_temp + cpi r_temp,3 + brne h_readmemorycounter_cFF1 + andi r_temp2,0xC0 + swap r_temp2 + + ;cpi r_temp,0xE0 + + configZ counters1,r_temp2 + ld r_temp,Z+ + sts pack1+35,r_temp + ld r_temp,Z+ + sts pack1+36,r_temp + ld r_temp,Z+ + sts pack1+37,r_temp + ld r_temp,Z+ + sts pack1+38,r_temp + rjmp h_readmemorycounter_ex1 +h_readmemorycounter_cFF1: + ldi r_temp,0xFF + sts pack1+35,r_temp + sts pack1+36,r_temp + sts pack1+37,r_temp + sts pack1+38,r_temp + +h_readmemorycounter_ex1: + inc r_bytep + cpi r_bytep,45 + breq h_readmemorycounter_ex_end1 + cpi r_bytep,43 + brne h_readmemorycounter_ex21 + lds r_temp,crc + com r_temp + sts pack1+43,r_temp + lds r_temp,crc+1 + com r_temp + sts pack1+44,r_temp +h_readmemorycounter_ex21: + ;ldi r_bcount,1 + configZ pack1,r_bytep + ld r_rwbyte,Z + rjmp handle_end +h_readmemorycounter_ex_end1: + lds r_bytep,pack1 + lds r_temp2,pack1+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_sleep1 + CRCInit1 + ldi r_mode,OW_READ_MEMORYCOUNTER1 + sts pack1+1,r_temp2 + sts pack1,r_bytep + rjmp h_readmemorycounter21 +h_readmemorycounter_ex_sleep1: + ldi r_mode,OW_SLEEP + clr r_sendflag + rjmp handle_end + + + + +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** + + +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_state + 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: + rjmp handle_end_sleep + + + +h_accesswrite2: + cpi r_bytep,1 + breq h_accesswrite_compl2 + sts resv1,r_rwbyte + rjmp handle_end_inc +h_accesswrite_compl2: + com r_rwbyte + lds r_temp,resv1 + cp r_temp,r_rwbyte + brne h_accesswrite_error2 + sts pin_set,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/OWDS2423_DS2423.S b/common/OWDS2423_DS2423.S new file mode 100644 index 0000000..f261e5f --- /dev/null +++ b/common/OWDS2423_DS2423.S @@ -0,0 +1,635 @@ + +// 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_ +#if defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny84A__) +#else +#define _NO_CONFIGBYTES_ +#define _DIS_FLASH_ +#endif +//#define _HANDLE_CC_COMMAND_ +//#define _DB_ + +#include "../common/OWConfig.s" +#include "../common/OWCRC16.s" + +.extern pack1,45 +.extern counters1,16 + +//.extern pack2,45 +.extern counters2,16 + +#define pack2 pack1 +;same EEPROM for Attiny44 + +.macro CHIP_INIT ;r_temp is pushed other Registers should be saved +.endm + +.macro COMMAND_TABLE + rjmp h_writescratchpad1 + rjmp h_writescratchpad_crc1 + rjmp h_readscratchpad1 + rjmp h_copyscratchpad1 + rjmp h_readmemory_addr1 + rjmp h_readmemory1 + rjmp h_readmemorycounter_addr1 + rjmp h_readmemorycounter1 + rjmp h_readmemorycounter_ex1 + + 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_WRITE_SCRATCHPAD1 OW_FIRST_COMMAND+0 +#define OW_WRITE_SCRATCHPAD_CRC1 OW_FIRST_COMMAND+1 +#define OW_READ_SCRATCHPAD1 OW_FIRST_COMMAND+2 +#define OW_COPY_SCRATCHPAD1 OW_FIRST_COMMAND+3 +#define OW_READ_MEMORY_ADDR1 OW_FIRST_COMMAND+4 +#define OW_READ_MEMORY1 OW_FIRST_COMMAND+5 +#define OW_READ_MEMORYCOUNTER_ADDR1 OW_FIRST_COMMAND+6 +#define OW_READ_MEMORYCOUNTER1 OW_FIRST_COMMAND+7 +#define OW_READ_MEMORYCOUNTER_EX1 OW_FIRST_COMMAND+8 + +#define OW_WRITE_SCRATCHPAD2 OW_FIRST_COMMAND+9 +#define OW_WRITE_SCRATCHPAD_CRC2 OW_FIRST_COMMAND+10 +#define OW_READ_SCRATCHPAD2 OW_FIRST_COMMAND+11 +#define OW_COPY_SCRATCHPAD2 OW_FIRST_COMMAND+12 +#define OW_READ_MEMORY_ADDR2 OW_FIRST_COMMAND+13 +#define OW_READ_MEMORY2 OW_FIRST_COMMAND+14 +#define OW_READ_MEMORYCOUNTER_ADDR2 OW_FIRST_COMMAND+15 +#define OW_READ_MEMORYCOUNTER2 OW_FIRST_COMMAND+16 +#define OW_READ_MEMORYCOUNTER_EX2 OW_FIRST_COMMAND+17 + + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + +h_readcommand1: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + cset 0x0F,OW_WRITE_SCRATCHPAD1 + cjmp 0xAA,hrc_set_readscratchpad1 + cset 0x5A,OW_COPY_SCRATCHPAD1 + cset 0xF0,OW_READ_MEMORY_ADDR1 + cset 0xA5,OW_READ_MEMORYCOUNTER_ADDR1 + 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 + rjmp h_readscratchpad1 + +h_writescratchpad1: + configZ pack1,r_bytep + inc r_bytep + st Z,r_rwbyte + cpi r_bytep,2 + breq h_writescratchpad_block1 + brsh h_writescratchpad_set_eoffset1 ;;33 + rjmp handle_end ;handle_end zu weit entfernt fuer br... +h_writescratchpad_set_eoffset1: + cpi r_bytep,35 + breq h_writescratchpad_setcrc1 + mov r_temp,r_bytep + subi r_temp,4 + sts pack1+2,r_temp ;AA und PF cleared + rjmp handle_end +;Start writeing to 32 Byte Block ; skip status byte +h_writescratchpad_block1: + lds r_temp,pack1 ; 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 pack1+2,r_temp ;E4:E0 vorher setzen + ; Byte 3 ueberspringen + rjmp handle_end_inc + +h_writescratchpad_setcrc1: + ;copy crc to pack + lds r_temp,crc + com r_temp + sts pack1+43,r_temp + lds r_temp,crc+1 + com r_temp ; invertieren , komischer name..... + sts pack1+44,r_temp + ldi r_mode,OW_WRITE_SCRATCHPAD_CRC1 + ldi r_sendflag,1 + ldi r_bytep,43 +h_writescratchpad_crc1: + cpi r_bytep,45 + breq h_writescratchpad_crc_end1 + configZ pack1,r_bytep + ld r_rwbyte,Z + rjmp handle_end_inc +h_writescratchpad_crc_end1: + rjmp handle_end_sleep + + +h_readscratchpad1: + cpi r_bytep,35 + breq h_readscratchpad_end1 + cpi r_bytep,3 + brne h_readscratchpad_read_byte1 +h_readscratchpad_set_offset1: + lds r_temp,pack1 + andi r_temp,0x1F + ldi r_temp2,3 + add r_temp,r_temp2 + mov r_bytep,r_temp +h_readscratchpad_read_byte1: + configZ pack1,r_bytep + ld r_rwbyte,Z + rjmp handle_end_inc +h_readscratchpad_end1: + rjmp handle_end_sleep + + + +h_copyscratchpad1: + cpi r_bytep,3 + brsh h_copyscratchpad_ok1 + configZ pack1,r_bytep + inc r_bytep + ld r_temp,Z + cp r_temp,r_rwbyte + brne h_copyscratchpad_nok1 + cpi r_bytep,3 + breq h_copyscratchpad_ok1 + ldi r_bcount,1 + rjmp handle_end +h_copyscratchpad_ok1: + ldi r_rwbyte,0xAA + ldi r_sendflag,1 + rjmp handle_end +h_copyscratchpad_nok1: + lds r_temp,pack1+3 + andi r_temp,~0x80 + sts pack1+3,r_temp + rjmp handle_end_sleep + + +h_readmemory_addr1: + cpi r_bytep,0 + brne h_readmrmory_addr_byte11 + sts pack1,r_rwbyte + rjmp handle_end_inc +h_readmrmory_addr_byte11: + sts pack1+1,r_rwbyte + ldi r_mode,OW_READ_MEMORY1 + ldi r_sendflag,1 + clr r_bytep + rjmp h_readmemory21 +h_readmemory1: + lds r_bytep,pack1 + lds r_temp2,pack1+1 + inc r_bytep + clr r_temp + adc r_temp2,r_temp + sbrc r_temp2,1 + rjmp h_readmemory_end1 + sts pack1+1,r_temp + sts pack1,r_bytep +h_readmemory21: + lds r_bytep,pack1 + andi r_bytep,0x1F + configZ pack1+3,r_bytep + ld r_rwbyte,Z + rjmp handle_end +h_readmemory_end1: + rjmp handle_end_sleep + + + + + + + + +h_readmemorycounter_addr1: + cpi r_bytep,0 + brne h_readmrmorycounter_addr_byte11 + sts pack1,r_rwbyte + inc r_bytep + ;ldi r_bcount,1 + rjmp handle_end +h_readmrmorycounter_addr_byte11: + sts pack1+1,r_rwbyte + ldi r_mode,OW_READ_MEMORYCOUNTER1 + ;ldi r_bcount,1 + ldi r_sendflag,1 + clr r_bytep + rjmp h_readmemorycounter21 +h_readmemorycounter1: + lds r_bytep,pack1 + lds r_temp2,pack1+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_next1 + sts pack1+1,r_temp2 + sts pack1,r_bytep +h_readmemorycounter21: ;Lesen von dem worauf die erstenzwei bytes zeigen + lds r_bytep,pack1 + andi r_bytep,0x1F + configZ pack1+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_next1: ; rest lesen + ldi r_mode,OW_READ_MEMORYCOUNTER_EX1 + ldi r_bytep,34 + lds r_temp2,pack1 + lds r_temp,pack1+1 + lsl r_temp2 + rol r_temp + cpi r_temp,3 + brne h_readmemorycounter_cFF1 + andi r_temp2,0xC0 + swap r_temp2 + + ;cpi r_temp,0xE0 + + configZ counters1,r_temp2 + ld r_temp,Z+ + sts pack1+35,r_temp + ld r_temp,Z+ + sts pack1+36,r_temp + ld r_temp,Z+ + sts pack1+37,r_temp + ld r_temp,Z+ + sts pack1+38,r_temp + rjmp h_readmemorycounter_ex1 +h_readmemorycounter_cFF1: + ldi r_temp,0xFF + sts pack1+35,r_temp + sts pack1+36,r_temp + sts pack1+37,r_temp + sts pack1+38,r_temp + +h_readmemorycounter_ex1: + inc r_bytep + cpi r_bytep,45 + breq h_readmemorycounter_ex_end1 + cpi r_bytep,43 + brne h_readmemorycounter_ex21 + lds r_temp,crc + com r_temp + sts pack1+43,r_temp + lds r_temp,crc+1 + com r_temp + sts pack1+44,r_temp +h_readmemorycounter_ex21: + ;ldi r_bcount,1 + configZ pack1,r_bytep + ld r_rwbyte,Z + rjmp handle_end +h_readmemorycounter_ex_end1: + lds r_bytep,pack1 + lds r_temp2,pack1+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_sleep1 + CRCInit1 + ldi r_mode,OW_READ_MEMORYCOUNTER1 + sts pack1+1,r_temp2 + sts pack1,r_bytep + rjmp h_readmemorycounter21 +h_readmemorycounter_ex_sleep1: + ldi r_mode,OW_SLEEP + clr r_sendflag + rjmp handle_end + + + + +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** + + + + +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 + 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_temp + sts pack2,r_bytep +h_readmemory22: + lds r_bytep,pack2 + andi r_bytep,0x1F + 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 diff --git a/common/OWDS2438_DS2438.S b/common/OWDS2438_DS2438.S new file mode 100644 index 0000000..3c00e1b --- /dev/null +++ b/common/OWDS2438_DS2438.S @@ -0,0 +1,351 @@ + +// 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_ + +#include "../common/OWConfig.s" +#include "../common/OWCRC8.s" + + +#if defined(__AVR_ATtiny25__) +.extern pack2,16 +.extern pack1,16 +#else +.extern pack2,64 +.extern pack1,64 +#endif +.extern DS2438_1_TEMP,2 +.extern DS2438_1_VAD,2 +.extern DS2438_2_TEMP,2 +.extern DS2438_2_VAD,2 +.comm block,1 ; Block der augegeben, geschrieben wird (Parameter von READ/WRITE Scratchpad) + + +.macro CHIP_INIT ;r_temp is pushed other Registers should be saved +.endm + +.macro COMMAND_TABLE + rjmp h_readscratchpad_adr1 + rjmp h_readscratchpad1 + rjmp h_writescratchpad_adr1 + rjmp h_writescratchpad1 + rjmp h_readscratchpad_adr2 + rjmp h_readscratchpad2 + rjmp h_writescratchpad_adr2 + rjmp h_writescratchpad2 +.endm + +#include "../common/OWRomFunctionsDual.s" +#include "../common/OWTimerInterrupt.s" + + + +; Ab hier Geraeteabhaenging +#define OW_READ_SCRATCHPAD_ADR1 OW_FIRST_COMMAND+0 +#define OW_READ_SCRATCHPAD1 OW_FIRST_COMMAND+1 +#define OW_WRITE_SCRATCHPAD_ADR1 OW_FIRST_COMMAND+2 +#define OW_WRITE_SCRATCHPAD1 OW_FIRST_COMMAND+3 +#define OW_READ_SCRATCHPAD_ADR2 OW_FIRST_COMMAND+4 +#define OW_READ_SCRATCHPAD2 OW_FIRST_COMMAND+5 +#define OW_WRITE_SCRATCHPAD_ADR2 OW_FIRST_COMMAND+6 +#define OW_WRITE_SCRATCHPAD2 OW_FIRST_COMMAND+7 + + +;--------------------------------------------------- +; READ COMMAND and start operation +;--------------------------------------------------- + +#ifdef _HANDLE_CC_COMMAND_ +h_readcommand12: + clr r_bytep + cset 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 + cset 0xBE,OW_READ_SCRATCHPAD_ADR1 + cset 0x4E,OW_WRITE_SCRATCHPAD_ADR1 + cjmp 0x44,hrc_set_convertT1 + cjmp 0xB4,hrc_set_convertV1 + FW_CONFIG_INFO1 +#ifdef _CHANGEABLE_ID_ + CHANGE_ID_COMMANDS +#endif + rjmp handle_end_sleep + + +hrc_set_convertT1: + ldi r_temp,1 + sts gcontrol,r_temp + lds r_temp,DS2438_1_TEMP + sts pack1+1,r_temp + lds r_temp,DS2438_1_TEMP+1 + sts pack1+2,r_temp + rjmp handle_end_sleep +hrc_set_convertV1: + lds r_temp,pack1 + sbrs r_temp,3 + rjmp hrc_set_convertVV1 + ldi r_temp,0xF4 //5V + sts pack1+3,r_temp + ldi r_temp,0x01 + sts pack1+4,r_temp + rjmp hrc_set_convertend1 +hrc_set_convertVV1: + ldi r_temp,3 + sts gcontrol,r_temp + lds r_temp,DS2438_1_VAD + sts pack1+3,r_temp + lds r_temp,DS2438_1_VAD+1 + sts pack1+4,r_temp +hrc_set_convertend1: + rjmp handle_end_sleep + + + +;--------------------------------------------------- +; READ SCRATCHPAD +;--------------------------------------------------- + +h_readscratchpad_adr1: + 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_SCRATCHPAD1 + CRCInit2 +h_readscratchpad1: + cpi r_bytep,8 + breq h_readscratchpad_crc1 + cpi r_bytep,9 + breq h_readscratchpad_all1 + lds r_temp,block + add r_temp,r_bytep + configZ pack1,r_temp + ld r_rwbyte,Z + rjmp handle_end_inc +h_readscratchpad_crc1: + lds r_rwbyte,crc + rjmp handle_end_inc +h_readscratchpad_all1: + rjmp handle_end_sleep + + + + +;--------------------------------------------------- +; WRITE SCRATCHPAD +;--------------------------------------------------- +h_writescratchpad_adr1: + 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_SCRATCHPAD1 + ldi r_bcount,1 + rjmp handle_end +h_writescratchpad1: + cpi r_bytep,8 + breq h_writescratchpad_all1 + lds r_temp,block + add r_temp,r_bytep + configZ pack1,r_temp + st Z,r_rwbyte + rjmp handle_end_inc +h_writescratchpad_all1: + rjmp handle_end_sleep + + + + + + + + +#ifdef _HANDLE_CC_COMMAND_ +hrc_set_convertT12: + ldi r_temp,3 + sts gcontrol,r_temp + lds r_temp,DS2438_2_TEMP + sts pack2+1,r_temp + lds r_temp,DS2438_2_TEMP+1 + sts pack2+2,r_temp + lds r_temp,DS2438_1_TEMP + sts pack1+1,r_temp + lds r_temp,DS2438_1_TEMP+1 + sts pack1+2,r_temp + rjmp handle_end_sleep +#endif + + +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** +;***************************************************************************************************************************************************************************************** + + + + + +h_readcommand2: + clr r_bytep +#ifndef _DIS_FLASH_ + FLASH_COMMANDS ; muss zu erst sein.... +#endif + 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_set_convertT2: + ldi r_temp,2 + sts gcontrol,r_temp + lds r_temp,DS2438_2_TEMP + sts pack2+1,r_temp + lds r_temp,DS2438_2_TEMP+1 + sts pack2+2,r_temp + rjmp handle_end_sleep +hrc_set_convertV2: + lds r_temp,pack2 + sbrs r_temp,3 + rjmp hrc_set_convertVV2 + ldi r_temp,0xF4 + sts pack2+3,r_temp + ldi r_temp,0x01 + sts pack2+4,r_temp + rjmp hrc_set_convertend2 +hrc_set_convertVV2: + ldi r_temp,3 + sts gcontrol,r_temp + lds r_temp,DS2438_2_VAD + sts pack2+3,r_temp + lds r_temp,DS2438_2_VAD+1 + sts pack2+4,r_temp +hrc_set_convertend2: + rjmp handle_end_sleep + + + +;--------------------------------------------------- +; READ SCRATCHPAD +;--------------------------------------------------- + +h_readscratchpad_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_sendflag,1 + ldi r_mode,OW_READ_SCRATCHPAD2 + CRCInit2 +h_readscratchpad2: + cpi r_bytep,8 + breq h_readscratchpad_crc2 + cpi r_bytep,9 + breq h_readscratchpad_all2 + lds r_temp,block + add r_temp,r_bytep + configZ pack2,r_temp + ld r_rwbyte,Z + rjmp handle_end_inc +h_readscratchpad_crc2: + lds r_rwbyte,crc + rjmp handle_end_inc +h_readscratchpad_all2: + 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/OWPinInterrupt.s b/common/OWPinInterrupt.s index df8952d..69f84f3 100644 --- a/common/OWPinInterrupt.s +++ b/common/OWPinInterrupt.s @@ -85,6 +85,7 @@ send_bit_low_loop: cpi r_temp,(~OWT_MIN_RESET)+OWT_WRITE ;aller zwei us zaehlt der timer brlo send_bit_low_loop ;wenn kleiner cbi OW_DDR,OW_PINN ;Leitung auf hochohmig + rjmp iend receive_bit: ;or reset @@ -100,7 +101,9 @@ receive_bit: ;or reset ori r_rwbyte,0x80 ldi r_temp2,0 ;fuer CRC Berechnung receive_bit_crc: + sdb CRCR + lsl r_bcount brne recive_bit_no_handle ;bcount nicht 0 ;naechstes byte .... diff --git a/common/OWRomFunctionsDual.s b/common/OWRomFunctionsDual.s index 3c2d152..6f1e709 100644 --- a/common/OWRomFunctionsDual.s +++ b/common/OWRomFunctionsDual.s @@ -213,13 +213,13 @@ hrc_set_searchrom: rjmp h_searchrom_next_bit hrc_start_read_command: ;Skip rom und Matchrom ok... + CRCInit1 lds r_temp,srbyte cpi r_temp,1 breq hrc_start_read_command1 cpi r_temp,2 breq hrc_start_read_command2 rjmp handle_end_sleep - CRCInit1 hrc_start_read_command1: ldi r_mode,OW_READ_COMMAND1 rjmp handle_end @@ -241,17 +241,24 @@ hrc_set_alarm_search: rjmp handle_end_sleep hrc_fw_configinfo1: +#ifdef _NO_CONFIGBYTES_ + rjmp handle_end_sleep +#else ldi r_mode,OW_FWCONFIGINFO1 ldi r_sendflag,1 CRCInit2 rjmp h_fwconfiginfo1 +#endif hrc_fw_configinfo2: +#ifdef _NO_CONFIGBYTES_ + rjmp handle_end_sleep +#else ldi r_mode,OW_FWCONFIGINFO2 ldi r_sendflag,1 CRCInit2 rjmp h_fwconfiginfo2 - +#endif ;--------------------------------------------------- ; MATCH ROM @@ -395,10 +402,26 @@ h_searchromr: ; stelle um auf empfangen ;--------------------------------------------------- h_fwconfiginfo1: +#ifdef _NO_CONFIGBYTES_ +h_fwconfiginfo2: + rjmp handle_end_sleep +#else configZ config_info1,r_bytep rjmp h_fwconfiginfo_go h_fwconfiginfo2: configZ config_info2,r_bytep +/*#ifdef _CRC16_ + cpi r_bytep,24 + breq h_fwconfiginfo_crc + cpi r_bytep,26 + breq h_fwconfiginfo_all +//h_fwconfiginfo_end: + //configZ config_info1,r_bytep //crc16 wird in config_info1 gespeichert, auch bei config_info2 + configZ config_info2,r_bytep + ld r_rwbyte,Z + rjmp handle_end_inc +#endif +*/ h_fwconfiginfo_go: cpi r_bytep,24 @@ -414,8 +437,10 @@ h_fwconfiginfo_go: breq h_fwconfiginfo_all #warning No CRC known code implemented #endif + h_fwconfiginfo_end: //configZ config_info1,r_bytep //crc16 wird in config_info1 gespeichert, auch bei config_info2 + //configZ config_info1,r_bytep ld r_rwbyte,Z rjmp handle_end_inc h_fwconfiginfo_crc: @@ -429,11 +454,15 @@ h_fwconfiginfo_crc: lds r_temp,crc+1 com r_temp sts config_info1+25,r_temp - rjmp h_fwconfiginfo_end + ldi r_mode,OW_FWCONFIGINFO1 //auch CRC vom Dev 2 wird in Configinfo 1 geschrieben also da weiter machen + configZ config_info1,r_bytep + ld r_rwbyte,Z + rjmp handle_end_inc + #endif h_fwconfiginfo_all: rjmp handle_end_sleep - +#endif ;--------------------------------------------------- ; CHANGE ROM FUNCTIONS @@ -554,11 +583,10 @@ spause: .global OWINIT OWINIT: -#ifndef _DIS_FLASH_ ; check for bootloader jumper ;vor allen anderen Registerconfigs push r_temp - +#ifndef _DIS_FLASH_ ldi r_temp,(1<