root/branch/leroy/sp4b2/SP4b2/SP4b2.c @ 509
491 | jeleroy | /***********************************************************************/
|
|
/* */
|
|||
/* 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. */
|
|||
/***********************************************************************/
|
|||
499 | jeleroy | #include "sfr32c87.h"
|
|
491 | jeleroy | ||
499 | jeleroy | #define port pd3
|
|
#define LCD_RS p3_0
|
|||
#define LCD_RW p3_1
|
|||
#define LCD_E p3_2
|
|||
#define LCD_B4 p3_4
|
|||
#define LCD_B5 p3_5
|
|||
#define LCD_B6 p3_6
|
|||
#define LCD_B7 p3_7
|
|||
void LCD_init_port(void);
|
|||
void tpo_us(unsigned short duree);
|
|||
void tpo_ms(unsigned short duree);
|
|||
void LCD_4b(unsigned char car);
|
|||
void LCD_8b(unsigned char car);
|
|||
void LCD_com(unsigned char car);
|
|||
void LCD_init(void);
|
|||
void LCD_char(unsigned char car);
|
|||
void LCD_str(unsigned char *str);
|
|||
void LCD_init_port(void){
|
|||
port = 0xFF;
|
|||
}
|
|||
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){
|
|||
tcspr = 0x8A;
|
|||
ta0mr = 0x82;
|
|||
ta0 = duree*1000;
|
|||
ta0s = 1;
|
|||
ta0os = 1;
|
|||
ta0ic = 0x00;
|
|||
while(ir_ta0ic != 1);
|
|||
ta0s = 0;
|
|||
}
|
|||
void LCD_4b(unsigned char car){
|
|||
LCD_E = 1;
|
|||
if (car & 128){
|
|||
LCD_B7 = 1;
|
|||
}else{
|
|||
LCD_B7 = 0;
|
|||
}
|
|||
if (car & 64){
|
|||
LCD_B6 = 1;
|
|||
}else{
|
|||
LCD_B6 = 0;
|
|||
}
|
|||
if (car & 32){
|
|||
LCD_B5 = 1;
|
|||
}else{
|
|||
LCD_B5 = 0;
|
|||
}
|
|||
if (car & 16){
|
|||
LCD_B4 = 1;
|
|||
}else{
|
|||
LCD_B4 = 0;
|
|||
}
|
|||
LCD_E = 0;
|
|||
}
|
|||
void LCD_8b(unsigned char car){
|
|||
LCD_4b(car);
|
|||
LCD_4b(car<<4);
|
|||
}
|
|||
void LCD_com(unsigned char car){
|
|||
LCD_RS = 0;
|
|||
LCD_8b(car);
|
|||
}
|
|||
void LCD_init(void){
|
|||
LCD_RS=0;
|
|||
tpo_ms(15);
|
|||
LCD_4b(0x30);
|
|||
tpo_ms(5);
|
|||
LCD_4b(0x30);
|
|||
tpo_us(100);
|
|||
LCD_4b(0x30);
|
|||
tpo_us(100);
|
|||
LCD_4b(0x20);
|
|||
LCD_com(0x28);
|
|||
LCD_com(0x06);
|
|||
LCD_com(0x0E);
|
|||
LCD_com(0x01);
|
|||
tpo_ms(5);
|
|||
}
|
|||
void LCD_char(unsigned char car){
|
|||
LCD_RS = 1;
|
|||
LCD_8b(car);
|
|||
}
|
|||
void LCD_str(unsigned char *str){
|
|||
int i = 0;
|
|||
while(str[i] != '\0'){
|
|||
LCD_char(str[i]);
|
|||
i ++;
|
|||
}
|
|||
}
|
|||
491 | jeleroy | void main(void)
|
|
{
|
|||
499 | jeleroy | char car[] = {'B','o','n','j','o','u','r',' ',};
|
|
LCD_init_port();
|
|||
LCD_init();
|
|||
LCD_str(car);
|
|||
491 | jeleroy | }
|