Projet

Général

Profil

/***********************************************************************/
/* */
/* FILE :SP4b1.c */
/* DATE :Tue, May 18, 2021 */
/* DESCRIPTION :main program file. */
/* CPU GROUP :87B */
/* */
/* This file is generated by Renesas Project Generator (Ver.4.18). */
/* NOTE:THIS IS A TYPICAL EXAMPLE. */
/***********************************************************************/
#include "sfr32c87.h"

void init_keyboard(void);
void tpo_50ms(void);
void decode_touche(unsigned char code_touche,unsigned char* valeur_touche);
unsigned char touche = 0; /**/
unsigned char premier_code_touche = 0; /**/
unsigned char deuxieme_code_touche = 0; /**/
unsigned char code_touche = 0;
unsigned char valeur_touche;
int i;


void main(void){
init_keyboard();
while(1){
pd10 = 0x0F;
p10=0;
pu31 = 1;
pu30 = 1;
/*if ((p10 & 0xf0)!= 0xf0)*/{
touche = p10;
tpo_50ms();
premier_code_touche = touche & 0xF0; /****/
pd10 = 0xF0;
// p10 = 0; //**
pu31 = 1; //***
p10 = touche;

touche = p10;

deuxieme_code_touche = 0x0F & touche;
code_touche = deuxieme_code_touche+premier_code_touche;
}
decode_touche(code_touche,&valeur_touche);
}
}

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;
}
void decode_touche(unsigned char code_touche,unsigned char* valeur_touche){
switch(code_touche){
case 'be' :
*valeur_touche = '1';
break;
case 'de' :
*valeur_touche = '2';
break;
case '7e' :
*valeur_touche = '3';
break;

case 'bd' :
*valeur_touche = '4';
break;

case 'dd' :
*valeur_touche = '5';
break;
case '7d' :
*valeur_touche = '6';
break;

case 'eb' :
*valeur_touche = '7';
break;
case 'bb' :
*valeur_touche = '8';
break;
case '7b' :
*valeur_touche = '9';
break;
case 'e7' :
*valeur_touche = '*';
break;
case 'd7' :
*valeur_touche = '0';
break;
case '77' :
valeur_touche = '#';
break;
}
}
(2-2/8)