avr: added apps and use them in multiple nodes.
This commit is contained in:
115
avr/apps/door/main.asm
Normal file
115
avr/apps/door/main.asm
Normal file
@@ -0,0 +1,115 @@
|
||||
; ***************************************************************************
|
||||
; 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. *
|
||||
; ***************************************************************************
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
.equ APP_DOOR_KEEPUPTIME = 50 ; 5s
|
||||
|
||||
.equ APP_DOOR_STATE_OPEN = 255
|
||||
.equ APP_DOOR_STATE_CLOSED = 0
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data
|
||||
|
||||
.dseg
|
||||
|
||||
appDoorKeepupData: .byte FILTER_KEEPUP_DATA_SIZE
|
||||
appDoorValSchedData: .byte VALSCHED_DATA_SIZE
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine AppDoor_Init @global
|
||||
;
|
||||
|
||||
AppDoor_Init:
|
||||
ldi yl, LOW(appDoorKeepupData)
|
||||
ldi yh, HIGH(appDoorKeepupData)
|
||||
rcall FilterKeepUp_Init
|
||||
ldi r16, APP_DOOR_KEEPUPTIME
|
||||
std Y+FILTER_KEEPUP_OFFS_RESTARTVALUE, r16
|
||||
|
||||
ldi yl, LOW(appDoorValSchedData)
|
||||
ldi yh, HIGH(appDoorValSchedData)
|
||||
rcall ValueScheduler_Init
|
||||
ldi r16, (1<<VALSCHED_FLAGS_REPEAT1_BIT) ; only repeat report interval for active motion
|
||||
std Y+VALSCHED_OFFS_FLAGS, r16
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine AppDoor_Every100ms @global
|
||||
;
|
||||
|
||||
AppDoor_Every100ms:
|
||||
rcall TCRT1K_GetValue ; get value into R16
|
||||
ldi yl, LOW(appDoorKeepupData)
|
||||
ldi yh, HIGH(appDoorKeepupData)
|
||||
brcc AppDoor_Every100ms_l1
|
||||
rcall FilterKeepUp_SetValue ; (R17)
|
||||
|
||||
AppDoor_Every100ms_l1:
|
||||
rcall FilterKeepUp_Every100ms
|
||||
rcall FilterKeepUp_GetValue ; get value into R16
|
||||
|
||||
ldi yl, LOW(appDoorValSchedData)
|
||||
ldi yh, HIGH(appDoorValSchedData)
|
||||
rcall ValueScheduler_SetValue ; (R17)
|
||||
rcall ValueScheduler_Every100ms ; (R16, R17)
|
||||
rcall ValueScheduler_CheckSend ; (R16)
|
||||
brcc AppDoor_Every100ms_end
|
||||
; prepare and send value message
|
||||
rcall appDoorSendValue
|
||||
brcc AppDoor_Every100ms_end ; jmp on error
|
||||
ldi yl, LOW(appDoorValSchedData)
|
||||
ldi yh, HIGH(appDoorValSchedData)
|
||||
rcall ValueScheduler_MarkSent ; (R16)
|
||||
AppDoor_Every100ms_end:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine appDoorSendValue
|
||||
;
|
||||
; @return CFLAGS set if message enqueued, cleared on error
|
||||
; @clobbers R17, R18, R19, R20, R21, R22, Y (R16, R23, R24, R25)
|
||||
|
||||
appDoorSendValue:
|
||||
ldi yl, LOW(appDoorValSchedData)
|
||||
ldi yh, HIGH(appDoorValSchedData)
|
||||
rcall ValueScheduler_GetValue ; get value to r16
|
||||
tst r16
|
||||
ldi r16, APP_DOOR_STATE_CLOSED
|
||||
breq appDoorSendValue_send
|
||||
ldi r16, APP_DOOR_STATE_OPEN
|
||||
appDoorSendValue_send:
|
||||
ldi r17, VALUE_ID_TCRT1K ; VALUE ID
|
||||
ldi r22, AQHOME_VALUETYPE_DOOR ; VALUE TYPE
|
||||
rjmp Main_Send8BitValue
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user