]> sigrok.org Git - sigrok-firmware-fx2lafw.git/blame - fx2lib/include/lights.h
Add Hantek PSO2020 firmware support
[sigrok-firmware-fx2lafw.git] / fx2lib / include / lights.h
CommitLineData
3608c106
UH
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
040a6eae 14// License along with this library; if not, see <http://www.gnu.org/licenses/>.
3608c106
UH
15
16/** \file lights.h
17 * macros for turning lights on the EZ-USB development board on and off.
18 **/
19
20#ifndef LIGHTS_H
21#define LIGHTS_H
22
23#include "fx2types.h"
24
25#ifndef FX1
26// FX2 Dev board lights
27#define D2ONH #0x88 // assembly high byte of light addr
28#define D2OFFH #0x80
29#define D3ONH #0x98
30#define D3OFFH #0x90
31#define D4ONH #0xA8
32#define D4OFFH #0xA0
33#define D5ONH #0xB8
34#define D5OFFH #0xB0
35volatile xdata at 0x8800 BYTE D2ON;
36volatile xdata at 0x8000 BYTE D2OFF;
37volatile xdata at 0x9800 BYTE D3ON;
38volatile xdata at 0x9000 BYTE D3OFF;
39volatile xdata at 0xA800 BYTE D4ON;
40volatile xdata at 0xA000 BYTE D4OFF;
41volatile xdata at 0xB800 BYTE D5ON;
42volatile xdata at 0xB000 BYTE D5OFF;
43#else
44// FX1 dev board lights
45#define D2ONH #0x80 // assembly high byte of light addr
46#define D2OFFH #0x81
47#define D3ONH #0x90
48#define D3OFFH #0x91
49#define D4ONH #0xA0
50#define D4OFFH #0xA1
51#define D5ONH #0xB0
52#define D5OFFH #0xB1
53volatile xdata at 0x8000 BYTE D2ON;
54volatile xdata at 0x8100 BYTE D2OFF;
55volatile xdata at 0x9000 BYTE D3ON;
56volatile xdata at 0x9100 BYTE D3OFF;
57volatile xdata at 0xA000 BYTE D4ON;
58volatile xdata at 0xA100 BYTE D4OFF;
59volatile xdata at 0xB000 BYTE D5ON;
60volatile xdata at 0xB100 BYTE D5OFF;
61#endif
62
63/**
64 * Easier to use macros defined below
65**/
66#define activate_light(LIGHT_ADDR) __asm \
67 mov __XPAGE, LIGHT_ADDR \
68 __endasm; __asm \
69 movx a, @r0 \
70__endasm \
71
72/**
73 * Easy to make lights blink with these macros:
74 * \code
75 * WORD ct=0;
76 * BOOL on=FALSE;
77 * while (TRUE) {
78 * if (!ct) {
79 * on=!on;
80 * if (on) d2on(); else d2off();
81 * }
82 * ++ct;
83 * }
84 * \endcode
85 **/
86#define d2on() activate_light(D2ONH)
87#define d2off() activate_light(D2OFFH)
88#define d3on() activate_light(D3ONH)
89#define d3off() activate_light(D3OFFH)
90#define d4on() activate_light(D4ONH)
91#define d4off() activate_light(D4OFFH)
92#define d5on() activate_light(D5ONH)
93#define d5off() activate_light(D5OFFH)
94
95#endif