Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.06 KB | None | 0 0
  1. ; LCD.s
  2. ; Student names: change this to your names or look very silly
  3. ; Last modification date: change this to the last modification date or look very silly
  4.  
  5. ; Runs on LM4F120/TM4C123
  6. ; Use SSI0 to send an 8-bit code to the ST7735 160x128 pixel LCD.
  7.  
  8. ; As part of Lab 7, students need to implement these LCD_WriteCommand and LCD_WriteData
  9. ; This driver assumes two low-level LCD functions
  10.  
  11. ; Backlight (pin 10) connected to +3.3 V
  12. ; MISO (pin 9) unconnected
  13. ; SCK (pin 8) connected to PA2 (SSI0Clk)
  14. ; MOSI (pin 7) connected to PA5 (SSI0Tx)
  15. ; TFT_CS (pin 6) connected to PA3 (SSI0Fss)
  16. ; CARD_CS (pin 5) unconnected
  17. ; Data/Command (pin 4) connected to PA6 (GPIO)
  18. ; RESET (pin 3) connected to PA7 (GPIO)
  19. ; VCC (pin 2) connected to +3.3 V
  20. ; Gnd (pin 1) connected to ground
  21.  
  22. GPIO_PORTA_DATA_R EQU 0x400043FC
  23. DC EQU 0x40004100
  24. DC_COMMAND EQU 0
  25. DC_DATA EQU 0x40
  26. SSI0_DR_R EQU 0x40008008
  27. SSI0_SR_R EQU 0x4000800C
  28. SSI_SR_RNE EQU 0x00000004 ; SSI Receive FIFO Not Empty
  29. SSI_SR_BSY EQU 0x00000010 ; SSI Busy Bit
  30. SSI_SR_TNF EQU 0x00000002 ; SSI Transmit FIFO Not Full
  31.  
  32. EXPORT writecommand
  33. EXPORT writedata
  34.  
  35. AREA |.text|, CODE, READONLY, ALIGN=2
  36. THUMB
  37. ALIGN
  38.  
  39. ; The Data/Command pin must be valid when the eighth bit is
  40. ; sent. The SSI module has hardware input and output FIFOs
  41. ; that are 8 locations deep. Based on the observation that
  42. ; the LCD interface tends to send a few commands and then a
  43. ; lot of data, the FIFOs are not used when writing
  44. ; commands, and they are used when writing data. This
  45. ; ensures that the Data/Command pin status matches the byte
  46. ; that is actually being transmitted.
  47. ; The write command operation waits until all data has been
  48. ; sent, configures the Data/Command pin for commands, sends
  49. ; the command, and then waits for the transmission to
  50. ; finish.
  51. ; The write data operation waits until there is room in the
  52. ; transmit FIFO, configures the Data/Command pin for data,
  53. ; and then adds the data to the transmit FIFO.
  54. ; NOTE: These functions will crash or stall indefinitely if
  55. ; the SSI0 module is not initialized and enabled.
  56.  
  57. ; This is a helper function that sends an 8-bit command to the LCD.
  58. ; Input: R0 8-bit command to transmit
  59. ; Output: none
  60. ; Assumes: SSI0 and port A have already been initialized and enabled
  61. writecommand
  62. ;; --UUU-- Code to write a command to the LCD
  63. ;1) Read SSI0_SR_R and check bit 4,
  64. ;2) If bit 4 is high, loop back to step 1 (wait for BUSY bit to be low)
  65. ;3) Clear D/C=PA6 to zero
  66. ;4) Write the command to SSI0_DR_R
  67. ;5) Read SSI0_SR_R and check bit 4,
  68. ;6) If bit 4 is high, loop back to step 5 (wait for BUSY bit to be low)
  69. high LDR R1, =SSI0_SR_R;
  70. LDR R2, [R1]; read SSIA_SR_R into R2
  71. AND R3, R2, #0x10;
  72. CMP R3, #0x10; check bit 4 if high go back to beginning
  73. BEQ high
  74. LDR R1, =DC ; Clear PA6
  75. LDR R2, [R1]
  76. BIC R2, #0x40 ; Clear PA6
  77. STR R2, [R1] ; Update PA6
  78.  
  79. LDR R1, =SSI0_DR_R
  80. STR R0, [R1] ; Write the command to SSIO_DR_R write command from R0 to SSIO_DR_R
  81. high2 LDR R1, =SSI0_SR_R; checking SSI0_DR_R again
  82. LDR R2, [R1]
  83. AND R3, R2, #0x10; Check bit 4 and return to high2 if high
  84. CMP R3, #0x10;
  85. BEQ high2
  86.  
  87. BX LR ; return
  88.  
  89. ; This is a helper function that sends an 8-bit data to the LCD.
  90. ; Input: R0 8-bit data to transmit
  91. ; Output: none
  92. ; Assumes: SSI0 and port A have already been initialized and enabled
  93. writedata
  94. ;; --UUU-- Code to write data to the LCD
  95. ;1) Read SSI0_SR_R and check bit 1,
  96. ;2) If bit 1 is low loop back to step 1 (wait for TNF bit to be high)
  97. ;3) Set D/C=PA6 to one
  98. ;4) Write the 8-bit data to SSI0_DR_R
  99. low LDR R1, =SSI0_SR_R
  100. LDR R2, [R1]
  101. AND R2, #0x02; read and check bit 1 of SSIO_SR_R
  102. CMP R2, #0
  103. BEQ low
  104. LDR R1, =DC
  105. LDR R2, [R1]
  106. ORR R2, #0x40; set PA6 1
  107. STR R2, [R1]
  108. LDR R1, = SSI0_DR_R
  109. LDR R2, [R1]
  110. MOV R2, R0
  111. STR R0, [R1]; store R0 to SSI0_DR_R
  112.  
  113.  
  114. BX LR ; return
  115.  
  116.  
  117. ;***************************************************
  118. ; This is a library for the Adafruit 1.8" SPI display.
  119. ; This library works with the Adafruit 1.8" TFT Breakout w/SD card
  120. ; ----> http://www.adafruit.com/products/358
  121. ; as well as Adafruit raw 1.8" TFT display
  122. ; ----> http://www.adafruit.com/products/618
  123. ;
  124. ; Check out the links above for our tutorials and wiring diagrams
  125. ; These displays use SPI to communicate, 4 or 5 pins are required to
  126. ; interface (RST is optional)
  127. ; Adafruit invests time and resources providing this open source code,
  128. ; please support Adafruit and open-source hardware by purchasing
  129. ; products from Adafruit!
  130. ;
  131. ; Written by Limor Fried/Ladyada for Adafruit Industries.
  132. ; MIT license, all text above must be included in any redistribution
  133. ;****************************************************
  134.  
  135. ALIGN ; make sure the end of this section is aligned
  136. END ; end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement