blob: 3405782d96783154680827efb10aa33f773a5d28 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#include "board.h"
#include "delay.h"
#include "lcd.h"
static void lcdPulseE(void);
static void lcdSetDAT(uint8_t value);
static void lcdSendCommand(uint8_t command);
static void lcdSendData(uint8_t data);
void lcdInit(void)
{
// Give time for LCD to prepare itself
delay(100);
lcdSendCommand(0x38);
lcdSendCommand(0x10);
lcdSendCommand(0x0D);
delay(5);
lcdClear();
}
void lcdClear(void)
{
lcdSendCommand(0x01);
delay(2);
}
void lcdPuts(const char *s)
{
lcdSendCommand(0x06);
while (*s != '\0')
lcdSendData(*s++);
}
void lcdPulseE(void)
{
P2OUT |= LCD_E;
delay(2);
P2OUT &= ~(LCD_E);
}
void lcdSetDAT(uint8_t value)
{
P2OUT &= ~(LCD_DATH);
P2OUT |= (value >> 4) & LCD_DATH;
P1OUT &= ~(LCD_DATL);
P1OUT |= value & LCD_DATL;
}
void lcdSendCommand(uint8_t command)
{
P1OUT &= ~(LCD_RS);
lcdSetDAT(command);
lcdPulseE();
}
void lcdSendData(uint8_t data)
{
P1OUT |= LCD_RS;
lcdSetDAT(data);
lcdPulseE();
}
|