Révision 340
Ajouté par clbouillot2 il y a presque 4 ans
SP4b1.c | ||
---|---|---|
/* NOTE:THIS IS A TYPICAL EXAMPLE. */
|
||
/***********************************************************************/
|
||
|
||
void main(void)
|
||
{
|
||
|
||
#include "sfr32c87.h"
|
||
|
||
void init_keyboard(void);
|
||
void tpo_50ms(void) ;
|
||
|
||
unsigned char touche_c = 0;
|
||
unsigned char touche_appuyee;
|
||
|
||
void main(void){
|
||
init_keyboard();
|
||
while(1){
|
||
if ( (p10 & 0xf0)!= 0xf0 ){ //les colonnes sont en entr?es
|
||
touche_c = p10 ;
|
||
tpo_50ms() ; // une temporisation entre en oeuvre pour ?viter les ph?nom?nes de rebond
|
||
|
||
p10 = 0x0e;
|
||
if ( (p10 & 0xff)== 0xbe ){ //diff?rents tests
|
||
touche_appuyee = '1';
|
||
}
|
||
if ( (p10 & 0xff)== 0xde ){
|
||
touche_appuyee = '2';
|
||
}
|
||
if ( (p10 & 0xff)== 0x7e ){
|
||
touche_appuyee = '3';
|
||
}
|
||
|
||
p10 = 0x0d;
|
||
if ( (p10 & 0xff)== 0xbd ){
|
||
touche_appuyee = '4';
|
||
}
|
||
if ( (p10 & 0xff)== 0xdd ){
|
||
touche_appuyee = '5';
|
||
}
|
||
if ( (p10 & 0xff)== 0x7d ){
|
||
touche_appuyee = '6';
|
||
}
|
||
|
||
p10 = 0x0b;
|
||
if ( (p10 & 0xff)== 0xeb ){
|
||
touche_appuyee = '7';
|
||
}
|
||
if ( (p10 & 0xff)== 0xdb ){
|
||
touche_appuyee = '8';
|
||
}
|
||
if ( (p10 & 0xff)== 0x7b ){
|
||
touche_appuyee = '9';
|
||
}
|
||
|
||
p10 = 0x07;
|
||
if ( (p10 & 0xff)== 0xe7 ){
|
||
touche_appuyee = '*';
|
||
}
|
||
if ( (p10 & 0xff)== 0xd7 ){
|
||
touche_appuyee = '0';
|
||
}
|
||
if ( (p10 & 0xff)== 0x77 ){
|
||
touche_appuyee = '#';
|
||
}
|
||
}
|
||
init_keyboard();
|
||
}
|
||
}
+
|
||
|
||
void init_keyboard(void){
|
||
pd10 = 0x0f; p10=0 ;pu31 = 1;
|
||
}
|
||
|
||
void tpo_50ms(void){
|
||
tcspr = 0x8A;
|
||
ta0mr = 0x82;
|
||
ta0 = 50000;
|
||
ta0s = 1;ta0os = 1;
|
||
ta0ic = 0x00;
|
||
while(ir_ta0ic != 1);
|
||
ta0s = 0;
|
||
}
|
Formats disponibles : Unified diff
implantation du code pour le clavier matricé