epdif.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /**
  2. * @filename : epdif.h
  3. * @brief : Header file of epdif.c providing EPD interface functions
  4. * Users have to implement all the functions in epdif.cpp
  5. * @author : Yehui from Waveshare
  6. *
  7. * Copyright (C) Waveshare July 7 2017
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10. * of this software and associated documnetation files (the "Software"), to deal
  11. * in the Software without restriction, including without limitation the rights
  12. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. * copies of the Software, and to permit persons to whom the Software is
  14. * furished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be included in
  17. * all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. * THE SOFTWARE.
  26. */
  27. #ifndef EPDIF_H
  28. #define EPDIF_H
  29. // Pin definition
  30. #define CS_PIN 0
  31. #define RST_PIN 1
  32. #define DC_PIN 2
  33. #define BUSY_PIN 3
  34. #ifndef uint8_t
  35. typedef unsigned char uint8_t;
  36. #endif
  37. #ifndef uint16_t
  38. typedef unsigned short uint16_t;
  39. #endif
  40. typedef struct eink_conf {
  41. uint8_t spi_id;
  42. uint8_t busy_pin;
  43. uint8_t res_pin;
  44. uint8_t dc_pin;
  45. uint8_t cs_pin;
  46. uint8_t full_mode;
  47. uint8_t port;
  48. void* userdata;
  49. }eink_conf_t;
  50. extern eink_conf_t econf;
  51. /**
  52. * e-Paper GPIO
  53. **/
  54. #define EPD_RST_PIN (econf.res_pin)
  55. #define EPD_DC_PIN (econf.dc_pin)
  56. #define EPD_CS_PIN (econf.cs_pin)
  57. #define EPD_BUSY_PIN (econf.busy_pin)
  58. #define EPD_SPI_ID (econf.spi_id)
  59. // Pin level definition
  60. #define LOW 0
  61. #define HIGH 1
  62. typedef struct {
  63. // GPIO_TypeDef* port;
  64. uint8_t port;
  65. } EPD_Pin;
  66. int EpdInitCallback(void);
  67. void EpdDigitalWriteCallback(int pin, int value);
  68. int EpdDigitalReadCallback(int pin);
  69. void EpdDelayMsCallback(unsigned int delaytime);
  70. void EpdSpiTransferCallback(unsigned char data);
  71. #endif /* EPDIF_H */