OpenCores
URL https://opencores.org/ocsvn/openmsp430/openmsp430/trunk

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [fpga/] [xilinx_diligent_s3board/] [software/] [leds/] [7seg.c] - Blame information for rev 199

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 olivier.gi
/*
2
*********************************************************************************************************
3
*
4
* Multiplexed LED Display Driver
5
*
6
* (c) Copyright 2004, modified by John Leung
7
* Reference: Jean J. Labrosse, Embedded Systems Building Blocks
8
* All Rights Reserved
9
*
10
* Filename : LED.C
11
* Programmer : John Leung
12
* Remarks : Modified for SaiWanHo project
13
* Date : 19th Nov 2004
14
* Hardware : PCB 11OCT2004.001
15
*********************************************************************************************************
16
* DESCRIPTION
17
*
18
* This module provides an interface to a multiplexed "8 segments x N digits" LED matrix.
19
*
20
* To use this driver:
21
*
22
* 1) You must define (LED.H):
23
*
24
* DISP_N_DIG The total number of segments to display, inc. dp status
25
* DISP_N_SS The total number of seven-segment digits (modules)
26
* DISP_PORT1_DIG The address of the DIGITS output port
27
* DISP_PORT_SEG The address of the SEGMENTS output port
28
* first_dig_msk The first digit mask for selecting the most significant digit
29
*
30
* 2) You must allocate a hardware timer which will interrupt the CPU at a rate of at least:
31
*
32
* DISP_N_DIG * 60 (Hz)
33
*
34
* The timer interrupt must vector to DispMuxISR (defined in LED_IA.ASM). You MUST write the
35
* code to clear the interrupt source. The interrupt source must be cleared either in DispMuxISR
36
* or in DispMuxHandler().
37
*
38
* 3) Adapt DispInitPort(), DispOutSeg() and DispOutDig() for your environment.
39
*********************************************************************************************************
40
*/
41
#include "7seg.h"
42
 
43
/*
44
*********************************************************************************************************
45
* SEVEN-SEGMENT Digit table
46
*********************************************************************************************************
47
*/
48
 
49
INT8U * const DispSegTbl[] = {
50
  (INT8U *) &DIGIT3,
51
  (INT8U *) &DIGIT2,
52
  (INT8U *) &DIGIT1,
53
  (INT8U *) &DIGIT0
54
};
55
 
56
/*
57
*********************************************************************************************************
58
* ASCII to SEVEN-SEGMENT conversion table
59
* a
60
* ------
61
* f | | b
62
* | g |
63
* Note: The segments are mapped as follows: ------
64
* e | | c
65
* a b c d e f g | d |
66
* -- -- -- -- -- -- -- -- ------
67
* B7 B6 B5 B4 B3 B2 B1 B0
68
*********************************************************************************************************
69
*/
70
 
