DEV_Config.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*****************************************************************************
  2. * | File : DEV_Config.h
  3. * | Author : Waveshare team
  4. * | Function : Hardware underlying interface
  5. * | Info :
  6. * Used to shield the underlying layers of each master
  7. * and enhance portability
  8. *----------------
  9. * | This version: V2.0
  10. * | Date : 2018-10-30
  11. * | Info :
  12. * 1.add:
  13. * UBYTE\UWORD\UDOUBLE
  14. * 2.Change:
  15. * EPD_RST -> EPD_RST_PIN
  16. * EPD_DC -> EPD_pin_dc
  17. * EPD_CS -> EPD_CS_PIN
  18. * EPD_BUSY -> EPD_BUSY_PIN
  19. * 3.Remote:
  20. * EPD_RST_1\EPD_RST_0
  21. * EPD_DC_1\EPD_DC_0
  22. * EPD_CS_1\EPD_CS_0
  23. * EPD_BUSY_1\EPD_BUSY_0
  24. * 3.add:
  25. * #define DEV_Digital_Write(_pin, _value) bcm2835_gpio_write(_pin, _value)
  26. * #define DEV_Digital_Read(_pin) bcm2835_gpio_lev(_pin)
  27. * #define DEV_SPI_WriteByte(__value) bcm2835_spi_transfer(__value)
  28. #
  29. # Permission is hereby granted, free of charge, to any person obtaining a copy
  30. # of this software and associated documnetation files (the "Software"), to deal
  31. # in the Software without restriction, including without limitation the rights
  32. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  33. # copies of the Software, and to permit persons to whom the Software is
  34. # furished to do so, subject to the following conditions:
  35. #
  36. # The above copyright notice and this permission notice shall be included in
  37. # all copies or substantial portions of the Software.
  38. #
  39. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  40. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  41. # FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  42. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  43. # LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  44. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  45. # THE SOFTWARE.
  46. #
  47. ******************************************************************************/
  48. #ifndef _DEV_CONFIG_H_
  49. #define _DEV_CONFIG_H_
  50. #include "luat_base.h"
  51. #include "luat_gpio.h"
  52. #include "luat_spi.h"
  53. #include "luat_timer.h"
  54. #include "luat_rtos.h"
  55. #include "u8g2.h"
  56. #include "Debug.h"
  57. /**
  58. * data
  59. **/
  60. #define UBYTE uint8_t
  61. #define UWORD uint16_t
  62. #define UDOUBLE uint32_t
  63. #define LUAT_EINK_SPI_DEVICE 255
  64. #define EPD_SHOW (1<<0)
  65. #define EPD_DRAW (1<<1)
  66. #define EPD_CLEAR (1<<2)
  67. #include "epdpaint.h"
  68. typedef struct eink_ctx{
  69. uint32_t str_color;
  70. Paint paint;
  71. uint8_t fb[];
  72. }eink_ctx_t;
  73. typedef struct eink_conf {
  74. uint8_t full_mode;
  75. uint8_t port;
  76. uint8_t pin_rst;
  77. uint8_t pin_dc;
  78. uint8_t pin_cs;
  79. uint8_t pin_busy;
  80. uint8_t async;
  81. uint64_t idp;
  82. uint32_t ctx_index;
  83. eink_ctx_t *ctxs[2]; // 暂时只支持2种颜色, 有需要的话后续继续
  84. u8g2_t luat_eink_u8g2;
  85. luat_spi_device_t* eink_spi_device;
  86. int eink_spi_ref;
  87. luat_rtos_queue_t eink_queue_handle;
  88. luat_rtos_task_handle eink_task_handle;
  89. void* userdata;
  90. }eink_conf_t;
  91. extern eink_conf_t econf;
  92. /**
  93. * e-Paper GPIO
  94. **/
  95. #define EPD_RST_PIN (econf.pin_rst)
  96. #define EPD_DC_PIN (econf.pin_dc)
  97. #define EPD_CS_PIN (econf.pin_cs)
  98. #define EPD_BUSY_PIN (econf.pin_busy)
  99. /**
  100. * GPIO read and write
  101. **/
  102. int DEV_Digital_Write(int pin, int level);
  103. #define DEV_Digital_Read luat_gpio_get
  104. /**
  105. * delay x ms
  106. **/
  107. #define DEV_Delay_ms(__xms) luat_timer_mdelay(__xms);
  108. void DEV_SPI_WriteByte(UBYTE value);
  109. void EPD_Busy_WaitUntil(uint8_t level,uint8_t send_cmd);
  110. #endif