finished basic new structure.

This commit is contained in:
Martin Preuss
2023-04-22 00:23:44 +02:00
parent 5e12b8ad4e
commit 3e6501c834
36 changed files with 34 additions and 328 deletions

View File

@@ -39,7 +39,7 @@
<target type="AvrHexFile" name="att84_base" >
<target type="AvrHexFile" name="att84_bootloader" >
<includes type="avrasm" >
-I $(builddir)
@@ -49,25 +49,7 @@
<sources type="avrasm" >
att84_base.asm
</sources>
</target>
<target type="AvrHexFile" name="att84_testflashimg" >
<includes type="avrasm" >
-I $(builddir)
-I $(srcdir)
-I $(topsrcdir)/avr
</includes>
<sources type="avrasm" >
att84_testflashimg.asm
att84_bootloader.asm
</sources>

View File

@@ -39,8 +39,8 @@
.include "common/utils_wait.asm"
.include "modules/com2/com2_defs.asm"
.include "modules/comproto/comproto_defs.asm"
.include "modules/com2/defs.asm"
.include "modules/comproto/defs.asm"
@@ -159,12 +159,12 @@ main:
; ***************************************************************************
; includes
.include "modules/com2/com2_lowlevel.asm"
.include "modules/com2/com2_crc.asm"
.include "modules/com2/com2_packets.asm"
.include "modules/com2/lowlevel.asm"
.include "modules/com2/crc.asm"
.include "modules/com2/packets.asm"
.include "common/crc8.asm"
.include "modules/flash/flash.asm"
.include "modules/flash/flashproto.asm"
.include "modules/flash/main.asm"
.include "modules/flash/proto.asm"

View File

@@ -208,39 +208,39 @@ firmwareStart: rjmp main
.include "common/crc8.asm"
#ifdef MODULES_TIMER
.include "modules/timer/timer.asm"
.include "modules/timer/main.asm"
#endif
#ifdef MODULES_LED
.include "modules/led/led.asm"
.include "modules/led/main.asm"
#endif
#ifdef MODULES_COM
.include "modules/com2/com2_defs.asm"
.include "modules/com2/com2.asm"
.include "modules/com2/defs.asm"
.include "modules/com2/main.asm"
#ifdef MODULES_COM_WITH_ADDR_PROTO
.include "modules/comproto/comproto_defs.asm"
.include "modules/comproto/comproto.asm"
.include "modules/comproto/comproto_addr.asm"
.include "modules/comproto/comproto_recvstats.asm"
.include "modules/comproto/comproto_sendstats.asm"
.include "modules/comproto/comproto_sysstats.asm"
.include "modules/comproto/comproto_memstats.asm"
.include "modules/comproto/comproto_pong.asm"
.include "modules/comproto/comproto_values.asm"
.include "modules/comproto/comproto_device.asm"
.include "modules/comproto/comproto_reboot.asm"
.include "modules/comproto/defs.asm"
.include "modules/comproto/main.asm"
.include "modules/comproto/addr.asm"
.include "modules/comproto/msg_recvstats.asm"
.include "modules/comproto/msg_sendstats.asm"
.include "modules/comproto/msg_sysstats.asm"
.include "modules/comproto/msg_memstats.asm"
.include "modules/comproto/msg_pong.asm"
.include "modules/comproto/msg_value.asm"
.include "modules/comproto/msg_device.asm"
.include "modules/comproto/msg_reboot.asm"
#endif
#endif
#ifdef MODULES_TWI_MASTER
.include "modules/twimaster/twimaster.asm"
.include "modules/twimaster/main.asm"
#endif
#ifdef MODULES_LCD
.include "modules/lcd/lcd.asm"
.include "modules/lcd/main.asm"
#endif
#ifdef MODULES_SI7021
.include "modules/si7021/si7021.asm"
.include "modules/si7021/main.asm"
#endif
#ifdef MODULES_STATS
.include "modules/stats/stats.asm"
.include "modules/stats/main.asm"
#endif

