Projet

Général

Profil

/***********************************************************************/
/* */
/* FILE :sp4b2.c */
/* DATE :Fri, May 28, 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 tpo_ms(void){
tcspr = 0x8A;
ta0mr = 0x82;
ta0 = 500000;
ta0s = 1;ta0os = 1;
ta0ic = 0x00;
while(ir_ta0ic != 1);
ta0s = 0;
}

void lcd4b(char c){ //Gestion des 4 bits
pd3 = 0xff;
p3_2 = 1; // E = 1;
if (c & 0x80){ //On fait un et entre chaque valeur pour savoir lequel est ? 1
p3_7 = 1;
}
else{
p3_7 = 0;
}
if (c & 0x40)
{
p3_6 = 1;
}
else{
p3_6 = 0;
}
if (c & 0x20)
{
p3_5 = 1;
}
else{
p3_5 = 0;
}
if (c & 0x10)
{
p3_4 = 1;
}
else{
p3_4 = 0;
}
p3_2 = 0; // E = 0;
}

void lcd8b(char c){ //On utilise notre fonction pr?cedente
lcd4b(c);
lcd4b(c << 4);
}

void lcdcom(char c){ //On affiche une commande
p1_0 = 0;
lcd8b(c);
}

void lcdinit(void){ //On initialise notre ?cran
p1_0=0;
tpo_ms();
lcd4b(0x30);
tpo_ms();
lcd4b(0x30);
tpo_ms();
lcd4b(0x30);
tpo_ms();
lcd4b(0x20);
lcdcom(0x28);
lcdcom(0x06);
lcdcom(0x0E);
lcdcom(0x01);
}


void lcdcar(char c){ //On affiche un carat?re
p3_0 = 1;
lcd8b(c);
}

void lcdstr(unsigned char *str){ //On affiche une chaine de caract?re
int i = 0;
int j = 0;
while(str[i] != '\0'){
lcdcar(str[i]);
i++;
}
}


void afficher(unsigned char *test){
tpo_ms();
lcdstr(test);
}


void affichage_touche(void){
char t;
char* touche= "X";
pd10 = 0xF0;
p10 = 0xFF;
pu30 = 1;
t = p10;
p10 = 0x00;
p10 = 0x0F; // On part de la premi?re colonne
t = p10;
if (t != 0x0F){
tpo_ms();
if (t == 0x07){ //On change un bit pour voir
touche = "#";
}
if (t == 0x0e){ //On change un bit pour voir
touche="3";
}
if (t == 0x0d){ //On change un bit pour voir
touche="6";
}
if (t == 0x0b){ //On change un bit pour voir
touche="9";
}

p10 = 0xEF; // On d?finit un premier chiffre pour commencer la v?rif
t = p10; //On r?cup?re la valeur appuy?e

if (t == 0xE7){ //On change un bit pour voir
tpo_ms();
afficher("*");
touche="";
}
if (t == 0xEB){
touche="7";
}

p10 = 0xDF; // On d?finit un premier chiffre pour commencer la v?rif
t = p10; //On r?cup?re la valeur appuy?e

if (t == 0xD7){ //On regarde la premi?re colonne
touche="0";
}
if (t == 0xDB){ //On change un bit pour voir
touche="8";
}
if (t == 0xDD){
// p10 = 0xDF;
touche="5";
}
if (t == 0xDE){
touche="2";
}

p10 = 0xBF; // On d?finit un premier chiffre pour commencer la v?rif
t = p10; //On r?cup?re la valeur appuy?e
if (t == 0xBD){ //On change un bit pour voir
touche="4";
}
if (t == 0xBE){ //On change un bit pour voir
touche="1";
}
afficher(touche);
}

}


void main(void) //On test dans notre main
{
char t;
lcdinit();
while (1){
t = p10;
affichage_touche();
}
}
(9-9/10)