-
Notifications
You must be signed in to change notification settings - Fork 0
/
LCD4_macro.inc
105 lines (87 loc) · 3.45 KB
/
LCD4_macro.inc
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
93
94
95
96
97
98
99
100
101
102
103
104
105
;===============================================================================================
; LCD Init
.equ LCD_CLR = 0 ; DB0: clear display
.equ LCD_HOME = 1 ; DB1: return to home position
.equ LCD_ENTRY_MODE = 2 ; DB2: set entry mode
.equ LCD_ENTRY_INC = 1 ; DB1: increment
.equ LCD_ENTRY_SHIFT = 0 ; DB2: shift
.equ LCD_ON = 3 ; DB3: turn lcd/cursor on
.equ LCD_ON_DISPLAY = 2 ; DB2: turn display on
.equ LCD_ON_CURSOR = 1 ; DB1: turn cursor on
.equ LCD_ON_BLINK = 0 ; DB0: blinking cursor
.equ LCD_MOVE = 4 ; DB4: move cursor/display
.equ LCD_MOVE_DISP = 3 ; DB3: move display (0-> move cursor)
.equ LCD_MOVE_RIGHT = 2 ; DB2: move right (0-> left)
.equ LCD_F = 5 ; DB5: function set
.equ LCD_F_8B = 4 ; DB4: set 8BIT mode (0->4BIT mode)
.equ LCD_F_2L = 3 ; DB3: two lines (0->one line)
.equ LCD_F_10D = 2 ; DB2: 5x10 font (0->5x7 font)
.equ LCD_CGRAM = 6 ; DB6: set CG RAM address
.equ LCD_DDRAM = 7 ; DB7: set DD RAM address
.equ SCR_L = 0b00011000 ; Ñäâèã ýêðàíà âëåâî
.equ SCR_R = 0b00011100 ; Ñäâèã ýêðàíà âïðàâî
.equ CUR_L = 0b00010000 ; Ñäâèã êóðñîðà âëåâî
.equ CUR_R = 0b00010100 ; Ñäâèã êóðñîðà âïðàâî
; Init Config
.MACRO INIT_LCD ; Èíèöèàëèçàöèÿ LCD
RCALL InitHW ; Íàñòðîèòü êîíòðîëüíûé ïîðò
RCALL LCD_DELAY ; Ïîäîæäàòü
WR_CMD (1<<LCD_F)|(0<<LCD_F_8B) ; Âûäàòü ôóíêöèè â ïîðò. Êîìàíäà èíèöèàëèçàöèè àäðåñàöèè ÄÂÀ ÐÀÇÀ!!!
WR_CMD (1<<LCD_F)|(0<<LCD_F_8B)|(1<<LCD_F_2L) ; Òàê êàê íà 4 áàéòàõ íåëüçÿ ïåðåäàòü ñðàçó âòîðîé áàéò
WR_CMD (1<<LCD_CLR) ;0x01
WR_CMD (1<<LCD_ENTRY_MODE)|(1<<LCD_ENTRY_INC) ;0x06
WR_CMD (1<<LCD_ON)|(1<<LCD_ON_DISPLAY)|(0<<LCD_ON_CURSOR)|(0<<LCD_ON_BLINK) ;0x0C
WR_CMD (1<<LCD_HOME)
.ENDM
;===============================================================================================
;Write Data
.MACRO WR_DATA
LDI R17,@0
RCALL DATA_WR
.ENDM
;===============================================================================================
;Write CMD
.MACRO WR_CMD
LDI R17,@0
RCALL CMD_WR
.ENDM
;===============================================================================================
; Read Data
.MACRO RD_DATA
RCALL DATA_RD
.ENDM
;===============================================================================================
; Read CMD
.MACRO RD_CMD
RCALL CMD_RD
.ENDM
;===============================================================================================
;Set COORD
;Syntax LCD_COORD X,Y
.MACRO LCD_COORD
LDI R17,(1<<LCD_DDRAM)|(@0+0x40*@1)
RCALL CMD_WR
.ENDM
;===============================================================================================
;Shift SCREEN/CURSOR
.MACRO SHIFT
LDI R17,@0
RCALL CMD_WR
.ENDM
;===============================================================================================
;LCD Clear
.MACRO LCDCLR
LDI R17,(1<<LCD_CLR)
RCALL CMD_WR
.ENDM
;===============================================================================================
;Write CGRAM
.MACRO WR_CGADR
LDI R17,(1<<LCD_CGRAM)|(@0)
RCALL CMD_WR
.ENDM
;Write DDRAM
.MACRO WR_DDADR
LDI R17,(1<<LCD_DDRAM)|(@0)
RCALL CMD_WR
.ENDM