avr: added SK6812_OnPacketReceived

This commit is contained in:
Martin Preuss
2024-11-04 23:27:16 +01:00
parent 42f76f9d09
commit 2e3705946e

View File

@@ -71,17 +71,50 @@ SK6812_Init_error:
; ---------------------------------------------------------------------------
; SK6812_Fini
; @routine SK6812_Fini
;
; IN:
; - nothing
; OUT:
; - CFLAG: set if okay, clear on error
; @return CFLAG set if okay, clear on error
; USED:
SK6812_Fini:
sec
ret
; @end
; ---------------------------------------------------------------------------
; @routine SK6812_OnPacketReceived @global
;
; @clobbers any, -X
SK6812_OnPacketReceived:
adiw xh:xl, 2 ; command
ld r16, X
sbiw xh:xl, 2
cpi r16, CPRO_CMD_VALUE_SET
breq SK6812_OnPacketReceived_set
clc ; unexpected msg
ret
SK6812_OnPacketReceived_set:
rcall CPRO_ReadValue ; (none)
cpi r17, VALUE_ID_LED_RGBW_VALUE
breq SK6812_OnPacketReceived_setRGBW
cpi r17, VALUE_ID_LED_NUMLEDS
breq SK6812_OnPacketReceived_setNumLeds
clc
ret
SK6812_OnPacketReceived_setRGBW:
rcall SK6812_SetAllColor ; value is in R18-R21
rjmp SK6812_OnPacketReceived_sendAck
SK6812_OnPacketReceived_setNumLeds:
sts sk6812NumLeds, r18
SK6812_OnPacketReceived_sendAck:
ldi r16, CPRO_CMD_VALUE_SET_ACK
rcall CPRO_SendSetValueResponse
sec
ret
; @end