LCD.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef __LCD_H_
  2. #define __LCD_H_
  3. #include "stm32f10x.h"
  4. #define LCD_WIDTH 128
  5. #define LCD_HEIGHT 128
  6. #define LCD_BUS_IO 0
  7. #define LCD_BUS_SPI 1
  8. #define LCD_BUS_TYPE LCD_BUS_SPI//LCD_BUS_IO //LCD_BUS_SPI
  9. #if(LCD_BUS_TYPE==LCD_BUS_IO)
  10. #define LCD_CS_PIN GPIO_Pin_12
  11. #define LCD_CS_PORT GPIOB
  12. #define LCD_CS_HIGH LCD_CS_PORT->BSRR = LCD_CS_PIN
  13. #define LCD_CS_LOW LCD_CS_PORT->BRR = LCD_CS_PIN
  14. #define LCD_SCK_PIN GPIO_Pin_13
  15. #define LCD_SCK_PORT GPIOB
  16. #define LCD_SCK_HIGH LCD_SCK_PORT->BSRR = LCD_SCK_PIN
  17. #define LCD_SCK_LOW LCD_SCK_PORT->BRR = LCD_SCK_PIN
  18. #define LCD_DCX_PIN GPIO_Pin_14
  19. #define LCD_DCX_PORT GPIOB
  20. #define LCD_DCX_HIGH LCD_DCX_PORT->BSRR = LCD_DCX_PIN
  21. #define LCD_DCX_LOW LCD_DCX_PORT->BRR = LCD_DCX_PIN
  22. #define LCD_SDA_PIN GPIO_Pin_15
  23. #define LCD_SDA_PORT GPIOB
  24. #define LCD_SDA_HIGH LCD_SDA_PORT->BSRR = LCD_SDA_PIN
  25. #define LCD_SDA_LOW LCD_SDA_PORT->BRR = LCD_SDA_PIN
  26. #elif(LCD_BUS_TYPE==LCD_BUS_SPI)
  27. #define LCD_SPI_NSS_PIN GPIO_Pin_12
  28. #define LCD_SPI_SCK_PIN GPIO_Pin_13
  29. #define LCD_DCX_PIN GPIO_Pin_14
  30. #define LCD_SPI_MOSI_PIN GPIO_Pin_15
  31. #define LCD_SPI_PORT GPIOB
  32. #define LCD_SPI_HANDLE SPI2
  33. #define LCD_DCX_PORT GPIOB
  34. #define LCD_SPI_NSS_HIGH LCD_SPI_PORT->BSRR = LCD_SPI_NSS_PIN
  35. #define LCD_SPI_NSS_LOW LCD_SPI_PORT->BRR = LCD_SPI_NSS_PIN
  36. #define LCD_DCX_HIGH LCD_DCX_PORT->BSRR = LCD_DCX_PIN
  37. #define LCD_DCX_LOW LCD_DCX_PORT->BRR = LCD_DCX_PIN
  38. #endif
  39. #define LCD_RESET_PIN GPIO_Pin_11
  40. #define LCD_RESET_PORT GPIOA
  41. #define LCD_RESET_HIGH LCD_RESET_PORT->BSRR = LCD_RESET_PIN
  42. #define LCD_RESET_LOW LCD_RESET_PORT->BRR = LCD_RESET_PIN
  43. #define LCD_BL_PIN GPIO_Pin_12
  44. #define LCD_BL_PORT GPIOA
  45. #define LCD_BL_HIGH LCD_BL_PORT->BSRR = LCD_BL_PIN
  46. #define LCD_BL_LOW LCD_BL_PORT->BRR = LCD_BL_PIN
  47. extern unsigned char showApn;
  48. extern unsigned char LastKeyLight;
  49. extern unsigned char KeyLightFlag;
  50. void LcdInit(void);
  51. void LCDBackLight(char Ct);
  52. void LcdSendData(unsigned char Data);
  53. void LcdClrAll(void);
  54. void LcdBlockWrite(u16 x1,u16 y1,u16 x2,u16 y2);
  55. #endif