-
Notifications
You must be signed in to change notification settings - Fork 0
/
lcd_driver.asm
92 lines (77 loc) · 2.22 KB
/
lcd_driver.asm
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
90
91
92
init_lcd:
LD B, 030h ;write command 030h
CALL write_command
LD B, 4 ;wait 4.1 ms
CALL milli_delay
LD B, 030h ;write command 030h
call write_command
LD B, 100 ;wait 100µs
CALL micro_delay
LD B, 030h ;write command 030h
call write_command
LD B, 100 ;wait 100µs
CALL micro_delay
LD B, 038h ;write command 038h
call write_command
LD B, 39 ;wait 39 µs
CALL micro_delay
call clear_display ;Display Clear
LD B, 004h ;write command 004h ;Entry mode set
call write_command
read_busy:
;set R/W high
;set E high
;get PIO_A_D in to A
;set E low
;set R/W low
;and A with 080h
;if A > 0 -> busy is high
ret
;write command from B register
write_command:
LD A, 04h ;set E high
OUT (PIO_B_D), A
LD A, B ;set command
OUT (PIO_A_D), A
LD A, 00h ;set E low
OUT (PIO_B_D), A
RET
write_data:
LD A, 01h ;set RS high
OUT (PIO_B_D), A
LD A, 05h ;set E high
OUT (PIO_B_D), A
LD A, B ;set data
OUT (PIO_A_D), A
LD A, 01h ;set E low
OUT (PIO_B_D), A
LD A, 01h ;set RS low
OUT (PIO_B_D), A
RET
clear_display:
LD B, 01h ;write command 01h ;Display Clear
CALL write_command
LD B, 2 ;wait 2 ms
CALL milli_delay
RET
display_off:
LD B, 08h ;write command 0Fh ;Display Off
CALL write_command
LD B, 39 ;wait 39 µs
CALL micro_delay
RET
display_on:
LD B, 0Ch ;write command 0Fh ;Display On
CALL write_command
LD B, 39 ;wait 39 µs
CALL micro_delay
RET
goto_home:
LD B, 02h ;write command 02h ;Return Home
CALL write_command
LD B, 2 ;wait 2 ms
CALL milli_delay
RET
;set position on display, A is lines and B is column
goto_pos:
RET