sk9822.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef __SK9822_H
  2. #define __SK9822_H
  3. #include <ioCC2530.h>
  4. #include "OnBoard.h"
  5. #define SK9822_SCK_PIN P1_4 //数据引脚
  6. #define SK9822_SCK_NUM GPIO_4
  7. #define SK9822_SDI_PIN P1_3 //数据引脚
  8. #define SK9822_SDI_NUM GPIO_3
  9. #define SK9822_PORT P1DIR
  10. //引脚配置为输出;
  11. #define SK9822_SCK_PIN_OUT() { SK9822_PORT |= SK9822_SCK_NUM; asm("NOP"); }
  12. //引脚配置为输入;
  13. #define SK9822_SCK_PIN_IN() { SK9822_PORT &= ~SK9822_SCK_NUM; asm("NOP"); }
  14. //引脚配置为输出;
  15. #define SK9822_SDI_PIN_OUT() { SK9822_PORT |= SK9822_SDI_NUM; asm("NOP"); }
  16. //引脚配置为输入;
  17. #define SK9822_SDI_PIN_IN() { SK9822_PORT &= ~SK9822_SDI_NUM; asm("NOP"); }
  18. //拉高数据线;
  19. #define SK9822_SCK_PIN_H() { SK9822_SCK_PIN = 1; asm("NOP"); }
  20. //拉低数据线;
  21. #define SK9822_SCK_PIN_L() { SK9822_SCK_PIN = 0; asm("NOP"); }
  22. //拉高数据线;
  23. #define SK9822_SDI_PIN_H() { SK9822_SDI_PIN = 1; asm("NOP"); }
  24. //拉低数据线;
  25. #define SK9822_SDI_PIN_L() { SK9822_SDI_PIN = 0; asm("NOP");}
  26. void SK9822_Write_Data(unsigned char Bri,unsigned char RED,unsigned char GREEN,unsigned char BLUE);
  27. void SK9822_Write_Byte(unsigned char Data);
  28. void SK9822_Intit(void);
  29. #endif