You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

243 lines
8.7 KiB

5 years ago
  1. /* --COPYRIGHT--,BSD
  2. * Copyright (c) 2013, Texas Instruments Incorporated
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. *
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. *
  12. * * Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. *
  16. * * Neither the name of Texas Instruments Incorporated nor the names of
  17. * its contributors may be used to endorse or promote products derived
  18. * from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  22. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  23. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  24. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  25. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  26. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  27. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  28. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  29. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  30. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. * --/COPYRIGHT--*/
  32. //*****************************************************************************
  33. //
  34. // HAL_MSP-EXP430G2_Sharp96x96.h - Prototypes for the Sharp96x96 LCD display driver.
  35. // There is no output from Sharp96x96 LCD.
  36. //
  37. // MSP430G2XX LCD Sharp96x96
  38. // ----------------- -----------------
  39. // | UCB0CLK/P1.5|---------> |SCLK EXTCOMIN|-- 0
  40. // /|\| | | |
  41. // | | UCB0SIMO/P1.7|---------> |SI EXTMODE|-- 0
  42. // --|RST | | |
  43. // | UCB0STE/P1.4|---------> |SCS |
  44. // | | | |
  45. // | P1.3|---------> |DISP |
  46. // | | | |
  47. // | | | |
  48. // | | -----------------
  49. //
  50. //*****************************************************************************
  51. #include <stdint.h>
  52. #ifndef __HAL_MSP-EXP430G2_SHARPLCD_H__
  53. #define __HAL_MSP-EXP430G2_SHARPLCD_H__
  54. //*****************************************************************************
  55. //
  56. // User Configuration for the LCD Driver
  57. //
  58. //*****************************************************************************
  59. // Ports from MSP430 connected to LCD
  60. #define LCD_MOSI_PORT P1OUT
  61. #define LCD_SCLK_PORT P1OUT
  62. #define LCD_POWER_DISP_PORT P1OUT
  63. #define LCD_POWER_DISP_DIR P1DIR
  64. #define LCD_SCS_PORT P1OUT
  65. #define LCD_SCS_DIR P1DIR
  66. // Pins from MSP430 connected to LCD
  67. #define LCD_MOSI_PIN BIT7
  68. #define LCD_MOSI_PORT_SEL1 P1SEL
  69. #define LCD_MOSI_PORT_SEL2 P1SEL2
  70. #define LCD_SCLK_PIN BIT5
  71. #define LCD_SCLK_PORT_SEL1 P1SEL
  72. #define LCD_SCLK_PORT_SEL2 P1SEL2
  73. #define LCD_POWER_PIN BIT0
  74. #define LCD_DISP_PIN BIT3
  75. #define LCD_SCS_PIN BIT4
  76. // LCD Screen Dimensions
  77. #define LCD_VERTICAL_MAX 96
  78. #define LCD_HORIZONTAL_MAX 96
  79. // Non-volatile Memory used to store DisplayBuffer
  80. #define NON_VOLATILE_MEMORY_BUFFER
  81. #ifdef NON_VOLATILE_MEMORY_BUFFER
  82. #define USE_FLASH_BUFFER
  83. #define NON_VOLATILE_MEMORY_ADDRESS 0xf400
  84. #endif //NON_VOLATILE_MEMORY_BUFFER
  85. //*****************************************************************************
  86. //
  87. // Clears CS line
  88. //
  89. // This macro allows to clear the Chip Select (CS) line
  90. //
  91. // \return None
  92. //
  93. //*****************************************************************************
  94. #define ClearCS() \
  95. LCD_SCS_PORT &= ~LCD_SCS_PIN;
  96. //*****************************************************************************
  97. //
  98. // Set CS line
  99. //
  100. // This macro allows to set the Chip Select (CS) line
  101. //
  102. // \return None
  103. //
  104. //*****************************************************************************
  105. #define SetCS() \
  106. LCD_SCS_PORT |= LCD_SCS_PIN;
  107. //*****************************************************************************
  108. //
  109. // Waits until the SPI communication with the LCD is finished a command to
  110. // the LCD Driver
  111. //
  112. // \param None
  113. //
  114. // \return None
  115. //*****************************************************************************
  116. #define WaitUntilLcdWriteFinished() \
  117. while (UCB0STAT & UCBUSY)
  118. //*****************************************************************************
  119. //
  120. // Writes command or data to the LCD Driver
  121. //
  122. // \param ucCmdData is the 8 or 16 bit command to send to the LCD driver
  123. // Uses the SET_LCD_DATA macro
  124. //
  125. // \return None
  126. //
  127. //*****************************************************************************
  128. #define WriteCmdData(ucCmdData) \
  129. do \
  130. { \
  131. while (!(IFG2 & UCB0TXIFG)); \
  132. UCB0TXBUF = ucCmdData; \
  133. } \
  134. while(0)
  135. //*****************************************************************************
  136. //
  137. // Unlocks FLASH controller
  138. //
  139. // This macro unlocks flash memory controller.
  140. //
  141. // \return None
  142. //
  143. //*****************************************************************************
  144. #define UnlockFlashMemory() \
  145. FCTL3 = FWKEY
  146. //*****************************************************************************
  147. //
  148. // Sets access right on FLASH controller
  149. //
  150. // \param uiAccesType defines access right. Valid parameters:
  151. // WRT.- Set Write access on flash controller
  152. // ERASE.- Sets Erase
  153. //
  154. // This macro sets the proper write or erase access on FLASH controller.
  155. // \return None
  156. //
  157. //*****************************************************************************
  158. #define SetFlashAccessRight(uiAccessType) \
  159. FCTL1 = FWKEY + uiAccessType
  160. //*****************************************************************************
  161. //
  162. // Removes access right on FLASH controller
  163. //
  164. // This macro removes access rights on FLASH controller.
  165. // \return None
  166. //
  167. //*****************************************************************************
  168. #define RemoveFlashAccessRight() \
  169. FCTL1 = FWKEY
  170. //*****************************************************************************
  171. //
  172. // Locks FLASH controller
  173. //
  174. // This macro locks flash memory controller.
  175. //
  176. // \return None
  177. //
  178. //*****************************************************************************
  179. #define LockFlashMemory() \
  180. FCTL3 = FWKEY + LOCK
  181. //*****************************************************************************
  182. //
  183. // Prepare to write memory
  184. //
  185. // This macro unlocks flash memory controller and
  186. // sets access right on flash controller
  187. //
  188. // \return None
  189. //
  190. //*****************************************************************************
  191. #define PrepareMemoryWrite() \
  192. UnlockFlashMemory(); \
  193. SetFlashAccessRight(WRT)
  194. //*****************************************************************************
  195. //
  196. // Finish memory writing
  197. //
  198. // This macro removes access rights on flash controller and
  199. // locks flash memory controller.
  200. //
  201. // \return None
  202. //
  203. //*****************************************************************************
  204. #define FinishMemoryWrite() \
  205. RemoveFlashAccessRight(); \
  206. LockFlashMemory()
  207. //*****************************************************************************
  208. //
  209. // Prototypes for the globals exported by this driver.
  210. //
  211. //*****************************************************************************
  212. extern void LCDInit(void);
  213. extern void InitializeDisplayBuffer(void *pvDisplayData, uint8_t ucValue);
  214. #endif // __HAL_MSP-EXP430G2_SHARPLCD_H__