Projet

Général

Profil

302 jgsoleilla
/***********************************************************************/
/* */
/* 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. */
/***********************************************************************/

321 jgsoleilla
#include "sfr32c87.h"

585 jgsoleilla
void init_keyboard(void);
void tpo_50ms(void);
char clavier(void);
321 jgsoleilla
585 jgsoleilla
void main(void){
321 jgsoleilla
585 jgsoleilla
char touche = 0;

init_keyboard();

321 jgsoleilla
while(1){
585 jgsoleilla
if (p10 != 0xf0 ){

while(1){
touche = clavier();
}

504 jgsoleilla
}
585 jgsoleilla
}
}

char clavier(void){
unsigned char touche;
unsigned char t;
321 jgsoleilla
585 jgsoleilla
p10 = 0x0E;
t = p10;
if (t == 0xBE){
tpo_50ms();
touche = '1';
}

if (t == 0xDE){
tpo_50ms();
touche = '2';
}
321 jgsoleilla
585 jgsoleilla
if (t == 0x7E){
tpo_50ms();
touche = '3';
}
504 jgsoleilla
585 jgsoleilla
p10 = 0x0D;
t = p10;
if (t == 0xBD){
tpo_50ms();
touche = '4';
}

if (t == 0xDD){
tpo_50ms();
touche = '5';
}
504 jgsoleilla
585 jgsoleilla
if (t == 0x7D){
tpo_50ms();
touche = '6';
}
321 jgsoleilla
585 jgsoleilla
p10 = 0x0B;
t = p10;
if (t == 0xEB){
tpo_50ms();
touche = '7';
}
504 jgsoleilla
585 jgsoleilla
if (t == 0xDB){
tpo_50ms();
touche = '8';
}
504 jgsoleilla
585 jgsoleilla
if (t == 0x7B){
tpo_50ms();
touche = '9';
}

p10 = 0x07;
t = p10;
if (t == 0xE7){
tpo_50ms();
touche = '*';
}
321 jgsoleilla
585 jgsoleilla
if (t == 0xD7){
tpo_50ms();
touche = '0';
321 jgsoleilla
}
585 jgsoleilla
if (t == 0x77){
tpo_50ms();
touche = '#';
}
return touche;
302 jgsoleilla
}
321 jgsoleilla


void tpo_50ms(void){
tcspr = 0x8A;
ta0mr = 0x82;
ta0 = 50000;
ta0s = 1;
ta0os = 1;
ta0ic = 0x00;
585 jgsoleilla
while(ir_ta0ic != 1){
321 jgsoleilla
ta0s = 0;
585 jgsoleilla
}
321 jgsoleilla
}
585 jgsoleilla

void init_keyboard(void){
p10 = 0;
pu31 = 1;
pd10 = 0x0F;
}