1 |
/* mija 2008 |
1 |
/* mija 2008 |
2 |
|
2 |
|
3 |
*.h file for defines lcd.c |
3 |
*.h file for defines lcd.c |
4 |
|
4 |
|
5 |
data PIN_D0 |
5 |
data PIN_D0 |
6 |
PIN_D1 |
6 |
PIN_D1 |
7 |
PIN_D2 |
7 |
PIN_D2 |
8 |
PIN_D3 |
8 |
PIN_D3 |
9 |
write PIN_E |
9 |
write PIN_E |
10 |
commamnd/data PIN_RS |
10 |
commamnd/data PIN_RS |
11 |
|
11 |
|
12 |
!!!!NOTE must be set PIN with PORT and DDR |
12 |
!!!!NOTE must be set PIN with PORT and DDR |
13 |
*/ |
13 |
*/ |
14 |
|
14 |
|
15 |
//************************************************************* |
15 |
//************************************************************* |
16 |
|
16 |
|
17 |
#define PIN_D0 PD1 |
17 |
#define PIN_D0 PD1 |
18 |
#define PORT_D0 PORTD |
18 |
#define PORT_D0 PORTD |
19 |
#define DDR_D0 DDRD |
19 |
#define DDR_D0 DDRD |
20 |
|
20 |
|
21 |
#define PIN_D1 PD2 |
21 |
#define PIN_D1 PD2 |
22 |
#define PORT_D1 PORTD |
22 |
#define PORT_D1 PORTD |
23 |
#define DDR_D1 DDRD |
23 |
#define DDR_D1 DDRD |
24 |
|
24 |
|
25 |
#define PIN_D2 PD0 |
25 |
#define PIN_D2 PD0 |
26 |
#define PORT_D2 PORTD |
26 |
#define PORT_D2 PORTD |
27 |
#define DDR_D2 DDRD |
27 |
#define DDR_D2 DDRD |
28 |
|
28 |
|
29 |
#define PIN_D3 PC5 |
29 |
#define PIN_D3 PC5 |
30 |
#define PORT_D3 PORTC |
30 |
#define PORT_D3 PORTC |
31 |
#define DDR_D3 DDRC |
31 |
#define DDR_D3 DDRC |
32 |
|
32 |
|
33 |
#define PIN_E PD4 |
33 |
#define PIN_E PD4 |
34 |
#define PORT_E PORTD |
34 |
#define PORT_E PORTD |
35 |
#define DDR_E DDRD |
35 |
#define DDR_E DDRD |
36 |
|
36 |
|
37 |
#define PIN_RS PD3 |
37 |
#define PIN_RS PD3 |
38 |
#define PORT_RS PORTD |
38 |
#define PORT_RS PORTD |
39 |
#define DDR_RS DDRD |
39 |
#define DDR_RS DDRD |
40 |
|
40 |
|
41 |
//************************************************************* |
41 |
//************************************************************* |
42 |
|
42 |
|
43 |
void LCD_init(void); |
43 |
void LCD_init(void); |
44 |
void LCD_putc(uint8_t data); |
44 |
void LCD_putc(uint8_t data); |
45 |
void LCD_gotoxy( uint8_t x, uint8_t y); |
45 |
void LCD_gotoxy( uint8_t x, uint8_t y); |
46 |
void LCD_clear(void); |
46 |
void LCD_clear(void); |
47 |
|
47 |
|
48 |
void LCD_send_data(uint8_t data); |
48 |
void LCD_send_data(uint8_t data); |
49 |
void LCD_send_command(uint8_t data); |
49 |
void LCD_send_command(uint8_t data); |
50 |
void LCD_send(uint8_t data); |
50 |
void LCD_send(uint8_t data); |
51 |
void LCD_send_nibble(uint8_t data); |
51 |
void LCD_send_nibble(uint8_t data); |
52 |
void LCD_init_IO_PIN(void); |
52 |
void LCD_init_IO_PIN(void); |
53 |
|
53 |
|
54 |
//************************************************************* |
54 |
//************************************************************* |
55 |
|
55 |
|
56 |
|
56 |
|
57 |
//********************** example printf *********************** |
57 |
//********************** example printf *********************** |
58 |
/* |
58 |
/* |
59 |
#inlcude <stdio.h> |
59 |
#inlcude <stdio.h> |
60 |
|
60 |
|
61 |
static int put_lcd(char c, FILE *stream); |
61 |
static int put_lcd(char c, FILE *stream); |
62 |
static FILE mystdout = FDEV_SETUP_STREAM(put_lcd, NULL,_FDEV_SETUP_WRITE); |
62 |
static FILE mystdout = FDEV_SETUP_STREAM(put_lcd, NULL,_FDEV_SETUP_WRITE); |
63 |
|
63 |
|
64 |
static int put_lcd(char c, FILE *stream) |
64 |
static int put_lcd(char c, FILE *stream) |
65 |
{ |
65 |
{ |
66 |
switch (c) |
66 |
switch (c) |
67 |
{ |
67 |
{ |
68 |
case '\n': LCD_gotoxy(1,2);break; |
68 |
case '\n': LCD_gotoxy(1,2);break; |
69 |
case '\r': LCD_gotoxy(1,1);break; |
69 |
case '\r': LCD_gotoxy(1,1);break; |
70 |
default : LCD_putc(c); |
70 |
default : LCD_putc(c); |
71 |
} |
71 |
} |
72 |
return 0; |
72 |
return 0; |
73 |
}*/ |
73 |
}*/ |
74 |
//************************************************************* |
74 |
//************************************************************* |
75 |
|
75 |
|