build: Reorganized code.
Most MCU-dependent variable definitions ist now put into node-specific files. Makes it easier to maintain code for different node types.
This commit is contained in:
2
0BUILD
2
0BUILD
@@ -95,7 +95,7 @@
|
||||
</output>
|
||||
|
||||
<cmd tool="$(avrdude)" checkDates="FALSE" >
|
||||
-p t84 -c stk500 -P /dev/ttyACM0 -B16 -U flash:w:avr/aqhomeavr.hex
|
||||
-p t84 -c stk500 -P /dev/ttyACM0 -B16 -U flash:w:avr/att84_temp1.hex
|
||||
</cmd>
|
||||
|
||||
<buildMessage>
|
||||
|
||||
3
avr/.gitignore
vendored
3
avr/.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
main.obj
|
||||
main.eep.hex
|
||||
*.eep.hex
|
||||
*.obj
|
||||
|
||||
19
avr/0BUILD
19
avr/0BUILD
@@ -2,6 +2,7 @@
|
||||
|
||||
<gwbuild>
|
||||
|
||||
<!--
|
||||
<target type="AvrHexFile" name="aqhomeavr" >
|
||||
|
||||
<includes type="avrasm" >
|
||||
@@ -16,6 +17,24 @@
|
||||
</sources>
|
||||
|
||||
|
||||
</target>
|
||||
-->
|
||||
|
||||
|
||||
<target type="AvrHexFile" name="att84_temp1" >
|
||||
|
||||
<includes type="avrasm" >
|
||||
-I $(builddir)
|
||||
-I $(srcdir)
|
||||
-I $(topsrcdir)/avr
|
||||
</includes>
|
||||
|
||||
|
||||
<sources type="avrasm" >
|
||||
att84_temp1.asm
|
||||
</sources>
|
||||
|
||||
|
||||
</target>
|
||||
|
||||
</gwbuild>
|
||||
|
||||
401
avr/att84_temp1.asm
Normal file
401
avr/att84_temp1.asm
Normal file
@@ -0,0 +1,401 @@
|
||||
; ***************************************************************************
|
||||
; Source file for temperature sensor node on AtTiny 84
|
||||
;
|
||||
; This is for the full system (i.e. not the boot loader).
|
||||
;
|
||||
; All definitions and changes should go into this file.
|
||||
;
|
||||
;
|
||||
; AtTiny84
|
||||
; --------
|
||||
; VCC 1 14 GND
|
||||
; PB0 2 13 PA0
|
||||
; PB1 3 12 PA1 COM-DATA
|
||||
; /RESET PB3 4 11 PA2 OWI
|
||||
; KEY1 PB2 5 10 PA3 LED
|
||||
; COM_ATTN PA7 6 9 PA4 TWI-SCL
|
||||
; TWI-SDA PA6 7 8 PA5
|
||||
; --------
|
||||
;
|
||||
; ***************************************************************************
|
||||
|
||||
|
||||
|
||||
.nolist
|
||||
.include "include/tn84def.inc" ; Define device ATtiny84
|
||||
.list
|
||||
|
||||
.include "defs.asm"
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; generic
|
||||
|
||||
.equ clock=1000000 ; Define the clock frequency
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; list of modules to use
|
||||
|
||||
#define MODULES_TIMER
|
||||
#define MODULES_COM
|
||||
#define MODULES_LED
|
||||
#define MODULES_TWI_MASTER
|
||||
#define MODULES_LCD
|
||||
#define MODULES_SI7021
|
||||
|
||||
|
||||
.equ VALUE_ID_TEMP1 = 0x01
|
||||
.equ VALUE_ID_HUM1 = 0x02
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; COM module
|
||||
|
||||
.equ COM_BIT_LENGTH = 52000 ; 104000=9600, 52000=19200, 26000=38400
|
||||
|
||||
.equ COM_DDR_DATA = DDRA
|
||||
.equ COM_PORT_DATA = PORTA
|
||||
.equ COM_PIN_DATA = PINA
|
||||
.equ COM_PINNUM_DATA = PORTA1
|
||||
|
||||
.equ COM_DDR_ATTN = DDRA
|
||||
.equ COM_PORT_ATTN = PORTA
|
||||
.equ COM_PIN_ATTN = PINA
|
||||
.equ COM_PINNUM_ATTN = PORTA7
|
||||
|
||||
.equ COM_IRQ_ADDR_ATTN = PCMSK0
|
||||
.equ COM_IRQ_BIT_ATTN = 7 ; bit 7 in PCMSK0
|
||||
.equ COM_IRQ_GIFR_ATTN = PCIF0
|
||||
.equ COM_IRQ_GIMSK_ATTN = PCIE0
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; TWI master module
|
||||
|
||||
.equ LCD_TWI_ADDRESS = 0x3c
|
||||
|
||||
.equ TWI_DDR_SCL = DDRA
|
||||
.equ TWI_PORT_SCL = PORTA
|
||||
.equ TWI_PIN_SCL = PINA
|
||||
.equ TWI_PINNUM_SCL = PORTA4
|
||||
|
||||
.equ TWI_DDR_SDA = DDRA
|
||||
.equ TWI_PORT_SDA = PORTA
|
||||
.equ TWI_PIN_SDA = PINA
|
||||
.equ TWI_PINNUM_SDA = PORTA6
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; BMP 280
|
||||
|
||||
.equ BMP280_ADDR = 0x76
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; SI 7021
|
||||
|
||||
.equ SI7021_ADDR = 0x40
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code segment
|
||||
|
||||
.cseg
|
||||
.org 000000
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Reset and interrupt vectors
|
||||
|
||||
rjmp main ; Reset vector
|
||||
reti ; EXT_INT0
|
||||
rjmp comIsrPcint0 ; PCI0
|
||||
reti ; PCI1
|
||||
reti ; WATCHDOG
|
||||
reti ; ICP1
|
||||
reti ; OC1A
|
||||
reti ; OC1B
|
||||
reti ; OVF1
|
||||
rjmp timerIrqOC0A ; OC0A
|
||||
reti ; OC0B
|
||||
reti ; OVF0
|
||||
reti ; ACI
|
||||
reti ; ADCC
|
||||
reti ; ERDY
|
||||
reti ; USI_STR
|
||||
reti ; USI_OVF
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; includes
|
||||
|
||||
.include "utils.asm"
|
||||
.include "timer.asm"
|
||||
.include "led.asm"
|
||||
.include "com.asm"
|
||||
.include "twimaster.asm"
|
||||
.include "lcd.asm"
|
||||
;.include "bmp280.asm"
|
||||
.include "si7021.asm"
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in SRAM
|
||||
|
||||
.dseg
|
||||
|
||||
ledA3Sram: .byte LED_SRAM_SIZE
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in EEPROM
|
||||
|
||||
.eseg
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in FLASH
|
||||
|
||||
.cseg
|
||||
|
||||
ledA3Flash: .db DDRA+0x20, PORTA+0x20, PINA+0x20, (1<<PORTA3)
|
||||
blinkPattern: .db 5, 5, 5, 5, 5, 10, 0xff, 0xff ; 3 short blinks, 1s pause, restart
|
||||
blinkPattern2: .db 10, 20, 0xff, 0xff ; 1 long blink, 2s pause, restart
|
||||
|
||||
|
||||
|
||||
.include "main.asm"
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onEvery100ms
|
||||
;
|
||||
; Called every 100ms. Add your routine calls here.
|
||||
;
|
||||
; IN:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - nothing
|
||||
; USED: depending on called routines
|
||||
|
||||
onEvery100ms:
|
||||
#ifdef MODULES_LED
|
||||
; ticker for LED module
|
||||
ldi zl, LOW(ledA3Flash)
|
||||
ldi zh, HIGH(ledA3Flash)
|
||||
ldi yl, LOW(ledA3Sram)
|
||||
ldi yh, HIGH(ledA3Sram)
|
||||
rcall Led_Tick
|
||||
#endif
|
||||
|
||||
; add more calls here
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onEverySecond
|
||||
;
|
||||
; Called every second. Add your routine calls here.
|
||||
;
|
||||
; IN:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - nothing
|
||||
; USED: depending on called routines
|
||||
|
||||
onEverySecond:
|
||||
; rcall TWI_Master_ScanNext
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onEvery10s
|
||||
;
|
||||
; Called every 10 seconds. Add your routine calls here.
|
||||
;
|
||||
; IN:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - nothing
|
||||
; USED: depending on called routines
|
||||
|
||||
onEvery10s:
|
||||
rcall printSendStats
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onEvery30s
|
||||
;
|
||||
; Called every 10 seconds. Add your routine calls here.
|
||||
;
|
||||
; IN:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - nothing
|
||||
; USED: depending on called routines
|
||||
|
||||
onEvery30s:
|
||||
#ifdef MODULES_SI7021
|
||||
rcall SI7021_PeriodicMeasurement
|
||||
rcall sendValueMsg
|
||||
#endif
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onEveryMinute
|
||||
;
|
||||
; Called every minute. Add your routine calls here.
|
||||
;
|
||||
; IN:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - nothing
|
||||
; USED: depending on called routines
|
||||
|
||||
onEveryMinute:
|
||||
in r15, SREG ; debug
|
||||
cli
|
||||
push r15
|
||||
|
||||
#ifdef MODULES_COM
|
||||
ldi r16, 219
|
||||
rcall COM_EnqueueComSendStats
|
||||
|
||||
;ldi r16, 219
|
||||
;rcall COM_EnqueuePing
|
||||
#endif
|
||||
|
||||
pop r15
|
||||
out SREG, r15
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onPacketReceived:
|
||||
;
|
||||
; Called after a packet was received via COM module. Add your routine calls here.
|
||||
;
|
||||
; The packet will be removed from buffer in any case after return from this call.
|
||||
; IN:
|
||||
; - Y : pointer to received buffer
|
||||
; OUT:
|
||||
; - CFLAG: set if handled, cleared otherwise
|
||||
; USED: depending on called routines
|
||||
|
||||
onPacketReceived:
|
||||
clc ; not handled
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef MODULES_COM
|
||||
debugSendByte:
|
||||
push r15
|
||||
in r15, SREG ; debug
|
||||
cli
|
||||
push r17
|
||||
push r22
|
||||
ldi r17, 8
|
||||
sbi DDRA, PORTA2 ; debug
|
||||
|
||||
cbi PORTA, PORTA2 ; debug (on)
|
||||
Utils_WaitNanoSecs 100000, 0, r22 ; start with 2t low
|
||||
|
||||
sbi PORTA, PORTA2 ; debug (off)
|
||||
nop
|
||||
nop
|
||||
cbi PORTA, PORTA2 ; debug (on)
|
||||
Utils_WaitNanoSecs 100000, 0, r22 ; start with 2t low
|
||||
|
||||
debugSendByte_loop:
|
||||
lsr r16
|
||||
brcs debugSendByte_sendLow
|
||||
cbi PORTA, PORTA2 ; debug (on)
|
||||
rjmp debugSendByte_wait
|
||||
debugSendByte_sendLow:
|
||||
sbi PORTA, PORTA2 ; debug (off)
|
||||
|
||||
debugSendByte_wait:
|
||||
Utils_WaitNanoSecs 100000, 0, r22
|
||||
dec r17
|
||||
brne debugSendByte_loop
|
||||
|
||||
cbi PORTA, PORTA2 ; debug (on)
|
||||
Utils_WaitNanoSecs 200000, 0, r22 ; end with 2t low
|
||||
sbi PORTA, PORTA2 ; debug (off)
|
||||
pop r22
|
||||
pop r17
|
||||
out SREG, r15
|
||||
pop r15
|
||||
ret
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
sendValueMsg:
|
||||
; send message for current temp
|
||||
lds r22, si7021Flags
|
||||
mov r16, r22
|
||||
andi r16, SI7021_FLAGS_TEMP_VALID
|
||||
breq sendValueMsg_checkHum
|
||||
ldi r16, 0xff ; destination address
|
||||
ldi r17, VALUE_ID_TEMP1 ; value id
|
||||
ldi r22, AQHOME_VALUETYPE_TEMP
|
||||
lds r18, si7021LastTemp ; value
|
||||
lds r19, si7021LastTemp+1
|
||||
ldi r20, 100 ; denominator
|
||||
clr r21
|
||||
push r22
|
||||
rcall COM_EnqueueValue
|
||||
pop r22
|
||||
sendValueMsg_checkHum:
|
||||
mov r16, r22
|
||||
andi r16, SI7021_FLAGS_HUM_VALID
|
||||
breq sendValueMsg_done
|
||||
ldi r16, 0xff ; destination address
|
||||
ldi r17, VALUE_ID_HUM1 ; value id
|
||||
ldi r22, AQHOME_VALUETYPE_HUMIDITY
|
||||
lds r18, si7021LastHumidity ; value
|
||||
lds r19, si7021LastHumidity+1
|
||||
ldi r20, 1 ; denominator
|
||||
clr r21
|
||||
push r22
|
||||
rcall COM_EnqueueValue
|
||||
pop r22
|
||||
sendValueMsg_done:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
7
avr/defs.asm
Normal file
7
avr/defs.asm
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
|
||||
|
||||
.equ AQHOME_VALUETYPE_TEMP = 1
|
||||
.equ AQHOME_VALUETYPE_HUMIDITY = 2
|
||||
|
||||
|
||||
326
avr/main.asm
326
avr/main.asm
@@ -1,138 +1,6 @@
|
||||
.nolist
|
||||
.include "include/tn84def.inc" ; Define device ATtiny84
|
||||
.list
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; generic
|
||||
|
||||
.equ clock=1000000 ; Define the clock frequency
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; COM module
|
||||
|
||||
.equ COM_BIT_LENGTH = 52000 ; 104000=9600, 52000=19200, 26000=38400
|
||||
|
||||
.equ COM_DDR_DATA = DDRA
|
||||
.equ COM_PORT_DATA = PORTA
|
||||
.equ COM_PIN_DATA = PINA
|
||||
.equ COM_PINNUM_DATA = PORTA1
|
||||
|
||||
.equ COM_DDR_ATTN = DDRA
|
||||
.equ COM_PORT_ATTN = PORTA
|
||||
.equ COM_PIN_ATTN = PINA
|
||||
.equ COM_PINNUM_ATTN = PORTA7
|
||||
|
||||
.equ COM_IRQ_ADDR_ATTN = PCMSK0
|
||||
.equ COM_IRQ_BIT_ATTN = 7 ; bit 7 in PCMSK0
|
||||
.equ COM_IRQ_GIFR_ATTN = PCIF0
|
||||
.equ COM_IRQ_GIMSK_ATTN = PCIE0
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; TWI master module
|
||||
|
||||
.equ LCD_TWI_ADDRESS = 0x3c
|
||||
|
||||
.equ TWI_DDR_SCL = DDRA
|
||||
.equ TWI_PORT_SCL = PORTA
|
||||
.equ TWI_PIN_SCL = PINA
|
||||
.equ TWI_PINNUM_SCL = PORTA4
|
||||
|
||||
.equ TWI_DDR_SDA = DDRA
|
||||
.equ TWI_PORT_SDA = PORTA
|
||||
.equ TWI_PIN_SDA = PINA
|
||||
.equ TWI_PINNUM_SDA = PORTA6
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; BMP 280
|
||||
|
||||
.equ BMP280_ADDR = 0x76
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code segment
|
||||
|
||||
.cseg
|
||||
.org 000000
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Reset and interrupt vectors
|
||||
|
||||
rjmp main ; Reset vector
|
||||
reti ; EXT_INT0
|
||||
rjmp comIsrPcint0 ; PCI0
|
||||
reti ; PCI1
|
||||
reti ; WATCHDOG
|
||||
reti ; ICP1
|
||||
reti ; OC1A
|
||||
reti ; OC1B
|
||||
reti ; OVF1
|
||||
rjmp timerIrqOC0A ; OC0A
|
||||
reti ; OC0B
|
||||
reti ; OVF0
|
||||
reti ; ACI
|
||||
reti ; ADCC
|
||||
reti ; ERDY
|
||||
reti ; USI_STR
|
||||
reti ; USI_OVF
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; includes
|
||||
|
||||
.include "utils.asm"
|
||||
.include "timer.asm"
|
||||
.include "led.asm"
|
||||
.include "com.asm"
|
||||
.include "twimaster.asm"
|
||||
.include "lcd.asm"
|
||||
.include "bmp280.asm"
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in SRAM
|
||||
|
||||
.dseg
|
||||
|
||||
ledA3Sram: .byte LED_SRAM_SIZE
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in EEPROM
|
||||
|
||||
.eseg
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in FLASH
|
||||
|
||||
.cseg
|
||||
|
||||
ledA3Flash: .db DDRA+0x20, PORTA+0x20, PINA+0x20, (1<<PORTA3)
|
||||
blinkPattern: .db 5, 5, 5, 5, 5, 10, 0xff, 0xff ; 3 short blinks, 1s pause, restart
|
||||
blinkPattern2: .db 10, 20, 0xff, 0xff ; 1 long blink, 2s pause, restart
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
main:
|
||||
@@ -190,18 +58,36 @@ main_loop:
|
||||
; USED: depending on called routines
|
||||
|
||||
initModules:
|
||||
#ifdef MODULES_TIMER
|
||||
rcall Timer_Init
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_LED
|
||||
ldi zl, LOW(ledA3Flash)
|
||||
ldi zh, HIGH(ledA3Flash)
|
||||
ldi yl, LOW(ledA3Sram)
|
||||
ldi yh, HIGH(ledA3Sram)
|
||||
rcall Led_Init
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_COM
|
||||
rcall Com_Init
|
||||
#endif
|
||||
#ifdef MODULES_TWI_MASTER
|
||||
rcall TWI_Master_Init
|
||||
#endif
|
||||
#ifdef MODULES_LCD
|
||||
rcall LCD_Init
|
||||
#endif
|
||||
#ifdef MODULES_BMP280
|
||||
rcall BMP280_Init
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_SI7021
|
||||
rcall SI7021_Init
|
||||
#endif
|
||||
|
||||
; done
|
||||
ret
|
||||
|
||||
|
||||
@@ -219,9 +105,12 @@ initModules:
|
||||
|
||||
runModulesUntilIdle:
|
||||
|
||||
#ifdef MODULES_TIMER
|
||||
; TIMER module
|
||||
rcall Timer_Run
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_COM
|
||||
; COM module (call until carry flag cleared but at most 10 times to not starve other modules)
|
||||
ldi r16, 10
|
||||
runModulesUntilIdle_Com:
|
||||
@@ -232,158 +121,13 @@ runModulesUntilIdle_Com:
|
||||
dec r16
|
||||
brne runModulesUntilIdle_Com
|
||||
runModulesUntilIdle_ComEnd:
|
||||
#endif
|
||||
|
||||
; add more modules here
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onEvery100ms
|
||||
;
|
||||
; Called every 100ms. Add your routine calls here.
|
||||
;
|
||||
; IN:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - nothing
|
||||
; USED: depending on called routines
|
||||
|
||||
onEvery100ms:
|
||||
; ticker for LED module
|
||||
ldi zl, LOW(ledA3Flash)
|
||||
ldi zh, HIGH(ledA3Flash)
|
||||
ldi yl, LOW(ledA3Sram)
|
||||
ldi yh, HIGH(ledA3Sram)
|
||||
rcall Led_Tick
|
||||
|
||||
; add more calls here
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onEverySecond
|
||||
;
|
||||
; Called every second. Add your routine calls here.
|
||||
;
|
||||
; IN:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - nothing
|
||||
; USED: depending on called routines
|
||||
|
||||
onEverySecond:
|
||||
; rcall TWI_Master_ScanNext
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onEvery10s
|
||||
;
|
||||
; Called every 10 seconds. Add your routine calls here.
|
||||
;
|
||||
; IN:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - nothing
|
||||
; USED: depending on called routines
|
||||
|
||||
onEvery10s:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onEveryMinute
|
||||
;
|
||||
; Called every minute. Add your routine calls here.
|
||||
;
|
||||
; IN:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - nothing
|
||||
; USED: depending on called routines
|
||||
|
||||
onEveryMinute:
|
||||
in r15, SREG ; debug
|
||||
cli
|
||||
push r15
|
||||
ldi r16, 219
|
||||
rcall COM_EnqueueComSendStats
|
||||
rcall printSendStats
|
||||
|
||||
;ldi r16, 219
|
||||
;rcall COM_EnqueuePing
|
||||
pop r15
|
||||
out SREG, r15
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onPacketReceived:
|
||||
;
|
||||
; Called after a packet was received via COM module. Add your routine calls here.
|
||||
;
|
||||
; The packet will be removed from buffer in any case after return from this call.
|
||||
; IN:
|
||||
; - Y : pointer to received buffer
|
||||
; OUT:
|
||||
; - CFLAG: set if handled, cleared otherwise
|
||||
; USED: depending on called routines
|
||||
|
||||
onPacketReceived:
|
||||
clc ; not handled
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
debugSendByte:
|
||||
push r15
|
||||
in r15, SREG ; debug
|
||||
cli
|
||||
push r17
|
||||
push r22
|
||||
ldi r17, 8
|
||||
sbi DDRA, PORTA2 ; debug
|
||||
|
||||
cbi PORTA, PORTA2 ; debug (on)
|
||||
Utils_WaitNanoSecs 100000, 0, r22 ; start with 2t low
|
||||
|
||||
sbi PORTA, PORTA2 ; debug (off)
|
||||
nop
|
||||
nop
|
||||
cbi PORTA, PORTA2 ; debug (on)
|
||||
Utils_WaitNanoSecs 100000, 0, r22 ; start with 2t low
|
||||
|
||||
debugSendByte_loop:
|
||||
lsr r16
|
||||
brcs debugSendByte_sendLow
|
||||
cbi PORTA, PORTA2 ; debug (on)
|
||||
rjmp debugSendByte_wait
|
||||
debugSendByte_sendLow:
|
||||
sbi PORTA, PORTA2 ; debug (off)
|
||||
|
||||
debugSendByte_wait:
|
||||
Utils_WaitNanoSecs 100000, 0, r22
|
||||
dec r17
|
||||
brne debugSendByte_loop
|
||||
|
||||
cbi PORTA, PORTA2 ; debug (on)
|
||||
Utils_WaitNanoSecs 200000, 0, r22 ; end with 2t low
|
||||
sbi PORTA, PORTA2 ; debug (off)
|
||||
pop r22
|
||||
pop r17
|
||||
out SREG, r15
|
||||
pop r15
|
||||
ret
|
||||
|
||||
|
||||
|
||||
@@ -392,6 +136,29 @@ printSendStats:
|
||||
push r15
|
||||
in r15, SREG ; debug
|
||||
cli
|
||||
|
||||
#ifdef MODULES_SI7021
|
||||
ldi r18, 0
|
||||
ldi r19, 1
|
||||
rcall LCD_SetCursor
|
||||
ldi zl, LOW(textSi7021Firmware)
|
||||
ldi zh, HIGH(textSi7021Firmware)
|
||||
rcall LCD_PrintFromFlash
|
||||
|
||||
lds r16, si7021Flags
|
||||
rcall LCD_PrintHexByte
|
||||
ldi r16, 32
|
||||
rcall LCD_PrintChar
|
||||
lds r18, si7021LastTemp
|
||||
lds r19, si7021LastTemp+1
|
||||
rcall LCD_PrintHexWord
|
||||
ldi r16, 32
|
||||
rcall LCD_PrintChar
|
||||
lds r18, si7021LastHumidity
|
||||
lds r19, si7021LastHumidity+1
|
||||
rcall LCD_PrintHexWord
|
||||
#endif
|
||||
|
||||
ldi r18, 0
|
||||
ldi r19, 2
|
||||
rcall LCD_SetCursor
|
||||
@@ -448,6 +215,7 @@ printSendStats:
|
||||
|
||||
|
||||
|
||||
textSi7021Firmware: .db "SI: ", 0, 0
|
||||
textStatsPacketsIn: .db "In : ", 0
|
||||
textStatsPacketsRecvErr: .db "RecvErr: ", 0
|
||||
textStatsPacketsOut: .db "Out : ", 0
|
||||
@@ -455,3 +223,5 @@ textStatsCollisions: .db "Coll : ", 0
|
||||
textStatsAborted: .db "Aborted: ", 0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user