avr: moved COM and COMPROTO defs and routines into dedicated files.

This commit is contained in:
Martin Preuss
2023-04-16 23:23:06 +02:00
parent d53b061aed
commit 5f4260d605
15 changed files with 1332 additions and 1001 deletions

View File

@@ -38,13 +38,17 @@
.equ clock=1000000 ; Define the clock frequency
.include "utils_wait.asm"
.include "com2_defs.asm"
.include "comproto_defs.asm"
; ---------------------------------------------------------------------------
; firmware settings including list of modules used
#define FW_TYPE AQHOME_FW_TYPE_ATT84_BASE
#define FW_MAIN_VERSION_HIGH 0
#define FW_MAIN_VERSION_LOW 1
#define FW_TYPE AQHOME_FW_TYPE_ATT84_BASE
#define FW_VERSION 0x0001
#define BASE_SYSTEM
@@ -106,46 +110,23 @@
; code segment
.cseg
.org 000000
.org 0x0000
; ---------------------------------------------------------------------------
; 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
; ---------------------------------------------------------------------------
; maintenance system starts here.
.org 0x20
rjmp main ; Reset vector
; rjmp start ; Reset vector
rjmp 0xe00 ; Reset vector
reti ; EXT_INT0
rjmp comIsrPcint0 ; PCI0
reti ; PCI0
reti ; PCI1
reti ; WATCHDOG
reti ; ICP1
reti ; OC1A
reti ; OC1B
reti ; OVF1
rjmp timerIrqOC0A ; OC0A
reti ; OC0A
reti ; OC0B
reti ; OVF0
reti ; ACI
@@ -155,160 +136,38 @@
reti ; USI_OVF
firmwareType: .dw FW_TYPE
firmwareVersion: .dw FW_VERSION
firmwareStart: .dw 0 ; will be overwritten when flashing
; ***************************************************************************
; main code
.org 0xe00
; TODO:
; - wait for a few seconds for an incoming flash message
; - if no such message received within that time period try starting the firmware
main:
rjmp main
; ***************************************************************************
; includes
.include "utils.asm"
.include "timer.asm"
.include "com.asm"
.include "comproto.asm"
.include "com2_lowlevel.asm"
.include "com2_crc.asm"
.include "com2_packets.asm"
.include "crc8.asm"
.include "flash.asm"
.include "flashproto.asm"
; ***************************************************************************
; data in SRAM
.dseg
; ***************************************************************************
; data in FLASH
.cseg
.include "main.asm"
; ---------------------------------------------------------------------------
; 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:
ret
; ---------------------------------------------------------------------------
; Called every second. Add your routine calls here. No arguments, no results.
onEverySecond:
rcall CPRO_OnEverySecond
ret
; ---------------------------------------------------------------------------
; Called every 5 seconds. Add your routine calls here. No arguments, no results.
onEvery5s:
ret
; ---------------------------------------------------------------------------
; Called every 10 seconds. Add your routine calls here. No arguments, no results.
onEvery10s:
ret
; ---------------------------------------------------------------------------
; Called every 30 seconds. Add your routine calls here. No arguments, no results.
onEvery30s:
ret
; ---------------------------------------------------------------------------
; Called every minute. Add your routine calls here. No arguments, no results.
onEvery1m:
ret
; ---------------------------------------------------------------------------
; Called every 5 minutes. Add your routine calls here. No arguments, no results.
onEvery5m:
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
; ---------------------------------------------------------------------------
; 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:
rcall CPRO_OnPacketReceived
ret