Revision 707

View differences:

branch/faye/sp4b2/SP4b2/SessionM32C_E8a_SYSTEM.ini
18 18
PROCESSOR_MODE=0
19 19
[COMMUNI]
20 20
COMSPEED=8
21
COMSPEED PROGRAM FLASH=8
22
COMSPEED DATA FLASH=8
21 23
[Driver Configuration]
22 24
Renesas Communications=USB interface,0,
23 25
[Target]
branch/faye/sp4b2/SP4b2/SP4b2.c
9 9
/*  NOTE:THIS IS A TYPICAL EXAMPLE.                                    */
10 10
/***********************************************************************/
11 11

  
12
#include "sfr32c87.h"
12
#include "sfr32c87.h" 
13
                       
14
  
13 15

  
14
void lcd_4b(unsigned char car); // envoi des 4 bits de poids fort
15
void lcd_8b(unsigned char car); // envoi des 8 bits de poids fort
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); 
16 23

  
17
void main(void)
18
{
19
	pd1 = 0xFF;
20
	while (1)
21
  {
22
  lcd_4b(0x30);
23
  lcd_8b(0x3F);
24
  }	
25
}
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
  
26 66

  
27
/*void lcd_8b(unsigned char car); // envoi des 8 bits de poids fort
67
void lcd_com(char c) 
68
{ 
69
        p3_0=0; 
70
        lcd_8b(c); 
71
} 
28 72

  
29
{
30
	lcd_4b(car<<4);
31
	lcd_4b(car>>4);
32
}*/
33
void lcd_4b(unsigned char car)
34
{
35
	pd1 =0xFF;
36
	p1_2 = 0; // E = 1
37
	if(car&0x80)
38
   {
39
	p1_7 = 1;
40
   }
41
   else
42
   {
43
	   p1_7 = 0;
44
   }
45
   	if(car&0x40)
46
   {
47
	p1_6 = 1;
48
   }
49
   else
50
   {
51
	   p1_6 = 0;
52
   }
53
   	if(car&0x10)
54
   {
55
	p1_5 = 1;
56
   }
57
   else
58
   {
59
	   p1_5 = 0;
60
   }
61
   	if(car&0x01)
62
   {
63
	p1_4 = 1;
64
   }
65
   else
66
   {
67
	   p1_4 = 0;
68
   }
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; 
69 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
           
70 210
}
71

  
211
	
212
	

Also available in: Unified diff