| Nano100BN Series BSP V3.03.002 The Board Support Package for Nano100BN Series

NuEdu-Basic01_7_Segment.c
Go to the documentation of this file.
1 /**************************************************************************/
12 #include <stdio.h>
13 #include "Nano100Series.h"
14 #include "NuEdu-Basic01_7_Segment.h"
27 /*---------------------------------------------------------------------------------------------------------*/
28 /* Porting Define */
29 /*---------------------------------------------------------------------------------------------------------*/
30 #define SEG_A_ON PA2=0
31 #define SEG_B_ON PA3=0
32 #define SEG_C_ON PA4=0
33 #define SEG_D_ON PA5=0
34 #define SEG_E_ON PA6=0
35 #define SEG_F_ON PA7=0
36 #define SEG_G_ON PD6=0
37 #define SEG_H_ON PD7=0
38 #define SEG_CONTROL1_ON PD14=1
39 #define SEG_CONTROL2_ON PD15=1
41 #define SEG_A_OFF PA2=1
42 #define SEG_B_OFF PA3=1
43 #define SEG_C_OFF PA4=1
44 #define SEG_D_OFF PA5=1
45 #define SEG_E_OFF PA6=1
46 #define SEG_F_OFF PA7=1
47 #define SEG_G_OFF PD6=1
48 #define SEG_H_OFF PD7=1
49 #define SEG_CONTROL1_OFF PD14=0
50 #define SEG_CONTROL2_OFF PD15=0
56 void Initial_SEG_GPIO(void)
57 {
58 //io initail output mode
59
60 GPIO_SetMode(PA, BIT2, GPIO_PMD_OUTPUT);
61 GPIO_SetMode(PA, BIT3, GPIO_PMD_OUTPUT);
62 GPIO_SetMode(PA, BIT4, GPIO_PMD_OUTPUT);
63 GPIO_SetMode(PA, BIT5, GPIO_PMD_OUTPUT);
64 GPIO_SetMode(PA, BIT6, GPIO_PMD_OUTPUT);
65 GPIO_SetMode(PA, BIT7, GPIO_PMD_OUTPUT);
66 GPIO_SetMode(PD, BIT6, GPIO_PMD_OUTPUT);
67 GPIO_SetMode(PD, BIT7, GPIO_PMD_OUTPUT);
68 GPIO_SetMode(PD, BIT14, GPIO_PMD_OUTPUT);
69 GPIO_SetMode(PD, BIT15, GPIO_PMD_OUTPUT);
70 }
71
76 void Open_Seven_Segment(void)
77 {
78 Initial_SEG_GPIO();
79 SEG_A_OFF;
80 SEG_B_OFF;
81 SEG_C_OFF;
82 SEG_D_OFF;
83 SEG_E_OFF;
84 SEG_F_OFF;
85 SEG_G_OFF;
86 SEG_H_OFF;
87 }
88
93 void Close_Seven_Segment(void)
94 {
95 SEG_A_OFF;
96 SEG_B_OFF;
97 SEG_C_OFF;
98 SEG_D_OFF;
99 SEG_E_OFF;
100 SEG_F_OFF;
101 SEG_G_OFF;
102 SEG_H_OFF;
103 SEG_CONTROL1_OFF;
104 SEG_CONTROL2_OFF;
105 }
106
115 void Show_Seven_Segment(unsigned char no, unsigned char number)
116 {
117 SEG_A_OFF;
118 SEG_B_OFF;
119 SEG_C_OFF;
120 SEG_D_OFF;
121 SEG_E_OFF;
122 SEG_F_OFF;
123 SEG_G_OFF;
124 SEG_H_OFF;
125 SEG_CONTROL1_OFF;
126 SEG_CONTROL2_OFF;
127
128 switch(number)
129 {
130 case 1:
131 SEG_CONTROL1_ON;
132 break;
133
134 case 2:
135 SEG_CONTROL2_ON;
136 break;
137 }
138
139 switch(no)
140 {
141 //show 0
142 case 0:
143 SEG_A_ON;
144 SEG_B_ON;
145 SEG_C_ON;
146 SEG_D_ON;
147 SEG_E_ON;
148 SEG_F_ON;
149 break;
150
151 //show 1
152 case 1:
153 SEG_B_ON;
154 SEG_C_ON;
155 break;
156
157 //show 2
158 case 2:
159 SEG_A_ON;
160 SEG_B_ON;
161 SEG_G_ON;
162 SEG_E_ON;
163 SEG_D_ON;
164 break;
165
166 //show 3
167 case 3:
168 SEG_A_ON;
169 SEG_B_ON;
170 SEG_G_ON;
171 SEG_C_ON;
172 SEG_D_ON;
173 break;
174
175 //show 4
176 case 4:
177 SEG_F_ON;
178 SEG_B_ON;
179 SEG_G_ON;
180 SEG_C_ON;
181 break;
182
183 //show 5
184 case 5:
185 SEG_A_ON;
186 SEG_F_ON;
187 SEG_G_ON;
188 SEG_C_ON;
189 SEG_D_ON;
190 break;
191
192 //show 6
193 case 6:
194 SEG_A_ON;
195 SEG_F_ON;
196 SEG_E_ON;
197 SEG_G_ON;
198 SEG_C_ON;
199 SEG_D_ON;
200 break;
201
202 //show 7
203 case 7:
204 SEG_A_ON;
205 SEG_B_ON;
206 SEG_C_ON;
207 SEG_F_ON;
208 break;
209
210 //show 8
211 case 8:
212 SEG_A_ON;
213 SEG_B_ON;
214 SEG_C_ON;
215 SEG_D_ON;
216 SEG_E_ON;
217 SEG_F_ON;
218 SEG_G_ON;
219 break;
220
221 //show 9
222 case 9:
223 SEG_A_ON;
224 SEG_B_ON;
225 SEG_C_ON;
226 SEG_F_ON;
227 SEG_G_ON;
228 break;
229 }
230 } /* end of group Nano130_Basic01_FUNCTIONS */
232 /* end of group NuEdu-SDK-Nano130_Basic01 */
234 /* end of group NANO100_Library */
236
237 /*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
SEG_D_ON
#define SEG_D_ON
Definition: NuEdu-Basic01_7_Segment.c:33
BIT5
#define BIT5
Bit 5 mask of an 32 bit integer.
Definition: Nano100Series.h:11874
PD
#define PD
Pointer to GPIO port D register structure.
Definition: Nano100Series.h:11698
Show_Seven_Segment
void Show_Seven_Segment(unsigned char no, unsigned char number)
This function turn on 7_Segment LED to show numbers.
Definition: NuEdu-Basic01_7_Segment.c:115
BIT7
#define BIT7
Bit 7 mask of an 32 bit integer.
Definition: Nano100Series.h:11876
SEG_G_ON
#define SEG_G_ON
Definition: NuEdu-Basic01_7_Segment.c:36
BIT6
#define BIT6
Bit 6 mask of an 32 bit integer.
Definition: Nano100Series.h:11875
BIT4
#define BIT4
Bit 4 mask of an 32 bit integer.
Definition: Nano100Series.h:11873
SEG_A_OFF
#define SEG_A_OFF
Definition: NuEdu-Basic01_7_Segment.c:41
SEG_B_ON
#define SEG_B_ON
Definition: NuEdu-Basic01_7_Segment.c:31
Nano100Series.h
Nano100 series peripheral access layer header file. This file contains all the peripheral register's ...
SEG_B_OFF
#define SEG_B_OFF
Definition: NuEdu-Basic01_7_Segment.c:42
SEG_CONTROL2_ON
#define SEG_CONTROL2_ON
Definition: NuEdu-Basic01_7_Segment.c:39
NuEdu-Basic01_7_Segment.h
NuEdu-Basic01 7_Segment LED driver header file for NuEdu-SDK-Nano130.
SEG_D_OFF
#define SEG_D_OFF
Definition: NuEdu-Basic01_7_Segment.c:44
SEG_C_ON
#define SEG_C_ON
Definition: NuEdu-Basic01_7_Segment.c:32
BIT2
#define BIT2
Bit 2 mask of an 32 bit integer.
Definition: Nano100Series.h:11871
SEG_E_OFF
#define SEG_E_OFF
Definition: NuEdu-Basic01_7_Segment.c:45
SEG_CONTROL1_ON
#define SEG_CONTROL1_ON
Definition: NuEdu-Basic01_7_Segment.c:38
SEG_F_ON
#define SEG_F_ON
Definition: NuEdu-Basic01_7_Segment.c:35
SEG_F_OFF
#define SEG_F_OFF
Definition: NuEdu-Basic01_7_Segment.c:46
PA
#define PA
Pointer to GPIO port A register structure.
Definition: Nano100Series.h:11695
Close_Seven_Segment
void Close_Seven_Segment(void)
This function turn off 7_Segment LED.
Definition: NuEdu-Basic01_7_Segment.c:93
BIT3
#define BIT3
Bit 3 mask of an 32 bit integer.
Definition: Nano100Series.h:11872
Initial_SEG_GPIO
void Initial_SEG_GPIO(void)
Set 7_Segment LED GPIO to output mode.
Definition: NuEdu-Basic01_7_Segment.c:56
BIT15
#define BIT15
Bit 15 mask of an 32 bit integer.
Definition: Nano100Series.h:11884
Open_Seven_Segment
void Open_Seven_Segment(void)
This function turn on 7_Segment LED.
Definition: NuEdu-Basic01_7_Segment.c:76
SEG_CONTROL1_OFF
#define SEG_CONTROL1_OFF
Definition: NuEdu-Basic01_7_Segment.c:49
SEG_E_ON
#define SEG_E_ON
Definition: NuEdu-Basic01_7_Segment.c:34
SEG_C_OFF
#define SEG_C_OFF
Definition: NuEdu-Basic01_7_Segment.c:43
GPIO_PMD_OUTPUT
#define GPIO_PMD_OUTPUT
Definition: gpio.h:38
SEG_H_OFF
#define SEG_H_OFF
Definition: NuEdu-Basic01_7_Segment.c:48
BIT14
#define BIT14
Bit 14 mask of an 32 bit integer.
Definition: Nano100Series.h:11883
SEG_A_ON
#define SEG_A_ON
Definition: NuEdu-Basic01_7_Segment.c:30
SEG_CONTROL2_OFF
#define SEG_CONTROL2_OFF
Definition: NuEdu-Basic01_7_Segment.c:50
SEG_G_OFF
#define SEG_G_OFF
Definition: NuEdu-Basic01_7_Segment.c:47
GPIO_SetMode
void GPIO_SetMode(GPIO_T *gpio, uint32_t u32PinMask, uint32_t u32Mode)
Set GPIO operation mode.
Definition: gpio.c:40