avr: implement setvalue for n12.

This commit is contained in:
Martin Preuss
2024-09-05 21:36:24 +02:00
parent 984cccc25b
commit 6b0972d76e
4 changed files with 186 additions and 17 deletions

View File

@@ -62,6 +62,8 @@
.equ VALUE_ID_REED1 = 0x04
.equ VALUE_ID_REED2 = 0x05
.equ VALUE_ID_REED_CONF = 0x81
; ***************************************************************************
@@ -193,10 +195,11 @@ sramTimerEnqueueValues: .byte 2
.cseg
#ifdef MODULES_LED
ledA3Flash: .db DDRA+0x20, PORTA+0x20, PINA+0x20, (1<<PORTA3)
blinkPattern: .db 2, 50, 0xff, 0xff ; 1 short blink, 5s pause, restart
;blinkPattern2: .db 2, 2, 0xff, 0xff ; 1 short blink, short pause, restart
#endif
@@ -325,20 +328,57 @@ onEvery100ms:
; ---------------------------------------------------------------------------
; onPacketReceived:
; @routine onPacketReceived:
;
; Called after a packet was received via COM module. Add your routine calls here.
;
; The packet will be released in any case after return from this call.
; IN:
; - X : pointer to received buffer
; OUT:
; - CFLAG: set if handled, cleared otherwise
; USED: depending on called routines
;
; @return CFLAG set if message handled, cleared otherwise
; @param X pointer to received buffer
; @clobbers all
onPacketReceived:
rcall CPRO_OnPacketReceived
; get msg code
adiw xh:xl, COM2_MSG_OFFS_CMD
ld r16, x
sbiw xh:xl, COM2_MSG_OFFS_CMD
cpi r16, CPRO_CMD_VALUE_SET
brne onPacketReceived_l1
; msg code is CPRO_CMD_VALUE_SET
; TODO
onPacketReceived_l1:
rjmp CPRO_OnPacketReceived
; @end
onSetValueReceived:
adiw xh:xl, CPRO_PACKET_SETVALUE_OFFS_VALUEID
ld r16, X
sbiw xh:xl, CPRO_PACKET_SETVALUE_OFFS_VALUEID
cpi r16, VALUE_ID_REED_CONF
brne onSetValueReceived_l1
rjmp onSetReedConf
onSetValueReceived_l1:
clc
ret
onSetReedConf:
; get new value
adiw xh:xl, CPRO_PACKET_SETVALUE_OFFS_VALUE
ld r16, X
sbiw xh:xl, CPRO_PACKET_SETVALUE_OFFS_VALUE
; set config
rcall REED_SetConfig
; send ACK
ldi r16, CPRO_CMD_VALUE_SET_ACK
rcall CPRO_SendSetValueResponse
sec
ret