View File

@@ -1,39 +0,0 @@
.nolist
.include "include/tn84def.inc" ; Define device ATtiny84
.list
; ***************************************************************************
; defines
; ---------------------------------------------------------------------------
; generic
.equ clock=1000000 ; Define the clock frequency
; ***************************************************************************
; code segment
.cseg
.org 0x0200
.db 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
.db 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17
.db 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27
.db 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37
.db 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47
.db 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57
.db 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67
.db 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77
.db 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87
.db 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97

View File

@@ -420,10 +420,10 @@ com2IsrPcint0_end:
.include "modules/com2/com2_packets.asm"
.include "modules/com2/com2_lowlevel.asm"
.include "modules/com2/com2_buffer.asm"
.include "modules/com2/com2_crc.asm"
.include "modules/com2/packets.asm"
.include "modules/com2/lowlevel.asm"
.include "modules/com2/buffer.asm"
.include "modules/com2/crc.asm"

View File

@@ -425,8 +425,8 @@ cproSendAddressPacket:
.include "modules/comproto/comproto_addr1.asm"
.include "modules/comproto/comproto_addr2.asm"
.include "modules/comproto/addr1.asm"
.include "modules/comproto/addr2.asm"
#endif ; MODULES_COM_WITH_ADDR_PROTO

View File

