Révision 477
Ajouté par chsabot il y a plus de 4 ans
| SP4b1.c | ||
|---|---|---|
|
|
||
|
#include "sfr32c87.h"
|
||
|
|
||
|
char t;
|
||
|
char touche;
|
||
|
void main(void){
|
||
|
#define LCD_E()
|
||
|
#define LCD_E_DIR()
|
||
|
|
||
|
pd10=0x0F;
|
||
|
pu31=1;
|
||
|
p10=0x00;
|
||
|
while(1){
|
||
|
t=p10;
|
||
|
if(t!=0xF0){
|
||
|
p10=0xFE;
|
||
|
t=p10;
|
||
|
if(t==0xDE){
|
||
|
touche='2';
|
||
|
}
|
||
|
if(t==0x7E){
|
||
|
touche='3';
|
||
|
}
|
||
|
if(t==0xBE){
|
||
|
touche='1';
|
||
|
}
|
||
|
p10=0xFD;
|
||
|
t=p10;
|
||
|
if(t==0x7D){
|
||
|
touche='6';
|
||
|
}
|
||
|
if(t==0xDD){
|
||
|
touche='5';
|
||
|
}
|
||
|
if(t==0xBD){
|
||
|
touche='4';
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
#define LCD_RW()
|
||
|
#define LCD_RW_DIR()
|
||
|
|
||
|
#define LCD_DC()
|
||
|
#define LCD_DC_DIR()
|
||
|
|
||
|
#define LCD_PORT()
|
||
|
#define LCD_PORT_DIR()
|
||
|
|
||
|
//temporisation en us
|
||
|
void tpo_us(unsigned short duree);
|
||
|
|
||
|
// temporisation en ms
|
||
|
void tpo_ms(unsigned short duree);
|
||
|
|
||
|
|
||
|
//envoie des 4 bits de poids fort
|
||
|
void lcd_4b(unsigned char car){
|
||
|
p1_2=1;
|
||
|
p1_2=0;
|
||
|
car=3;
|
||
|
if (car & 8){
|
||
|
p1_4=1;
|
||
|
}
|
||
|
else{
|
||
|
p1_4=0;
|
||
|
}
|
||
|
if (car & 16){
|
||
|
p1_5=1;
|
||
|
}
|
||
|
else{
|
||
|
p1_5=0;
|
||
|
}
|
||
|
if (car & 32){
|
||
|
p1_6=1;
|
||
|
}
|
||
|
else{
|
||
|
p1_6=0;
|
||
|
}
|
||
|
if (car & 64){
|
||
|
p1_7=1;
|
||
|
}
|
||
|
else{
|
||
|
p1_7=0;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
void main(void){
|
||
|
lcd_4b(0xF0);
|
||
|
}
|
||
|
|
||
|
|
||
|
//Clavier
|
||
|
//char t;
|
||
|
//char touche;
|
||
|
//void main(void){
|
||
|
|
||
|
// pd10=0x0F;
|
||
|
// pu31=1;
|
||
|
// p10=0x00;
|
||
|
// while(1){
|
||
|
// t=p10;
|
||
|
// if(t!=0xF0){
|
||
|
// p10=0xFE;
|
||
|
// t=p10;
|
||
|
// if(t==0xDE){
|
||
|
// touche='2';
|
||
|
// }
|
||
|
// if(t==0x7E){
|
||
|
// touche='3';
|
||
|
// }
|
||
|
// if(t==0xBE){
|
||
|
// touche='1';
|
||
|
// }
|
||
|
// p10=0xFD;
|
||
|
// t=p10;
|
||
|
// if(t==0x7D){
|
||
|
// touche='6';
|
||
|
// }
|
||
|
// if(t==0xDD){
|
||
|
// touche='5';
|
||
|
// }
|
||
|
// if(t==0xBD){
|
||
|
// touche='4';
|
||
|
// }
|
||
|
//
|
||
|
// }
|
||
|
// }
|
||
|
//}
|
||
|
|
||
|
|
||
Formats disponibles : Unified diff
Modification pour l'afficheur