|
/***********************************************************************/
|
|
/* */
|
|
/* FILE :SP4b2.c */
|
|
/* DATE :Tue, May 25, 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"
|
|
#include <stdlib.h>
|
|
|
|
char touche;//***
|
|
char t;
|
|
|
|
void lcd4b(unsigned char car);
|
|
void lcd8b(unsigned char car);
|
|
void lcdcom(unsigned char car);
|
|
void lcdChar (unsigned char car);
|
|
void tpo_us(unsigned short duree);
|
|
void tpo_ms(unsigned short duree);
|
|
void lcd_init(void);
|
|
void lcd_str(unsigned char * str);
|
|
void clavier (void);
|
|
void init_keyboard (void);
|
|
|
|
void main(void)
|
|
{
|
|
unsigned char c[]="Je pense que ca marche";
|
|
//pd1 = 0xff;
|
|
pd3 = 0xff;//***
|
|
//lcd4b(c);
|
|
//lcd8b(c);
|
|
//lcdcom(c);
|
|
|
|
clavier();
|
|
|
|
}
|
|
|
|
void lcd4b(unsigned char car)
|
|
{
|
|
p3_2=1;
|
|
|
|
if (car & 0x80)//****
|
|
{
|
|
p3_7=1;
|
|
}else
|
|
{
|
|
p3_7=0;
|
|
}
|
|
|
|
if (car & 0x40)
|
|
{
|
|
p3_6=1;
|
|
}else
|
|
{
|
|
p3_6=0;
|
|
}
|
|
|
|
if (car & 0x20)
|
|
{
|
|
p3_5=1;
|
|
}else
|
|
{
|
|
p3_5=0;
|
|
}
|
|
|
|
if (car & 0x10)
|
|
{
|
|
p3_4=1;
|
|
}else
|
|
{
|
|
p3_4=0;
|
|
}
|
|
|
|
p3_2=0;
|
|
}
|
|
|
|
void lcd8b(unsigned char car)
|
|
{
|
|
|
|
lcd4b(car);
|
|
lcd4b(car << 4);
|
|
|
|
}
|
|
|
|
void lcdcom(unsigned char car)
|
|
{
|
|
p3_0=0;
|
|
lcd8b(car);
|
|
}
|
|
|
|
void lcdChar (unsigned char car)
|
|
{
|
|
p3_0=1;
|
|
lcd8b(car);
|
|
|
|
}
|
|
|
|
|
|
void tpo_us(unsigned short duree){
|
|
tcspr = 0x8A;
|
|
ta0mr = 0x82;
|
|
ta0 = duree;
|
|
ta0s = 1; ta0os = 1;
|
|
ta0ic = 0x00;
|
|
while(ir_ta0ic != 1);
|
|
ta0s = 0;
|
|
}
|
|
|
|
void tpo_ms(unsigned short duree){
|
|
tpo_us(duree*1000);//**** risqu?
|
|
}
|
|
|
|
void lcd_str(unsigned char * str){
|
|
int i=0;
|
|
|
|
while(str[i] != '\0'){
|
|
lcdChar(str[i]);//** i++
|
|
i++;
|
|
}
|
|
}
|
|
|
|
void lcd_init(void)
|
|
{
|
|
p3_0=0;
|
|
tpo_ms(15);
|
|
lcd4b(0x30);
|
|
tpo_ms(5);
|
|
lcd4b(0x30);
|
|
tpo_us(100);
|
|
lcd4b(0x30);
|
|
tpo_us(100);
|
|
lcd4b(0x20);
|
|
lcdcom(0x28);
|
|
lcdcom(0x06);
|
|
lcdcom(0x0E);
|
|
lcdcom(0x01);
|
|
tpo_ms(5);
|
|
}
|
|
|
|
void clavier (void)
|
|
{
|
|
init_keyboard();
|
|
lcd_init();
|
|
while(1){
|
|
|
|
|
|
p10=0x07;
|
|
t=p10;
|
|
if(t==0x77)
|
|
{
|
|
lcdcom(0x01);//***
|
|
tpo_ms(10);//***
|
|
touche='#';
|
|
lcd_str("#");//**
|
|
|
|
}
|
|
if(t==0xD7)
|
|
{
|
|
lcdcom(0x01);//***
|
|
tpo_ms(10);//***
|
|
touche='0';
|
|
lcd_str("Arret Alarme");//***
|
|
}
|
|
if(t==0xE7)
|
|
{
|
|
lcdcom(0x01);
|
|
tpo_ms(10);
|
|
touche='*';
|
|
lcd_str("*");
|
|
}
|
|
|
|
|
|
p10=0x0B;//**
|
|
t=p10;
|
|
if(t==0x7B)
|
|
{
|
|
lcdcom(0x01);
|
|
tpo_ms(10);
|
|
touche='9';
|
|
lcd_str("...");
|
|
}
|
|
if(t==0xDB)
|
|
{
|
|
lcdcom(0x01);
|
|
tpo_ms(10);
|
|
touche='8';
|
|
lcd_str("...");
|
|
}
|
|
if(t==0xEB)
|
|
{
|
|
lcdcom(0x01);
|
|
tpo_ms(10);
|
|
touche='7';
|
|
lcd_str("Ajout Zone");
|
|
}
|
|
|
|
|
|
p10=0x0D;
|
|
t=p10;
|
|
if(t==0x7D)
|
|
{
|
|
lcdcom(0x01);
|
|
tpo_ms(10);
|
|
touche='6';
|
|
lcd_str("...");
|
|
}
|
|
if(t==0xDD)
|
|
{
|
|
lcdcom(0x01);
|
|
tpo_ms(10);
|
|
touche='5';
|
|
lcd_str("130 km/h");
|
|
}
|
|
if(t==0xBD)
|
|
{
|
|
lcdcom(0x01);
|
|
tpo_ms(10);
|
|
touche='4';
|
|
lcd_str("110 km/h");
|
|
}
|
|
|
|
|
|
p10=0x0E;
|
|
t=p10;
|
|
if(t==0x7E)
|
|
{
|
|
lcdcom(0x01);
|
|
tpo_ms(10);
|
|
touche='3';
|
|
lcd_str("90 km/h");
|
|
}
|
|
if(t==0xDE)
|
|
{
|
|
lcdcom(0x01);
|
|
tpo_ms(10);
|
|
touche='2';
|
|
lcd_str("70 km/h");
|
|
}
|
|
if(t==0xBE)
|
|
{
|
|
lcdcom(0x01);
|
|
tpo_ms(10);
|
|
touche='1';
|
|
lcd_str("50 km/h");
|
|
}
|
|
|
|
|
|
pu31=1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void init_keyboard (void)
|
|
{
|
|
pd10=0x0F;//poids fort en sortie et poids faible en entree
|
|
p10=0x00;
|
|
pu31=1;//Mise en place de nos pull up
|
|
|
|
}
|