@@ -1,237 +0,0 @@
; ***************************************************************************
; copyright : (C) 2023 by Martin Preuss
; email : martin@libchipcard.de
;
; ***************************************************************************
; * This file is part of the project "AqHome". *
; * Please see toplevel file COPYING of that project for license details. *
; ***************************************************************************
.nolist
.include "include/tn84def.inc" ; Define device ATtiny84
.list
;
.equ clock=1000000 ; Define the clock frequency
; ***************************************************************************
; defs about modules used
.equ MODULE_ID_OS = 0
.equ MODULE_ID_TIMER = 1
.equ MODULE_ID_LED_A3 = 2
.equ MODULE_ID_WAN = 3
.equ MODULE_ID_PIN = 4
.equ MODULE_ID_COUNT = 5
; ***************************************************************************
; defs for OS
; OS module
.include "os/defs.asm"
; timer module
.equ TIMER_ENABLE_100Hz = 1
.equ TIMER_ENABLE_10Hz = 1
.equ TIMER_ENABLE_1Hz = 1
.include "timer/defs.asm"
; led module
.include "led/defs.asm"
; wan module
.include "wan/defs.asm"
; pin module
.include "pin/defs.asm"
; ***************************************************************************
; data segment
.dseg
.org SRAM_START
ledA3Sram: .byte LED_SRAM_SIZE
wanA7A1Sram: .byte WAN_IFACE_SIZE
; ***************************************************************************
; code segment
.cseg
.org 000000
; ***************************************************************************
; Reset and interrupt vectors
rjmp Main ; Reset vector
reti ; EXT_INT0
rjmp pinIsrInt0 ; PCI0
rjmp pinIsrInt1 ; 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
;
; ***************************************************************************
; Interrupt service routines from modules
.include "timer/irq.asm"
.include "wan/irq.asm"
.include "pin/irq.asm"
; ***************************************************************************
; Info list of used modules
osModuleInfoList:
modInfoOs:
rjmp Os_SignalHandler ; jump to handler
.db MODULE_ID_OS, 0 ; id, reserved byte (0)
.dw 0 ; pointer to flash data
.dw 0 ; pointer to SRAM data
.db "OS ", 0 ; name
modInfoTimer:
rjmp Timer_SignalHandler ; jump to handler
.db MODULE_ID_TIMER, 0 ; id, reserved byte (0)
.dw 0 ; pointer to flash data
.dw 0 ; pointer to SRAM data
.db "TIMER ", 0 ; name
modInfoLedA3:
rjmp Led_SignalHandler ; jump to handler
.db MODULE_ID_LED_A3, 0 ; id, reserved byte (0)
.dw ledA3Flash ; pointer to flash data
.dw ledA3Sram ; pointer to SRAM data
.db "LED ", 0 ; name
modInfoWan:
rjmp Wan_SignalHandler ; jump to handler
.db MODULE_ID_WAN, 0 ; id, reserved byte (0)
.dw wanA7A1Flash ; pointer to flash data
.dw wanA7A1Sram ; pointer to SRAM data
.db "WAN ", 0 ; name
modInfoPin:
rjmp Pin_SignalHandler ; jump to handler
.db MODULE_ID_PIN, 0 ; id, reserved byte (0)
.dw 0 ; pointer to flash data
.dw 0 ; pointer to SRAM data
.db "PIN ", 0 ; name
.dw 0 ; end of module list
; ***************************************************************************
; Flash data for modules
ledA3Flash: .db DDRA+0x20, PORTA+0x20, PINA+0x20, (1<<PORTA3)
wanA7A1Flash: .db 1, 0 ; id, flags
.db DDRA+0x20, PORTA+0x20, PINA+0x20, (1<<PORTA1) ; port info for DATA line
.db DDRA+0x20, PORTA+0x20, PINA+0x20, (1<<PORTA7) ; port info for ATTN line
pinInt0Entries:
; flags PCMSK port_addr pin_mask handler_lo handler_hi data_lo data_hi
.db PIN_ENTRY_FLAGS_ON_LOW, 0x80, DDRA+0x20, (1<<PORTA7), LOW(wanIntAttn0), HIGH(wanIntAttn0), LOW(modInfoWan), HIGH(modInfoWan)
.db 0, 0, 0, 0, 0, 0, 0, 0 ; end of list
pinInt1Entries:
; flags reserved port_addr pin_mask handler_lo handler_hi data_lo data_hi
.db 0, 0, 0, 0, 0, 0, 0, 0 ; end of list
; ***************************************************************************
; Signal maps for modules
; map for signals emitted by OS module
osSignalMap:
; SIGNAL ID SLOT ID MODINFO pointer for handling module
.db 0, 0, 0, 0 ; end of table
; map for signals emitted by timer module
timerSignalMap:
; SIGNAL ID SLOT ID MODINFO pointer for handling module
.db TIMER_SIGNAL_TICK_10HZ, OS_SLOT_TICK, LOW(modInfoOs), HIGH(modInfoOs) ; OS module
.db TIMER_SIGNAL_TICK_10HZ, LED_SLOT_TIMER_TICK, LOW(modInfoLedA3), HIGH(modInfoLedA3) ; LED module
; .db TIMER_SIGNAL_TICK_1HZ, WAN_SLOT_DEBUG, LOW(modInfoWan), HIGH(modInfoWan) ; WAN module
.db 0, 0, 0, 0 ; end of table
; ***************************************************************************
; Code from used modules
.include "os/main.asm"
.include "timer/main.asm"
.include "led/main.asm"
.include "wan/main.asm"
.include "pin/main.asm"
;
; ***************************************************************************
; main code
Main:
.ifdef SPH ; if SPH is defined
ldi r16, High(RAMEND)
out SPH, r16 ; init MSB stack pointer
.endif
ldi r16, Low(RAMEND)
out SPL, r16 ; init LSB stack pointer
rcall OS_Init ; init all modules
ldi r16, 0
ldi r17, MODULE_ID_LED_A3
ldi r18, LED_SLOT_SET_PATTERN
ldi xh, HIGH(blinkPattern)
ldi xl, LOW(blinkPattern)
rcall OS_CallModuleHandler
sei ; Enable interrupts
rjmp OS_EventLoop
blinkPattern: .db 20, 10, 5, 5, 5, 5, 5, 20, 10, 20, 0xff, 0xff ; 2s on, 1s off, 300ms on, 300ms off, restart
;
; End of source code
;
; (Add Copyright information here, e.g.
; .db "(C)2022 by Martin Preuss", 0, 0