board_LGDP4532.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * This file is subject to the terms of the GFX License. If a copy of
  3. * the license was not distributed with this file, you can obtain one at:
  4. *
  5. * http://ugfx.org/license.html
  6. */
  7. /*
  8. driver quickly hacked together from a chinese sourcecode that came
  9. with the board and existing ili9320 code by Chris van Dongen (sjaak)
  10. (sjaak2002 at msn.com)
  11. Also added rotation for 180 and 270 degrees and minor tweaks to
  12. setcursor
  13. Added code comes without warranty and free bugs. Feel free to use
  14. or misuse the added code :D
  15. */
  16. /**
  17. * @file boards/addons/gdisp/board_ILI9325_hy_stm32_100p.h
  18. * @brief GDISP Graphic Driver subsystem board SPI interface for the ILI9325 display.
  19. *
  20. * @note This file contains a mix of hardware specific and operating system specific
  21. * code. You will need to change it for your CPU and/or operating system.
  22. */
  23. #ifndef GDISP_LLD_BOARD_H
  24. #define GDISP_LLD_BOARD_H
  25. // For a multiple display configuration we would put all this in a structure and then
  26. // set g->board to that structure.
  27. #define GDISP_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */
  28. #define GDISP_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */
  29. static inline void init_board(GDisplay *g) {
  30. (void) g;
  31. // As we are not using multiple displays we set g->board to NULL as we don't use it.
  32. /* FSMC setup for F1 */
  33. rccEnableAHB(RCC_AHBENR_FSMCEN, 0);
  34. /* set pin modes. by default sets in board files */
  35. /* IOBus busD = {GPIOD, PAL_WHOLE_PORT, 0};
  36. IOBus busE = {GPIOE, PAL_WHOLE_PORT, 0};
  37. palSetBusMode(&busD, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
  38. palSetBusMode(&busE, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
  39. palSetPadMode(GPIOE, GPIOE_TFT_RST, PAL_MODE_OUTPUT_PUSHPULL);
  40. palSetPadMode(GPIOD, GPIOD_TFT_LIGHT, PAL_MODE_OUTPUT_PUSHPULL);
  41. */
  42. const uint8_t FSMC_Bank = 0x0;
  43. /* Bank1 NOR/SRAM control register configuration */
  44. // FSMC_MemoryType_NOR | FSMC_MemoryDataWidth_16b | FSMC_WriteOperation_Enable
  45. FSMC_Bank1->BTCR[FSMC_Bank] = (uint32_t)(0x8 | 0x10 | 0x1000);
  46. // if FSMC_MemoryType_NOR
  47. FSMC_Bank1->BTCR[FSMC_Bank] |= ((uint32_t)0x00000040);
  48. /* Bank1 NOR/SRAM timing register configuration */
  49. // AddressSetupTime | DataSetupTime | FSMC_AccessMode_B
  50. FSMC_Bank1->BTCR[FSMC_Bank+1] = (uint32_t)(0x2 | (0x5 << 8) | 0x10000000);
  51. /* Bank1 NOR/SRAM timing register for write configuration, if extended mode is used */
  52. FSMC_Bank1E->BWTR[FSMC_Bank] = 0x0FFFFFFF;
  53. /* Enable FSMC Bank1_SRAM Bank */
  54. FSMC_Bank1->BTCR[FSMC_Bank] |= 0x1;
  55. }
  56. static inline void post_init_board(GDisplay *g) {
  57. (void) g;
  58. }
  59. static inline void setpin_reset(GDisplay *g, bool_t state) {
  60. (void) g;
  61. if(state)
  62. palClearPad(GPIOE, GPIOE_TFT_RST);
  63. else
  64. palSetPad(GPIOE, GPIOE_TFT_RST);
  65. }
  66. static inline void set_backlight(GDisplay *g, uint8_t percent) {
  67. (void) g;
  68. (void)percent;
  69. }
  70. static inline void gdisp_lld_backlight(GDisplay *g, uint8_t percent) {
  71. (void) g;
  72. (void)percent;
  73. }
  74. static inline void acquire_bus(GDisplay *g) {
  75. (void) g;
  76. }
  77. static inline void release_bus(GDisplay *g) {
  78. (void) g;
  79. }
  80. static inline void write_index(GDisplay *g, uint16_t index) {
  81. (void) g;
  82. GDISP_REG = index;
  83. }
  84. static inline void write_data(GDisplay *g, uint16_t data) {
  85. (void) g;
  86. GDISP_RAM = data;
  87. }
  88. static inline void setreadmode(GDisplay *g) {
  89. (void) g;
  90. }
  91. static inline void setwritemode(GDisplay *g) {
  92. (void) g;
  93. }
  94. static inline uint16_t read_data(GDisplay *g) {
  95. (void) g;
  96. return GDISP_RAM;
  97. }
  98. #endif /* GDISP_LLD_BOARD_H */