71
const INT8U DispASCIItoSegTbl[] = {// ASCII to SEVEN-SEGMENT conversion table
72
0x00, // ' '
73
0x00, // '!', No seven-segment conversion for exclamation point
74
0x44, // '"', Double quote
75
0x00, // '#', Pound sign
76
0x00, // '$', No seven-segment conversion for dollar sign
77
0x00, // '%', No seven-segment conversion for percent sign
78
0x00, // '&', No seven-segment conversion for ampersand
79
0x40, // ''', Single quote
80
0x9C, // '(', Same as '['
81
0xF0, // ')', Same as ']'
82
0x00, // '*', No seven-segment conversion for asterix
83
0x00, // '+', No seven-segment conversion for plus sign
84
0x00, // ',', No seven-segment conversion for comma
85
0x02, // '-', Minus sign
86
0x00, // '.', No seven-segment conversion for period
87
0x00, // '/', No seven-segment conversion for slash
88
0xFC, // '0'
89
0x60, // '1'
90
0xDA, // '2'
91
0xF2, // '3'
92
0x66, // '4'
93
0xB6, // '5'
94
0xBE, // '6'
95
0xE0, // '7'
96
0xFE, // '8'
97
0xF6, // '9'
98
0x00, // ':', No seven-segment conversion for colon
99
0x00, // ';', No seven-segment conversion for semi-colon
100
0x00, // '<', No seven-segment conversion for less-than sign
101
0x12, // '=', Equal sign
102
0x00, // '>', No seven-segment conversion for greater-than sign
103
0xCA, //'?', Question mark
104
0x00, // '@', No seven-segment conversion for commercial at-sign
105
0xEE, // 'A'
106
0x3E, // 'B', Actually displayed as 'b'
107
0x9C, // 'C'
108
0x7A, // 'D', Actually displayed as 'd'
109
0x9E, // 'E'
110
0x8E, // 'F'
111
0xBC, // 'G', Actually displayed as 'g'
112
0x6E, // 'H'
113
0x60, // 'I', Same as '1'
114
0x78, // 'J'
115
0x00, // 'K', No seven-segment conversion
116
0x1C, // 'L'
117
0x6E, // 'M', No seven-segment conversion
118
0x2A, // 'N', Actually displayed as 'n'
119
0xFC, // 'O', Same as '0'
120
0xCE, // 'P'
121
0x00, // 'Q', No seven-segment conversion
122
0x0A, // 'R', Actually displayed as 'r'
123
0xB6, // 'S', Same as '5'
124
0x1E, // 'T', Actually displayed as 't'
125
0x7C, // 'U'
126
0x00, // 'V', No seven-segment conversion
127
0x00, // 'W', No seven-segment conversion
128
0x00, // 'X', No seven-segment conversion
129
0x76, // 'Y'
130
0x00, // 'Z', No seven-segment conversion
131
0x00, // '['
132
0x00, // '\', No seven-segment conversion
133
0x00, // ']'
134
0x00, // '^', No seven-segment conversion
135
0x00, // '_', Underscore
136
0x00, // '`', No seven-segment conversion for reverse quote
137
0xFA, // 'a'
138
0x3E, // 'b'
139
0x1A, // 'c'
140
0x7A, // 'd'
141
0xDE, // 'e'
142
0x8E, // 'f', Actually displayed as 'F'
143
0xBC, // 'g'
144
0x2E, // 'h'
145
0x20, // 'i'
146
0x78, // 'j', Actually displayed as 'J'
147
0x00, // 'k', No seven-segment conversion
148
0x1C, // 'l', Actually displayed as 'L'
149
0x00, // 'm', No seven-segment conversion
150
0x2A, // 'n'
151
0x3A, // 'o'
152
0xCE, // 'p', Actually displayed as 'P'
153
0x00, // 'q', No seven-segment conversion
154
0x0A, // 'r'
155
0xB6, // 's', Actually displayed as 'S'
156
0x1E, // 't'
157
0x38, // 'u'
158
0x00, // 'v', No seven-segment conversion
159
0x00, // 'w', No seven-segment conversion
160
0x00, // 'x', No seven-segment conversion
161
0x76, // 'y', Actually displayed as 'Y'
162
0x00 // 'z', No seven-segment conversion
163
};
164
 
165
/*
166
*********************************************************************************************************
167
* DISPLAY ASCII STRING ON SEVEN-SEGMENT DISPLAY
168
*
169
* Description: This function is called to display an ASCII string on the seven-segment display.
170
* Arguments : dig is the position of the first digit where the string will appear:
171
* 0 for the first seven-segment digit.
172
* 1 for the second seven-segment digit.
173
* . . . . . . .
174
* . . . . . . .
175
* DISP_N_SS - 1 is the last seven-segment digit.
176
* s is the ASCII string to display
177
* Returns : none
178
* Notes : - Not all ASCII characters can be displayed on a seven-segment display. Consult the
179
* ASCII to seven-segment conversion table DispASCIItoSegTbl[].
180
*********************************************************************************************************
181
*/
182
 
183
void DispStr (INT8U offset, INT8U *s)
184
{
185
  int dig        = 0;
186
  register INT8U* p;
187
  register INT8U c;
188
  while (dig < DIGIT_NR) {
189
    p = DispSegTbl[dig];
190
    c = *(offset+s);
191
    *p = DispASCIItoSegTbl[c - 0x20];
192
    dig++;
193
    s++;
194
  }
195
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.