/
pd44.c
89 lines (69 loc) · 1.36 KB
/
pd44.c
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <inttypes.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <util/delay.h>
#include "iocompat.h"
#include "pins.h"
void _sendByte(unsigned char addr, unsigned char val) {
#ifdef PD44_CE1
HIGH(PD44_CE1);
#endif
HIGH(PD44_RD);
HIGH(PD44_WR);
SET(PD44_A0, ((addr >> 0) & 1));
SET(PD44_A1, ((addr >> 1) & 1));
SET(PD44_A2, ((addr >> 2) & 1));
PD44_DATA = val;
LOW(PD44_WR);
HIGH(PD44_WR);
LOW(PD44_RD);
#ifdef PD44_CE1
LOW(PD44_CE1);
#endif
}
void pd44_init(void) {
OUTPUT(PD44_WR);
#ifdef PD44_CE1
OUTPUT(PD44_CE1);
#endif
OUTPUT(PD44_RD);
LOW(PD44_RD);
OUTPUT(PD44_A2);
OUTPUT(PD44_A1);
OUTPUT(PD44_A0);
OUTPUT(PD44_D0);
OUTPUT(PD44_D1);
OUTPUT(PD44_D2);
OUTPUT(PD44_D3);
OUTPUT(PD44_D4);
OUTPUT(PD44_D5);
OUTPUT(PD44_D6);
OUTPUT(PD44_D7);
OUTPUT(PD44_RST);
HIGH(PD44_RST);
}
void inline pd44_sendByte(unsigned char addr, unsigned char val) {
_sendByte(addr | 4, val);
}
void inline pd44_sendCtrl(unsigned char val) {
_sendByte(0, val);
}
void pd44_sendChar(unsigned char addr, char c) {
if (c < ' ' || c > 0x7E)
c = 0x7F;
_sendByte(addr | 4, c);
}
void pd44_reset(void) {
LOW(PD44_RST);
HIGH(PD44_RST);
}
void pd44_cls(void) {
pd44_sendCtrl(0x80);
}
void pd44_brigthness(unsigned char val) {
pd44_sendCtrl(val & 0x3);
}
void pd44_lamptest() {
pd44_sendCtrl(1<<6);
}