Révision 583
Ajouté par nipelloux il y a environ 4 ans
branch/pelloux/sp4b1/SP4b1/SP4b1.c | ||
---|---|---|
/***********************************************************************/
|
||
|
||
#include "sfr32c87.h"
|
||
char touche;
|
||
char t;
|
||
|
||
void init_keyboard (void);
|
||
void tpo_50ms(void);
|
||
|
||
void main(void)
|
||
{
|
||
|
||
pd10=0x0F;
|
||
init_keyboard();
|
||
|
||
while(1){
|
||
|
||
//3eme colonne
|
||
|
||
p10=0x07;
|
||
t=p10;
|
||
if(t==0x77)
|
||
{
|
||
touche='#';
|
||
}
|
||
if(t==0xD7)
|
||
{
|
||
touche='0';
|
||
}
|
||
if(t==0xE7)
|
||
{
|
||
touche='*';
|
||
}
|
||
|
||
|
||
p10=0x0B;
|
||
t=p10;
|
||
if(t==0x7B)
|
||
{
|
||
touche='9';
|
||
}
|
||
if(t==0xDB)
|
||
{
|
||
touche='8';
|
||
}
|
||
if(t==0xEB)
|
||
{
|
||
touche='7';
|
||
}
|
||
|
||
|
||
p10=0x0D;
|
||
t=p10;
|
||
if(t==0x7D)
|
||
{;
|
||
touche='6';
|
||
}
|
||
if(t==0xDD)
|
||
{
|
||
touche='5';
|
||
}
|
||
if(t==0xBD)
|
||
{
|
||
touche='4';
|
||
}
|
||
|
||
|
||
p10=0x0E;
|
||
t=p10;
|
||
if(t==0x7E)
|
||
{
|
||
touche='3';
|
||
}
|
||
if(t==0xDE)
|
||
{
|
||
touche='2';
|
||
}
|
||
if(t==0xBE)
|
||
{
|
||
touche='1';
|
||
}
|
||
|
||
|
||
pu31=1;
|
||
|
||
}
|
||
|
||
}
|
||
|
||
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;
|
||
}
|
branch/pelloux/sp4b2/SP4b2/SessionM32C_E8a_SYSTEM.ini | ||
---|---|---|
PROCESSOR_MODE=0
|
||
[COMMUNI]
|
||
COMSPEED=8
|
||
COMSPEED PROGRAM FLASH=8
|
||
COMSPEED DATA FLASH=8
|
||
[Driver Configuration]
|
||
Renesas Communications=USB interface,0,
|
||
[Target]
|
||
M32C E8a SYSTEM=Renesas Communications
|
||
[USER_DATA]
|
||
RESET=fe0000
|
||
RESET=fe004a
|
branch/pelloux/sp4b2/SP4b2/SP4b2.c | ||
---|---|---|
/***********************************************************************/
|
||
|
||
#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 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='R';
|
||
unsigned char c[]="Je pense que ca marche";
|
||
//pd1 = 0xff;
|
||
pd3 = 0xff;
|
||
pd3 = 0xff;//***
|
||
//lcd4b(c);
|
||
//lcd8b(c);
|
||
//lcdcom(c);
|
||
lcd_init();
|
||
lcdChar(c);
|
||
|
||
clavier();
|
||
|
||
}
|
||
|
||
void lcd4b(unsigned char car)
|
||
{
|
||
p3_2=1;
|
||
|
||
if (car & 0x80)
|
||
if (car & 0x80)//****
|
||
{
|
||
p3_7=1;
|
||
}else
|
||
... | ... | |
}
|
||
|
||
void tpo_ms(unsigned short duree){
|
||
tpo_us(duree*1000);
|
||
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)
|
||
{
|
||
... | ... | |
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
|
||
|
||
}
|
Formats disponibles : Unified diff
Clavier fonctionnel et qui affiche bien ce qu'il faut sur l'ecran lcd