-
Notifications
You must be signed in to change notification settings - Fork 0
/
LCD.s
132 lines (121 loc) · 4.57 KB
/
LCD.s
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
; LCD.s
; Student names: Anqing Chen and Nicholas Chu
; Last modification date: 4/21/2019
; Runs on LM4F120/TM4C123
; Use SSI0 to send an 8-bit code to the ST7735 160x128 pixel LCD.
; As part of Lab 7, students need to implement these LCD_WriteCommand and LCD_WriteData
; This driver assumes two low-level LCD functions
; Backlight (pin 10) connected to +3.3 V
; MISO (pin 9) unconnected
; SCK (pin 8) connected to PA2 (SSI0Clk)
; MOSI (pin 7) connected to PA5 (SSI0Tx)
; TFT_CS (pin 6) connected to PA3 (SSI0Fss)
; CARD_CS (pin 5) unconnected
; Data/Command (pin 4) connected to PA6 (GPIO)
; RESET (pin 3) connected to PA7 (GPIO)
; VCC (pin 2) connected to +3.3 V
; Gnd (pin 1) connected to ground
DC EQU 0x40004100
DC_COMMAND EQU 0
DC_DATA EQU 0x40
SSI0_DR_R EQU 0x40008008
SSI0_SR_R EQU 0x4000800C
SSI_SR_RNE EQU 0x00000004 ; SSI Receive FIFO Not Empty
SSI_SR_BSY EQU 0x00000010 ; SSI Busy Bit
SSI_SR_TNF EQU 0x00000002 ; SSI Transmit FIFO Not Full
EXPORT writecommand
EXPORT writedata
AREA |.text|, CODE, READONLY, ALIGN=2
THUMB
ALIGN
; The Data/Command pin must be valid when the eighth bit is
; sent. The SSI module has hardware input and output FIFOs
; that are 8 locations deep. Based on the observation that
; the LCD interface tends to send a few commands and then a
; lot of data, the FIFOs are not used when writing
; commands, and they are used when writing data. This
; ensures that the Data/Command pin status matches the byte
; that is actually being transmitted.
; The write command operation waits until all data has been
; sent, configures the Data/Command pin for commands, sends
; the command, and then waits for the transmission to
; finish.
; The write data operation waits until there is room in the
; transmit FIFO, configures the Data/Command pin for data,
; and then adds the data to the transmit FIFO.
; NOTE: These functions will crash or stall indefinitely if
; the SSI0 module is not initialized and enabled.
; This is a helper function that sends an 8-bit command to the LCD.
; Input: R0 8-bit command to transmit
; Output: none
; Assumes: SSI0 and port A have already been initialized and enabled
writecommand
;;--UUU-- Complete this (copy from Lab7-8)
;; Code to write a command to the LCD
;1) Read SSI0_SR_R and check bit 4,
;2) If bit 4 is high, loop back to step 1 (wait for BUSY bit to be low)
;3) Clear D/C=PA6 to zero
;4) Write the command to SSI0_DR_R
;5) Read SSI0_SR_R and check bit 4,
;6) If bit 4 is high, loop back to step 5 (wait for BUSY bit to be low)
PUSH {R4-R6, LR}
LDR R1, =SSI0_SR_R
LDR R2, =SSI0_DR_R
MOV R3, #0
check1
LDR R4, [R1]
AND R4, #0x10
CMP R4, #0
BNE check1
LDR R4, =DC
STR R3, [R4]
STR R0, [R2]
check2
LDR R4, [R1]
AND R4, #0x10
CMP R4, #0
BNE check2
POP {R4-R6, PC} ; return
; This is a helper function that sends an 8-bit data to the LCD.
; Input: R0 8-bit data to transmit
; Output: none
; Assumes: SSI0 and port A have already been initialized and enabled
writedata
;;--UUU-- Complete this (copy from Lab7-8)
;; Code to write data to the LCD
;1) Read SSI0_SR_R and check bit 1,
;2) If bit 1 is low loop back to step 1 (wait for TNF bit to be high)
;3) Set D/C=PA6 to one
;4) Write the 8-bit data to SSI0_DR_R
PUSH {R4, LR}
LDR R1, =SSI0_SR_R
LDR R2, =SSI0_DR_R
MOV R3, #0x40
check3
LDR R4, [R1]
AND R4, #0x02
CMP R4, #0
BEQ check3
LDR R4, =DC
STR R3, [R4]
STR R0, [R2]
POP {R4, PC} ; return
;***************************************************
; This is a library for the Adafruit 1.8" SPI display.
; This library works with the Adafruit 1.8" TFT Breakout w/SD card
; ----> http://www.adafruit.com/products/358
; as well as Adafruit raw 1.8" TFT display
; ----> http://www.adafruit.com/products/618
;
; Check out the links above for our tutorials and wiring diagrams
; These displays use SPI to communicate, 4 or 5 pins are required to
; interface (RST is optional)
; Adafruit invests time and resources providing this open source code,
; please support Adafruit and open-source hardware by purchasing
; products from Adafruit!
;
; Written by Limor Fried/Ladyada for Adafruit Industries.
; MIT license, all text above must be included in any redistribution
;****************************************************
ALIGN ; make sure the end of this section is aligned
END ; end of file