stm320518_eval_lcd.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. /**
  2. ******************************************************************************
  3. * @file stm320518_eval_lcd.h
  4. * @author MCD Application Team
  5. * @version V1.0.0
  6. * @date 20-April-2012
  7. * @brief This file contains all the functions prototypes for the stm320518_eval_lcd
  8. * firmware driver.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
  13. *
  14. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  15. * You may not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at:
  17. *
  18. * http://www.st.com/software_license_agreement_liberty_v2
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an "AS IS" BASIS,
  22. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. *
  26. ******************************************************************************
  27. */
  28. /* Define to prevent recursive inclusion -------------------------------------*/
  29. #ifndef __STM320518_EVAL_LCD_H
  30. #define __STM320518_EVAL_LCD_H
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /* Includes ------------------------------------------------------------------*/
  35. #include "stm320518_eval.h"
  36. #include "../Common/fonts.h"
  37. /** @addtogroup Utilities
  38. * @{
  39. */
  40. /** @addtogroup STM32_EVAL
  41. * @{
  42. */
  43. /** @addtogroup STM320518_EVAL
  44. * @{
  45. */
  46. /** @addtogroup STM320518_EVAL_LCD
  47. * @{
  48. */
  49. /** @defgroup STM320518_EVAL_LCD_Exported_Types
  50. * @{
  51. */
  52. typedef struct
  53. {
  54. int16_t X;
  55. int16_t Y;
  56. } Point, * pPoint;
  57. /**
  58. * @}
  59. */
  60. /** @defgroup STM320518_EVAL_LCD_Exported_Constants
  61. * @{
  62. */
  63. /**
  64. * @brief Uncomment the line below if you want to use LCD_DrawBMP function to
  65. * display a bitmap picture on the LCD. This function assumes that the bitmap
  66. * file is loaded in the SPI Flash (mounted on STM320518-EVAL board), however
  67. * user can tailor it according to his application hardware requirement.
  68. */
  69. /*#define USE_LCD_DrawBMP*/
  70. /**
  71. * @brief Uncomment the line below if you want to use user defined Delay function
  72. * (for precise timing), otherwise default _delay_ function defined within
  73. * this driver is used (less precise timing).
  74. */
  75. /* #define USE_Delay */
  76. #ifdef USE_Delay
  77. #include "main.h"
  78. #define _delay_ Delay /* !< User can provide more timing precise _delay_ function
  79. (with 10ms time base), using SysTick for example */
  80. #else
  81. #define _delay_ delay /* !< Default _delay_ function with less precise timing */
  82. #endif
  83. /**
  84. * @brief LCD Control pins
  85. */
  86. #define LCD_NCS_PIN GPIO_Pin_4
  87. #define LCD_NCS_GPIO_PORT GPIOF
  88. #define LCD_NCS_GPIO_CLK RCC_AHBPeriph_GPIOF
  89. #define LCD_NWR_PIN GPIO_Pin_15
  90. #define LCD_NWR_GPIO_PORT GPIOD
  91. #define LCD_NWR_GPIO_CLK RCC_AHBPeriph_GPIOD
  92. #define LCD_RS_PIN GPIO_Pin_7
  93. #define LCD_RS_GPIO_PORT GPIOD
  94. #define LCD_RS_GPIO_CLK RCC_AHBPeriph_GPIOD
  95. /**
  96. * @brief LCD SPI Interface pins
  97. */
  98. #define LCD_SPI_SCK_PIN GPIO_Pin_5 /* PA.05 */
  99. #define LCD_SPI_SCK_GPIO_PORT GPIOA /* GPIOA */
  100. #define LCD_SPI_SCK_GPIO_CLK RCC_AHBPeriph_GPIOA
  101. #define LCD_SPI_SCK_SOURCE GPIO_PinSource15
  102. #define LCD_SPI_SCK_AF GPIO_AF_0
  103. #if defined (STM320518_EVAL_REVA)
  104. #define LCD_SPI_MISO_PIN GPIO_Pin_6 /* PA.06 */
  105. #define LCD_SPI_MISO_GPIO_PORT GPIOA /* GPIOA */
  106. #define LCD_SPI_MISO_GPIO_CLK RCC_AHBPeriph_GPIOA
  107. #define LCD_SPI_MISO_SOURCE GPIO_PinSource6
  108. #define LCD_SPI_MISO_AF GPIO_AF_0
  109. #elif defined (STM320518_EVAL_REVB)
  110. #define LCD_SPI_MISO_PIN GPIO_Pin_4 /* PB.04 */
  111. #define LCD_SPI_MISO_GPIO_PORT GPIOB /* GPIOB */
  112. #define LCD_SPI_MISO_GPIO_CLK RCC_AHBPeriph_GPIOB
  113. #define LCD_SPI_MISO_SOURCE GPIO_PinSource4
  114. #define LCD_SPI_MISO_AF GPIO_AF_0
  115. #endif /* STM320518_EVAL_REVA*/
  116. #define LCD_SPI_MOSI_PIN GPIO_Pin_7 /* PA.07 */
  117. #define LCD_SPI_MOSI_GPIO_PORT GPIOA /* GPIOA */
  118. #define LCD_SPI_MOSI_GPIO_CLK RCC_AHBPeriph_GPIOA
  119. #define LCD_SPI_MOSI_SOURCE GPIO_PinSource7
  120. #define LCD_SPI_MOSI_AF GPIO_AF_0
  121. #define LCD_SPI SPI1
  122. #define LCD_SPI_CLK RCC_APB2Periph_SPI1
  123. /**
  124. * @brief LCD Registers
  125. */
  126. #define LCD_REG_0 0x00
  127. #define LCD_REG_1 0x01
  128. #define LCD_REG_2 0x02
  129. #define LCD_REG_3 0x03
  130. #define LCD_REG_4 0x04
  131. #define LCD_REG_5 0x05
  132. #define LCD_REG_6 0x06
  133. #define LCD_REG_7 0x07
  134. #define LCD_REG_8 0x08
  135. #define LCD_REG_9 0x09
  136. #define LCD_REG_10 0x0A
  137. #define LCD_REG_12 0x0C
  138. #define LCD_REG_13 0x0D
  139. #define LCD_REG_14 0x0E
  140. #define LCD_REG_15 0x0F
  141. #define LCD_REG_16 0x10
  142. #define LCD_REG_17 0x11
  143. #define LCD_REG_18 0x12
  144. #define LCD_REG_19 0x13
  145. #define LCD_REG_20 0x14
  146. #define LCD_REG_21 0x15
  147. #define LCD_REG_22 0x16
  148. #define LCD_REG_23 0x17
  149. #define LCD_REG_24 0x18
  150. #define LCD_REG_25 0x19
  151. #define LCD_REG_26 0x1A
  152. #define LCD_REG_27 0x1B
  153. #define LCD_REG_28 0x1C
  154. #define LCD_REG_29 0x1D
  155. #define LCD_REG_30 0x1E
  156. #define LCD_REG_31 0x1F
  157. #define LCD_REG_32 0x20
  158. #define LCD_REG_33 0x21
  159. #define LCD_REG_34 0x22
  160. #define LCD_REG_35 0x23
  161. #define LCD_REG_36 0x24
  162. #define LCD_REG_37 0x25
  163. #define LCD_REG_39 0x27
  164. #define LCD_REG_40 0x28
  165. #define LCD_REG_41 0x29
  166. #define LCD_REG_43 0x2B
  167. #define LCD_REG_45 0x2D
  168. #define LCD_REG_48 0x30
  169. #define LCD_REG_49 0x31
  170. #define LCD_REG_50 0x32
  171. #define LCD_REG_51 0x33
  172. #define LCD_REG_52 0x34
  173. #define LCD_REG_53 0x35
  174. #define LCD_REG_54 0x36
  175. #define LCD_REG_55 0x37
  176. #define LCD_REG_56 0x38
  177. #define LCD_REG_57 0x39
  178. #define LCD_REG_59 0x3B
  179. #define LCD_REG_60 0x3C
  180. #define LCD_REG_61 0x3D
  181. #define LCD_REG_62 0x3E
  182. #define LCD_REG_63 0x3F
  183. #define LCD_REG_64 0x40
  184. #define LCD_REG_65 0x41
  185. #define LCD_REG_66 0x42
  186. #define LCD_REG_67 0x43
  187. #define LCD_REG_68 0x44
  188. #define LCD_REG_69 0x45
  189. #define LCD_REG_70 0x46
  190. #define LCD_REG_71 0x47
  191. #define LCD_REG_72 0x48
  192. #define LCD_REG_73 0x49
  193. #define LCD_REG_74 0x4A
  194. #define LCD_REG_75 0x4B
  195. #define LCD_REG_76 0x4C
  196. #define LCD_REG_77 0x4D
  197. #define LCD_REG_78 0x4E
  198. #define LCD_REG_79 0x4F
  199. #define LCD_REG_80 0x50
  200. #define LCD_REG_81 0x51
  201. #define LCD_REG_82 0x52
  202. #define LCD_REG_83 0x53
  203. #define LCD_REG_84 0x54
  204. #define LCD_REG_85 0x55
  205. #define LCD_REG_86 0x56
  206. #define LCD_REG_87 0x57
  207. #define LCD_REG_88 0x58
  208. #define LCD_REG_89 0x59
  209. #define LCD_REG_90 0x5A
  210. #define LCD_REG_91 0x5B
  211. #define LCD_REG_92 0x5C
  212. #define LCD_REG_93 0x5D
  213. #define LCD_REG_96 0x60
  214. #define LCD_REG_97 0x61
  215. #define LCD_REG_106 0x6A
  216. #define LCD_REG_118 0x76
  217. #define LCD_REG_128 0x80
  218. #define LCD_REG_129 0x81
  219. #define LCD_REG_130 0x82
  220. #define LCD_REG_131 0x83
  221. #define LCD_REG_132 0x84
  222. #define LCD_REG_133 0x85
  223. #define LCD_REG_134 0x86
  224. #define LCD_REG_135 0x87
  225. #define LCD_REG_136 0x88
  226. #define LCD_REG_137 0x89
  227. #define LCD_REG_139 0x8B
  228. #define LCD_REG_140 0x8C
  229. #define LCD_REG_141 0x8D
  230. #define LCD_REG_143 0x8F
  231. #define LCD_REG_144 0x90
  232. #define LCD_REG_145 0x91
  233. #define LCD_REG_146 0x92
  234. #define LCD_REG_147 0x93
  235. #define LCD_REG_148 0x94
  236. #define LCD_REG_149 0x95
  237. #define LCD_REG_150 0x96
  238. #define LCD_REG_151 0x97
  239. #define LCD_REG_152 0x98
  240. #define LCD_REG_153 0x99
  241. #define LCD_REG_154 0x9A
  242. #define LCD_REG_157 0x9D
  243. #define LCD_REG_192 0xC0
  244. #define LCD_REG_193 0xC1
  245. #define LCD_REG_227 0xE3
  246. #define LCD_REG_229 0xE5
  247. #define LCD_REG_231 0xE7
  248. #define LCD_REG_239 0xEF
  249. #define LCD_REG_232 0xE8
  250. #define LCD_REG_233 0xE9
  251. #define LCD_REG_234 0xEA
  252. #define LCD_REG_235 0xEB
  253. #define LCD_REG_236 0xEC
  254. #define LCD_REG_237 0xED
  255. #define LCD_REG_241 0xF1
  256. #define LCD_REG_242 0xF2
  257. /**
  258. * @brief LCD color
  259. */
  260. #define LCD_COLOR_WHITE 0xFFFF
  261. #define LCD_COLOR_BLACK 0x0000
  262. #define LCD_COLOR_GREY 0xF7DE
  263. #define LCD_COLOR_BLUE 0x001F
  264. #define LCD_COLOR_BLUE2 0x051F
  265. #define LCD_COLOR_RED 0xF800
  266. #define LCD_COLOR_MAGENTA 0xF81F
  267. #define LCD_COLOR_GREEN 0x07E0
  268. #define LCD_COLOR_CYAN 0x7FFF
  269. #define LCD_COLOR_YELLOW 0xFFE0
  270. /**
  271. * @brief LCD Lines depending on the chosen fonts.
  272. */
  273. #define LCD_LINE_0 LINE(0)
  274. #define LCD_LINE_1 LINE(1)
  275. #define LCD_LINE_2 LINE(2)
  276. #define LCD_LINE_3 LINE(3)
  277. #define LCD_LINE_4 LINE(4)
  278. #define LCD_LINE_5 LINE(5)
  279. #define LCD_LINE_6 LINE(6)
  280. #define LCD_LINE_7 LINE(7)
  281. #define LCD_LINE_8 LINE(8)
  282. #define LCD_LINE_9 LINE(9)
  283. #define LCD_LINE_10 LINE(10)
  284. #define LCD_LINE_11 LINE(11)
  285. #define LCD_LINE_12 LINE(12)
  286. #define LCD_LINE_13 LINE(13)
  287. #define LCD_LINE_14 LINE(14)
  288. #define LCD_LINE_15 LINE(15)
  289. #define LCD_LINE_16 LINE(16)
  290. #define LCD_LINE_17 LINE(17)
  291. #define LCD_LINE_18 LINE(18)
  292. #define LCD_LINE_19 LINE(19)
  293. #define LCD_LINE_20 LINE(20)
  294. #define LCD_LINE_21 LINE(21)
  295. #define LCD_LINE_22 LINE(22)
  296. #define LCD_LINE_23 LINE(23)
  297. #define LCD_LINE_24 LINE(24)
  298. #define LCD_LINE_25 LINE(25)
  299. #define LCD_LINE_26 LINE(26)
  300. #define LCD_LINE_27 LINE(27)
  301. #define LCD_LINE_28 LINE(28)
  302. #define LCD_LINE_29 LINE(29)
  303. /**
  304. * @brief LCD default font
  305. */
  306. #define LCD_DEFAULT_FONT Font16x24
  307. /**
  308. * @brief LCD Direction
  309. */
  310. #define LCD_DIR_HORIZONTAL 0x0000
  311. #define LCD_DIR_VERTICAL 0x0001
  312. /**
  313. * @brief LCD Size (Width and Height)
  314. */
  315. #define LCD_PIXEL_WIDTH 0x0140
  316. #define LCD_PIXEL_HEIGHT 0x00F0
  317. /**
  318. * @}
  319. */
  320. /** @defgroup STM320518_EVAL_LCD_Exported_Macros
  321. * @{
  322. */
  323. #define ASSEMBLE_RGB(R, G, B) ((((R)& 0xF8) << 8) | (((G) & 0xFC) << 3) | (((B) & 0xF8) >> 3))
  324. /**
  325. * @}
  326. */
  327. /** @defgroup STM320518_EVAL_LCD_Exported_Functions
  328. * @{
  329. */
  330. void LCD_DeInit(void);
  331. void LCD_Setup(void);
  332. void STM320518_LCD_Init(void);
  333. void LCD_SetColors(__IO uint16_t _TextColor, __IO uint16_t _BackColor);
  334. void LCD_GetColors(__IO uint16_t *_TextColor, __IO uint16_t *_BackColor);
  335. void LCD_SetTextColor(__IO uint16_t Color);
  336. void LCD_SetBackColor(__IO uint16_t Color);
  337. void LCD_ClearLine(uint16_t Line);
  338. void LCD_Clear(uint16_t Color);
  339. void LCD_SetCursor(uint16_t Xpos, uint16_t Ypos);
  340. void LCD_DrawChar(uint16_t Xpos, uint16_t Ypos, const uint16_t *c);
  341. void LCD_DisplayChar(uint16_t Line, uint16_t Column, uint8_t Ascii);
  342. void LCD_SetFont(sFONT *fonts);
  343. sFONT *LCD_GetFont(void);
  344. void LCD_DisplayStringLine(uint16_t Line, uint8_t *ptr);
  345. void LCD_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint8_t Height, uint16_t Width);
  346. void LCD_WindowModeDisable(void);
  347. void LCD_DrawLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length, uint8_t Direction);
  348. void LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint8_t Height, uint16_t Width);
  349. void LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius);
  350. void LCD_DrawMonoPict(const uint32_t *Pict);
  351. void LCD_DrawBMP(uint32_t BmpAddress);
  352. void LCD_DrawUniLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
  353. void LCD_DrawFullRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
  354. void LCD_DrawFullCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius);
  355. void LCD_PolyLine(pPoint Points, uint16_t PointCount);
  356. void LCD_PolyLineRelative(pPoint Points, uint16_t PointCount);
  357. void LCD_ClosedPolyLine(pPoint Points, uint16_t PointCount);
  358. void LCD_ClosedPolyLineRelative(pPoint Points, uint16_t PointCount);
  359. void LCD_FillPolyLine(pPoint Points, uint16_t PointCount);
  360. void LCD_nCS_StartByte(uint8_t Start_Byte);
  361. void LCD_WriteRegIndex(uint8_t LCD_Reg);
  362. void LCD_WriteReg(uint8_t LCD_Reg, uint16_t LCD_RegValue);
  363. void LCD_WriteRAM_Prepare(void);
  364. void LCD_WriteRAMWord(uint16_t RGB_Code);
  365. uint16_t LCD_ReadReg(uint8_t LCD_Reg);
  366. void LCD_WriteRAM(uint16_t RGB_Code);
  367. void LCD_PowerOn(void);
  368. void LCD_DisplayOn(void);
  369. void LCD_DisplayOff(void);
  370. void LCD_CtrlLinesConfig(void);
  371. void LCD_CtrlLinesWrite(GPIO_TypeDef* GPIOx, uint16_t CtrlPins, BitAction BitVal);
  372. void LCD_SPIConfig(void);
  373. /**
  374. * @}
  375. */
  376. #ifdef __cplusplus
  377. }
  378. #endif
  379. #endif /* __STM320518_EVAL_LCD_H */
  380. /**
  381. * @}
  382. */
  383. /**
  384. * @}
  385. */
  386. /**
  387. * @}
  388. */
  389. /**
  390. * @}
  391. */
  392. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/