]> sigrok.org Git - sigrok-firmware-fx2lafw.git/blob - fx2lib/include/lights.h
Import fx2lib into fx2lafw directly.
[sigrok-firmware-fx2lafw.git] / fx2lib / include / lights.h
1 // Copyright (C) 2009 Ubixum, Inc. 
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
16
17 /** \file lights.h
18  * macros for turning lights on the EZ-USB development board on and off.
19  **/
20
21 #ifndef LIGHTS_H
22 #define LIGHTS_H
23
24 #include "fx2types.h"
25
26 #ifndef FX1
27 // FX2 Dev board lights
28 #define D2ONH #0x88 // assembly high byte of light addr 
29 #define D2OFFH #0x80 
30 #define D3ONH #0x98 
31 #define D3OFFH #0x90 
32 #define D4ONH #0xA8 
33 #define D4OFFH #0xA0 
34 #define D5ONH #0xB8 
35 #define D5OFFH #0xB0 
36 volatile xdata at 0x8800 BYTE D2ON;
37 volatile xdata at 0x8000 BYTE D2OFF;
38 volatile xdata at 0x9800 BYTE D3ON;
39 volatile xdata at 0x9000 BYTE D3OFF;
40 volatile xdata at 0xA800 BYTE D4ON;
41 volatile xdata at 0xA000 BYTE D4OFF;
42 volatile xdata at 0xB800 BYTE D5ON;
43 volatile xdata at 0xB000 BYTE D5OFF;
44 #else
45 // FX1 dev board lights
46 #define D2ONH #0x80 // assembly high byte of light addr 
47 #define D2OFFH #0x81 
48 #define D3ONH #0x90 
49 #define D3OFFH #0x91 
50 #define D4ONH #0xA0 
51 #define D4OFFH #0xA1 
52 #define D5ONH #0xB0 
53 #define D5OFFH #0xB1 
54 volatile xdata at 0x8000 BYTE D2ON;
55 volatile xdata at 0x8100 BYTE D2OFF;
56 volatile xdata at 0x9000 BYTE D3ON;
57 volatile xdata at 0x9100 BYTE D3OFF;
58 volatile xdata at 0xA000 BYTE D4ON;
59 volatile xdata at 0xA100 BYTE D4OFF;
60 volatile xdata at 0xB000 BYTE D5ON;
61 volatile xdata at 0xB100 BYTE D5OFF;
62 #endif
63
64 /**
65  * Easier to use macros defined below 
66 **/
67 #define activate_light(LIGHT_ADDR) __asm \
68  mov __XPAGE, LIGHT_ADDR \
69  __endasm; __asm \
70  movx a, @r0 \
71 __endasm \
72
73 /**
74  *  Easy to make lights blink with these macros:
75  *  \code
76  *      WORD ct=0;
77  *      BOOL on=FALSE;
78  *      while (TRUE) {
79  *          if (!ct) {
80  *              on=!on;
81  *              if (on) d2on(); else d2off();
82  *          }
83  *          ++ct;
84  *      }
85  *  \endcode
86  **/
87 #define d2on() activate_light(D2ONH)
88 #define d2off() activate_light(D2OFFH)
89 #define d3on() activate_light(D3ONH)
90 #define d3off() activate_light(D3OFFH)
91 #define d4on() activate_light(D4ONH)
92 #define d4off() activate_light(D4OFFH)
93 #define d5on() activate_light(D5ONH)
94 #define d5off() activate_light(D5OFFH)
95
96 #endif