DEV_Config.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*****************************************************************************
  2. * | File : DEV_Config.c
  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. # ******************************************************************************
  13. # Permission is hereby granted, free of charge, to any person obtaining a copy
  14. # of this software and associated documnetation files (the "Software"), to deal
  15. # in the Software without restriction, including without limitation the rights
  16. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  17. # copies of the Software, and to permit persons to whom the Software is
  18. # furished to do so, subject to the following conditions:
  19. #
  20. # The above copyright notice and this permission notice shall be included in
  21. # all copies or substantial portions of the Software.
  22. #
  23. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  25. # FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  26. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  27. # LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  28. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  29. # THE SOFTWARE.
  30. #
  31. ******************************************************************************/
  32. #include "DEV_Config.h"
  33. #include "stm32f1xx_hal_spi.h"
  34. extern SPI_HandleTypeDef hspi1;
  35. void DEV_SPI_WriteByte(UBYTE value)
  36. {
  37. HAL_SPI_Transmit(&hspi1, &value, 1, 1000);
  38. }
  39. void DEV_SPI_Write_nByte(UBYTE *value, UDOUBLE len)
  40. {
  41. HAL_SPI_Transmit(&hspi1, value, len, 1000);
  42. }
  43. int DEV_Module_Init(void)
  44. {
  45. DEV_Digital_Write(EPD_DC_PIN, 0);
  46. DEV_Digital_Write(EPD_CS_PIN, 0);
  47. DEV_Digital_Write(EPD_PWR_PIN, 1);
  48. DEV_Digital_Write(EPD_RST_PIN, 1);
  49. return 0;
  50. }
  51. void DEV_Module_Exit(void)
  52. {
  53. DEV_Digital_Write(EPD_DC_PIN, 0);
  54. DEV_Digital_Write(EPD_CS_PIN, 0);
  55. //close 5V
  56. DEV_Digital_Write(EPD_PWR_PIN, 0);
  57. DEV_Digital_Write(EPD_RST_PIN, 0);
  58. }