Files
aqhomecontrol/avr/att84_bootloader.asm

152 lines
3.4 KiB
NASM

; ***************************************************************************
; Source file for base system node on AtTiny 84
;
; This is for the maintenance system (i.e. the flash 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
; KEY1 PB2 5 10 PA3 LED
; COM_ATTN PA7 6 9 PA4
; 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
.include "common/utils_wait.asm"
.include "modules/com2/defs.asm"
.include "modules/comproto/defs.asm"
; ---------------------------------------------------------------------------
; firmware settings
#define FW_TYPE AQHOME_FW_TYPE_ATT84_BASE
#define FW_VERSION 0x0001
#define BASE_SYSTEM
#define WITH_FLASH
; ---------------------------------------------------------------------------
; 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
; ***************************************************************************
; code segment
.cseg
.org 0x0000
; ---------------------------------------------------------------------------
; Reset and interrupt vectors
; rjmp start ; Reset vector
rjmp main ; Reset vector
reti ; EXT_INT0
reti ; PCI0
reti ; PCI1
reti ; WATCHDOG
reti ; ICP1
reti ; OC1A
reti ; OC1B
reti ; OVF1
reti ; OC0A
reti ; OC0B
reti ; OVF0
reti ; ACI
reti ; ADCC
reti ; ERDY
reti ; USI_STR
reti ; USI_OVF
firmwareType: .dw FW_TYPE
firmwareVersion: .dw FW_VERSION
firmwareModules: .dw 0
firmwareStart: rjmp main ; will be overwritten when flashing
; ***************************************************************************
; main code
.org AQHOME_BOOTLOADER_ADDR
main:
rjmp bootLoader ; this routine is in modules/flash/proto.asm
; ***************************************************************************
; includes
.include "modules/com2/lowlevel.asm"
.include "modules/com2/crc.asm"
.include "modules/com2/packets.asm"
.include "common/crc8.asm"
.include "modules/flash/bootloader.asm"
.include "modules/flash/flash.asm"
.include "modules/flash/recv.asm"
.include "modules/flash/send.asm"
.include "modules/flash/wait.asm"
.include "modules/flash/hdl_flash_start.asm"
.include "modules/flash/hdl_flash_data.asm"
.include "modules/flash/hdl_flash_end.asm"
.include "modules/flash/flash_rsp.asm"
.include "modules/flash/flash_ready.asm"