137 lines
3.1 KiB
NASM
137 lines
3.1 KiB
NASM
; ***************************************************************************
|
|
; Source file for base system node on AtTiny 85
|
|
;
|
|
; This is for the maintenance system (i.e. the flash loader).
|
|
;
|
|
; All definitions and changes should go into this file.
|
|
;
|
|
;
|
|
; ***************************************************************************
|
|
|
|
.equ clock=1000000 ; Define the clock frequency
|
|
|
|
.nolist
|
|
.include "include/tn85def.inc" ; Define device ATtiny85
|
|
.list
|
|
|
|
.include "version.asm"
|
|
.include "../defs.asm"
|
|
.include "devices/all/defs.asm"
|
|
|
|
|
|
|
|
; ***************************************************************************
|
|
; defines
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; generic
|
|
|
|
.include "common/utils_wait.asm"
|
|
.include "modules/com2/defs.asm"
|
|
.include "modules/comproto/defs.asm"
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; firmware settings
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; LED
|
|
|
|
.equ LED_DDR = DDRB
|
|
.equ LED_PORT = PORTB
|
|
.equ LED_PIN = PINB
|
|
.equ LED_PINNUM = PORTB4
|
|
|
|
|
|
|
|
; ***************************************************************************
|
|
; code segment
|
|
|
|
.cseg
|
|
.org 0x0000
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; Reset and interrupt vectors
|
|
rjmp main ; Reset vector
|
|
reti ; EXT_INT0
|
|
reti ; PCI0
|
|
reti ; OC1A
|
|
reti ; OVF1
|
|
reti ; OVF0
|
|
reti ; ERDY
|
|
reti ; ACI
|
|
reti ; ADCC
|
|
reti ; OC1B
|
|
reti ; OC0A
|
|
reti ; OC0B
|
|
reti ; WATCHDOG
|
|
reti ; USI_STR
|
|
reti ; USI_OVF
|
|
|
|
devInfoBlock: ; 12 bytes
|
|
devInfoManufacturer: .db 'A', 'Q', 'U', 'A'
|
|
devInfoId: .db DEVICEINFO_ID, 0
|
|
devInfoVersion: .db DEVICEINFO_VERSION, DEVICEINFO_REVISION ; version, revision
|
|
firmwareVersion: .db FIRMWARE_VARIANT_BOOT, FIRMWARE_VERSION_MAJOR
|
|
.db FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCHLEVEL
|
|
|
|
firmwareStart: rjmp main ; will be overwritten when flashing
|
|
|
|
|
|
|
|
; ***************************************************************************
|
|
; main code
|
|
|
|
|
|
.org BOOTLOADER_ADDR
|
|
|
|
|
|
main:
|
|
rjmp bootLoader ; this routine is in modules/bootloader/main.asm
|
|
|
|
|
|
|
|
; ***************************************************************************
|
|
; includes
|
|
|
|
.include "common/utils_wait_fixed.asm"
|
|
.include "common/utils_copy_from_flash.asm"
|
|
.include "common/utils_copy_sdram.asm"
|
|
|
|
.include "modules/flash/defs.asm"
|
|
.include "modules/flash/eeprom.asm"
|
|
.include "modules/flash/io.asm"
|
|
.include "modules/flash/io_attn.asm"
|
|
.include "modules/flash/io_bitbang.asm"
|
|
.include "modules/flash/flashxp.asm"
|
|
.include "modules/flash/flash1p.asm"
|
|
.include "modules/flash/flashprocess.asm"
|
|
.include "modules/flash/wait.asm"
|
|
.include "modules/bootloader/main.asm"
|
|
.include "modules/network/msg/defs.asm"
|
|
.include "modules/network/msg/crc.asm"
|
|
|
|
|
|
|
|
systemSetSpeed:
|
|
.if clock == 8000000
|
|
ldi r16, (1<<CLKPCE)
|
|
ldi r17, 0
|
|
out CLKPR, r16
|
|
out CLKPR, r17
|
|
.endif
|
|
|
|
.if clock == 1000000
|
|
ldi r16, (1<<CLKPCE)
|
|
ldi r17, (1<<CLKPS1) | (1<<CLKPS0)
|
|
out CLKPR, r16
|
|
out CLKPR, r17
|
|
.endif
|
|
ret
|
|
|
|
|