Rename tools to ao-<foo>
[fw/altos] / ao-tools / target / blink / blink.c
1 /*
2  * Copyright © 2008 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18
19 sfr at 0x80 P0;
20 sfr at 0x90 P1;
21 sfr at 0xA0 P2;
22 sfr at 0xC6 CLKCON;
23
24 sfr at 0xF1 PERCFG;
25 sfr at 0xF2 ADCCFG;
26 sfr at 0xF3 P0SEL;
27 sfr at 0xF4 P1SEL;
28 sfr at 0xF5 P2SEL;
29
30 sfr at 0xFD P0DIR;
31 sfr at 0xFE P1DIR;
32 sfr at 0xFF P2DIR;
33 sfr at 0x8F P0INP;
34 sfr at 0xF6 P1INP;
35 sfr at 0xF7 P2INP;
36
37 sfr at 0x89 P0IFG;
38 sfr at 0x8A P1IFG;
39 sfr at 0x8B P2IFG;
40
41 #define nop()   _asm nop _endasm;
42
43 void
44 delay (unsigned char n)
45 {
46         unsigned char i = 0, j = 0;
47
48         n <<= 1;
49         while (--n != 0)
50                 while (--j != 0)
51                         while (--i != 0)
52                                 nop();
53 }
54
55 void
56 dit() {
57         P1 = 0xff;
58         delay(1);
59         P1 = 0xfd;
60         delay(1);
61 }
62
63 void
64 dah () {
65         P1 = 0xff;
66         delay(3);
67         P1 = 0xfd;
68         delay(1);
69 }
70
71 void
72 charspace () {
73         delay(2);
74 }
75
76 void
77 wordspace () {
78         delay(8);
79 }
80
81 #define _ dit();
82 #define ___ dah();
83 #define C charspace();
84 #define W wordspace();
85
86 main ()
87 {
88         CLKCON = 0;
89         /* Set p1_1 to output */
90         P1DIR = 0x02;
91         P1INP = 0x00;
92         P2INP = 0x00;
93         for (;;) {
94                 ___ _ ___ _ C ___ ___ _ ___ W   /* cq */
95                 ___ _ _ C _ W                   /* de */
96                 ___ _ ___ C ___ _ _ C           /* kd */
97                 ___ ___ _ _ _ C _ _ _ C         /* 7s */
98                 ___ ___ _ ___ C ___ ___ _ W     /* qg */
99         }
100 }