Statistics
| Revision:

root / branch / faye / sp4b2 / SP4b2 / SP4b2.c @ 707

History | View | Annotate | Download (4.26 KB)

1
/***********************************************************************/
2
/*                                                                     */
3
/*  FILE        :SP4b2.c                                               */
4
/*  DATE        :Fri, May 28, 2021                                     */
5
/*  DESCRIPTION :main program file.                                    */
6
/*  CPU GROUP   :87B                                                   */
7
/*                                                                     */
8
/*  This file is generated by Renesas Project Generator (Ver.4.18).    */
9
/*  NOTE:THIS IS A TYPICAL EXAMPLE.                                    */
10
/***********************************************************************/
11

    
12
#include "sfr32c87.h" 
13
                       
14
  
15

    
16
void lcd_4b (char c); 
17
void lcd_8b (char c); 
18
void lcd_com (char c); 
19
void lcd_init (void); 
20
void lcd_car (char c); 
21
void tpo_ms(int t); 
22
void tpo_us(int t); 
23

    
24
void lcd_4b (char c) 
25
{ 
26
        p3_2=1; 
27
         
28
        if (c&0x80) 
29
        { 
30
                p3_7=1; 
31
        } 
32
        else  
33
                p3_7 = 0; 
34
         
35
        if (c&0x40) 
36
        { 
37
                p3_6=1; 
38
        } 
39
        else  
40
                p3_6 = 0;
41
                
42
                  if (c&0x20) 
43
        { 
44
                p3_5=1; 
45
        } 
46
        else  
47
                p3_5 = 0; 
48
         
49
        if (c&0x10) 
50
        { 
51
                p3_4=1; 
52
        } 
53
        else  
54
                p3_4 = 0; 
55
         
56
         
57
        p3_2=0;
58
                 
59
} 
60
void lcd_8b (char c) 
61
{ 
62
        lcd_4b (c); 
63
        lcd_4b (c<<4); 
64
} 
65
  
66

    
67
void lcd_com(char c) 
68
{ 
69
        p3_0=0; 
70
        lcd_8b(c); 
71
} 
72

    
73
void tpo_ms(int t) 
74
{ 
75
        tcspr = 0x8a; 
76
        ta0mr = 0x82; 
77
        ta0=t*1000; 
78
        ta0s = 1; 
79
        ta0os=1; 
80
        ta0ic=0x00; 
81
        while (ir_ta0ic!=1); 
82
        ta0s=0;                 
83
} 
84

    
85
void tpo_us(int t) 
86
{ 
87
        tcspr = 0x8a; 
88
        ta0mr = 0x82; 
89
        ta0=t; 
90
        ta0s = 1; 
91
        ta0os=1; 
92
        ta0ic=0x00; 
93
        while (ir_ta0ic!=1); 
94
        ta0s=0;                 
95
} 
96

    
97
void lcd_init (void) 
98
{ 
99
                 
100
        pd3=0xFF; 
101
        p3 = 0; 
102
        p3_0=0;  
103
        tpo_ms(15);  
104
        lcd_4b(0x30);  
105
        tpo_ms(5);  
106
        lcd_4b(0x30);  
107
        tpo_us(100);  
108
        lcd_4b(0x30);  
109
        tpo_us(100);  
110
        lcd_4b(0x20);  
111
        lcd_com(0x28);  
112
        lcd_com(0x06);  
113
        lcd_com(0x0E);  
114
        lcd_com(0x01);  
115
        tpo_ms(5); 
116
} 
117

    
118
void lcd_car (char c) 
119
{ 
120
        p3_0=1; 
121
        lcd_8b(c);         
122
} 
123
  
124
char decode_touche(char t){ 
125
        char t;  
126
        char touche; 
127
        pd10= 0x0F; 
128
         pu31=1; 
129
         p10=0x00; 
130
           p10= 0xFe; 
131
           t=p10; 
132
         
133
           if (t==0xde){ 
134
              touche ='2'; 
135
           } 
136
        
137
           if (t==0xbe){ 
138
             touche ='1'; 
139
           } 
140
           if (t==0x7e){ 
141
               touche ='3'; 
142
           } 
143
          
144
         p10= 0xFd; 
145
           t=p10; 
146
           if (t==0xdd){ 
147
               touche ='5'; 
148
           } 
149
         
150
         if (t==0xbd){ 
151
               touche ='4'; 
152
           } 
153
           
154
           
155
          if (t==0x7d){ 
156
               touche ='6'; 
157
           } 
158
      
159
            p10= 0xFb; 
160
            t=p10; 
161
           if (t==0xdb){ 
162
               touche ='8'; 
163
        } 
164
                 
165
                  if (t==0xeb){ 
166
               touche ='7'; 
167
        } 
168
           
169
           if (t==0x7b){ 
170
               touche ='9'; 
171
        } 
172
           
173
           p10= 0xF7; 
174
           t=p10; 
175
    
176
           if (t==0xd7){ 
177
               touche ='0'; 
178
        } 
179
          
180
        if (t==0x77){ 
181
               touche ='#'; 
182
        } 
183
          
184
        if (t==0xe7){ 
185
               touche ='*'; 
186
         } 
187
    return touche; 
188
        
189
        } 
190
  
191

    
192
void main(void){  
193
     char t; 
194
     t=p10; 
195
     
196
     lcd_init (); 
197
      
198
     
199
     
200
         while(1){       
201
              /*if(p10!=0xf0){ 
202
                 p10=0x00;*/ 
203
                lcd_car ('A'); 
204
                 
205
                /*while(p10!=0xf0){ 
206
                 p10=0x00; 
207
                 }*/      
208
            } 
209
           
210
}
211
        
212