Révision 702
Ajouté par beclement2 il y a presque 4 ans
branch/CLEMENT/sp4b2/sp4b2/SessionM32C_E8a_SYSTEM.ini | ||
---|---|---|
[Target]
|
||
M32C E8a SYSTEM=Renesas Communications
|
||
[USER_DATA]
|
||
RESET=fe0006
|
||
RESET=fe001c
|
branch/CLEMENT/sp4b2/sp4b2/sp4b2.c | ||
---|---|---|
|
||
#include "sfr32c87.h"
|
||
|
||
void lcd4b(char c){ //Gestion des 4 bits
|
||
/* void lcd4b(char c){ //Gestion des 4 bits
|
||
pd3 = 0xff;
|
||
p3_2 = 1; // E = 1;
|
||
|
||
... | ... | |
p3_2 = 0; // E = 0;
|
||
}
|
||
|
||
void tpo_ms(void){
|
||
tcspr = 0x8A;
|
||
ta0mr = 0x82;
|
||
ta0 = 50000;
|
||
ta0s = 1;ta0os = 1;
|
||
ta0ic = 0x00;
|
||
while(ir_ta0ic != 1);
|
||
ta0s = 0;
|
||
}
|
||
|
||
void lcd8b(char c){ //On utilise notre fonction pr?cedente
|
||
|
||
lcd4b(c);
|
||
... | ... | |
|
||
void lcdinit(void){ //On initialise notre ?cran
|
||
p3_0=0;
|
||
// tpo_ms(15);
|
||
tpo_ms();
|
||
lcd4b(0x30);
|
||
// tpo_ms(5);
|
||
tpo_ms();
|
||
lcd4b(0x30);
|
||
// tpo_us(100);
|
||
//tpo_us(100);
|
||
lcd4b(0x30);
|
||
// tpo_us(100);
|
||
//tpo_us(100);
|
||
lcd4b(0x20);
|
||
lcdcom(0x28);
|
||
lcdcom(0x06);
|
||
... | ... | |
}
|
||
}
|
||
|
||
void init_keyboard(void){
|
||
pd10 = 0x0F;
|
||
p10=0;
|
||
pu31 = 1;
|
||
}
|
||
|
||
void afficher(unsigned char *test){
|
||
|
||
tpo_ms;
|
||
lcdstr(test);
|
||
|
||
}
|
||
|
||
|
||
void affichage_touche(void){
|
||
|
||
char t;
|
||
|
||
|
||
p10 = 0x0F; // On part de la premi?re colonne
|
||
t = p10;
|
||
if (t != 0x0F){
|
||
|
||
if (t == 0x07){ //On change un bit pour voir
|
||
tpo_ms();
|
||
afficher("#");
|
||
|
||
}
|
||
|
||
if (t == 0x0e){ //On change un bit pour voir
|
||
tpo_ms();
|
||
afficher("3");
|
||
}
|
||
|
||
if (t == 0x0d){ //On change un bit pour voir
|
||
tpo_ms();
|
||
afficher("6");
|
||
}
|
||
|
||
if (t == 0x0b){ //On change un bit pour voir
|
||
tpo_ms();
|
||
afficher("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("*");
|
||
}
|
||
if (t == 0xEB){
|
||
tpo_ms();
|
||
afficher("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
|
||
tpo_ms();
|
||
afficher("0");
|
||
}
|
||
if (t == 0xDB){ //On change un bit pour voir
|
||
tpo_ms();
|
||
afficher("8");
|
||
}
|
||
if (t == 0xDD){
|
||
// p10 = 0xDF;
|
||
tpo_ms();
|
||
afficher("5");
|
||
}
|
||
if (t == 0xDE){
|
||
tpo_ms();
|
||
afficher("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
|
||
tpo_ms();
|
||
afficher("4");
|
||
}
|
||
|
||
if (t == 0xBE){ //On change un bit pour voir
|
||
tpo_ms();
|
||
afficher("1");
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
void main(void) //On test dans notre main
|
||
{
|
||
|
||
/* char t;
|
||
lcdinit();
|
||
init_keyboard();
|
||
|
||
while (1){
|
||
t = p10;
|
||
if (t != 0xf0)
|
||
{
|
||
affichage_touche();
|
||
}
|
||
}
|
||
|
||
lcdinit();
|
||
lcdstr("Test");
|
||
|
||
} */
|
||
|
||
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();
|
||
|
||
}
|
||
}
|
Formats disponibles : Unified diff
Fin du programme, assemblage du code lcd + clavier fait.