1 |
3 |
jlechner |
/**
|
2 |
|
|
* \brief Driver for 7-segment module.
|
3 |
|
|
*/
|
4 |
|
|
|
5 |
|
|
#ifndef __dis7seg_h__
|
6 |
|
|
#define __dis7seg_h__
|
7 |
|
|
|
8 |
|
|
#include "drivers.h"
|
9 |
|
|
|
10 |
|
|
#define DISP7SEG_STATUS_BOFF 0
|
11 |
|
|
#define DISP7SEG_STATUS_LOOR 0x7
|
12 |
|
|
#define DISP7SEG_STATUS_FSS 0x4
|
13 |
|
|
#define DISP7SEG_STATUS_BUSY 0x3
|
14 |
|
|
#define DISP7SEG_STATUS_ERR 0x2
|
15 |
|
|
#define DISP7SEG_STATUS_RDY 0x1
|
16 |
|
|
#define DISP7SEG_STATUS_INT 0x0
|
17 |
|
|
|
18 |
|
|
#define DISP7SEG_CONFIG_BOFF 2
|
19 |
|
|
#define DISP7SEG_CONFIG_LOOW 0x7
|
20 |
|
|
#define DISP7SEG_CONFIG_EFSS 0x4
|
21 |
|
|
#define DISP7SEG_CONFIG_OUTD 0x3
|
22 |
|
|
#define DISP7SEG_CONFIG_SRES 0x2
|
23 |
|
|
#define DISP7SEG_CONFIG_ID 0x1
|
24 |
|
|
#define DISP7SEG_CONFIG_INTA 0x0
|
25 |
|
|
|
26 |
|
|
#define DISP7SEG_PRESC_L_BOFF 4
|
27 |
|
|
#define DISP7SEG_PRESC_H_BOFF 5
|
28 |
|
|
#define DISP7SEG_DISPLAY_CMD 6
|
29 |
|
|
#define DISP7SEG_DISPLAY_VALUE 7
|
30 |
|
|
|
31 |
|
|
/**
|
32 |
|
|
* \struct dis7seg_handle_t
|
33 |
|
|
* \brief Stores context for access of a specific extension module.
|
34 |
|
|
*/
|
35 |
|
|
typedef struct {
|
36 |
|
|
scarts_addr_t baseAddress;
|
37 |
|
|
uint8_t segmentCount;
|
38 |
|
|
} dis7seg_handle_t;
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
/**
|
42 |
|
|
* \brief Initilizes a new handle for a memory mapped module.
|
43 |
|
|
* \param h The handle which is initialized.
|
44 |
|
|
* \param baseAddress The base addresse where the module is mapped.
|
45 |
|
|
* \param segmentCount The number of available segments.
|
46 |
|
|
*/
|
47 |
|
|
void dis7seg_initHandle(dis7seg_handle_t *h, scarts_addr_t baseAddress, uint8_t segmentCount);
|
48 |
|
|
|
49 |
|
|
/**
|
50 |
|
|
* \brief Free dynamically allocated resources.
|
51 |
|
|
* \param h Handle.
|
52 |
|
|
*/
|
53 |
|
|
void dis7seg_releaseHandle(dis7seg_handle_t *h);
|
54 |
|
|
|
55 |
|
|
/**
|
56 |
|
|
* \brief Sets the prescaler for multiplexing digits.
|
57 |
|
|
* \param h Handle.
|
58 |
|
|
* \param value Specifies the number of clock cycles for multiplexing the digits.
|
59 |
|
|
*/
|
60 |
|
|
void dis7seg_setPrescaler(dis7seg_handle_t *h, uint16_t value);
|
61 |
|
|
|
62 |
|
|
/**
|
63 |
|
|
* \brief Display a value on a specific digit.
|
64 |
|
|
* \param h Handle.
|
65 |
|
|
* \param index Specifies which digit is used.
|
66 |
|
|
* \param value Displayed value.
|
67 |
|
|
*/
|
68 |
|
|
void dis7seg_setDigitValue(dis7seg_handle_t *h, uint8_t index, uint8_t value);
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
void dis7seg_displayUInt(dis7seg_handle_t *h, uint8_t index, uint32_t value);
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
/**
|
75 |
|
|
* \brief Display a byte value on two digits.
|
76 |
|
|
* \param h Handle.
|
77 |
|
|
* \param index Specifies the index of the first digit.
|
78 |
|
|
* The second digit is written on index+1.
|
79 |
|
|
* \param value Displayed value.
|
80 |
|
|
*/
|
81 |
|
|
void dis7seg_displayUInt8(dis7seg_handle_t *h, uint8_t index, uint8_t value);
|
82 |
|
|
|
83 |
|
|
/**
|
84 |
|
|
* \brief Display a 2-byte value on four digits.
|
85 |
|
|
* \param h Handle.
|
86 |
|
|
* \param index Specifies the index of the first digit.
|
87 |
|
|
* The second digit is written on index+1, etc.
|
88 |
|
|
* \param value Displayed value.
|
89 |
|
|
*/
|
90 |
|
|
void dis7seg_displayUInt16(dis7seg_handle_t *h, uint8_t index, uint16_t value);
|
91 |
|
|
|
92 |
|
|
/**
|
93 |
|
|
* \brief Display a 4-byte value on eight digits.
|
94 |
|
|
* \param h Handle.
|
95 |
|
|
* \param index Specifies the index of the first digit.
|
96 |
|
|
* The second digit is written on index+1, etc.
|
97 |
|
|
* \param value Displayed value.
|
98 |
|
|
*/
|
99 |
|
|
void dis7seg_displayUInt32(dis7seg_handle_t *h, uint8_t index, uint32_t value);
|
100 |
|
|
|
101 |
|
|
/**
|
102 |
|
|
* \brief Display a byte value as hexadecimal number on two digits.
|
103 |
|
|
* \param h Handle.
|
104 |
|
|
* \param index Specifies the index of the first digit.
|
105 |
|
|
* The second digit is written on index+1.
|
106 |
|
|
* \param value Displayed value.
|
107 |
|
|
*/
|
108 |
|
|
void dis7seg_displayHexUInt8(dis7seg_handle_t *h, uint8_t index, uint8_t value);
|
109 |
|
|
|
110 |
|
|
/**
|
111 |
|
|
* \brief Display a 2-byte value as hexadecimal number on four digits.
|
112 |
|
|
* \param h Handle.
|
113 |
|
|
* \param index Specifies the index of the first digit.
|
114 |
|
|
* The second digit is written on index+1, etc.
|
115 |
|
|
* \param value Displayed value.
|
116 |
|
|
*/
|
117 |
|
|
void dis7seg_displayHexUInt16(dis7seg_handle_t *h, uint8_t index, uint16_t value);
|
118 |
|
|
|
119 |
|
|
/**
|
120 |
|
|
* \brief Display a 4-byte value as hexadecimal number on eight digits.
|
121 |
|
|
* \param h Handle.
|
122 |
|
|
* \param index Specifies the index of the first digit.
|
123 |
|
|
* The second digit is written on index+1, etc.
|
124 |
|
|
* \param value Displayed value.
|
125 |
|
|
*/
|
126 |
|
|
void dis7seg_displayHexUInt32(dis7seg_handle_t *h, uint8_t index, uint32_t value);
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
/**
|
130 |
|
|
* \brief Get the currently displayed value of a specific digit.
|
131 |
|
|
* \param h Handle.
|
132 |
|
|
* \param index Specifies the index of the digit.
|
133 |
|
|
* \return The Displayed value.
|
134 |
|
|
*/
|
135 |
|
|
uint8_t dis7seg_getDigitValue(dis7seg_handle_t *h, uint8_t index);
|
136 |
|
|
|
137 |
|
|
/**
|
138 |
|
|
* \brief Enable/disable the dot segment of a specific digit.
|
139 |
|
|
* \param h Handle.
|
140 |
|
|
* \param index Specifies the index of the digit.
|
141 |
|
|
* \param enabled 1..enabled, 0..disabled.
|
142 |
|
|
*/
|
143 |
|
|
|
144 |
|
|
/**
|
145 |
|
|
* \brief Display a byte value on two digits.
|
146 |
|
|
* \param h Handle.
|
147 |
|
|
* \param index Specifies the index of the first digit.
|
148 |
|
|
* The second digit is written on index+1.
|
149 |
|
|
* \param value Displayed value.
|
150 |
|
|
*/
|
151 |
|
|
void dis7seg_displayByte(dis7seg_handle_t *h, uint8_t index, uint8_t value);
|
152 |
|
|
|
153 |
|
|
/**
|
154 |
|
|
* \brief Display a 2-byte value on four digits.
|
155 |
|
|
* \param h Handle.
|
156 |
|
|
* \param index Specifies the index of the first digit.
|
157 |
|
|
* The second digit is written on index+1, etc.
|
158 |
|
|
* \param value Displayed value.
|
159 |
|
|
*/
|
160 |
|
|
void dis7seg_displayHalfword(dis7seg_handle_t *h, uint8_t index, uint16_t value);
|
161 |
|
|
|
162 |
|
|
/**
|
163 |
|
|
* \brief Display a 4-byte value on eight digits.
|
164 |
|
|
* \param h Handle.
|
165 |
|
|
* \param index Specifies the index of the first digit.
|
166 |
|
|
* The second digit is written on index+1, etc.
|
167 |
|
|
* \param value Displayed value.
|
168 |
|
|
*/
|
169 |
|
|
void dis7seg_displayWord(dis7seg_handle_t *h, uint8_t index, uint32_t value);
|
170 |
|
|
|
171 |
|
|
|
172 |
|
|
void dis7seg_setDigitDot(dis7seg_handle_t *h, uint8_t index, uint8_t enabled);
|
173 |
|
|
|
174 |
|
|
#endif // __dis7seg_h__
|