dmd_ssd2119.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*************************************************************************//**
  2. * @file dmd_ssd2119.h
  3. * @brief Dot matrix display driver for LCD controller SSD2119
  4. * @author Energy Micro AS
  5. ******************************************************************************
  6. * @section License
  7. * <b>(C) Copyright 2012 Energy Micro AS, http://www.energymicro.com</b>
  8. ******************************************************************************
  9. *
  10. * Permission is granted to anyone to use this software for any purpose,
  11. * including commercial applications, and to alter it and redistribute it
  12. * freely, subject to the following restrictions:
  13. *
  14. * 1. The origin of this software must not be misrepresented; you must not
  15. * claim that you wrote the original software.
  16. * 2. Altered source versions must be plainly marked as such, and must not be
  17. * misrepresented as being the original software.
  18. * 3. This notice may not be removed or altered from any source distribution.
  19. * 4. The source and compiled code may only be used on Energy Micro "EFM32"
  20. * microcontrollers and "EFR4" radios.
  21. *
  22. * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
  23. * obligation to support this Software. Energy Micro AS is providing the
  24. * Software "AS IS", with no express or implied warranties of any kind,
  25. * including, but not limited to, any implied warranties of merchantability
  26. * or fitness for any particular purpose or warranties against infringement
  27. * of any proprietary rights of a third party.
  28. *
  29. * Energy Micro AS will not be liable for any consequential, incidental, or
  30. * special damages, or any other relief, or for any claim by any third party,
  31. * arising from your use of this Software.
  32. *
  33. *****************************************************************************/
  34. #ifndef __DMD_SSD2119_H
  35. #define __DMD_SSD2119_H
  36. #include <stdint.h>
  37. #include "graphics/em_types.h"
  38. /* TODO: remove this and replace with include types and ecodes */
  39. #define ECODE_DMD_BASE 0x00000000
  40. /* Error codes */
  41. /** Successful call */
  42. #define DMD_OK 0x00000000
  43. /** Driver not initialized correctly */
  44. #define DMD_ERROR_DRIVER_NOT_INITIALIZED (ECODE_DMD_BASE | 0x0001)
  45. /** Driver is already initialized */
  46. #define DMD_ERROR_DRIVER_ALREADY_INITIALIZED (ECODE_DMD_BASE | 0x0002)
  47. /** Length of data is larger than size of clip */
  48. #define DMD_ERROR_TOO_MUCH_DATA (ECODE_DMD_BASE | 0x0003)
  49. /** Pixel is outside current clipping area */
  50. #define DMD_ERROR_PIXEL_OUT_OF_BOUNDS (ECODE_DMD_BASE | 0x0004)
  51. /** Clipping area is empty */
  52. #define DMD_ERROR_EMPTY_CLIPPING_AREA (ECODE_DMD_BASE | 0x0005)
  53. /** Wrong device code */
  54. #define DMD_ERROR_WRONG_DEVICE_CODE (ECODE_DMD_BASE | 0x0006)
  55. /** Memory error */
  56. #define DMD_ERROR_MEMORY_ERROR (ECODE_DMD_BASE | 0x0007)
  57. /** Error code expected, but didn't happen */
  58. #define DMD_ERROR_NO_ERROR_CODE (ECODE_DMD_BASE | 0x0008)
  59. /** Test run failed */
  60. #define DMD_ERROR_TEST_FAILED (ECODE_DMD_BASE | 0x0009)
  61. /** Frame update frequency of display */
  62. #define DMD_FRAME_FREQUENCY 80
  63. /** Horizontal size of the display */
  64. #define DMD_HORIZONTAL_SIZE 320
  65. /** Vertical size of the display */
  66. #define DMD_VERTICAL_SIZE 240
  67. /* Tests */
  68. /** Device code test */
  69. #define DMD_TEST_DEVICE_CODE 0x00000001
  70. /** Memory test */
  71. #define DMD_TEST_MEMORY 0x00000002
  72. /** Parameter checks test */
  73. #define DMD_TEST_PARAMETER_CHECKS 0x00000004
  74. /** Color test */
  75. #define DMD_TEST_COLORS 0x00000008
  76. /** Clipping test */
  77. #define DMD_TEST_CLIPPING 0x00000010
  78. #define DMD_MEMORY_TEST_WIDTH 4
  79. #define DMD_MEMORY_TEST_HEIGHT 3
  80. /** @struct __DMD_DisplayGeometry
  81. * @brief Dimensions of the display
  82. */
  83. typedef struct __DMD_DisplayGeometry
  84. {
  85. /** Horizontal size of the display, in pixels */
  86. uint16_t xSize;
  87. /** Vertical size of the display, in pixels */
  88. uint16_t ySize;
  89. /** X coordinate of the top left corner of the clipping area */
  90. uint16_t xClipStart;
  91. /** Y coordinate of the top left corner of the clipping area */
  92. uint16_t yClipStart;
  93. /** Width of the clipping area */
  94. uint16_t clipWidth;
  95. /** Height of the clipping area */
  96. uint16_t clipHeight;
  97. } DMD_DisplayGeometry; /**< Typedef for display dimensions */
  98. /** @struct __DMD_MemoryError
  99. * @brief Information about a memory error
  100. */
  101. typedef struct __DMD_MemoryError
  102. {
  103. /** X coordinate of the address where the error happened */
  104. uint16_t x;
  105. /** Y coordinate of the address where the error happened */
  106. uint16_t y;
  107. /** The color that was written to the memory address */
  108. uint8_t writtenColor[3];
  109. /** The color that was read from the memory address */
  110. uint8_t readColor[3];
  111. } DMD_MemoryError; /**< Typedef for memory error information */
  112. /* Module prototypes */
  113. EMSTATUS DMD_init(uint32_t cmdRegAddr, uint32_t dataRegAddr);
  114. EMSTATUS DMD_getDisplayGeometry(DMD_DisplayGeometry **geometry);
  115. EMSTATUS DMD_setClippingArea(uint16_t xStart, uint16_t yStart,
  116. uint16_t width, uint16_t height);
  117. EMSTATUS DMD_writeData(uint16_t x, uint16_t y,
  118. const uint8_t data[], uint32_t numPixels);
  119. EMSTATUS DMD_writeDataRLE(uint16_t x, uint16_t y, uint16_t xlen, uint16_t ylen,
  120. const uint8_t *data);
  121. EMSTATUS DMD_writeDataRLEFade(uint16_t x, uint16_t y, uint16_t xlen, uint16_t ylen,
  122. const uint8_t *data,
  123. int red, int green, int blue, int weight);
  124. EMSTATUS DMD_readData(uint16_t x, uint16_t y,
  125. uint8_t data[], uint32_t numPixels);
  126. EMSTATUS DMD_writeColor(uint16_t x, uint16_t y, uint8_t red,
  127. uint8_t green, uint8_t blue, uint32_t numPixels);
  128. EMSTATUS DMD_writePixel(uint16_t x, uint16_t y, uint16_t color,
  129. uint32_t numPixels);
  130. EMSTATUS DMD_readPixel(uint16_t x, uint16_t y, uint16_t *color);
  131. EMSTATUS DMD_sleep(void);
  132. EMSTATUS DMD_wakeUp(void);
  133. /* Test functions */
  134. EMSTATUS DMD_testParameterChecks(void);
  135. EMSTATUS DMD_testMemory(uint16_t x, uint16_t y,
  136. uint32_t useClipWrite, uint32_t useClipRead,
  137. DMD_MemoryError *memoryError);
  138. EMSTATUS DMD_testMemory2(uint16_t x, uint16_t y,
  139. uint32_t useClipWrite);
  140. EMSTATUS DMD_testDeviceCode(void);
  141. EMSTATUS DMD_testColors(uint32_t delay);
  142. EMSTATUS DMD_testClipping(void);
  143. EMSTATUS DMD_runTests(uint32_t tests, uint32_t *result);
  144. EMSTATUS DMD_flipDisplay(int horizontal, int vertical);
  145. #endif