Projet

Général

Profil

506 nipelloux
/***********************************************************************/
/* */
/* 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"
583 nipelloux
#include <stdlib.h>
506 nipelloux
583 nipelloux
char touche;//***
char t;

506 nipelloux
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);
583 nipelloux
void lcd_str(unsigned char * str);
void clavier (void);
void init_keyboard (void);

506 nipelloux
void main(void)
{
583 nipelloux
unsigned char c[]="Je pense que ca marche";
506 nipelloux
//pd1 = 0xff;
583 nipelloux
pd3 = 0xff;//***
506 nipelloux
//lcd4b(c);
//lcd8b(c);
//lcdcom(c);

583 nipelloux
clavier();

506 nipelloux
}

void lcd4b(unsigned char car)
{
p3_2=1;

583 nipelloux
if (car & 0x80)//****
506 nipelloux
{
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){
583 nipelloux
tpo_us(duree*1000);//**** risqu?
506 nipelloux
}

583 nipelloux
void lcd_str(unsigned char * str){
int i=0;

while(str[i] != '\0'){
lcdChar(str[i]);//** i++
i++;
}
}
506 nipelloux
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);
}
583 nipelloux
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

}