avr: more work on avr app framework.
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
apps.asm
|
||||
data.asm
|
||||
defs.asm
|
||||
hw_tn84.asm
|
||||
hw_tn85.asm
|
||||
includes.asm
|
||||
main.asm
|
||||
modules.asm
|
||||
|
||||
@@ -37,6 +37,13 @@ initApps:
|
||||
rcall AppDoor_Init
|
||||
#endif
|
||||
|
||||
#ifdef APPS_REPORTSENSORS
|
||||
rcall AppReportSensors_Init
|
||||
#endif
|
||||
|
||||
#ifdef APPS_STATS
|
||||
rcall AppStats_Init
|
||||
#endif
|
||||
; done
|
||||
ret
|
||||
; @end
|
||||
|
||||
65
avr/devices/all/hw_tn84.asm
Normal file
65
avr/devices/all/hw_tn84.asm
Normal file
@@ -0,0 +1,65 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 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. *
|
||||
; ***************************************************************************
|
||||
|
||||
; Hardware routine for AtTiny 84 devices
|
||||
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine systemInitHardware
|
||||
;
|
||||
|
||||
systemInitHardware:
|
||||
; set all ports as inputs and enable internal pull-up resistors
|
||||
ldi r16, 0xff
|
||||
clr r17
|
||||
.ifdef PORTA
|
||||
out DDRA, r17 ; all input
|
||||
out PORTA, r16 ; enable pull-up on all
|
||||
.endif
|
||||
|
||||
.ifdef PORTB
|
||||
out DDRB, r17 ; all input
|
||||
out PORTB, r16 ; enable pull-up on all
|
||||
.endif
|
||||
|
||||
.ifdef PORTC
|
||||
out DDRC, r17 ; all input
|
||||
out PORTC, r16 ; enable pull-up on all
|
||||
.endif
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine systemSetSpeed
|
||||
;
|
||||
|
||||
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
|
||||
; @end
|
||||
|
||||
|
||||
65
avr/devices/all/hw_tn85.asm
Normal file
65
avr/devices/all/hw_tn85.asm
Normal file
@@ -0,0 +1,65 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 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. *
|
||||
; ***************************************************************************
|
||||
|
||||
; Hardware routine for AtTiny 85 devices
|
||||
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine systemInitHardware
|
||||
;
|
||||
|
||||
systemInitHardware:
|
||||
; set all ports as inputs and enable internal pull-up resistors
|
||||
ldi r16, 0xff
|
||||
clr r17
|
||||
.ifdef PORTA
|
||||
out DDRA, r17 ; all input
|
||||
out PORTA, r16 ; enable pull-up on all
|
||||
.endif
|
||||
|
||||
.ifdef PORTB
|
||||
out DDRB, r17 ; all input
|
||||
out PORTB, r16 ; enable pull-up on all
|
||||
.endif
|
||||
|
||||
.ifdef PORTC
|
||||
out DDRC, r17 ; all input
|
||||
out PORTC, r16 ; enable pull-up on all
|
||||
.endif
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine systemSetSpeed
|
||||
;
|
||||
|
||||
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
|
||||
; @end
|
||||
|
||||
|
||||
@@ -65,8 +65,15 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_STATS
|
||||
; .include "modules/stats/main.asm"
|
||||
#ifdef MODULES_OWI_MASTER
|
||||
.include "modules/owimaster/main.asm"
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_DS18B20
|
||||
.include "modules/ds18b20/main2.asm"
|
||||
#ifdef MODULES_NETWORK
|
||||
.include "modules/ds18b20/send.asm"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_MOTION
|
||||
@@ -81,6 +88,12 @@
|
||||
.include "modules/tcrt1000/main2.asm"
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_SK6812
|
||||
.include "modules/sk6812/main.asm"
|
||||
#ifdef MODULES_NETWORK
|
||||
.include "modules/sk6812/recv.asm"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef APPS_MOTION
|
||||
.include "modules/f_keepup/main.asm"
|
||||
@@ -105,4 +118,20 @@
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef APPS_REPORTSENSORS
|
||||
.include "apps/reportsensors/data.asm"
|
||||
.include "apps/reportsensors/main.asm"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef APPS_STATS
|
||||
.include "apps/stats/data.asm"
|
||||
.include "apps/stats/main.asm"
|
||||
.include "apps/network/stats.asm"
|
||||
.include "modules/network/msg/sendstats-w.asm"
|
||||
.include "modules/network/msg/recvstats-w.asm"
|
||||
.include "modules/network/msg/device-w.asm"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -123,4 +123,43 @@ onSystemTimerTick:
|
||||
|
||||
|
||||
|
||||
#ifdef MODULES_CLOCK
|
||||
|
||||
sysOnEverySecond:
|
||||
#ifdef MODULES_DS18B20
|
||||
rcall Ds18b20_OnEverySecond
|
||||
#endif
|
||||
|
||||
#ifdef APPS_REPORTSENSORS
|
||||
rcall AppReportSensors_OnEverySecond
|
||||
#endif
|
||||
rjmp onEverySecond
|
||||
; @end
|
||||
|
||||
|
||||
sysOnEveryMinute:
|
||||
#ifdef APPS_STATS
|
||||
rcall AppStats_OnEveryMinute
|
||||
#endif
|
||||
rjmp onEveryMinute
|
||||
; @end
|
||||
|
||||
|
||||
sysOnEveryHour:
|
||||
rjmp onEveryHour
|
||||
; @end
|
||||
|
||||
|
||||
sysOnEveryDay:
|
||||
rjmp onEveryDay
|
||||
; @end
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -157,10 +157,6 @@ runModules_ComEnd:
|
||||
rcall CNY70_Run
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_DS18B20
|
||||
rcall Ds18b20_Run
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_MOTION_LIGHT
|
||||
; rcall MotionLight_Run
|
||||
#endif
|
||||
@@ -190,6 +186,10 @@ handleMessages:
|
||||
|
||||
rcall onMessageReceived
|
||||
|
||||
#ifdef MODULES_SK6812
|
||||
rcall SK6812_OnPacketReceived
|
||||
#endif
|
||||
|
||||
#ifdef APPS_NETWORK
|
||||
; handle messages
|
||||
ldi yl, LOW(netInterfaceData)
|
||||
|
||||
@@ -17,18 +17,18 @@
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Main_SendValue
|
||||
; @routine Main_SendValueReport
|
||||
;
|
||||
; @param R17 value id
|
||||
; @param R19:R18 value
|
||||
; @param R21:R20 denom (e.g. 100, meaning value must be divided by 100)
|
||||
; @param R22 value type
|
||||
|
||||
Main_SendValue:
|
||||
Main_SendValueReport:
|
||||
push r17
|
||||
rcall NET_Buffer_Alloc ; (R16, R17, X)
|
||||
pop r17
|
||||
brcc sendValue_end ; jmp on error
|
||||
brcc Main_SendValueReport_end ; jmp on error
|
||||
push r16 ; buffer num
|
||||
ldi r16, 0xff ; DEST addr
|
||||
adiw xh:xl, 1
|
||||
@@ -38,10 +38,43 @@ Main_SendValue:
|
||||
sbiw xh:xl, 1
|
||||
pop r16 ; buffer num
|
||||
rcall NET_Interface_AddOutgoingMsgNum ; (R17, R18, X)
|
||||
brcs sendValue_end ; jump if okay
|
||||
brcs Main_SendValueReport_end ; jump if okay
|
||||
rcall NET_Buffer_ReleaseByNum ; otherwise release buffer
|
||||
clc
|
||||
sendValue_end:
|
||||
Main_SendValueReport_end:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Main_SendValueResponse
|
||||
;
|
||||
; @param R17 value id
|
||||
; @param R19:R18 value
|
||||
; @param R21:R20 denom (e.g. 100, meaning value must be divided by 100)
|
||||
; @param R22 value type
|
||||
; @param R23 command
|
||||
; @param R25:R24 ref msg id
|
||||
|
||||
Main_SendValueResponse:
|
||||
push r17
|
||||
rcall NET_Buffer_Alloc ; (R16, R17, X)
|
||||
pop r17
|
||||
brcc Main_SendValueResponse_end ; jmp on error
|
||||
push r16 ; buffer num
|
||||
ldi r16, 0xff ; DEST addr
|
||||
adiw xh:xl, 1
|
||||
ldi yl, LOW(netInterfaceData)
|
||||
ldi yh, HIGH(netInterfaceData)
|
||||
rcall NETMSG_ValueWriteResponse ; (R16, R17, R18, R19, R20, R21, R23, R24, R25)
|
||||
sbiw xh:xl, 1
|
||||
pop r16 ; buffer num
|
||||
rcall NET_Interface_AddOutgoingMsgNum ; (R17, R18, X)
|
||||
brcs Main_SendValueResponse_end ; jump if okay
|
||||
rcall NET_Buffer_ReleaseByNum ; otherwise release buffer
|
||||
clc
|
||||
Main_SendValueResponse_end:
|
||||
ret
|
||||
; @end
|
||||
|
||||
@@ -56,12 +89,12 @@ sendValue_end:
|
||||
; @param R17 value id
|
||||
; @param R22 value type
|
||||
|
||||
Main_Send8BitValue:
|
||||
Main_Send8BitValueReport:
|
||||
mov r18, r16 ; R19:R18 = value
|
||||
clr r19
|
||||
ldi r20, 1 ; R21:R20 = denom
|
||||
clr r21
|
||||
rjmp Main_SendValue
|
||||
rjmp Main_SendValueReport
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user