Révision 453
Ajouté par begresset il y a presque 4 ans
SP4b1.c | ||
---|---|---|
|
||
#include "sfr32c87.h"
|
||
|
||
/*#define LCD_PORT p1
|
||
#define LCD_PORT_DIR 1
|
||
#define LCD_E LCD_PORT_2
|
||
#define LCD_RW LCD_PORT_1
|
||
#define LCD_DC LCD_PORT_0
|
||
#define LCD_E_DIR LCD_PORT_DIR
|
||
#define LCD_RW_DIR LCD_PORT_DIR
|
||
#define LCD_DC_DIR LCD_PORT_DIR*/
|
||
|
||
|
||
void lcd_4b(unsigned char car){
|
||
pd3=0xFF;
|
||
p3_2=1;
|
||
if (car&0b10000000){
|
||
p3_7=1;
|
||
}
|
||
else{
|
||
p3_7=0;
|
||
}
|
||
if (car&0b01000000){
|
||
p3_6=1;
|
||
}
|
||
else{
|
||
p3_6=0;
|
||
}
|
||
if (car&0b00100000){
|
||
p3_5=1;
|
||
}
|
||
else{
|
||
p3_5=0;
|
||
}
|
||
if (car&0b00010000){
|
||
p3_4=1;
|
||
}
|
||
else{
|
||
p3_4=0;
|
||
}
|
||
p3_2=0;
|
||
}
|
||
|
||
void lcd_8b(unsigned char car){
|
||
lcd_4b(car);
|
||
lcd_4b(car<<4);
|
||
}
|
||
|
||
void lcd_com(unsigned char com){
|
||
p3_0=0;
|
||
lcd_8b(com);
|
||
}
|
||
|
||
void lcd_init(void){
|
||
pd3=0xFF;
|
||
p3_0=0;
|
||
lcd_4b(0x30);
|
||
lcd_4b(0x30);
|
||
lcd_4b(0x30);
|
||
lcd_4b(0x20);
|
||
lcd_com(0x28);
|
||
lcd_com(0x06);
|
||
lcd_com(0x0E);
|
||
lcd_com(0x01);
|
||
}
|
||
|
||
void lcd_car(unsigned char car){
|
||
p3_0=1;
|
||
lcd_8b(car);
|
||
}
|
||
|
||
void main (void){
|
||
lcd_init();
|
||
lcd_car(0b01100001);
|
||
|
||
}
|
||
/*id init_keyboard(void);
|
||
void tpo_50ms(void);
|
||
|
||
... | ... | |
while(ir_ta0ic != 1);
|
||
ta0s=0;
|
||
}*/
|
||
char touche;
|
||
/*char touche;
|
||
char t;
|
||
void main(void){
|
||
pd10=0x0F;
|
||
... | ... | |
pu31=0xFF;
|
||
pu30=0xFF;
|
||
while(1){
|
||
//p10=0b11110111;
|
||
//if((p10&0xFF)!=0xFF){
|
||
//t=p10;
|
||
if(p10==0xe1){
|
||
p10=0b11110111;
|
||
if((p10&0x0F)!=0x0F){
|
||
t=p10;
|
||
}
|
||
p10=0b11111011;
|
||
if((p10&0x0F)!=0x0F){
|
||
t=p10;
|
||
}
|
||
p10=0b11111101;
|
||
if((p10&0x0F)!=0x0F){
|
||
t=p10;
|
||
}
|
||
p10=0b11111110;
|
||
if((p10&0x0F)!=0x0F){
|
||
t=p10;
|
||
}
|
||
/*switch(p10){
|
||
case 0xe1 :
|
||
touche='*';
|
||
case 0xd1 :
|
||
touche='0';
|
||
case 0x71 :
|
||
touche='#';
|
||
case 0xeb :
|
||
touche='7';
|
||
case 0xdb :
|
||
touche='8';
|
||
case 0x7b :
|
||
touche='9';
|
||
case 0xbd :
|
||
touche='4';
|
||
case 0xdd :
|
||
touche='5';
|
||
case 0x7d :
|
||
touche='6';
|
||
case 0xbe :
|
||
touche='1';
|
||
case 0xde :
|
||
touche='2';
|
||
case 0x7e :
|
||
touche='3';
|
||
}*/
|
||
|
||
/*if(p10==0xe1){
|
||
touche='*';
|
||
}
|
||
if (p10=0xd1){
|
||
... | ... | |
}
|
||
if (p10=0x71){
|
||
touche='#';
|
||
}
|
||
//p10=0b11111011;
|
||
//if((p10&0xF0)!=0xF0){
|
||
//t=p10;
|
||
//if(p10=0x0b){
|
||
if (p10=0xeb){
|
||
}*/
|
||
|
||
/*if (p10=0xeb){
|
||
touche='7';
|
||
}
|
||
if (p10=0xdb){
|
||
... | ... | |
}
|
||
if (p10=0x7b){
|
||
touche='9';
|
||
}
|
||
//p10=0b11111101;
|
||
//if((p10&0xF0)!=0xF0){
|
||
//t=p10;
|
||
//if(p10=0x0d){
|
||
if (p10=0xbd){
|
||
}*/
|
||
|
||
/*if (p10=0xbd){
|
||
touche='4';
|
||
}
|
||
if (p10=0xdd){
|
||
... | ... | |
}
|
||
if (p10=0x7d){
|
||
touche='6';
|
||
}
|
||
//p10=0b11111110;
|
||
//if((p10&0xF0)!=0xF0){
|
||
//t=p10;
|
||
//if(p10=0x0e){
|
||
if (p10=0xbe){
|
||
touche='1';
|
||
}
|
||
if (p10=0xde){
|
||
touche='2';
|
||
}
|
||
if (p10=0x7e){
|
||
touche='3';
|
||
}
|
||
}
|
||
}
|
||
}*/
|
||
|
||
//if (p10=0xbe){
|
||
//touche='1';
|
||
//}
|
||
//if (p10=0xde){
|
||
//touche='2';
|
||
//}
|
||
//if (p10=0x7e){
|
||
//touche='3';
|
||
//}
|
||
//}
|
||
//}
|
||
|
||
|
||
|
Formats disponibles : Unified diff
Séance de TP 2b.