author | Tero Marttila <terom@fixme.fi> |
Sat, 08 May 2010 16:00:18 +0300 | |
changeset 17 | a7c668003a19 |
parent 16 | 11d6167a67cb |
child 18 | 79b25e81721f |
permissions | -rw-r--r-- |
3 | 1 |
.nolist |
2 |
.include "m168def.inc" ; Same family as 328P |
|
3 |
.list |
|
4 |
||
5 |
;; Interrupt Vector |
|
6 |
.org 0x00 |
|
7 |
rjmp init |
|
8 |
||
9 |
.org SPIaddr |
|
10 |
rjmp SPI_Interrupt |
|
11 |
||
8 | 12 |
.org ADCCaddr |
13 |
rjmp ADC_Interrupt |
|
14 |
||
3 | 15 |
;; SPI |
17
a7c668003a19
split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
16 |
.include "spi.inc" |
3 | 17 |
|
18 |
;; LCD |
|
17
a7c668003a19
split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
19 |
.include "led7seg.inc" |
3 | 20 |
|
8 | 21 |
;; ADC |
17
a7c668003a19
split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
22 |
.include "adc.inc" |
8 | 23 |
|
17
a7c668003a19
split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
24 |
;; Utils |
a7c668003a19
split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
25 |
.include "delay.inc" |
7 | 26 |
|
6 | 27 |
;; Count down from 9 |
28 |
; Returns once we've hit zero |
|
29 |
Main_Countdown: |
|
16 | 30 |
; init from F |
17
a7c668003a19
split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
31 |
ldi r24, LED7_F |
6 | 32 |
|
15
c8f3a514bbef
read SPI to r10, and use it (hack)
Tero Marttila <terom@fixme.fi>
parents:
8
diff
changeset
|
33 |
_count_loop: |
6 | 34 |
; display |
35 |
mov r16, r24 |
|
17
a7c668003a19
split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
36 |
rcall LED7_Show |
6 | 37 |
|
38 |
; exit if zero |
|
39 |
tst r24 |
|
15
c8f3a514bbef
read SPI to r10, and use it (hack)
Tero Marttila <terom@fixme.fi>
parents:
8
diff
changeset
|
40 |
breq _count_end |
6 | 41 |
|
42 |
; count down |
|
43 |
dec r24 |
|
44 |
||
45 |
; wait... |
|
46 |
rcall Delay_1s |
|
47 |
||
48 |
; next |
|
15
c8f3a514bbef
read SPI to r10, and use it (hack)
Tero Marttila <terom@fixme.fi>
parents:
8
diff
changeset
|
49 |
rjmp _count_loop |
c8f3a514bbef
read SPI to r10, and use it (hack)
Tero Marttila <terom@fixme.fi>
parents:
8
diff
changeset
|
50 |
|
c8f3a514bbef
read SPI to r10, and use it (hack)
Tero Marttila <terom@fixme.fi>
parents:
8
diff
changeset
|
51 |
_count_end: |
c8f3a514bbef
read SPI to r10, and use it (hack)
Tero Marttila <terom@fixme.fi>
parents:
8
diff
changeset
|
52 |
; done |
c8f3a514bbef
read SPI to r10, and use it (hack)
Tero Marttila <terom@fixme.fi>
parents:
8
diff
changeset
|
53 |
ret |
6 | 54 |
|
55 |
;; Blink between dot and empty |
|
56 |
Main_Blink: |
|
57 |
_blink_loop: |
|
58 |
; dot |
|
17
a7c668003a19
split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
59 |
ldi r16, LED7_DOT |
a7c668003a19
split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
60 |
rcall LED7_Show |
6 | 61 |
|
62 |
; wait... |
|
63 |
rcall Delay_1s |
|
64 |
||
65 |
; empty |
|
17
a7c668003a19
split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
66 |
ldi r16, LED7_EMPTY |
a7c668003a19
split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
67 |
rcall LED7_Show |
6 | 68 |
|
69 |
rcall Delay_1s |
|
70 |
||
71 |
; loop |
|
72 |
rjmp _blink_loop |
|
73 |
||
74 |
;; Chase segments |
|
75 |
Main_Spin: |
|
76 |
_spin_init: |
|
77 |
; init from top |
|
78 |
ldi r24, 0b00000001 |
|
79 |
||
80 |
_spin_next: |
|
81 |
; display |
|
82 |
mov r16, r24 |
|
17
a7c668003a19
split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
83 |
rcall LED7_ShowRaw |
6 | 84 |
|
17
a7c668003a19
split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
85 |
; delay from ADC |
15
c8f3a514bbef
read SPI to r10, and use it (hack)
Tero Marttila <terom@fixme.fi>
parents:
8
diff
changeset
|
86 |
;rcall ADC_Read8 |
c8f3a514bbef
read SPI to r10, and use it (hack)
Tero Marttila <terom@fixme.fi>
parents:
8
diff
changeset
|
87 |
;mov r20, r16 |
c8f3a514bbef
read SPI to r10, and use it (hack)
Tero Marttila <terom@fixme.fi>
parents:
8
diff
changeset
|
88 |
|
c8f3a514bbef
read SPI to r10, and use it (hack)
Tero Marttila <terom@fixme.fi>
parents:
8
diff
changeset
|
89 |
; delay from input |
c8f3a514bbef
read SPI to r10, and use it (hack)
Tero Marttila <terom@fixme.fi>
parents:
8
diff
changeset
|
90 |
mov r20, r10 |
c8f3a514bbef
read SPI to r10, and use it (hack)
Tero Marttila <terom@fixme.fi>
parents:
8
diff
changeset
|
91 |
|
c8f3a514bbef
read SPI to r10, and use it (hack)
Tero Marttila <terom@fixme.fi>
parents:
8
diff
changeset
|
92 |
; constant |
c8f3a514bbef
read SPI to r10, and use it (hack)
Tero Marttila <terom@fixme.fi>
parents:
8
diff
changeset
|
93 |
;ldi r20, 20 |
8 | 94 |
|
17
a7c668003a19
split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
95 |
; short delay |
a7c668003a19
split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
96 |
rcall VarDelay |
6 | 97 |
|
98 |
; next segment |
|
99 |
lsl r24 |
|
100 |
||
101 |
; go back to A if we hit G |
|
102 |
sbrc r24, 6 |
|
103 |
rjmp _spin_init |
|
104 |
||
105 |
rjmp _spin_next |
|
4 | 106 |
|
107 |
Main: |
|
3 | 108 |
init: |
109 |
; Stack |
|
110 |
ldi r16, high(RAMEND) |
|
111 |
ldi r17, low(RAMEND) |
|
112 |
out SPH, r16 |
|
113 |
out SPL, r17 |
|
114 |
||
115 |
; Enable interrupts |
|
116 |
sei |
|
117 |
||
8 | 118 |
; ADC (slowest to start up) |
15
c8f3a514bbef
read SPI to r10, and use it (hack)
Tero Marttila <terom@fixme.fi>
parents:
8
diff
changeset
|
119 |
; rcall ADC_Init |
8 | 120 |
|
3 | 121 |
; SPI |
122 |
rcall SPI_Init |
|
123 |
||
8 | 124 |
; LCD (requires interrupts, blocks) |
17
a7c668003a19
split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
125 |
rcall LED7_Init |
6 | 126 |
|
127 |
; Run |
|
128 |
; spin! |
|
17
a7c668003a19
split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
129 |
rcall Main_Spin |
15
c8f3a514bbef
read SPI to r10, and use it (hack)
Tero Marttila <terom@fixme.fi>
parents:
8
diff
changeset
|
130 |
|
c8f3a514bbef
read SPI to r10, and use it (hack)
Tero Marttila <terom@fixme.fi>
parents:
8
diff
changeset
|
131 |
; count! |
17
a7c668003a19
split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
132 |
; rcall Main_Countdown |
a7c668003a19
split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
133 |
; rcall Main_Blink |
4 | 134 |
|
135 |
end: |
|
136 |
rjmp end |
|
137 |