forked from quasipedia/Lanterns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclockCommon.S
59 lines (48 loc) · 1.5 KB
/
clockCommon.S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
;;;
;;; clockCommon.S
;;;
;;; Common functions for setting TLC strings for the clock
;;;
.include "m168.h"
#include "reg_mnemonics.h"
.text
.global clockFace_setOffChannels
.global clockFace_setOnChannels
;;; Function: setOffChannels
;;; Takes: a bit mask in REG_SCRATCH_1,
;;; a starting channel number in REG_SCRATCH_2, and
;;; a bit counter in REG_SCRATCH_3, and
;;; assumes intensity 0 set in REG_TLC_CHANNEL_INTENSITY
;;; Calls TLC_setChannelTargetIntensity for each bit in the mask that is zero
;;; Increments the channel number
clockFace_setOffChannels:
; Rotate Right, rightmost bit of REG_SCRATCH_1 ends up in carry
ror REG_SCRATCH_1
brcs dontTurnOff
;; turn off the channel
mov REG_TLC_CHANNEL_NUMBER, REG_SCRATCH_2
call TLC_setChannelTargetIntensity
dontTurnOff:
inc REG_SCRATCH_2 ; Channel number
dec REG_SCRATCH_3 ; Counter
brne clockFace_setOffChannels
ret
;;; Function: setOnhannels
;;; Takes: a bit mask in REG_SCRATCH_1,
;;; a starting channel number in REG_SCRATCH_2, and
;;; a counter in REG_SCRATCH_3, and
;;; assumes intensity 0 set in REG_TLC_CHANNEL_INTENSITY
;;; Calls TLC_setChannelTargetIntensity for each bit in the mask that is zero
clockFace_setOnChannels:
; Rotate Right, rightmost bit of REG_SCRATCH_1 ends up in carry
ror REG_SCRATCH_1
brcc dontTurnOn
;; turn off the channel
mov REG_TLC_CHANNEL_NUMBER, REG_SCRATCH_2
call TLC_setChannelTargetIntensity
dontTurnOn:
inc REG_SCRATCH_2 ; Channel number
dec REG_SCRATCH_3 ; Counter
brne clockFace_setOnChannels
ret
.end