avr: started working on base system vs. main system.
base system will be a base system which can be used to flash and start the main system.
This commit is contained in:
16
avr/0BUILD
16
avr/0BUILD
@@ -36,6 +36,22 @@
|
||||
|
||||
|
||||
</target>
|
||||
|
||||
<target type="AvrHexFile" name="att84_base" >
|
||||
|
||||
<includes type="avrasm" >
|
||||
-I $(builddir)
|
||||
-I $(srcdir)
|
||||
-I $(topsrcdir)/avr
|
||||
</includes>
|
||||
|
||||
|
||||
<sources type="avrasm" >
|
||||
att84_base.asm
|
||||
</sources>
|
||||
|
||||
|
||||
</target>
|
||||
|
||||
</gwbuild>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
; ***************************************************************************
|
||||
; Source file for temperature sensor node on AtTiny 84
|
||||
; Source file for base system node on AtTiny 84
|
||||
;
|
||||
; This is for the full system (i.e. not the boot loader).
|
||||
; This is for the maintenance system (i.e. the flash loader).
|
||||
;
|
||||
; All definitions and changes should go into this file.
|
||||
;
|
||||
@@ -11,10 +11,10 @@
|
||||
; VCC 1 14 GND
|
||||
; PB0 2 13 PA0
|
||||
; PB1 3 12 PA1 COM-DATA
|
||||
; /RESET PB3 4 11 PA2 OWI
|
||||
; /RESET PB3 4 11 PA2
|
||||
; KEY1 PB2 5 10 PA3 LED
|
||||
; COM_ATTN PA7 6 9 PA4 TWI-SCL
|
||||
; TWI-SDA PA6 7 8 PA5
|
||||
; COM_ATTN PA7 6 9 PA4
|
||||
; PA6 7 8 PA5
|
||||
; --------
|
||||
;
|
||||
; ***************************************************************************
|
||||
@@ -42,17 +42,24 @@
|
||||
; ---------------------------------------------------------------------------
|
||||
; list of modules to use
|
||||
|
||||
#define BASE_SYSTEM
|
||||
#define WITH_FLASH
|
||||
|
||||
#define MODULES_TIMER
|
||||
#define MODULES_COM
|
||||
#define MODULES_LED
|
||||
#define MODULES_TWI_MASTER
|
||||
#define MODULES_LCD
|
||||
#define MODULES_SI7021
|
||||
;#define MODULES_LED
|
||||
; #define MODULES_TWI_MASTER
|
||||
; #define MODULES_LCD
|
||||
; #define MODULES_SI7021
|
||||
|
||||
|
||||
.equ VALUE_ID_TEMP1 = 0x01
|
||||
.equ VALUE_ID_HUM1 = 0x02
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; EEPROM positions
|
||||
|
||||
|
||||
.equ EEPROM_OFFS_UUID = 0 ; 4 bytes (occupy total of 8 bytes for extensibility)
|
||||
.equ EEPROM_OFFS_COMADDR = 8 ; 1 byte
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
@@ -80,8 +87,6 @@
|
||||
; ---------------------------------------------------------------------------
|
||||
; TWI master module
|
||||
|
||||
.equ LCD_TWI_ADDRESS = 0x3c
|
||||
|
||||
.equ TWI_DDR_SCL = DDRA
|
||||
.equ TWI_PORT_SCL = PORTA
|
||||
.equ TWI_PIN_SCL = PINA
|
||||
@@ -94,6 +99,29 @@
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; LCD module
|
||||
|
||||
.equ LCD_TWI_ADDRESS = 0x3c
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; BMP 280
|
||||
|
||||
.equ BMP280_ADDR = 0x76
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; SI 7021
|
||||
|
||||
.equ SI7021_ADDR = 0x40
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code segment
|
||||
|
||||
@@ -104,58 +132,47 @@
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Reset and interrupt vectors
|
||||
rjmp PC+0x20 ; Reset vector
|
||||
rjmp PC+0x20 ; EXT_INT0
|
||||
rjmp PC+0x20 ; PCI0
|
||||
rjmp PC+0x20 ; PCI1
|
||||
rjmp PC+0x20 ; WATCHDOG
|
||||
rjmp PC+0x20 ; ICP1
|
||||
rjmp PC+0x20 ; OC1A
|
||||
rjmp PC+0x20 ; OC1B
|
||||
rjmp PC+0x20 ; OVF1
|
||||
rjmp PC+0x20 ; OC0A
|
||||
rjmp PC+0x20 ; OC0B
|
||||
rjmp PC+0x20 ; OVF0
|
||||
rjmp PC+0x20 ; ACI
|
||||
rjmp PC+0x20 ; ADCC
|
||||
rjmp PC+0x20 ; ERDY
|
||||
rjmp PC+0x20 ; USI_STR
|
||||
rjmp PC+0x20 ; USI_OVF
|
||||
|
||||
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
|
||||
|
||||
.org 0x40
|
||||
; ---------------------------------------------------------------------------
|
||||
; Node Id (not overwritten when updating system)
|
||||
|
||||
nodeUid: .db 0, 0, 0, 0, 0, 0, 0, 0
|
||||
|
||||
|
||||
|
||||
|
||||
.org 0x50 ; begin of maintenance system
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Reset and interrupt vectors of maintenance system
|
||||
; maintenance system starts here.
|
||||
|
||||
maintIrqHandlerTable:
|
||||
.dw main ; reset address
|
||||
.dw 0 ; EXT_INT0
|
||||
.dw comIsrPcint0 ; PCI0
|
||||
.dw 0 ; PCI1
|
||||
.dw 0 ; WATCHDOG
|
||||
.dw 0 ; ICP1
|
||||
.dw 0 ; OC1A
|
||||
.dw 0 ; OC1B
|
||||
.dw 0 ; OVF1
|
||||
.dw timerIrqOC0A ; OC0A
|
||||
.dw 0 ; OC0B
|
||||
.dw 0 ; OVF0
|
||||
.dw 0 ; ACI
|
||||
.dw 0 ; ADCC
|
||||
.dw 0 ; ERDY
|
||||
.dw 0 ; USI_STR
|
||||
.dw 0 ; USI_OVF
|
||||
.org 0x20
|
||||
|
||||
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
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
@@ -163,13 +180,9 @@ maintIrqHandlerTable:
|
||||
|
||||
.include "utils.asm"
|
||||
.include "timer.asm"
|
||||
.include "led.asm"
|
||||
.include "com.asm"
|
||||
.include "comproto.asm"
|
||||
;.include "twimaster.asm"
|
||||
;.include "lcd.asm"
|
||||
;.include "bmp280.asm"
|
||||
;.include "si7021.asm"
|
||||
.include "flash.asm"
|
||||
|
||||
|
||||
|
||||
@@ -178,19 +191,12 @@ maintIrqHandlerTable:
|
||||
|
||||
.dseg
|
||||
|
||||
ledA3Sram: .byte LED_SRAM_SIZE
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; 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
|
||||
|
||||
|
||||
|
||||
@@ -199,58 +205,36 @@ blinkPattern2: .db 10, 20, 0xff, 0xff ; 1 long blink, 2s pause, restart
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onEvery100ms
|
||||
;
|
||||
; Called every 100ms. Add your routine calls here.
|
||||
;
|
||||
; IN:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - nothing
|
||||
; USED: depending on called routines
|
||||
; Called on first time run, i.e. on system start. No arguments, no results.
|
||||
|
||||
onSystemStart:
|
||||
rcall Utils_SetupUid
|
||||
ldi r16, COM_MAINTENANCE_ADDR ; use fixed address in base system, smaller code
|
||||
sts comAddress, r16
|
||||
; rcall CPRO_StartReclaimAddrProcedure
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every 100ms. Add your routine calls here. No arguments, no results.
|
||||
|
||||
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
|
||||
; Called every second. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEverySecond:
|
||||
rcall CPRO_OnEverySecond
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onEvery10s
|
||||
;
|
||||
; Called every 10 seconds. Add your routine calls here.
|
||||
;
|
||||
; IN:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - nothing
|
||||
; USED: depending on called routines
|
||||
; Called every 10 seconds. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery10s:
|
||||
ret
|
||||
@@ -258,15 +242,7 @@ onEvery10s:
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onEvery30s
|
||||
;
|
||||
; Called every 10 seconds. Add your routine calls here.
|
||||
;
|
||||
; IN:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - nothing
|
||||
; USED: depending on called routines
|
||||
; Called every 30 seconds. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery30s:
|
||||
ret
|
||||
@@ -274,24 +250,49 @@ onEvery30s:
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onEveryMinute
|
||||
;
|
||||
; Called every minute. Add your routine calls here.
|
||||
;
|
||||
; IN:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - nothing
|
||||
; USED: depending on called routines
|
||||
; Called every minute. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEveryMinute:
|
||||
in r15, SREG ; debug
|
||||
cli
|
||||
push r15
|
||||
ldi r16, 219
|
||||
rcall CPRO_EnqueueComSendStats
|
||||
pop r15
|
||||
out SREG, r15
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every 15 minutes. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery15m:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every 30 minutes. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery30m:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every hour. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery1h:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every 12 hours. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery12h:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every day. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery1d:
|
||||
ret
|
||||
|
||||
|
||||
@@ -309,7 +310,7 @@ onEveryMinute:
|
||||
; USED: depending on called routines
|
||||
|
||||
onPacketReceived:
|
||||
clc ; not handled
|
||||
rcall CPRO_OnPacketReceived
|
||||
ret
|
||||
|
||||
|
||||
|
||||
@@ -49,6 +49,8 @@
|
||||
#define MODULES_LCD
|
||||
#define MODULES_SI7021
|
||||
|
||||
#define LCD_MINIMAL_FONT
|
||||
|
||||
|
||||
.equ VALUE_ID_TEMP1 = 0x01
|
||||
.equ VALUE_ID_HUM1 = 0x02
|
||||
@@ -132,37 +134,33 @@
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; 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
|
||||
|
||||
|
||||
; Reset and interrupt vectors (will be removed as soon as we can flash data over COM)
|
||||
|
||||
rjmp PC+0x500 ; Reset vector
|
||||
rjmp PC+0x500 ; EXT_INT0
|
||||
rjmp PC+0x500 ; PCI0
|
||||
rjmp PC+0x500 ; PCI1
|
||||
rjmp PC+0x500 ; WATCHDOG
|
||||
rjmp PC+0x500 ; ICP1
|
||||
rjmp PC+0x500 ; OC1A
|
||||
rjmp PC+0x500 ; OC1B
|
||||
rjmp PC+0x500 ; OVF1
|
||||
rjmp PC+0x500 ; OC0A
|
||||
rjmp PC+0x500 ; OC0B
|
||||
rjmp PC+0x500 ; OVF0
|
||||
rjmp PC+0x500 ; ACI
|
||||
rjmp PC+0x500 ; ADCC
|
||||
rjmp PC+0x500 ; ERDY
|
||||
rjmp PC+0x500 ; USI_STR
|
||||
rjmp PC+0x500 ; USI_OVF
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; maintenance system starts here.
|
||||
; working system starts here.
|
||||
|
||||
.org 0x50
|
||||
.org 0x0500
|
||||
|
||||
|
||||
realInterruptTable:
|
||||
rjmp main ; Reset vector
|
||||
reti ; EXT_INT0
|
||||
rjmp comIsrPcint0 ; PCI0
|
||||
@@ -193,7 +191,6 @@ realInterruptTable:
|
||||
.include "comproto_addr.asm"
|
||||
.include "twimaster.asm"
|
||||
.include "lcd.asm"
|
||||
;.include "bmp280.asm"
|
||||
.include "si7021.asm"
|
||||
|
||||
|
||||
@@ -208,14 +205,6 @@ ledA3Sram: .byte LED_SRAM_SIZE
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in EEPROM
|
||||
|
||||
.eseg
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in FLASH
|
||||
|
||||
@@ -223,7 +212,7 @@ ledA3Sram: .byte LED_SRAM_SIZE
|
||||
|
||||
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
|
||||
;blinkPattern2: .db 10, 20, 0xff, 0xff ; 1 long blink, 2s pause, restart
|
||||
|
||||
|
||||
.include "main.asm"
|
||||
@@ -231,15 +220,7 @@ blinkPattern2: .db 10, 20, 0xff, 0xff ; 1 long blink, 2s pause, restart
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onSystemStart
|
||||
;
|
||||
; Called on first time run, i.e. on system start.
|
||||
;
|
||||
; IN:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - nothing
|
||||
; USED: depending on called routines
|
||||
; Called on first time run, i.e. on system start. No arguments, no results.
|
||||
|
||||
onSystemStart:
|
||||
rcall Utils_SetupUid
|
||||
@@ -253,15 +234,7 @@ onSystemStart:
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onEvery100ms
|
||||
;
|
||||
; Called every 100ms. Add your routine calls here.
|
||||
;
|
||||
; IN:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - nothing
|
||||
; USED: depending on called routines
|
||||
; Called every 100ms. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery100ms:
|
||||
#ifdef MODULES_LED
|
||||
@@ -272,23 +245,12 @@ onEvery100ms:
|
||||
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
|
||||
; Called every second. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEverySecond:
|
||||
; rcall TWI_Master_ScanNext
|
||||
@@ -298,15 +260,7 @@ onEverySecond:
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onEvery10s
|
||||
;
|
||||
; Called every 10 seconds. Add your routine calls here.
|
||||
;
|
||||
; IN:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - nothing
|
||||
; USED: depending on called routines
|
||||
; Called every 10 seconds. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery10s:
|
||||
rcall printSendStats
|
||||
@@ -315,15 +269,7 @@ onEvery10s:
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onEvery30s
|
||||
;
|
||||
; Called every 10 seconds. Add your routine calls here.
|
||||
;
|
||||
; IN:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - nothing
|
||||
; USED: depending on called routines
|
||||
; Called every 30 seconds. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery30s:
|
||||
#ifdef MODULES_SI7021
|
||||
@@ -340,15 +286,7 @@ onEvery30s:
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onEveryMinute
|
||||
;
|
||||
; Called every minute. Add your routine calls here.
|
||||
;
|
||||
; IN:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - nothing
|
||||
; USED: depending on called routines
|
||||
; Called every minute. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEveryMinute:
|
||||
#ifdef MODULES_COM
|
||||
@@ -364,6 +302,46 @@ onEveryMinute_l1:
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every 15 minutes. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery15m:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every 30 minutes. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery30m:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every hour. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery1h:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every 12 hours. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery12h:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every day. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery1d:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onPacketReceived:
|
||||
;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
.equ COM_MAXWAIT = 200 ; maximum loop count when waiting for rising/falling clock (TODO: Make frequency-dependant)
|
||||
|
||||
.equ COM_MAINTENANCE_ADDR = 0xf1
|
||||
|
||||
.equ COM_BUFFER_FLAGS_DONE = 0x80
|
||||
.equ COM_BUFFER_FLAGS_RECEIVED = 0x40
|
||||
@@ -36,6 +37,9 @@
|
||||
.equ COM_MSG_OFFS_DESTADDR = 0
|
||||
.equ COM_MSG_OFFS_MSGLEN = 1
|
||||
.equ COM_MSG_OFFS_MSGDATA = 2
|
||||
.equ COM_MSG_OFFS_CMD = 2 ; first at COM_MSG_OFFS_MSGDATA
|
||||
.equ COM_MSG_OFFS_SRCADDR = 3
|
||||
.equ COM_MSG_OFFS_PAYLOAD = 4 ; payload for the cmd follows here
|
||||
|
||||
.equ COM_ERR_NOTFORME = 1
|
||||
.equ COM_ERR_CHECKSUM = 2
|
||||
@@ -581,6 +585,8 @@ comReceivePacketToSram_acceptAddr:
|
||||
brcc comReceivePacketToSram_error
|
||||
eor r1, r16
|
||||
st X+, r16
|
||||
cpi r16, (COM_BUFFER_SIZE-3-COM_BUFFER_OFFS_DATA)+1
|
||||
brcc comReceivePacketToSram_error ; packet too long (TODO: count overruns)
|
||||
tst r16
|
||||
breq comReceivePacketToSram_readXOR
|
||||
mov r17, r16
|
||||
|
||||
100
avr/comproto.asm
100
avr/comproto.asm
@@ -18,6 +18,12 @@
|
||||
.equ CPRO_CMD_DENY_ADDRESS = 63
|
||||
.equ CPRO_CMD_ADDRESS_RANGE = 64
|
||||
|
||||
.equ CPRO_CMD_FLASH_START = 70
|
||||
.equ CPRO_CMD_FLASH_END = 71
|
||||
.equ CPRO_CMD_FLASH_ADDR = 72
|
||||
.equ CPRO_CMD_FLASH_DATA = 73
|
||||
.equ CPRO_CMD_FLASH_RSP = 74
|
||||
|
||||
|
||||
; flags for variable payload enqueue function
|
||||
.equ CPRO_PAYLOAD_FLAGS_SECONDS = 0x01
|
||||
@@ -31,15 +37,20 @@
|
||||
.equ CPRO_PAYLOAD_FLAGS_SHIFT_NUM = 5
|
||||
|
||||
|
||||
.equ CPRO_PACKET_OFFS_DESTADDR = 0
|
||||
.equ CPRO_PACKET_OFFS_MSGLEN = 1
|
||||
.equ CPRO_PACKET_OFFS_CMD = 2
|
||||
.equ CPRO_PACKET_OFFS_SRCADDR = 3
|
||||
.equ CPRO_PACKET_OFFS_PAYLOAD = 4
|
||||
.equ CPRO_PACKET_HAVEADDR_OFFS_ADDRESS = COM_MSG_OFFS_PAYLOAD+4
|
||||
.equ CPRO_PACKET_CLAIMADDR_OFFS_ADDRESS = COM_MSG_OFFS_PAYLOAD+4
|
||||
.equ CPRO_PACKET_DENYADDR_OFFS_ADDRESS = COM_MSG_OFFS_PAYLOAD+4
|
||||
|
||||
.equ CPRO_PACKET_FLASH_START_OFFS_MSGNUM = COM_MSG_OFFS_PAYLOAD+0 ; 2 bytes
|
||||
.equ CPRO_PACKET_FLASH_START_OFFS_ADDR = COM_MSG_OFFS_PAYLOAD+2 ; 2 bytes
|
||||
|
||||
.equ CPRO_PACKET_FLASH_ADDR_OFFS_MSGNUM = COM_MSG_OFFS_PAYLOAD+0 ; 2 bytes
|
||||
.equ CPRO_PACKET_FLASH_ADDR_OFFS_ADDR = COM_MSG_OFFS_PAYLOAD+2 ; 2 bytes
|
||||
|
||||
.equ CPRO_PACKET_FLASH_DATA_OFFS_MSGNUM = COM_MSG_OFFS_PAYLOAD+0 ; 2 bytes
|
||||
.equ CPRO_PACKET_FLASH_DATA_OFFS_ADDR = COM_MSG_OFFS_PAYLOAD+2 ; 2 bytes
|
||||
.equ CPRO_PACKET_FLASH_DATA_OFFS_DATA = COM_MSG_OFFS_PAYLOAD+4 ; 2 bytes
|
||||
|
||||
.equ CPRO_PACKET_HAVEADDR_OFFS_ADDRESS = 8
|
||||
.equ CPRO_PACKET_CLAIMADDR_OFFS_ADDRESS = 8
|
||||
.equ CPRO_PACKET_DENYADDR_OFFS_ADDRESS = 8
|
||||
|
||||
.equ CPRO_WAITTIME_GETADDR = 130
|
||||
.equ CPRO_WAITTIME_CLAIMADDR = 17
|
||||
@@ -64,11 +75,13 @@
|
||||
|
||||
|
||||
cproDataBegin:
|
||||
#ifndef BASE_SYSTEM
|
||||
cproMode: .byte 1 ; "normal", "waitForHaveAddress", "samplingAddresses", "claimAddress"
|
||||
cproAddrRangeBegin: .byte 1
|
||||
cproAddrRangeEnd: .byte 1
|
||||
cproAddressWaitCounter: .byte 1 ; counter for seconds to wait for all nodes to respond
|
||||
cproUsedAddresses: .byte 16 ; one bit per address known to b in use
|
||||
#endif
|
||||
cproDataEnd:
|
||||
|
||||
|
||||
@@ -93,6 +106,7 @@ CPRO_Init:
|
||||
|
||||
|
||||
CPRO_OnEverySecond:
|
||||
#ifndef BASE_SYSTEM
|
||||
lds r17, cproMode
|
||||
cpi r17, CPRO_MODE_NORMAL
|
||||
breq CPRO_OnEverySecond_done
|
||||
@@ -121,6 +135,7 @@ CPRO_OnEverySecond_l6:
|
||||
brne CPRO_OnEverySecond_done
|
||||
rjmp cproHandle1sReclaimingAddr
|
||||
CPRO_OnEverySecond_done:
|
||||
#endif
|
||||
ret
|
||||
|
||||
|
||||
@@ -137,11 +152,12 @@ CPRO_OnEverySecond_done:
|
||||
; USED: depending on called routines
|
||||
|
||||
CPRO_OnPacketReceived:
|
||||
ldd r16, y+(COM_BUFFER_OFFS_DATA+CPRO_PACKET_OFFS_CMD)
|
||||
ldd r16, y+(COM_BUFFER_OFFS_DATA+COM_MSG_OFFS_CMD)
|
||||
cpi r16, CPRO_CMD_PING
|
||||
brne CPRO_OnPacketReceived_l1
|
||||
rjmp cproHandlePing
|
||||
CPRO_OnPacketReceived_l1:
|
||||
#ifndef BASE_SYSTEM
|
||||
cpi r16, CPRO_CMD_NEED_ADDRESS
|
||||
brne CPRO_OnPacketReceived_l2
|
||||
rjmp cproHandlePckNeedAddr
|
||||
@@ -162,12 +178,13 @@ CPRO_OnPacketReceived_l5:
|
||||
brne CPRO_OnPacketReceived_l6
|
||||
rjmp cproHandlePckClaimAddr
|
||||
CPRO_OnPacketReceived_l6:
|
||||
#endif
|
||||
clc
|
||||
ret
|
||||
|
||||
|
||||
cproHandlePing:
|
||||
ldd r16, y+(COM_BUFFER_OFFS_DATA+CPRO_PACKET_OFFS_SRCADDR)
|
||||
ldd r16, y+(COM_BUFFER_OFFS_DATA+COM_MSG_OFFS_SRCADDR)
|
||||
tst r16
|
||||
breq cproHandlePing_notHandled
|
||||
rcall CPRO_EnqueuePong
|
||||
@@ -214,6 +231,7 @@ CPRO_EnqueuePong:
|
||||
|
||||
|
||||
|
||||
#ifndef BASE_SYSTEM
|
||||
; ---------------------------------------------------------------------------
|
||||
; Enqueue a COM Send stats packet.
|
||||
;
|
||||
@@ -266,9 +284,11 @@ CPRO_EnqueueComSendStats_error:
|
||||
out SREG, r15
|
||||
clc
|
||||
ret
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef BASE_SYSTEM
|
||||
; ---------------------------------------------------------------------------
|
||||
; Enqueue a TWI Bus Member packet.
|
||||
;
|
||||
@@ -316,9 +336,11 @@ CPRO_EnqueueTwiBusMember:
|
||||
CPRO_EnqueueTwiBusMember_error:
|
||||
clc
|
||||
ret
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef BASE_SYSTEM
|
||||
; ---------------------------------------------------------------------------
|
||||
; Enqueue a DEBUG packet.
|
||||
;
|
||||
@@ -366,9 +388,11 @@ CPRO_EnqueueDebug:
|
||||
CPRO_EnqueueDebug_error:
|
||||
clc
|
||||
ret
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef BASE_SYSTEM
|
||||
; ---------------------------------------------------------------------------
|
||||
; Enqueue a VALUE packet.
|
||||
;
|
||||
@@ -419,9 +443,11 @@ CPRO_EnqueueValue:
|
||||
CPRO_EnqueueValue_error:
|
||||
clc
|
||||
ret
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef BASE_SYSTEM
|
||||
; ---------------------------------------------------------------------------
|
||||
; Enqueue a NEEDADDRESS packet.
|
||||
;
|
||||
@@ -434,9 +460,11 @@ CPRO_EnqueueValue_error:
|
||||
CPRO_EnqueueNeedAddress:
|
||||
ldi r18, CPRO_CMD_NEED_ADDRESS
|
||||
rjmp cproEnqueueAddressPacket
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef BASE_SYSTEM
|
||||
; ---------------------------------------------------------------------------
|
||||
; Enqueue a HAVE_ADDRESS packet.
|
||||
;
|
||||
@@ -450,9 +478,11 @@ CPRO_EnqueueHaveAddress:
|
||||
ldi r18, CPRO_CMD_HAVE_ADDRESS
|
||||
lds r19, comAddress
|
||||
rjmp cproEnqueueAddressPacket
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef BASE_SYSTEM
|
||||
; ---------------------------------------------------------------------------
|
||||
; Enqueue a CLAIM_ADDRESS packet.
|
||||
;
|
||||
@@ -465,9 +495,11 @@ CPRO_EnqueueHaveAddress:
|
||||
CPRO_EnqueueClaimAddress:
|
||||
ldi r18, CPRO_CMD_CLAIM_ADDRESS
|
||||
rjmp cproEnqueueAddressPacket
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef BASE_SYSTEM
|
||||
; ---------------------------------------------------------------------------
|
||||
; Enqueue a DENY_ADDRESS packet.
|
||||
;
|
||||
@@ -481,9 +513,11 @@ CPRO_EnqueueDenyAddress:
|
||||
ldi r18, CPRO_CMD_DENY_ADDRESS
|
||||
lds r19, comAddress
|
||||
rjmp cproEnqueueAddressPacket
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef BASE_SYSTEM
|
||||
; ---------------------------------------------------------------------------
|
||||
; cproEnqueueAddressPacket
|
||||
; Enqueue a NEED/HAVE/CLAIM ADDRESS packet.
|
||||
@@ -518,6 +552,7 @@ cproEnqueueAddressPacket:
|
||||
cproEnqueueAddressPacket_error:
|
||||
clc
|
||||
ret
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -667,6 +702,51 @@ cproCalcPayloadSize_l2:
|
||||
|
||||
|
||||
|
||||
#ifdef WITH_FLASH
|
||||
; ---------------------------------------------------------------------------
|
||||
; Enqueue a FLASHDATA_ACK packet.
|
||||
;
|
||||
; IN:
|
||||
; - R16: destination address
|
||||
; - R17: ACK(1) or NAK(0)
|
||||
; - R19:R18: msg num
|
||||
; OUT:
|
||||
; - CFLAG: set if okay, clear otherwise
|
||||
; MODIFIED REGS: R6, R7, R8, R9, R10, R11, R12, R16, R17, X, Y (R3, R4, R15, R16, R17, R18, R19, R20, R21)
|
||||
|
||||
CPRO_EnqueueFlashRsp:
|
||||
mov r6, r16
|
||||
mov r7, r17
|
||||
mov r8, r18
|
||||
mov r9, r19
|
||||
|
||||
rcall COM_AllocBufferAndGetXY ; (r16, r17, r21)
|
||||
brcc CPRO_EnqueueFlashRsp_error
|
||||
|
||||
push xh
|
||||
push xl
|
||||
mov r16, r6
|
||||
ldi r17, CPRO_PAYLOAD_FLAGS_SECONDS | (3<<CPRO_PAYLOAD_FLAGS_SHIFT_NUM)
|
||||
ldi r18, CPRO_CMD_FLASH_RSP
|
||||
rcall cproBeginMsgWithVariablePayload ; (R3, R4, R16, R17, R18, R19, R20, R21, X)
|
||||
st X+, r8 ; 4: msg num (low)
|
||||
st X+, r9 ; 5: msg num (high)
|
||||
st X+, r7 ; 6: ACK or NAK
|
||||
pop xl
|
||||
pop xh
|
||||
rcall cproCalcAndAddChecksumByte
|
||||
|
||||
; mark buffer as enqueued with PRIO "important" (higher number of retries)
|
||||
ldi r20, COM_BUFFER_PRIO_IMPORTANT
|
||||
rcall COM_EnqueuePacket ; (R15, R16)
|
||||
brcc CPRO_EnqueueFlashRsp_error
|
||||
sec
|
||||
ret
|
||||
CPRO_EnqueueFlashRsp_error:
|
||||
clc
|
||||
ret
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
120
avr/lcd.asm
120
avr/lcd.asm
@@ -398,7 +398,7 @@ LCD_PrintHexWord_errorNoPop:
|
||||
; ---------------------------------------------------------------------------
|
||||
; lcdPrintHexWord
|
||||
;
|
||||
; Convert a give word into HEX and write it to the current position.
|
||||
; Convert a given word into HEX and write it to the current position.
|
||||
;
|
||||
; IN:
|
||||
; - r18: low byte of the word
|
||||
@@ -554,6 +554,32 @@ lcdPrintOneChar_error:
|
||||
; REGS: r16, r17, Z
|
||||
|
||||
lcdGetCharMatrix:
|
||||
#ifdef LCD_MINIMAL_FONT
|
||||
rcall lcdUpcase
|
||||
cpi r16, 65+32
|
||||
brcc lcdGetCharMatrix_l1
|
||||
cpi r16, 32
|
||||
brcc lcdGetCharMatrix_l2
|
||||
lcdGetCharMatrix_l1:
|
||||
ldi r16, 32
|
||||
lcdGetCharMatrix_l2:
|
||||
ldi r17, 32
|
||||
sub r16, r17
|
||||
mov zl, r16
|
||||
clr zh
|
||||
clr r17
|
||||
lsl zl ; *2
|
||||
rol zh
|
||||
add zl, r16 ; *3
|
||||
adc zh, r17
|
||||
lsl zl ; *6
|
||||
rol zh
|
||||
ldi r16, LOW(lcdFont6x8Minimal*2)
|
||||
ldi r17, HIGH(lcdFont6x8Minimal*2)
|
||||
add zl, r16
|
||||
adc zh, r17
|
||||
ret
|
||||
#else
|
||||
cpi r16, 95+32
|
||||
brcc lcdGetCharMatrix_l1
|
||||
cpi r16, 32
|
||||
@@ -577,6 +603,29 @@ lcdGetCharMatrix_l2:
|
||||
add zl, r16
|
||||
adc zh, r17
|
||||
ret
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef LCD_MINIMAL_FONT
|
||||
; ---------------------------------------------------------------------------
|
||||
; Uppercase the given character if it is lower case.
|
||||
;
|
||||
; IN:
|
||||
; - R16: char
|
||||
; OUT:
|
||||
; - R16: char
|
||||
; REGS: r16, r17
|
||||
|
||||
lcdUpcase:
|
||||
cpi r16, 'a'
|
||||
brcs lcdUpcase_done
|
||||
cpi r16, 'z'+1
|
||||
brcc lcdUpcase_done
|
||||
ldi r17, 32
|
||||
sub r16, r17
|
||||
lcdUpcase_done:
|
||||
ret
|
||||
#endif
|
||||
|
||||
|
||||
; TODO: set adressing mode??
|
||||
@@ -589,6 +638,74 @@ lcdHelloMsg: .db "AqHOME 2023", 0
|
||||
|
||||
; font taken from Tiny4kOLED (https://github.com/datacute/Tiny4kOLED/tree/master/src) by Stephen Denne (MIT license),
|
||||
; original by Neven Boyanov
|
||||
#ifdef LCD_MINIMAL_FONT
|
||||
lcdFont6x8Minimal:
|
||||
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ; 0
|
||||
.db 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 ; ! 1
|
||||
.db 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 ; " 2
|
||||
.db 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 ; # 3
|
||||
.db 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 ; $ 4
|
||||
.db 0x00, 0x62, 0x64, 0x08, 0x13, 0x23 ; % 5
|
||||
.db 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 ; & 6
|
||||
.db 0x00, 0x00, 0x05, 0x03, 0x00, 0x00 ; ' 7
|
||||
.db 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 ; ( 8
|
||||
.db 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 ; ) 9
|
||||
.db 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 ; * 10
|
||||
.db 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 ; + 11
|
||||
.db 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 ; , 12
|
||||
.db 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 ; - 13
|
||||
.db 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 ; . 14
|
||||
.db 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 ; / 15
|
||||
.db 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E ; 0 16
|
||||
.db 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 ; 1 17
|
||||
.db 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 ; 2 18
|
||||
.db 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 ; 3 19
|
||||
.db 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 ; 4 20
|
||||
.db 0x00, 0x27, 0x45, 0x45, 0x45, 0x39 ; 5 21
|
||||
.db 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30 ; 6 22
|
||||
.db 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 ; 7 23
|
||||
.db 0x00, 0x36, 0x49, 0x49, 0x49, 0x36 ; 8 24
|
||||
.db 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E ; 9 25
|
||||
.db 0x00, 0x00, 0x36, 0x36, 0x00, 0x00 ; : 26
|
||||
.db 0x00, 0x00, 0x56, 0x36, 0x00, 0x00 ; ; 27
|
||||
.db 0x00, 0x08, 0x14, 0x22, 0x41, 0x00 ; < 28
|
||||
.db 0x00, 0x14, 0x14, 0x14, 0x14, 0x14 ; = 29
|
||||
.db 0x00, 0x00, 0x41, 0x22, 0x14, 0x08 ; > 30
|
||||
.db 0x00, 0x02, 0x01, 0x51, 0x09, 0x06 ; ? 31
|
||||
.db 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E ; @ 32
|
||||
.db 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C ; A 33
|
||||
.db 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36 ; B 34
|
||||
.db 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22 ; C 35
|
||||
.db 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C ; D 36
|
||||
.db 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41 ; E 37
|
||||
.db 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01 ; F 38
|
||||
.db 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A ; G 39
|
||||
.db 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F ; H 40
|
||||
.db 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00 ; I 41
|
||||
.db 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01 ; J 42
|
||||
.db 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41 ; K 43
|
||||
.db 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40 ; L 44
|
||||
.db 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F ; M 45
|
||||
.db 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F ; N 46
|
||||
.db 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E ; O 47
|
||||
.db 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06 ; P 48
|
||||
.db 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E ; Q 49
|
||||
.db 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46 ; R 50
|
||||
.db 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 ; S 51
|
||||
.db 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01 ; T 52
|
||||
.db 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F ; U 53
|
||||
.db 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F ; V 54
|
||||
.db 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F ; W 55
|
||||
.db 0x00, 0x63, 0x14, 0x08, 0x14, 0x63 ; X 56
|
||||
.db 0x00, 0x07, 0x08, 0x70, 0x08, 0x07 ; Y 57
|
||||
.db 0x00, 0x61, 0x51, 0x49, 0x45, 0x43 ; Z 58
|
||||
.db 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00 ; [ 59
|
||||
.db 0x00, 0x02, 0x04, 0x08, 0x10, 0x20 ; \ 60
|
||||
.db 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00 ; ] 61
|
||||
.db 0x00, 0x04, 0x02, 0x01, 0x02, 0x04 ; ^ 62
|
||||
.db 0x00, 0x40, 0x40, 0x40, 0x40, 0x40 ; _ 63
|
||||
.db 0x00, 0x00, 0x01, 0x02, 0x04, 0x00 ; ' 64
|
||||
#else
|
||||
lcdFont6x8:
|
||||
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ; 0
|
||||
.db 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 ; ! 1
|
||||
@@ -685,6 +802,7 @@ lcdFont6x8:
|
||||
.db 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00 ; | 92
|
||||
.db 0x00, 0x00, 0x41, 0x41, 0x36, 0x08 ; } 93
|
||||
.db 0x00, 0x08, 0x04, 0x08, 0x10, 0x08 ; ~ 94
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
33
avr/main.asm
33
avr/main.asm
@@ -18,6 +18,7 @@ main:
|
||||
rcall onSystemStart
|
||||
|
||||
|
||||
#ifdef MODULES_LED
|
||||
ldi xl, LOW(blinkPattern) ; debug: set blink pattern
|
||||
ldi xh, HIGH(blinkPattern)
|
||||
ldi zl, LOW(ledA3Flash)
|
||||
@@ -25,6 +26,7 @@ main:
|
||||
ldi yl, LOW(ledA3Sram)
|
||||
ldi yh, HIGH(ledA3Sram)
|
||||
rcall Led_SetPattern
|
||||
#endif
|
||||
|
||||
; ldi r16, 1
|
||||
; sts twiMasterScanEnabled, r16
|
||||
@@ -135,33 +137,12 @@ runModulesUntilIdle_ComEnd:
|
||||
|
||||
|
||||
|
||||
#ifdef MODULES_LCD
|
||||
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
|
||||
@@ -241,6 +222,7 @@ printSendStats:
|
||||
pop r15
|
||||
out SREG, r15
|
||||
ret
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -287,19 +269,18 @@ sendValueMsg_done:
|
||||
pop r15
|
||||
out SREG, r15
|
||||
ret
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
textSi7021Firmware: .db "SI: ", 0, 0
|
||||
textStatsPacketsIn: .db "In : ", 0
|
||||
textStatsPacketsRecvErr: .db "RecvErr: ", 0
|
||||
textStatsPacketsOut: .db "Out : ", 0
|
||||
textUid: .db "UID : ", 0
|
||||
textRandom: .db "RANDOM : ", 0
|
||||
textAddress: .db "ADDR :", 0, 0
|
||||
textBitmap: .db "BITMAP :", 0, 0
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
101
avr/utils.asm
101
avr/utils.asm
@@ -146,6 +146,7 @@ Utils_FillSram_end:
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
; ---------------------------------------------------------------------------
|
||||
; Increment a 32 bit counter at the address given by X.
|
||||
; IN:
|
||||
@@ -170,6 +171,7 @@ Utils_IncrementCounter32:
|
||||
st -x, r19
|
||||
st -x, r18
|
||||
ret
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -243,105 +245,6 @@ Utils_WriteEeprom:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Utils_ReadFlashPageIntoPageBuffer
|
||||
;
|
||||
;
|
||||
; IN:
|
||||
; - Z: Address to read from (byte address as for LPM!)
|
||||
; OUT:
|
||||
; - nothing
|
||||
; MODIFIED REGISTERS: R0, R1, R15, R16, R20, R24, R25, Z
|
||||
|
||||
Utils_ReadFlashPageIntoPageBuffer:
|
||||
in r15, SREG
|
||||
cli
|
||||
ldi r24, LOW(PAGESIZE*2)
|
||||
ldi r25, HIGH(PAGESIZE*2)
|
||||
Utils_ReadFlashPageIntoPageBuffer_loop:
|
||||
lpm r0, Z+ ; read source data from FLASH (low)
|
||||
lpm r1, Z ; read source data from FLASH (high)
|
||||
sbiw ZH:ZL, 1 ; rewind Z address for following SPM
|
||||
ldi r20, (1<<SPMEN) ; enable next SPM, write into temp page buffer
|
||||
rcall utilsDoSpm ; (R16)
|
||||
adiw ZH:ZL, 2
|
||||
sbiw r25:r24, 2 ;use subi for PAGESIZEB<=256
|
||||
brne Utils_ReadFlashPageIntoPageBuffer_loop
|
||||
out SREG, r15
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Utils_EraseFlashPage
|
||||
;
|
||||
;
|
||||
; IN:
|
||||
; - Z: Address of the page to erase.
|
||||
; OUT:
|
||||
; - nothing
|
||||
; MODIFIED REGISTERS: R0, R1, R15, R16, R18, R19, R20
|
||||
|
||||
Utils_EraseFlashPage:
|
||||
in r15, SREG
|
||||
cli
|
||||
ldi r20, (1<<PGERS) + (1<<SPMEN) ; enable next SPM, erase page (R1/R0 ignored)
|
||||
rcall utilsDoSpm ; (R16)
|
||||
out SREG, r15
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Utils_WriteFlashPage
|
||||
;
|
||||
;
|
||||
; IN:
|
||||
; - Z: Address of the page to erase.
|
||||
; OUT:
|
||||
; - nothing
|
||||
; MODIFIED REGISTERS: R0, R1, R15, R16, R18, R19, R20
|
||||
|
||||
Utils_WriteFlashPage:
|
||||
in r15, SREG
|
||||
cli
|
||||
ldi r20, (1<<PGWRT) + (1<<SPMEN) ; enable next SPM, erase page (R1/R0 ignored)
|
||||
rcall utilsDoSpm ; (R16)
|
||||
out SREG, r15
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; utilsDoSpm
|
||||
;
|
||||
; wait until possible previous SPM finished and then issue another SPM.
|
||||
;
|
||||
; IN:
|
||||
; - R20: value for register SPMCR
|
||||
; - R0: low value for SPM
|
||||
; - R1: high value for SPM
|
||||
; - Z : address for SPM (byte address!)
|
||||
; OUT:
|
||||
; - nothing
|
||||
; REGS: R16
|
||||
|
||||
utilsDoSpm:
|
||||
wait: ; wait for possibly previous SPM to complete
|
||||
in r16, SPMCSR
|
||||
sbrc r16, SPMEN
|
||||
rjmp wait
|
||||
; SPM timed sequence
|
||||
out SPMCSR, r20
|
||||
spm
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Utils_PseudoRandom
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user