blob: cbfd2e74a26c79ce0791f1aa06878d8f4e63eb4c [file] [log] [blame]
wdenkc935d3b2004-01-03 19:43:48 +00001/*
2 * (C) Copyright 2003, Li-Pro.Net <www.li-pro.net>
3 * Stephan Linz <linz@li-pro.net>
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 *
23 * common/sevenseg.h
24 *
25 * NIOS PIO based seven segment led support functions
26 */
27
28#ifndef __DK1S10_SEVENSEG_H__
29#define __DK1S10_SEVENSEG_H__
30
31#ifdef CONFIG_SEVENSEG
32
33/*
34 * 15 8 7 0
35 * |-----------------------|--------|
36 * | controll value | value |
37 * ----------------------------------
38 */
39#define SEVENSEG_RAW (int)(0) /* write out byte value (hex) */
40#define SEVENSEG_OFF (int)( 1 << 8) /* display switch off */
41#define SEVENSEG_SET_DPL (int)( 2 << 8) /* set dp low nibble */
42#define SEVENSEG_SET_DPH (int)( 3 << 8) /* set dp high nibble */
43#define SEVENSEG_RES_DPL (int)( 4 << 8) /* reset dp low nibble */
44#define SEVENSEG_RES_DPH (int)( 5 << 8) /* reset dp high nibble */
45#define SEVENSEG_TOG_DPL (int)( 6 << 8) /* toggle dp low nibble */
46#define SEVENSEG_TOG_DPH (int)( 7 << 8) /* toggle dp high nibble */
47#define SEVENSEG_LO (int)( 8 << 8) /* write out low nibble only */
48#define SEVENSEG_HI (int)( 9 << 8) /* write out high nibble only */
49#define SEVENSEG_STR (int)(10 << 8) /* write out a string */
50
51#define SEVENSEG_MASK_VAL (0xff) /* only used by SEVENSEG_RAW */
52#define SEVENSEG_MASK_CTRL (~SEVENSEG_MASK_VAL)
53
54#ifdef SEVENSEG_DIGIT_HI_LO_EQUAL
55
56#define SEVENSEG_DIGITS_0 ( SEVENSEG_DIGIT_A \
57 | SEVENSEG_DIGIT_B \
58 | SEVENSEG_DIGIT_C \
59 | SEVENSEG_DIGIT_D \
60 | SEVENSEG_DIGIT_E \
61 | SEVENSEG_DIGIT_F )
62#define SEVENSEG_DIGITS_1 ( SEVENSEG_DIGIT_B \
63 | SEVENSEG_DIGIT_C )
64#define SEVENSEG_DIGITS_2 ( SEVENSEG_DIGIT_A \
65 | SEVENSEG_DIGIT_B \
66 | SEVENSEG_DIGIT_D \
67 | SEVENSEG_DIGIT_E \
68 | SEVENSEG_DIGIT_G )
69#define SEVENSEG_DIGITS_3 ( SEVENSEG_DIGIT_A \
70 | SEVENSEG_DIGIT_B \
71 | SEVENSEG_DIGIT_C \
72 | SEVENSEG_DIGIT_D \
73 | SEVENSEG_DIGIT_G )
74#define SEVENSEG_DIGITS_4 ( SEVENSEG_DIGIT_B \
75 | SEVENSEG_DIGIT_C \
76 | SEVENSEG_DIGIT_F \
77 | SEVENSEG_DIGIT_G )
78#define SEVENSEG_DIGITS_5 ( SEVENSEG_DIGIT_A \
79 | SEVENSEG_DIGIT_C \
80 | SEVENSEG_DIGIT_D \
81 | SEVENSEG_DIGIT_F \
82 | SEVENSEG_DIGIT_G )
83#define SEVENSEG_DIGITS_6 ( SEVENSEG_DIGIT_A \
84 | SEVENSEG_DIGIT_C \
85 | SEVENSEG_DIGIT_D \
86 | SEVENSEG_DIGIT_E \
87 | SEVENSEG_DIGIT_F \
88 | SEVENSEG_DIGIT_G )
89#define SEVENSEG_DIGITS_7 ( SEVENSEG_DIGIT_A \
90 | SEVENSEG_DIGIT_B \
91 | SEVENSEG_DIGIT_C )
92#define SEVENSEG_DIGITS_8 ( SEVENSEG_DIGIT_A \
93 | SEVENSEG_DIGIT_B \
94 | SEVENSEG_DIGIT_C \
95 | SEVENSEG_DIGIT_D \
96 | SEVENSEG_DIGIT_E \
97 | SEVENSEG_DIGIT_F \
98 | SEVENSEG_DIGIT_G )
99#define SEVENSEG_DIGITS_9 ( SEVENSEG_DIGIT_A \
100 | SEVENSEG_DIGIT_B \
101 | SEVENSEG_DIGIT_C \
102 | SEVENSEG_DIGIT_D \
103 | SEVENSEG_DIGIT_F \
104 | SEVENSEG_DIGIT_G )
105#define SEVENSEG_DIGITS_A ( SEVENSEG_DIGIT_A \
106 | SEVENSEG_DIGIT_B \
107 | SEVENSEG_DIGIT_C \
108 | SEVENSEG_DIGIT_E \
109 | SEVENSEG_DIGIT_F \
110 | SEVENSEG_DIGIT_G )
111#define SEVENSEG_DIGITS_B ( SEVENSEG_DIGIT_C \
112 | SEVENSEG_DIGIT_D \
113 | SEVENSEG_DIGIT_E \
114 | SEVENSEG_DIGIT_F \
115 | SEVENSEG_DIGIT_G )
116#define SEVENSEG_DIGITS_C ( SEVENSEG_DIGIT_D \
117 | SEVENSEG_DIGIT_E \
118 | SEVENSEG_DIGIT_G )
119#define SEVENSEG_DIGITS_D ( SEVENSEG_DIGIT_B \
120 | SEVENSEG_DIGIT_C \
121 | SEVENSEG_DIGIT_D \
122 | SEVENSEG_DIGIT_E \
123 | SEVENSEG_DIGIT_G )
124#define SEVENSEG_DIGITS_E ( SEVENSEG_DIGIT_A \
125 | SEVENSEG_DIGIT_D \
126 | SEVENSEG_DIGIT_E \
127 | SEVENSEG_DIGIT_F \
128 | SEVENSEG_DIGIT_G )
129#define SEVENSEG_DIGITS_F ( SEVENSEG_DIGIT_A \
130 | SEVENSEG_DIGIT_E \
131 | SEVENSEG_DIGIT_F \
132 | SEVENSEG_DIGIT_G )
133
134#else /* !SEVENSEG_DIGIT_HI_LO_EQUAL */
135#error SEVENSEG: different pin asssignments not supported
136#endif
137
138void sevenseg_set(int value);
139
140#endif /* CONFIG_SEVENSEG */
141
142#endif /* __DK1S10_SEVENSEG_H__ */