Stefan Schuermans commited on 2015-08-16 08:52:13
Showing 10 changed files, with 1497 additions and 0 deletions.
... | ... |
@@ -0,0 +1 @@ |
1 |
+build |
... | ... |
@@ -0,0 +1,24 @@ |
1 |
+cmake_minimum_required(VERSION 2.8 ) |
|
2 |
+ |
|
3 |
+project(bulb_mm C ASM) |
|
4 |
+ |
|
5 |
+set(CMAKE_BUILD_TYPE MinSizeRel) |
|
6 |
+set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -std=c99) |
|
7 |
+ |
|
8 |
+set(AVR_MCU attiny2313) |
|
9 |
+set(AVR_PROGRAMMER avr910) |
|
10 |
+set(AVR_UPLOADTOOL_PORT /dev/ttyUSB0) |
|
11 |
+set(AVR_UPLOADTOOL_OPTIONS -b 115200) |
|
12 |
+ |
|
13 |
+ |
|
14 |
+#add_avr_executable(bulb_orig |
|
15 |
+# bulb.asm) |
|
16 |
+ |
|
17 |
+add_avr_executable(bulb |
|
18 |
+ bulb.c) |
|
19 |
+ |
|
20 |
+add_avr_executable(bulb_dim |
|
21 |
+ bulb_dim.c) |
|
22 |
+ |
|
23 |
+add_avr_executable(bulb_animation |
|
24 |
+ bulb_animation.c) |
... | ... |
@@ -0,0 +1,16 @@ |
1 |
+configure your programmer in CMakeLists.txt |
|
2 |
+ |
|
3 |
+build on Linux |
|
4 |
+============== |
|
5 |
+ |
|
6 |
+rm -rf build |
|
7 |
+mkdir build |
|
8 |
+cd build |
|
9 |
+cmake -DCMAKE_TOOLCHAIN_FILE=../generic-gcc-avr.cmake .. |
|
10 |
+make |
|
11 |
+ |
|
12 |
+flashing on Linux |
|
13 |
+================= |
|
14 |
+ |
|
15 |
+make upload_bulb_dim |
|
16 |
+ |
... | ... |
@@ -0,0 +1,60 @@ |
1 |
+#define ANIMATION_SIZE 8 |
|
2 |
+const struct Frame animation[ANIMATION_SIZE] PROGMEM = |
|
3 |
+{ |
|
4 |
+ { |
|
5 |
+ { {0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, |
|
6 |
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, |
|
7 |
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
|
8 |
+ }, |
|
9 |
+ 2, |
|
10 |
+ }, |
|
11 |
+ { |
|
12 |
+ { {0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00}, |
|
13 |
+ {0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00}, |
|
14 |
+ {0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00} |
|
15 |
+ }, |
|
16 |
+ 4, |
|
17 |
+ }, |
|
18 |
+ { |
|
19 |
+ { {0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00}, |
|
20 |
+ {0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00}, |
|
21 |
+ {0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00} |
|
22 |
+ }, |
|
23 |
+ 8, |
|
24 |
+ }, |
|
25 |
+ { |
|
26 |
+ { {0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00}, |
|
27 |
+ {0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00}, |
|
28 |
+ {0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00} |
|
29 |
+ }, |
|
30 |
+ 16, |
|
31 |
+ }, |
|
32 |
+ { |
|
33 |
+ { {0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00}, |
|
34 |
+ {0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00}, |
|
35 |
+ {0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00} |
|
36 |
+ }, |
|
37 |
+ 32, |
|
38 |
+ }, |
|
39 |
+ { |
|
40 |
+ { {0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00}, |
|
41 |
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00}, |
|
42 |
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00} |
|
43 |
+ }, |
|
44 |
+ 64, |
|
45 |
+ }, |
|
46 |
+ { |
|
47 |
+ { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}, |
|
48 |
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}, |
|
49 |
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF} |
|
50 |
+ }, |
|
51 |
+ 128 |
|
52 |
+ }, |
|
53 |
+ { |
|
54 |
+ { {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, |
|
55 |
+ {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, |
|
56 |
+ {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
|
57 |
+ }, |
|
58 |
+ 255 |
|
59 |
+ } |
|
60 |
+}; |
... | ... |
@@ -0,0 +1,119 @@ |
1 |
+/* bulb - BlinkenArea ultimate logo board |
|
2 |
+ Copyright (C) 2015 Martin Müllenhaupt <mm+bulb@netlair.de> |
|
3 |
+ Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
|
4 |
+*/ |
|
5 |
+ |
|
6 |
+#include <avr/io.h> |
|
7 |
+ |
|
8 |
+#define NUM_ZEILEN 6 |
|
9 |
+#define NUM_SPALTEN 7 |
|
10 |
+ |
|
11 |
+uint8_t frame[NUM_ZEILEN] = {0}; |
|
12 |
+ |
|
13 |
+void showFrame() |
|
14 |
+{ |
|
15 |
+ static uint8_t zeile = 0; |
|
16 |
+ static uint16_t updateCounter = 0; |
|
17 |
+ ++updateCounter; |
|
18 |
+ |
|
19 |
+ if (updateCounter > 100) |
|
20 |
+ { |
|
21 |
+ updateCounter = 0; |
|
22 |
+ ++zeile; |
|
23 |
+ if(zeile >= NUM_ZEILEN) |
|
24 |
+ { |
|
25 |
+ zeile = 0; |
|
26 |
+ } |
|
27 |
+ |
|
28 |
+ |
|
29 |
+ PORTD = ~(1 << zeile); |
|
30 |
+ PORTB = frame[zeile]; |
|
31 |
+ |
|
32 |
+ } |
|
33 |
+ |
|
34 |
+} |
|
35 |
+ |
|
36 |
+void noAnimation() |
|
37 |
+{ |
|
38 |
+ for(int zeile = 0; zeile < NUM_ZEILEN; ++zeile) |
|
39 |
+ { |
|
40 |
+ frame[zeile] = 0xFF; |
|
41 |
+ } |
|
42 |
+} |
|
43 |
+ |
|
44 |
+ |
|
45 |
+void blinkAnimation() |
|
46 |
+{ |
|
47 |
+ static uint8_t on = 0; |
|
48 |
+ |
|
49 |
+ static uint16_t updateCounter = 0; |
|
50 |
+ ++updateCounter; |
|
51 |
+ |
|
52 |
+ if (updateCounter > 1000) |
|
53 |
+ { |
|
54 |
+ updateCounter = 0; |
|
55 |
+ if (on) |
|
56 |
+ { |
|
57 |
+ on = 0; |
|
58 |
+ } |
|
59 |
+ else |
|
60 |
+ { |
|
61 |
+ on = 1; |
|
62 |
+ } |
|
63 |
+ } |
|
64 |
+ |
|
65 |
+ for(int zeile = 0; zeile < NUM_ZEILEN; ++zeile) |
|
66 |
+ { |
|
67 |
+ if (on) |
|
68 |
+ { |
|
69 |
+ frame[zeile] = 0xFF; |
|
70 |
+ } |
|
71 |
+ else |
|
72 |
+ { |
|
73 |
+ frame[zeile] = 0; |
|
74 |
+ } |
|
75 |
+ } |
|
76 |
+} |
|
77 |
+ |
|
78 |
+void laufLichtAnimation() |
|
79 |
+{ |
|
80 |
+ static uint8_t led = 0; |
|
81 |
+ static uint16_t updateCounter = 0; |
|
82 |
+ |
|
83 |
+ if (updateCounter > 10000) |
|
84 |
+ { |
|
85 |
+ updateCounter = 0; |
|
86 |
+ |
|
87 |
+ frame[led/7] = 0; |
|
88 |
+ ++led; |
|
89 |
+ if(led >= (NUM_ZEILEN*NUM_SPALTEN)) |
|
90 |
+ { |
|
91 |
+ led = 0; |
|
92 |
+ } |
|
93 |
+ frame[led/7] = (1 << (led % NUM_SPALTEN) ); |
|
94 |
+ } |
|
95 |
+ ++updateCounter; |
|
96 |
+} |
|
97 |
+ |
|
98 |
+int main(void) |
|
99 |
+{ |
|
100 |
+ // PA[01] to output, low |
|
101 |
+ PORTA = 0; |
|
102 |
+ DDRA = 0x03; |
|
103 |
+ |
|
104 |
+ // PB[0-6] to output, low - PB7 to input, pull-up enabled |
|
105 |
+ DDRB = 0x7F; |
|
106 |
+ PORTB = 0x80; |
|
107 |
+ |
|
108 |
+ // PD[0-5] to output, high - PD6 to input, pull-up enabled |
|
109 |
+ DDRD = 0x3F; |
|
110 |
+ PORTD = 0x7F; |
|
111 |
+ |
|
112 |
+ while(1) |
|
113 |
+ { |
|
114 |
+ showFrame(); |
|
115 |
+ laufLichtAnimation(); |
|
116 |
+ //noAnimation(); |
|
117 |
+ //blinkAnimation(); |
|
118 |
+ } |
|
119 |
+} |
... | ... |
@@ -0,0 +1,105 @@ |
1 |
+/* bulb - BlinkenArea ultimate logo board |
|
2 |
+ Copyright (C) 2015 Martin Müllenhaupt <mm+bulb@netlair.de> |
|
3 |
+ Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
|
4 |
+*/ |
|
5 |
+ |
|
6 |
+#include <avr/io.h> |
|
7 |
+#include <avr/interrupt.h> |
|
8 |
+#include <avr/pgmspace.h> |
|
9 |
+ |
|
10 |
+#define F_CPU 8000000UL // 8 MHz |
|
11 |
+#include <util/delay.h> |
|
12 |
+#include <stdlib.h> |
|
13 |
+ |
|
14 |
+#define ROW_COUNT 6 |
|
15 |
+#define COLUMN_COUNT 7 |
|
16 |
+#define MAX_ROW_TIME 16 |
|
17 |
+ |
|
18 |
+struct Frame |
|
19 |
+{ |
|
20 |
+ uint8_t data[3][COLUMN_COUNT]; |
|
21 |
+ uint8_t time; |
|
22 |
+}; |
|
23 |
+ |
|
24 |
+#include "animations/testbild.c" |
|
25 |
+ |
|
26 |
+uint8_t currentFrame = 0; |
|
27 |
+ |
|
28 |
+ISR(TIMER1_COMPA_vect) |
|
29 |
+{ |
|
30 |
+ static uint8_t row = 0; |
|
31 |
+ static uint8_t timeRow = 0; |
|
32 |
+ static uint16_t timeFrame = 0; |
|
33 |
+ |
|
34 |
+ ++timeRow; |
|
35 |
+ if (timeRow >= MAX_ROW_TIME) |
|
36 |
+ { |
|
37 |
+ row = (row + 1) % ROW_COUNT; |
|
38 |
+ PORTB = 0; |
|
39 |
+ PORTD = ~(1 << row); |
|
40 |
+ timeRow = 0; |
|
41 |
+ |
|
42 |
+ /* upon complete draw cycle increase frame time */ |
|
43 |
+ if (row == 0) |
|
44 |
+ { |
|
45 |
+ ++timeFrame; |
|
46 |
+ if (timeFrame >= pgm_read_byte(&(animation[currentFrame].time))*4) |
|
47 |
+ { |
|
48 |
+ currentFrame = (currentFrame + 1) % ANIMATION_SIZE; |
|
49 |
+ timeFrame = 0; |
|
50 |
+ } |
|
51 |
+ } |
|
52 |
+ } |
|
53 |
+ |
|
54 |
+ uint8_t row_data = 0; |
|
55 |
+ for(uint8_t column = 0; column < COLUMN_COUNT; ++column) |
|
56 |
+ { |
|
57 |
+ uint8_t pixelTime = pgm_read_byte(&(animation[currentFrame].data[row/2][column])); |
|
58 |
+ if (row % 2) |
|
59 |
+ { |
|
60 |
+ pixelTime &= 0x0F; |
|
61 |
+ } |
|
62 |
+ else |
|
63 |
+ { |
|
64 |
+ pixelTime = pixelTime >> 4; |
|
65 |
+ } |
|
66 |
+ if (pixelTime > timeRow) |
|
67 |
+ { |
|
68 |
+ row_data |= (1 << column); |
|
69 |
+ } |
|
70 |
+ } |
|
71 |
+ PORTB = row_data; |
|
72 |
+} |
|
73 |
+ |
|
74 |
+int main(void) |
|
75 |
+{ |
|
76 |
+ // PA[01] to output, low |
|
77 |
+ PORTA = 0; |
|
78 |
+ DDRA = 0x03; |
|
79 |
+ |
|
80 |
+ // PB[0-6] to output, low - PB7 to input, pull-up enabled |
|
81 |
+ DDRB = 0x7F; |
|
82 |
+ PORTB = 0x80; |
|
83 |
+ |
|
84 |
+ // PD[0-5] to output, high - PD6 to input, pull-up enabled |
|
85 |
+ DDRD = 0x3F; |
|
86 |
+ PORTD = 0x7F; |
|
87 |
+ |
|
88 |
+ // set clock to 8 MHz |
|
89 |
+ CLKPR = (1<<CLKPCE); |
|
90 |
+ CLKPR = 0; |
|
91 |
+ |
|
92 |
+ TCCR1B |= (1 << WGM12); // Configure timer 1 for CTC mode |
|
93 |
+ |
|
94 |
+ TIMSK |= (1 << OCIE1A); // Enable CTC interrupt |
|
95 |
+ |
|
96 |
+ sei(); // Enable global interrupts |
|
97 |
+ |
|
98 |
+ OCR1A = 4; // Set CTC compare value to 1Hz at 1MHz AVR clock, with a prescaler of 64 |
|
99 |
+ |
|
100 |
+ TCCR1B |= ((1 << CS10) | (1 << CS11)); // Start timer at Fcpu/64 |
|
101 |
+ |
|
102 |
+ for(;;) |
|
103 |
+ { |
|
104 |
+ } |
|
105 |
+} |
... | ... |
@@ -0,0 +1,336 @@ |
1 |
+/* bulb - BlinkenArea ultimate logo board |
|
2 |
+ version 1.0 date 2015-08-15 |
|
3 |
+ Copyright (C) 2015 Martin Müllenhaupt <mm+bulb@netlair.de> |
|
4 |
+ Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
|
5 |
+*/ |
|
6 |
+ |
|
7 |
+ |
|
8 |
+#include <avr/io.h> |
|
9 |
+#include <avr/interrupt.h> |
|
10 |
+ |
|
11 |
+#define F_CPU 8000000UL // 8 MHz |
|
12 |
+#include <util/delay.h> |
|
13 |
+#include <stdlib.h> |
|
14 |
+ |
|
15 |
+#define NUM_ZEILEN 6 |
|
16 |
+#define NUM_SPALTEN 7 |
|
17 |
+#define NUM_LEDS (NUM_ZEILEN * NUM_SPALTEN) |
|
18 |
+#define MAX_TIME 32 |
|
19 |
+ |
|
20 |
+#define LED(index) frame[updateBufferIndex][index/NUM_SPALTEN][index%NUM_SPALTEN] |
|
21 |
+#define LED_INDEX_FROM_MANUAL(index) frame[updateBufferIndex][(index-1)/NUM_SPALTEN][(index-1)%NUM_SPALTEN] |
|
22 |
+ |
|
23 |
+/* 0 = off; 255 = max brightness */ |
|
24 |
+uint8_t frame[2][NUM_ZEILEN][NUM_SPALTEN] = {0}; |
|
25 |
+ |
|
26 |
+uint8_t displayBufferIndex = 0; |
|
27 |
+uint8_t updateBufferIndex = 1; |
|
28 |
+ |
|
29 |
+ISR(TIMER1_COMPA_vect) |
|
30 |
+{ |
|
31 |
+ static uint8_t zeile = 0; |
|
32 |
+ static uint8_t time = 0; |
|
33 |
+ |
|
34 |
+ ++time; |
|
35 |
+ |
|
36 |
+ if (time == MAX_TIME) |
|
37 |
+ { |
|
38 |
+ ++zeile; |
|
39 |
+ zeile %= NUM_ZEILEN; |
|
40 |
+ PORTB = 0; |
|
41 |
+ PORTD = ~(1 << zeile); |
|
42 |
+ time = 0; |
|
43 |
+ } |
|
44 |
+ |
|
45 |
+ uint8_t row_data = 0; |
|
46 |
+ for(uint8_t spalte = 0; spalte < NUM_SPALTEN; ++spalte) |
|
47 |
+ { |
|
48 |
+ if (frame[displayBufferIndex][zeile][spalte] > time) |
|
49 |
+ { |
|
50 |
+ row_data |= (1 << spalte); |
|
51 |
+ } |
|
52 |
+ } |
|
53 |
+ PORTB = row_data; |
|
54 |
+} |
|
55 |
+ |
|
56 |
+void swapBuffers() |
|
57 |
+{ |
|
58 |
+ updateBufferIndex = ( updateBufferIndex + 1 ) % 2; |
|
59 |
+ displayBufferIndex = ( displayBufferIndex + 1 ) % 2; |
|
60 |
+} |
|
61 |
+ |
|
62 |
+void wurm(uint8_t length, uint8_t reverse) |
|
63 |
+{ |
|
64 |
+ for (int8_t frontPosition = reverse ? NUM_LEDS : 0; |
|
65 |
+ reverse ? frontPosition >= - length - 1 : frontPosition < NUM_LEDS + length; |
|
66 |
+ reverse ? --frontPosition : ++frontPosition) |
|
67 |
+ { |
|
68 |
+ for(uint8_t pos = 0; pos < NUM_LEDS; ++pos) |
|
69 |
+ { |
|
70 |
+ int8_t dist = abs(pos - frontPosition); |
|
71 |
+ uint8_t value = 0; |
|
72 |
+ if ( ((reverse && pos >= frontPosition) || |
|
73 |
+ (!reverse && pos <= frontPosition)) && |
|
74 |
+ dist < length) |
|
75 |
+ { |
|
76 |
+ value = MAX_TIME / (1 + 4 * dist); |
|
77 |
+ } |
|
78 |
+ LED(pos) = value; |
|
79 |
+ } |
|
80 |
+ swapBuffers(); |
|
81 |
+ _delay_us(20000); |
|
82 |
+ } |
|
83 |
+} |
|
84 |
+ |
|
85 |
+#define FIRST_SCANLINE 0 |
|
86 |
+#define LAST_SCANLINE 7 |
|
87 |
+ |
|
88 |
+void single_scanline_hori(uint8_t scanposition, uint8_t value) |
|
89 |
+{ |
|
90 |
+ switch(scanposition) |
|
91 |
+ { |
|
92 |
+ case 0: |
|
93 |
+ for (uint8_t i = 3; i <= 10; ++i) |
|
94 |
+ { |
|
95 |
+ LED_INDEX_FROM_MANUAL(i) = value; |
|
96 |
+ } |
|
97 |
+ break; |
|
98 |
+ case 1: |
|
99 |
+ LED_INDEX_FROM_MANUAL(2) = value; |
|
100 |
+ LED_INDEX_FROM_MANUAL(11) = value; |
|
101 |
+ LED_INDEX_FROM_MANUAL(32) = value; |
|
102 |
+ break; |
|
103 |
+ case 2: |
|
104 |
+ LED_INDEX_FROM_MANUAL(1) = value; |
|
105 |
+ LED_INDEX_FROM_MANUAL(31) = value; |
|
106 |
+ LED_INDEX_FROM_MANUAL(33) = value; |
|
107 |
+ LED_INDEX_FROM_MANUAL(12) = value; |
|
108 |
+ break; |
|
109 |
+ case 3: |
|
110 |
+ LED_INDEX_FROM_MANUAL(28) = value; |
|
111 |
+ LED_INDEX_FROM_MANUAL(29) = value; |
|
112 |
+ LED_INDEX_FROM_MANUAL(30) = value; |
|
113 |
+ LED_INDEX_FROM_MANUAL(34) = value; |
|
114 |
+ LED_INDEX_FROM_MANUAL(13) = value; |
|
115 |
+ LED_INDEX_FROM_MANUAL(42) = value; |
|
116 |
+ break; |
|
117 |
+ case 4: |
|
118 |
+ LED_INDEX_FROM_MANUAL(27) = value; |
|
119 |
+ LED_INDEX_FROM_MANUAL(41) = value; |
|
120 |
+ LED_INDEX_FROM_MANUAL(40) = value; |
|
121 |
+ LED_INDEX_FROM_MANUAL(35) = value; |
|
122 |
+ LED_INDEX_FROM_MANUAL(14) = value; |
|
123 |
+ break; |
|
124 |
+ case 5: |
|
125 |
+ LED_INDEX_FROM_MANUAL(26) = value; |
|
126 |
+ LED_INDEX_FROM_MANUAL(39) = value; |
|
127 |
+ LED_INDEX_FROM_MANUAL(36) = value; |
|
128 |
+ LED_INDEX_FROM_MANUAL(37) = value; |
|
129 |
+ LED_INDEX_FROM_MANUAL(15) = value; |
|
130 |
+ break; |
|
131 |
+ case 6: |
|
132 |
+ LED_INDEX_FROM_MANUAL(25) = value; |
|
133 |
+ LED_INDEX_FROM_MANUAL(38) = value; |
|
134 |
+ LED_INDEX_FROM_MANUAL(16) = value; |
|
135 |
+ break; |
|
136 |
+ case 7: |
|
137 |
+ for (uint8_t i = 17; i <= 24; ++i) |
|
138 |
+ { |
|
139 |
+ LED_INDEX_FROM_MANUAL(i) = value; |
|
140 |
+ } |
|
141 |
+ break; |
|
142 |
+ } |
|
143 |
+} |
|
144 |
+ |
|
145 |
+void single_scanline_vert(uint8_t scanposition, uint8_t value) |
|
146 |
+{ |
|
147 |
+ switch(scanposition) |
|
148 |
+ { |
|
149 |
+ case 0: |
|
150 |
+ for (uint8_t i = 10; i <= 17; ++i) |
|
151 |
+ { |
|
152 |
+ LED_INDEX_FROM_MANUAL(i) = value; |
|
153 |
+ } |
|
154 |
+ break; |
|
155 |
+ case 1: |
|
156 |
+ LED_INDEX_FROM_MANUAL(9) = value; |
|
157 |
+ LED_INDEX_FROM_MANUAL(34) = value; |
|
158 |
+ LED_INDEX_FROM_MANUAL(35) = value; |
|
159 |
+ LED_INDEX_FROM_MANUAL(36) = value; |
|
160 |
+ LED_INDEX_FROM_MANUAL(18) = value; |
|
161 |
+ break; |
|
162 |
+ case 2: |
|
163 |
+ LED_INDEX_FROM_MANUAL(8) = value; |
|
164 |
+ LED_INDEX_FROM_MANUAL(33) = value; |
|
165 |
+ LED_INDEX_FROM_MANUAL(42) = value; |
|
166 |
+ LED_INDEX_FROM_MANUAL(37) = value; |
|
167 |
+ LED_INDEX_FROM_MANUAL(19) = value; |
|
168 |
+ break; |
|
169 |
+ case 3: |
|
170 |
+ LED_INDEX_FROM_MANUAL(7) = value; |
|
171 |
+ LED_INDEX_FROM_MANUAL(32) = value; |
|
172 |
+ LED_INDEX_FROM_MANUAL(38) = value; |
|
173 |
+ LED_INDEX_FROM_MANUAL(20) = value; |
|
174 |
+ break; |
|
175 |
+ case 4: |
|
176 |
+ LED_INDEX_FROM_MANUAL(6) = value; |
|
177 |
+ LED_INDEX_FROM_MANUAL(31) = value; |
|
178 |
+ LED_INDEX_FROM_MANUAL(39) = value; |
|
179 |
+ LED_INDEX_FROM_MANUAL(21) = value; |
|
180 |
+ break; |
|
181 |
+ case 5: |
|
182 |
+ LED_INDEX_FROM_MANUAL(5) = value; |
|
183 |
+ LED_INDEX_FROM_MANUAL(30) = value; |
|
184 |
+ LED_INDEX_FROM_MANUAL(40) = value; |
|
185 |
+ LED_INDEX_FROM_MANUAL(22) = value; |
|
186 |
+ break; |
|
187 |
+ case 6: |
|
188 |
+ LED_INDEX_FROM_MANUAL(4) = value; |
|
189 |
+ LED_INDEX_FROM_MANUAL(29) = value; |
|
190 |
+ LED_INDEX_FROM_MANUAL(41) = value; |
|
191 |
+ LED_INDEX_FROM_MANUAL(23) = value; |
|
192 |
+ break; |
|
193 |
+ case 7: |
|
194 |
+ LED_INDEX_FROM_MANUAL(1) = value; |
|
195 |
+ LED_INDEX_FROM_MANUAL(2) = value; |
|
196 |
+ LED_INDEX_FROM_MANUAL(3) = value; |
|
197 |
+ for (uint8_t i = 24; i <= 28; ++i) |
|
198 |
+ { |
|
199 |
+ LED_INDEX_FROM_MANUAL(i) = value; |
|
200 |
+ } |
|
201 |
+ break; |
|
202 |
+ } |
|
203 |
+} |
|
204 |
+ |
|
205 |
+void scanline(uint8_t length, uint8_t horizontal, uint8_t reverse) |
|
206 |
+{ |
|
207 |
+ int8_t firstCenter = FIRST_SCANLINE - length + 1; |
|
208 |
+ int8_t lastCenter = LAST_SCANLINE + length - 1; |
|
209 |
+ for (int8_t centerPosition = reverse ? lastCenter : firstCenter; |
|
210 |
+ reverse ? centerPosition >= firstCenter : centerPosition <= lastCenter; |
|
211 |
+ reverse ? -- centerPosition : ++centerPosition) |
|
212 |
+ { |
|
213 |
+ for(int8_t linePos = FIRST_SCANLINE; linePos <= LAST_SCANLINE; ++linePos) |
|
214 |
+ { |
|
215 |
+ int8_t dist = abs(centerPosition - linePos); |
|
216 |
+ if (horizontal) |
|
217 |
+ { |
|
218 |
+ if (dist < length) |
|
219 |
+ { |
|
220 |
+ single_scanline_hori(linePos, MAX_TIME / (4*dist + 1)); |
|
221 |
+ } |
|
222 |
+ else |
|
223 |
+ { |
|
224 |
+ single_scanline_hori(linePos, 0); |
|
225 |
+ } |
|
226 |
+ } |
|
227 |
+ else |
|
228 |
+ { |
|
229 |
+ if (dist < length) |
|
230 |
+ { |
|
231 |
+ single_scanline_vert(linePos, MAX_TIME / (4*dist + 1)); |
|
232 |
+ } |
|
233 |
+ else |
|
234 |
+ { |
|
235 |
+ single_scanline_vert(linePos, 0); |
|
236 |
+ } |
|
237 |
+ |
|
238 |
+ } |
|
239 |
+ } |
|
240 |
+ |
|
241 |
+ swapBuffers(); |
|
242 |
+ _delay_us(30000); |
|
243 |
+ } |
|
244 |
+ |
|
245 |
+} |
|
246 |
+ |
|
247 |
+void blink() |
|
248 |
+{ |
|
249 |
+ for(int8_t pos = 0; pos < NUM_LEDS; ++pos) |
|
250 |
+ { |
|
251 |
+ LED(pos) = 0; |
|
252 |
+ } |
|
253 |
+ swapBuffers(); |
|
254 |
+ _delay_us(100000); |
|
255 |
+ |
|
256 |
+ for(int8_t pos = 0; pos < NUM_LEDS; ++pos) |
|
257 |
+ { |
|
258 |
+ LED(pos) = MAX_TIME; |
|
259 |
+ } |
|
260 |
+ swapBuffers(); |
|
261 |
+ _delay_us(100000); |
|
262 |
+} |
|
263 |
+ |
|
264 |
+#define ROT_SIZE 5 |
|
265 |
+void dimRotation() |
|
266 |
+{ |
|
267 |
+ for(uint8_t position = 0; position < ROT_SIZE-1; ++position) |
|
268 |
+ { |
|
269 |
+ for(uint8_t led = 0; led < NUM_LEDS; ++led) |
|
270 |
+ { |
|
271 |
+ uint8_t this_led = ((led + position) % NUM_LEDS); |
|
272 |
+ |
|
273 |
+ LED(this_led) = (led%(ROT_SIZE-1)) * (MAX_TIME/(ROT_SIZE-1)); |
|
274 |
+ } |
|
275 |
+ swapBuffers(); |
|
276 |
+ _delay_us(100000); |
|
277 |
+ } |
|
278 |
+} |
|
279 |
+ |
|
280 |
+int main(void) |
|
281 |
+{ |
|
282 |
+ // PA[01] to output, low |
|
283 |
+ PORTA = 0; |
|
284 |
+ DDRA = 0x03; |
|
285 |
+ |
|
286 |
+ // PB[0-6] to output, low - PB7 to input, pull-up enabled |
|
287 |
+ DDRB = 0x7F; |
|
288 |
+ PORTB = 0x80; |
|
289 |
+ |
|
290 |
+ // PD[0-5] to output, high - PD6 to input, pull-up enabled |
|
291 |
+ DDRD = 0x3F; |
|
292 |
+ PORTD = 0x7F; |
|
293 |
+ |
|
294 |
+ // set clock to 8 MHz |
|
295 |
+ CLKPR = (1<<CLKPCE); |
|
296 |
+ CLKPR = 0; |
|
297 |
+ |
|
298 |
+ TCCR1B |= (1 << WGM12); // Configure timer 1 for CTC mode |
|
299 |
+ |
|
300 |
+ TIMSK |= (1 << OCIE1A); // Enable CTC interrupt |
|
301 |
+ |
|
302 |
+ sei(); // Enable global interrupts |
|
303 |
+ |
|
304 |
+ OCR1A = 8; // Set CTC compare value to 1Hz at 1MHz AVR clock, with a prescaler of 64 |
|
305 |
+ |
|
306 |
+ TCCR1B |= ((1 << CS10) | (1 << CS11)); // Start timer at Fcpu/64 |
|
307 |
+ |
|
308 |
+ for(;;) |
|
309 |
+ { |
|
310 |
+ for (uint8_t length = 1; length <= 8; length += 2) |
|
311 |
+ { |
|
312 |
+ wurm(length, 0); |
|
313 |
+ wurm(length, 1); |
|
314 |
+ } |
|
315 |
+ |
|
316 |
+ |
|
317 |
+ for (int8_t horizontal = 1; horizontal >= 0; --horizontal) |
|
318 |
+ { |
|
319 |
+ for (uint8_t length = 1; length <= 6; ++length) |
|
320 |
+ { |
|
321 |
+ for (uint8_t reverse = 0; reverse <= 1; ++reverse) |
|
322 |
+ { |
|
323 |
+ scanline(length, horizontal, reverse); |
|
324 |
+ } |
|
325 |
+ } |
|
326 |
+ } |
|
327 |
+ |
|
328 |
+ blink(); |
|
329 |
+ blink(); |
|
330 |
+ blink(); |
|
331 |
+ for (uint8_t i = 1; i <= 8; ++i) |
|
332 |
+ { |
|
333 |
+ dimRotation(); |
|
334 |
+ } |
|
335 |
+ } |
|
336 |
+} |
... | ... |
@@ -0,0 +1,344 @@ |
1 |
+########################################################################## |
|
2 |
+# "THE ANY BEVERAGE-WARE LICENSE" (Revision 42 - based on beer-ware |
|
3 |
+# license): |
|
4 |
+# <dev@layer128.net> wrote this file. As long as you retain this notice |
|
5 |
+# you can do whatever you want with this stuff. If we meet some day, and |
|
6 |
+# you think this stuff is worth it, you can buy me a be(ve)er(age) in |
|
7 |
+# return. (I don't like beer much.) |
|
8 |
+# |
|
9 |
+# Matthias Kleemann |
|
10 |
+########################################################################## |
|
11 |
+ |
|
12 |
+########################################################################## |
|
13 |
+# The toolchain requires some variables set. |
|
14 |
+# |
|
15 |
+# AVR_MCU (default: atmega8) |
|
16 |
+# the type of AVR the application is built for |
|
17 |
+# AVR_L_FUSE (NO DEFAULT) |
|
18 |
+# the LOW fuse value for the MCU used |
|
19 |
+# AVR_H_FUSE (NO DEFAULT) |
|
20 |
+# the HIGH fuse value for the MCU used |
|
21 |
+# AVR_UPLOADTOOL (default: avrdude) |
|
22 |
+# the application used to upload to the MCU |
|
23 |
+# NOTE: The toolchain is currently quite specific about |
|
24 |
+# the commands used, so it needs tweaking. |
|
25 |
+# AVR_UPLOADTOOL_PORT (default: usb) |
|
26 |
+# the port used for the upload tool, e.g. usb |
|
27 |
+# AVR_PROGRAMMER (default: avrispmkII) |
|
28 |
+# the programmer hardware used, e.g. avrispmkII |
|
29 |
+########################################################################## |
|
30 |
+ |
|
31 |
+########################################################################## |
|
32 |
+# options |
|
33 |
+########################################################################## |
|
34 |
+option(WITH_MCU "Add the mCU type to the target file name." ON) |
|
35 |
+ |
|
36 |
+########################################################################## |
|
37 |
+# executables in use |
|
38 |
+########################################################################## |
|
39 |
+find_program(AVR_CC avr-gcc) |
|
40 |
+find_program(AVR_CXX avr-g++) |
|
41 |
+find_program(AVR_OBJCOPY avr-objcopy) |
|
42 |
+find_program(AVR_SIZE_TOOL avr-size) |
|
43 |
+find_program(AVR_OBJDUMP avr-objdump) |
|
44 |
+ |
|
45 |
+########################################################################## |
|
46 |
+# toolchain starts with defining mandatory variables |
|
47 |
+########################################################################## |
|
48 |
+set(CMAKE_SYSTEM_NAME Generic) |
|
49 |
+set(CMAKE_SYSTEM_PROCESSOR avr) |
|
50 |
+set(CMAKE_C_COMPILER ${AVR_CC}) |
|
51 |
+set(CMAKE_CXX_COMPILER ${AVR_CXX}) |
|
52 |
+ |
|
53 |
+########################################################################## |
|
54 |
+# some necessary tools and variables for AVR builds, which may not |
|
55 |
+# defined yet |
|
56 |
+# - AVR_UPLOADTOOL |
|
57 |
+# - AVR_UPLOADTOOL_PORT |
|
58 |
+# - AVR_PROGRAMMER |
|
59 |
+# - AVR_MCU |
|
60 |
+# - AVR_SIZE_ARGS |
|
61 |
+########################################################################## |
|
62 |
+ |
|
63 |
+# default upload tool |
|
64 |
+if(NOT AVR_UPLOADTOOL) |
|
65 |
+ set( |
|
66 |
+ AVR_UPLOADTOOL avrdude |
|
67 |
+ CACHE STRING "Set default upload tool: avrdude" |
|
68 |
+ ) |
|
69 |
+ find_program(AVR_UPLOADTOOL avrdude) |
|
70 |
+endif(NOT AVR_UPLOADTOOL) |
|
71 |
+ |
|
72 |
+# default upload tool port |
|
73 |
+if(NOT AVR_UPLOADTOOL_PORT) |
|
74 |
+ set( |
|
75 |
+ AVR_UPLOADTOOL_PORT usb |
|
76 |
+ CACHE STRING "Set default upload tool port: usb" |
|
77 |
+ ) |
|
78 |
+endif(NOT AVR_UPLOADTOOL_PORT) |
|
79 |
+ |
|
80 |
+# default programmer (hardware) |
|
81 |
+if(NOT AVR_PROGRAMMER) |
|
82 |
+ set( |
|
83 |
+ AVR_PROGRAMMER avrispmkII |
|
84 |
+ CACHE STRING "Set default programmer hardware model: avrispmkII" |
|
85 |
+ ) |
|
86 |
+endif(NOT AVR_PROGRAMMER) |
|
87 |
+ |
|
88 |
+# default MCU (chip) |
|
89 |
+if(NOT AVR_MCU) |
|
90 |
+ set( |
|
91 |
+ AVR_MCU atmega8 |
|
92 |
+ CACHE STRING "Set default MCU: atmega8 (see 'avr-gcc --target-help' for valid values)" |
|
93 |
+ ) |
|
94 |
+endif(NOT AVR_MCU) |
|
95 |
+ |
|
96 |
+#default avr-size args |
|
97 |
+if(NOT AVR_SIZE_ARGS) |
|
98 |
+ if(APPLE) |
|
99 |
+ set(AVR_SIZE_ARGS -B) |
|
100 |
+ else(APPLE) |
|
101 |
+ set(AVR_SIZE_ARGS -C;--mcu=${AVR_MCU}) |
|
102 |
+ endif(APPLE) |
|
103 |
+endif(NOT AVR_SIZE_ARGS) |
|
104 |
+ |
|
105 |
+########################################################################## |
|
106 |
+# check build types: |
|
107 |
+# - Debug |
|
108 |
+# - Release |
|
109 |
+# - RelWithDebInfo |
|
110 |
+# |
|
111 |
+# Release is chosen, because of some optimized functions in the |
|
112 |
+# AVR toolchain, e.g. _delay_ms(). |
|
113 |
+########################################################################## |
|
114 |
+if(NOT ((CMAKE_BUILD_TYPE MATCHES Release) OR |
|
115 |
+ (CMAKE_BUILD_TYPE MATCHES RelWithDebInfo) OR |
|
116 |
+ (CMAKE_BUILD_TYPE MATCHES Debug) OR |
|
117 |
+ (CMAKE_BUILD_TYPE MATCHES MinSizeRel))) |
|
118 |
+ set( |
|
119 |
+ CMAKE_BUILD_TYPE Release |
|
120 |
+ CACHE STRING "Choose cmake build type: Debug Release RelWithDebInfo MinSizeRel" |
|
121 |
+ FORCE |
|
122 |
+ ) |
|
123 |
+endif(NOT ((CMAKE_BUILD_TYPE MATCHES Release) OR |
|
124 |
+ (CMAKE_BUILD_TYPE MATCHES RelWithDebInfo) OR |
|
125 |
+ (CMAKE_BUILD_TYPE MATCHES Debug) OR |
|
126 |
+ (CMAKE_BUILD_TYPE MATCHES MinSizeRel))) |
|
127 |
+ |
|
128 |
+########################################################################## |
|
129 |
+ |
|
130 |
+########################################################################## |
|
131 |
+# target file name add-on |
|
132 |
+########################################################################## |
|
133 |
+if(WITH_MCU) |
|
134 |
+ set(MCU_TYPE_FOR_FILENAME "-${AVR_MCU}") |
|
135 |
+else(WITH_MCU) |
|
136 |
+ set(MCU_TYPE_FOR_FILENAME "") |
|
137 |
+endif(WITH_MCU) |
|
138 |
+ |
|
139 |
+########################################################################## |
|
140 |
+# add_avr_executable |
|
141 |
+# - IN_VAR: EXECUTABLE_NAME |
|
142 |
+# |
|
143 |
+# Creates targets and dependencies for AVR toolchain, building an |
|
144 |
+# executable. Calls add_executable with ELF file as target name, so |
|
145 |
+# any link dependencies need to be using that target, e.g. for |
|
146 |
+# target_link_libraries(<EXECUTABLE_NAME>-${AVR_MCU}.elf ...). |
|
147 |
+########################################################################## |
|
148 |
+function(add_avr_executable EXECUTABLE_NAME) |
|
149 |
+ if(NOT ARGN) |
|
150 |
+ message(FATAL_ERROR "No source files given for ${EXECUTABLE_NAME}.") |
|
151 |
+ endif(NOT ARGN) |
|
152 |
+ |
|
153 |
+ # set file names |
|
154 |
+ set(elf_file ${EXECUTABLE_NAME}${MCU_TYPE_FOR_FILENAME}.elf) |
|
155 |
+ set(hex_file ${EXECUTABLE_NAME}${MCU_TYPE_FOR_FILENAME}.hex) |
|
156 |
+ set(map_file ${EXECUTABLE_NAME}${MCU_TYPE_FOR_FILENAME}.map) |
|
157 |
+ set(eeprom_image ${EXECUTABLE_NAME}${MCU_TYPE_FOR_FILENAME}-eeprom.hex) |
|
158 |
+ |
|
159 |
+ # elf file |
|
160 |
+ add_executable(${elf_file} EXCLUDE_FROM_ALL ${ARGN}) |
|
161 |
+ |
|
162 |
+ set_target_properties( |
|
163 |
+ ${elf_file} |
|
164 |
+ PROPERTIES |
|
165 |
+ COMPILE_FLAGS "-mmcu=${AVR_MCU}" |
|
166 |
+ LINK_FLAGS "-mmcu=${AVR_MCU} -Wl,--gc-sections -mrelax -Wl,-Map,${map_file}" |
|
167 |
+ ) |
|
168 |
+ |
|
169 |
+ add_custom_command( |
|
170 |
+ OUTPUT ${hex_file} |
|
171 |
+ COMMAND |
|
172 |
+ ${AVR_OBJCOPY} -j .text -j .data -O ihex ${elf_file} ${hex_file} |
|
173 |
+ COMMAND |
|
174 |
+ ${AVR_SIZE_TOOL} ${AVR_SIZE_ARGS} ${elf_file} |
|
175 |
+ DEPENDS ${elf_file} |
|
176 |
+ ) |
|
177 |
+ |
|
178 |
+ # eeprom |
|
179 |
+ add_custom_command( |
|
180 |
+ OUTPUT ${eeprom_image} |
|
181 |
+ COMMAND |
|
182 |
+ ${AVR_OBJCOPY} -j .eeprom --set-section-flags=.eeprom=alloc,load |
|
183 |
+ --change-section-lma .eeprom=0 --no-change-warnings |
|
184 |
+ -O ihex ${elf_file} ${eeprom_image} |
|
185 |
+ DEPENDS ${elf_file} |
|
186 |
+ ) |
|
187 |
+ |
|
188 |
+ add_custom_target( |
|
189 |
+ ${EXECUTABLE_NAME} |
|
190 |
+ ALL |
|
191 |
+ DEPENDS ${hex_file} ${eeprom_image} |
|
192 |
+ ) |
|
193 |
+ |
|
194 |
+ set_target_properties( |
|
195 |
+ ${EXECUTABLE_NAME} |
|
196 |
+ PROPERTIES |
|
197 |
+ OUTPUT_NAME "${elf_file}" |
|
198 |
+ ) |
|
199 |
+ |
|
200 |
+ # clean |
|
201 |
+ get_directory_property(clean_files ADDITIONAL_MAKE_CLEAN_FILES) |
|
202 |
+ set_directory_properties( |
|
203 |
+ PROPERTIES |
|
204 |
+ ADDITIONAL_MAKE_CLEAN_FILES "${map_file}" |
|
205 |
+ ) |
|
206 |
+ |
|
207 |
+ # upload - with avrdude |
|
208 |
+ add_custom_target( |
|
209 |
+ upload_${EXECUTABLE_NAME} |
|
210 |
+ ${AVR_UPLOADTOOL} -p ${AVR_MCU} -c ${AVR_PROGRAMMER} ${AVR_UPLOADTOOL_OPTIONS} |
|
211 |
+ -U flash:w:${hex_file} |
|
212 |
+ -P ${AVR_UPLOADTOOL_PORT} |
|
213 |
+ DEPENDS ${hex_file} |
|
214 |
+ COMMENT "Uploading ${hex_file} to ${AVR_MCU} using ${AVR_PROGRAMMER}" |
|
215 |
+ ) |
|
216 |
+ |
|
217 |
+ # upload eeprom only - with avrdude |
|
218 |
+ # see also bug http://savannah.nongnu.org/bugs/?40142 |
|
219 |
+ add_custom_target( |
|
220 |
+ upload_eeprom_${EXECUTABLE_NAME} |
|
221 |
+ ${AVR_UPLOADTOOL} -p ${AVR_MCU} -c ${AVR_PROGRAMMER} ${AVR_UPLOADTOOL_OPTIONS} |
|
222 |
+ -U eeprom:w:${eeprom_image} |
|
223 |
+ -P ${AVR_UPLOADTOOL_PORT} |
|
224 |
+ DEPENDS ${eeprom_image} |
|
225 |
+ COMMENT "Uploading ${eeprom_image} to ${AVR_MCU} using ${AVR_PROGRAMMER}" |
|
226 |
+ ) |
|
227 |
+ |
|
228 |
+ # get status |
|
229 |
+ add_custom_target( |
|
230 |
+ get_status_${EXECUTABLE_NAME} |
|
231 |
+ ${AVR_UPLOADTOOL} -p ${AVR_MCU} -c ${AVR_PROGRAMMER} -P ${AVR_UPLOADTOOL_PORT} -n -v |
|
232 |
+ COMMENT "Get status from ${AVR_MCU}" |
|
233 |
+ ) |
|
234 |
+ |
|
235 |
+ # get fuses |
|
236 |
+ add_custom_target( |
|
237 |
+ get_fuses_${EXECUTABLE_NAME} |
|
238 |
+ ${AVR_UPLOADTOOL} -p ${AVR_MCU} -c ${AVR_PROGRAMMER} -P ${AVR_UPLOADTOOL_PORT} -n |
|
239 |
+ -U lfuse:r:-:b |
|
240 |
+ -U hfuse:r:-:b |
|
241 |
+ COMMENT "Get fuses from ${AVR_MCU}" |
|
242 |
+ ) |
|
243 |
+ |
|
244 |
+ # set fuses |
|
245 |
+ add_custom_target( |
|
246 |
+ set_fuses_${EXECUTABLE_NAME} |
|
247 |
+ ${AVR_UPLOADTOOL} -p ${AVR_MCU} -c ${AVR_PROGRAMMER} -P ${AVR_UPLOADTOOL_PORT} |
|
248 |
+ -U lfuse:w:${AVR_L_FUSE}:m |
|
249 |
+ -U hfuse:w:${AVR_H_FUSE}:m |
|
250 |
+ COMMENT "Setup: High Fuse: ${AVR_H_FUSE} Low Fuse: ${AVR_L_FUSE}" |
|
251 |
+ ) |
|
252 |
+ |
|
253 |
+ # get oscillator calibration |
|
254 |
+ add_custom_target( |
|
255 |
+ get_calibration_${EXECUTABLE_NAME} |
|
256 |
+ ${AVR_UPLOADTOOL} -p ${AVR_MCU} -c ${AVR_PROGRAMMER} -P ${AVR_UPLOADTOOL_PORT} |
|
257 |
+ -U calibration:r:${AVR_MCU}_calib.tmp:r |
|
258 |
+ COMMENT "Write calibration status of internal oscillator to ${AVR_MCU}_calib.tmp." |
|
259 |
+ ) |
|
260 |
+ |
|
261 |
+ # set oscillator calibration |
|
262 |
+ add_custom_target( |
|
263 |
+ set_calibration_${EXECUTABLE_NAME} |
|
264 |
+ ${AVR_UPLOADTOOL} -p ${AVR_MCU} -c ${AVR_PROGRAMMER} -P ${AVR_UPLOADTOOL_PORT} |
|
265 |
+ -U calibration:w:${AVR_MCU}_calib.hex |
|
266 |
+ COMMENT "Program calibration status of internal oscillator from ${AVR_MCU}_calib.hex." |
|
267 |
+ ) |
|
268 |
+ |
|
269 |
+ # disassemble |
|
270 |
+ add_custom_target( |
|
271 |
+ disassemble_${EXECUTABLE_NAME} |
|
272 |
+ ${AVR_OBJDUMP} -h -S ${elf_file} > ${EXECUTABLE_NAME}.lst |
|
273 |
+ DEPENDS ${elf_file} |
|
274 |
+ ) |
|
275 |
+ |
|
276 |
+endfunction(add_avr_executable) |
|
277 |
+ |
|
278 |
+########################################################################## |
|
279 |
+# add_avr_library |
|
280 |
+# - IN_VAR: LIBRARY_NAME |
|
281 |
+# |
|
282 |
+# Calls add_library with an optionally concatenated name |
|
283 |
+# <LIBRARY_NAME>${MCU_TYPE_FOR_FILENAME}. |
|
284 |
+# This needs to be used for linking against the library, e.g. calling |
|
285 |
+# target_link_libraries(...). |
|
286 |
+########################################################################## |
|
287 |
+function(add_avr_library LIBRARY_NAME) |
|
288 |
+ if(NOT ARGN) |
|
289 |
+ message(FATAL_ERROR "No source files given for ${LIBRARY_NAME}.") |
|
290 |
+ endif(NOT ARGN) |
|
291 |
+ |
|
292 |
+ set(lib_file ${LIBRARY_NAME}${MCU_TYPE_FOR_FILENAME}) |
|
293 |
+ |
|
294 |
+ add_library(${lib_file} STATIC ${ARGN}) |
|
295 |
+ |
|
296 |
+ set_target_properties( |
|
297 |
+ ${lib_file} |
|
298 |
+ PROPERTIES |
|
299 |
+ COMPILE_FLAGS "-mmcu=${AVR_MCU}" |
|
300 |
+ OUTPUT_NAME "${lib_file}" |
|
301 |
+ ) |
|
302 |
+ |
|
303 |
+ if(NOT TARGET ${LIBRARY_NAME}) |
|
304 |
+ add_custom_target( |
|
305 |
+ ${LIBRARY_NAME} |
|
306 |
+ ALL |
|
307 |
+ DEPENDS ${lib_file} |
|
308 |
+ ) |
|
309 |
+ |
|
310 |
+ set_target_properties( |
|
311 |
+ ${LIBRARY_NAME} |
|
312 |
+ PROPERTIES |
|
313 |
+ OUTPUT_NAME "${lib_file}" |
|
314 |
+ ) |
|
315 |
+ endif(NOT TARGET ${LIBRARY_NAME}) |
|
316 |
+ |
|
317 |
+endfunction(add_avr_library) |
|
318 |
+ |
|
319 |
+########################################################################## |
|
320 |
+# avr_target_link_libraries |
|
321 |
+# - IN_VAR: EXECUTABLE_TARGET |
|
322 |
+# - ARGN : targets and files to link to |
|
323 |
+# |
|
324 |
+# Calls target_link_libraries with AVR target names (concatenation, |
|
325 |
+# extensions and so on. |
|
326 |
+########################################################################## |
|
327 |
+function(avr_target_link_libraries EXECUTABLE_TARGET) |
|
328 |
+ if(NOT ARGN) |
|
329 |
+ message(FATAL_ERROR "Nothing to link to ${EXECUTABLE_TARGET}.") |
|
330 |
+ endif(NOT ARGN) |
|
331 |
+ |
|
332 |
+ get_target_property(TARGET_LIST ${EXECUTABLE_TARGET} OUTPUT_NAME) |
|
333 |
+ |
|
334 |
+ foreach(TGT ${ARGN}) |
|
335 |
+ if(TARGET ${TGT}) |
|
336 |
+ get_target_property(ARG_NAME ${TGT} OUTPUT_NAME) |
|
337 |
+ list(APPEND TARGET_LIST ${ARG_NAME}) |
|
338 |
+ else(TARGET ${TGT}) |
|
339 |
+ list(APPEND NON_TARGET_LIST ${TGT}) |
|
340 |
+ endif(TARGET ${TGT}) |
|
341 |
+ endforeach(TGT ${ARGN}) |
|
342 |
+ |
|
343 |
+ target_link_libraries(${TARGET_LIST} ${NON_TARGET_LIST}) |
|
344 |
+endfunction(avr_target_link_libraries EXECUTABLE_TARGET) |
... | ... |
@@ -0,0 +1,482 @@ |
1 |
+;*************************************************************************** |
|
2 |
+;* A P P L I C A T I O N N O T E F O R T H E A V R F A M I L Y |
|
3 |
+;* |
|
4 |
+;* Number :AVR000 |
|
5 |
+;* File Name :"tn2313def.inc" |
|
6 |
+;* Title :Register/Bit Definitions for the ATtiny2313 |
|
7 |
+;* Date :03.06.17 |
|
8 |
+;* Version :1.00 |
|
9 |
+;* Support E-mail :avr@atmel.com |
|
10 |
+;* Target MCU :ATtiny2313 |
|
11 |
+;* |
|
12 |
+;* DESCRIPTION |
|
13 |
+;* When including this file in the assembly program file, all I/O register |
|
14 |
+;* names and I/O register bit names appearing in the data book can be used. |
|
15 |
+;* In addition, the two registers forming the data pointer Z have been |
|
16 |
+;* assigned names ZL - ZH. |
|
17 |
+;* |
|
18 |
+;* The Register names are represented by their hexadecimal address. |
|
19 |
+;* |
|
20 |
+;* The Register Bit names are represented by their bit number (0-7). |
|
21 |
+;* |
|
22 |
+;* Please observe the difference in using the bit names with instructions |
|
23 |
+;* such as "sbr"/"cbr" (set/clear bit in register) and "sbrs"/"sbrc" |
|
24 |
+;* (skip if bit in register set/cleared). The following example illustrates |
|
25 |
+;* this: |
|
26 |
+;* |
|
27 |
+;* in r16,PORTB ;read PORTB latch |
|
28 |
+;* sbr r16,(1<<PB6)+(1<<PB5) ;set PB6 and PB5 (use masks, not bit#) |
|
29 |
+;* out PORTB,r16 ;output to PORTB |
|
30 |
+;* |
|
31 |
+;* in r16,TIFR ;read the Timer Interrupt Flag Register |
|
32 |
+;* sbrc r16,TOV0 ;test the overflow flag (use bit#) |
|
33 |
+;* rjmp TOV0_is_set ;jump if set |
|
34 |
+;* ... ;otherwise do something else |
|
35 |
+;* |
|
36 |
+;*************************************************************************** |
|
37 |
+ |
|
38 |
+;***** Specify Device |
|
39 |
+.device ATtiny2313 |
|
40 |
+ |
|
41 |
+ |
|
42 |
+;***************************************************************************** |
|
43 |
+; I/O Register Definitions |
|
44 |
+;***************************************************************************** |
|
45 |
+ |
|
46 |
+.equ SREG = 0x3F |
|
47 |
+.equ SPL = 0x3D |
|
48 |
+.equ OCR0B = 0x3C |
|
49 |
+.equ GIMSK = 0x3B |
|
50 |
+.equ EIFR = 0x3A |
|
51 |
+.equ GIFR = 0x3A ; for compatibility purpose |
|
52 |
+.equ TIMSK = 0x39 |
|
53 |
+.equ TIFR = 0x38 |
|
54 |
+.equ SPMCSR = 0x37 |
|
55 |
+.equ OCR0A = 0x36 |
|
56 |
+.equ MCUCR = 0x35 |
|
57 |
+.equ MCUSR = 0x34 |
|
58 |
+.equ TCCR0B = 0x33 |
|
59 |
+.equ TCCR0 = 0x33 ; for compatibility purpose |
|
60 |
+.equ TCNT0 = 0x32 |
|
61 |
+.equ OSCCAL = 0x31 |
|
62 |
+.equ TCCR0A = 0x30 |
|
63 |
+.equ TCCR1A = 0x2F |
|
64 |
+.equ TCCR1B = 0x2E |
|
65 |
+.equ TCNT1H = 0x2D |
|
66 |
+.equ TCNT1L = 0x2C |
|
67 |
+.equ OCR1AH = 0x2B |
|
68 |
+.equ OCR1AL = 0x2A |
|
69 |
+.equ OCR1BH = 0x29 |
|
70 |
+.equ OCR1BL = 0x28 |
|
71 |
+.equ CLKPR = 0x26 |
|
72 |
+.equ ICR1H = 0x25 |
|
73 |
+.equ ICR1L = 0x24 |
|
74 |
+.equ SFIOR = 0x23 |
|
75 |
+.equ TCCR1C = 0x22 |
|
76 |
+.equ WDTCR = 0x21 |
|
77 |
+.equ PCMSK = 0x20 |
|
78 |
+.equ EEAR = 0x1E ; for compatibility purpose |
|
79 |
+.equ EEARL = 0x1E |
|
80 |
+.equ EEDR = 0x1D |
|
81 |
+.equ EECR = 0x1C |
|
82 |
+.equ PORTA = 0x1B |
|
83 |
+.equ DDRA = 0x1A |
|
84 |
+.equ PINA = 0x19 |
|
85 |
+.equ PORTB = 0x18 |
|
86 |
+.equ DDRB = 0x17 |
|
87 |
+.equ PINB = 0x16 |
|
88 |
+.equ GPIOR2 = 0x15 |
|
89 |
+.equ GPIOR1 = 0x14 |
|
90 |
+.equ GPIOR0 = 0x13 |
|
91 |
+.equ PORTD = 0x12 |
|
92 |
+.equ DDRD = 0x11 |
|
93 |
+.equ PIND = 0x10 |
|
94 |
+.equ USIDR = 0x0F |
|
95 |
+.equ USISR = 0x0E |
|
96 |
+.equ USICR = 0x0D |
|
97 |
+.equ UDR = 0x0C |
|
98 |
+.equ UCSRA = 0x0B |
|
99 |
+.equ USR = 0x0B ; for compatibility purpose |
|
100 |
+.equ UCSRB = 0x0A |
|
101 |
+.equ UCR = 0x0A ; for compatibility purpose |
|
102 |
+.equ UBRRL = 0x09 |
|
103 |
+.equ UBRR = 0x09 ; for compatibility purpose |
|
104 |
+.equ ACSR = 0x08 |
|
105 |
+.equ UCSRC = 0x03 |
|
106 |
+.equ UBRRH = 0x02 |
|
107 |
+.equ DIDR = 0x01 |
|
108 |
+ |
|
109 |
+ |
|
110 |
+;***************************************************************************** |
|
111 |
+; Bit Definitions |
|
112 |
+;***************************************************************************** |
|
113 |
+ |
|
114 |
+;***** SREG ******* |
|
115 |
+.equ I = 7 |
|
116 |
+.equ T = 6 |
|
117 |
+.equ H = 5 |
|
118 |
+.equ S = 4 |
|
119 |
+.equ V = 3 |
|
120 |
+.equ N = 2 |
|
121 |
+;.equ Z = 1 |
|
122 |
+.equ C = 0 |
|
123 |
+ |
|
124 |
+;***** SPL ******** |
|
125 |
+.equ SP7 = 7 |
|
126 |
+.equ SP6 = 6 |
|
127 |
+.equ SP5 = 5 |
|
128 |
+.equ SP4 = 4 |
|
129 |
+.equ SP3 = 3 |
|
130 |
+.equ SP2 = 2 |
|
131 |
+.equ SP1 = 1 |
|
132 |
+.equ SP0 = 0 |
|
133 |
+ |
|
134 |
+;***** GIMSK ****** |
|
135 |
+.equ INT1 = 7 |
|
136 |
+.equ INT0 = 6 |
|
137 |
+.equ PCIE = 5 |
|
138 |
+ |
|
139 |
+;***** EIFR ******* |
|
140 |
+.equ INTF1 = 7 |
|
141 |
+.equ INTF0 = 6 |
|
142 |
+.equ PCIF = 5 |
|
143 |
+ |
|
144 |
+;***** TIMSK ****** |
|
145 |
+.equ TOIE1 = 7 |
|
146 |
+.equ OCIE1A = 6 |
|
147 |
+.equ OCIE1B = 5 |
|
148 |
+.equ ICIE1 = 3 |
|
149 |
+.equ OCIE0B = 2 |
|
150 |
+.equ TOIE0 = 1 |
|
151 |
+.equ OCIE0A = 0 |
|
152 |
+.equ TICIE = 3 ; for compatibility purpose |
|
153 |
+ |
|
154 |
+;***** TIFR ******* |
|
155 |
+.equ TOV1 = 7 |
|
156 |
+.equ OCF1A = 6 |
|
157 |
+.equ OCF1B = 5 |
|
158 |
+.equ ICF1 = 3 |
|
159 |
+.equ OCF0B = 2 |
|
160 |
+.equ TOV0 = 1 |
|
161 |
+.equ OCF0A = 0 |
|
162 |
+ |
|
163 |
+;***** SPMCSR ***** |
|
164 |
+.equ CTPB = 4 |
|
165 |
+.equ RFLB = 3 |
|
166 |
+.equ PGWRT = 2 |
|
167 |
+.equ PGERS = 1 |
|
168 |
+.equ SPMEN = 0 |
|
169 |
+ |
|
170 |
+;***** MCUCR ****** |
|
171 |
+.equ PUD = 7 |
|
172 |
+.equ SM1 = 6 |
|
173 |
+.equ SE = 5 |
|
174 |
+.equ SM0 = 4 |
|
175 |
+.equ ISC11 = 3 |
|
176 |
+.equ ISC10 = 2 |
|
177 |
+.equ ISC01 = 1 |
|
178 |
+.equ ISC00 = 0 |
|
179 |
+.equ SM = 4 ; for compatibility purpose |
|
180 |
+ |
|
181 |
+;***** MCUSR ****** |
|
182 |
+.equ WDRF = 3 |
|
183 |
+.equ BORF = 2 |
|
184 |
+.equ EXTRF = 1 |
|
185 |
+.equ PORF = 0 |
|
186 |
+ |
|
187 |
+;***** TCCR0B ***** |
|
188 |
+.equ FOC0A = 7 |
|
189 |
+.equ FOC0B = 6 |
|
190 |
+.equ WGM02 = 3 |
|
191 |
+.equ CS02 = 2 |
|
192 |
+.equ CS01 = 1 |
|
193 |
+.equ CS00 = 0 |
|
194 |
+ |
|
195 |
+;***** OSCCAL ***** |
|
196 |
+.equ CAL6 = 6 |
|
197 |
+.equ CAL5 = 5 |
|
198 |
+.equ CAL4 = 4 |
|
199 |
+.equ CAL3 = 3 |
|
200 |
+.equ CAL2 = 2 |
|
201 |
+.equ CAL1 = 1 |
|
202 |
+.equ CAL0 = 0 |
|
203 |
+ |
|
204 |
+;***** TCCR0A ***** |
|
205 |
+.equ COM0A1 = 7 |
|
206 |
+.equ COM0A0 = 6 |
|
207 |
+.equ COM0B1 = 5 |
|
208 |
+.equ COM0B0 = 4 |
|
209 |
+.equ WGM01 = 1 |
|
210 |
+.equ WGM00 = 0 |
|
211 |
+ |
|
212 |
+;***** TCCR1A ***** |
|
213 |
+.equ COM1A1 = 7 |
|
214 |
+.equ COM1A0 = 6 |
|
215 |
+.equ COM1B1 = 5 |
|
216 |
+.equ COM1B0 = 4 |
|
217 |
+.equ WGM11 = 1 |
|
218 |
+.equ WGM10 = 0 |
|
219 |
+.equ PWM11 = 1 ; for compatibility purpose |
|
220 |
+.equ PWM10 = 0 ; for compatibility purpose |
|
221 |
+ |
|
222 |
+;***** TCCR1B ***** |
|
223 |
+.equ ICNC1 = 7 |
|
224 |
+.equ ICES1 = 6 |
|
225 |
+.equ WGM13 = 4 |
|
226 |
+.equ WGM12 = 3 |
|
227 |
+.equ CS12 = 2 |
|
228 |
+.equ CS11 = 1 |
|
229 |
+.equ CS10 = 0 |
|
230 |
+.equ CTC1 = 3 ; for compatibility purpose |
|
231 |
+ |
|
232 |
+;***** CLKPR ****** |
|
233 |
+.equ CLKPCE = 7 |
|
234 |
+.equ CLKPS3 = 3 |
|
235 |
+.equ CLKPS2 = 2 |
|
236 |
+.equ CLKPS1 = 1 |
|
237 |
+.equ CLKPS0 = 0 |
|
238 |
+ |
|
239 |
+;***** SFIOR ****** |
|
240 |
+.equ PSR10 = 0 |
|
241 |
+ |
|
242 |
+;***** TCCR1C ***** |
|
243 |
+.equ FOC1A = 7 |
|
244 |
+.equ FOC1B = 6 |
|
245 |
+ |
|
246 |
+;***** WDTCSR ***** |
|
247 |
+.equ WDIF = 7 |
|
248 |
+.equ WDIE = 6 |
|
249 |
+.equ WDP3 = 5 |
|
250 |
+.equ WDCE = 4 |
|
251 |
+.equ WDE = 3 |
|
252 |
+.equ WDP2 = 2 |
|
253 |
+.equ WDP1 = 1 |
|
254 |
+.equ WDP0 = 0 |
|
255 |
+.equ WDTOE = 4 |
|
256 |
+ |
|
257 |
+;***** PCMSK ****** |
|
258 |
+.equ PCINT7 = 7 |
|
259 |
+.equ PCINT6 = 6 |
|
260 |
+.equ PCINT5 = 5 |
|
261 |
+.equ PCINT4 = 4 |
|
262 |
+.equ PCINT3 = 3 |
|
263 |
+.equ PCINT2 = 2 |
|
264 |
+.equ PCINT1 = 1 |
|
265 |
+.equ PCINT0 = 0 |
|
266 |
+ |
|
267 |
+;***** EECR ******* |
|
268 |
+.equ EEPM1 = 5 |
|
269 |
+.equ EEPM0 = 4 |
|
270 |
+.equ EERIE = 3 |
|
271 |
+.equ EEMPE = 2 |
|
272 |
+.equ EEPE = 1 |
|
273 |
+.equ EERE = 0 |
|
274 |
+; Kept for backward compatibility |
|
275 |
+.equ EEMWE = 2 |
|
276 |
+.equ EEWE = 1 |
|
277 |
+ |
|
278 |
+ |
|
279 |
+;***** PORTA ****** |
|
280 |
+.equ PORTA2 = 2 |
|
281 |
+.equ PORTA1 = 1 |
|
282 |
+.equ PORTA0 = 0 |
|
283 |
+ |
|
284 |
+;***** DDRA ******* |
|
285 |
+.equ DDA2 = 2 |
|
286 |
+.equ DDA1 = 1 |
|
287 |
+.equ DDA0 = 0 |
|
288 |
+ |
|
289 |
+;***** PINA ******* |
|
290 |
+.equ PINA2 = 2 |
|
291 |
+.equ PINA1 = 1 |
|
292 |
+.equ PINA0 = 0 |
|
293 |
+ |
|
294 |
+;***** PORTB ****** |
|
295 |
+.equ PORTB7 = 7 |
|
296 |
+.equ PORTB6 = 6 |
|
297 |
+.equ PORTB5 = 5 |
|
298 |
+.equ PORTB4 = 4 |
|
299 |
+.equ PORTB3 = 3 |
|
300 |
+.equ PORTB2 = 2 |
|
301 |
+.equ PORTB1 = 1 |
|
302 |
+.equ PORTB0 = 0 |
|
303 |
+ |
|
304 |
+;***** DDRB ******* |
|
305 |
+.equ DDB7 = 7 |
|
306 |
+.equ DDB6 = 6 |
|
307 |
+.equ DDB5 = 5 |
|
308 |
+.equ DDB4 = 4 |
|
309 |
+.equ DDB3 = 3 |
|
310 |
+.equ DDB2 = 2 |
|
311 |
+.equ DDB1 = 1 |
|
312 |
+.equ DDB0 = 0 |
|
313 |
+ |
|
314 |
+;***** PINB ******* |
|
315 |
+.equ PINB7 = 7 |
|
316 |
+.equ PINB6 = 6 |
|
317 |
+.equ PINB5 = 5 |
|
318 |
+.equ PINB4 = 4 |
|
319 |
+.equ PINB3 = 3 |
|
320 |
+.equ PINB2 = 2 |
|
321 |
+.equ PINB1 = 1 |
|
322 |
+.equ PINB0 = 0 |
|
323 |
+ |
|
324 |
+;***** PORTD ****** |
|
325 |
+.equ PORTD6 = 6 |
|
326 |
+.equ PORTD5 = 5 |
|
327 |
+.equ PORTD4 = 4 |
|
328 |
+.equ PORTD3 = 3 |
|
329 |
+.equ PORTD2 = 2 |
|
330 |
+.equ PORTD1 = 1 |
|
331 |
+.equ PORTD0 = 0 |
|
332 |
+ |
|
333 |
+;***** DDRD ******* |
|
334 |
+.equ DDD6 = 6 |
|
335 |
+.equ DDD5 = 5 |
|
336 |
+.equ DDD4 = 4 |
|
337 |
+.equ DDD3 = 3 |
|
338 |
+.equ DDD2 = 2 |
|
339 |
+.equ DDD1 = 1 |
|
340 |
+.equ DDD0 = 0 |
|
341 |
+ |
|
342 |
+;***** PIND ******* |
|
343 |
+.equ PIND6 = 6 |
|
344 |
+.equ PIND5 = 5 |
|
345 |
+.equ PIND4 = 4 |
|
346 |
+.equ PIND3 = 3 |
|
347 |
+.equ PIND2 = 2 |
|
348 |
+.equ PIND1 = 1 |
|
349 |
+.equ PIND0 = 0 |
|
350 |
+ |
|
351 |
+;***** USISR ****** |
|
352 |
+.equ USISIF = 7 |
|
353 |
+.equ USIOIF = 6 |
|
354 |
+.equ USIPF = 5 |
|
355 |
+.equ USIDC = 4 |
|
356 |
+.equ USICNT3 = 3 |
|
357 |
+.equ USICNT2 = 2 |
|
358 |
+.equ USICNT1 = 1 |
|
359 |
+.equ USICNT0 = 0 |
|
360 |
+ |
|
361 |
+;***** USICR ****** |
|
362 |
+.equ USISIE = 7 |
|
363 |
+.equ USIOIE = 6 |
|
364 |
+.equ USIWM1 = 5 |
|
365 |
+.equ USIWM0 = 4 |
|
366 |
+.equ USICS1 = 3 |
|
367 |
+.equ USICS0 = 2 |
|
368 |
+.equ USICLK = 1 |
|
369 |
+.equ USITC = 0 |
|
370 |
+ |
|
371 |
+;***** UCSRA ****** |
|
372 |
+.equ RXC = 7 |
|
373 |
+.equ TXC = 6 |
|
374 |
+.equ UDRE = 5 |
|
375 |
+.equ FE = 4 |
|
376 |
+.equ DOR = 3 |
|
377 |
+.equ UPE = 2 |
|
378 |
+.equ PE = 2 ; for compatibility purpose |
|
379 |
+.equ U2X = 1 |
|
380 |
+.equ MPCM = 0 |
|
381 |
+;.equ OR = 3 ; for compatibility purpose |
|
382 |
+ |
|
383 |
+;***** UCSRB ****** |
|
384 |
+.equ RXCIE = 7 |
|
385 |
+.equ TXCIE = 6 |
|
386 |
+.equ UDRIE = 5 |
|
387 |
+.equ RXEN = 4 |
|
388 |
+.equ TXEN = 3 |
|
389 |
+.equ UCSZ2 = 2 |
|
390 |
+.equ RXB8 = 1 |
|
391 |
+.equ TXB8 = 0 |
|
392 |
+.equ CHR9 = 2 ; for compatibility purpose |
|
393 |
+ |
|
394 |
+;***** ACSR ******* |
|
395 |
+.equ ACD = 7 |
|
396 |
+.equ ACBG = 6 |
|
397 |
+.equ ACO = 5 |
|
398 |
+.equ ACI = 4 |
|
399 |
+.equ ACIE = 3 |
|
400 |
+.equ ACIC = 2 |
|
401 |
+.equ ACIS1 = 1 |
|
402 |
+.equ ACIS0 = 0 |
|
403 |
+ |
|
404 |
+;***** UCSRC ****** |
|
405 |
+.equ UMSEL = 6 |
|
406 |
+.equ UPM1 = 5 |
|
407 |
+.equ UPM0 = 4 |
|
408 |
+.equ USBS = 3 |
|
409 |
+.equ UCSZ1 = 2 |
|
410 |
+.equ UCSZ0 = 1 |
|
411 |
+.equ UCPOL = 0 |
|
412 |
+ |
|
413 |
+;***** DIDR ****** |
|
414 |
+.equ AIN1D = 1 |
|
415 |
+.equ AIN0D = 0 |
|
416 |
+ |
|
417 |
+;***************************************************************************** |
|
418 |
+; CPU Register Declarations |
|
419 |
+;***************************************************************************** |
|
420 |
+ |
|
421 |
+.def XL = r26 ; X pointer low |
|
422 |
+.def XH = r27 ; X pointer high |
|
423 |
+.def YL = r28 ; Y pointer low |
|
424 |
+.def YH = r29 ; Y pointer high |
|
425 |
+.def ZL = r30 ; Z pointer low |
|
426 |
+.def ZH = r31 ; Z pointer high |
|
427 |
+ |
|
428 |
+ |
|
429 |
+;***************************************************************************** |
|
430 |
+; Data Memory Declarations |
|
431 |
+;***************************************************************************** |
|
432 |
+ |
|
433 |
+.equ RAMEND = 0xDF ; Highest internal data memory (SRAM) address. |
|
434 |
+ ;(128 Bytes RAM + IO + REG) |
|
435 |
+.equ EEPROMEND = 0x7F ; Highest EEPROM address. |
|
436 |
+ ;(128 Bytes) |
|
437 |
+.equ EEADRBITS = 7 ; no. of bits in EEPROM address register |
|
438 |
+ |
|
439 |
+.equ RAM_SIZE = 128 |
|
440 |
+ |
|
441 |
+ |
|
442 |
+;***************************************************************************** |
|
443 |
+; Program Memory Declarations |
|
444 |
+;***************************************************************************** |
|
445 |
+ |
|
446 |
+.equ FLASHEND = 0x3FF ; Highest program memory (flash) address |
|
447 |
+ ; (When addressed as 16 bit words) |
|
448 |
+ ; ( 1024 words , 2K byte ) |
|
449 |
+ |
|
450 |
+;**** Page Size **** |
|
451 |
+.equ PAGESIZE = 16 ;number of WORDS in a Flash page |
|
452 |
+.equ EEPAGESIZE = 2 ;number of WORDS in an EEPROM page |
|
453 |
+ |
|
454 |
+;***************************************************************************** |
|
455 |
+;**** Interrupt Vectors **** |
|
456 |
+;***************************************************************************** |
|
457 |
+ |
|
458 |
+.equ INT0addr = 0x001 ;External Interrupt0 |
|
459 |
+.equ INT1addr = 0x002 ;External Interrupt1 |
|
460 |
+.equ ICP1addr = 0x003 ;Input capture interrupt 1 |
|
461 |
+.equ OC1Aaddr = 0x004 ;Timer/Counter1 Compare Match A |
|
462 |
+.equ OVF1addr = 0x005 ;Overflow1 Interrupt |
|
463 |
+.equ OVF0addr = 0x006 ;Overflow0 Interrupt |
|
464 |
+.equ URXC0addr = 0x007 ;USART0 RX Complete Interrupt |
|
465 |
+.equ UDRE0addr = 0x008 ;USART0 Data Register Empty Interrupt |
|
466 |
+.equ UTXC0addr = 0x009 ;USART0 TX Complete Interrupt |
|
467 |
+.equ ACIaddr = 0x00A ;Analog Comparator Interrupt |
|
468 |
+.equ PCINTaddr = 0x00B ;Pin Change Interrupt |
|
469 |
+.equ OC1Baddr = 0x00C ;Timer/Counter1 Compare Match B |
|
470 |
+.equ OC0Aaddr = 0x00D ;Timer/Counter0 Compare Match A |
|
471 |
+.equ OC0Baddr = 0x00E ;Timer/Counter0 Compare Match B |
|
472 |
+.equ USI_STARTaddr = 0x00F ;USI start interrupt |
|
473 |
+.equ USI_OVFaddr = 0x010 ;USI overflow interrupt |
|
474 |
+.equ ERDYaddr = 0x011 ;EEPROM write complete |
|
475 |
+.equ WDTaddr = 0x012 ;Watchdog Timer Interrupt |
|
476 |
+ ; for compatibility purpose |
|
477 |
+.equ URXCaddr = 0x007 |
|
478 |
+.equ UDREaddr = 0x008 |
|
479 |
+.equ UTXCaddr = 0x009 |
|
480 |
+ |
|
481 |
+;***************************************************************************** |
|
482 |
+;***************************************************************************** |
|
0 | 483 |