luat_ht1621.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef __SEGMENTLCD__H__
  2. #define __SEGMENTLCD__H__
  3. #include "luat_base.h"
  4. #include "luat_gpio.h"
  5. //定义HT1621的命令
  6. #define ComMode 0x52 //4COM,1/3bias 1000 010 1001 0
  7. #define RCosc 0x30 //内部RC振荡器(上电默认)1000 0011 0000
  8. #define LCD_on 0x06 //打开LCD 偏压发生器1000 0000 0 11 0
  9. #define LCD_off 0x04 //关闭LCD显示
  10. #define Sys_en 0x02 //系统振荡器开 1000 0000 0010
  11. #define CTRl_cmd 0x80 //写控制命令
  12. #define Data_cmd 0xa0 //写数据命令
  13. //设置变量寄存器函数
  14. // #define sbi(x, y) (x |= (1 << y)) /*置位寄器x的第y位*/
  15. // #define cbi(x, y) (x &= ~(1 <<y )) /*清零寄器x的第y位*/
  16. //IO端口定义
  17. #define LCD_DATA 4
  18. #define LCD_WR 5
  19. #define LCD_CS 6
  20. #ifndef HIGH
  21. #define HIGH 1
  22. #endif
  23. #ifndef LOW
  24. #define LOW 1
  25. #endif
  26. typedef struct luat_ht1621_conf {
  27. int pin_data;
  28. int pin_wr;
  29. int pin_cs;
  30. }luat_ht1621_conf_t;
  31. //定义端口HT1621数据端口
  32. #define LCD_DATA1 luat_gpio_set(LCD_DATA,HIGH)
  33. #define LCD_DATA0 luat_gpio_set(LCD_DATA,LOW)
  34. #define LCD_WR1 luat_gpio_set(LCD_WR,HIGH)
  35. #define LCD_WR0 luat_gpio_set(LCD_WR,LOW)
  36. #define LCD_CS1 luat_gpio_set(LCD_CS,HIGH)
  37. #define LCD_CS0 luat_gpio_set(LCD_CS,LOW)
  38. void luat_ht1621_init(luat_ht1621_conf_t *conf);
  39. void luat_ht1621_write_cmd(luat_ht1621_conf_t *conf, uint8_t cmd);
  40. void luat_ht1621_write_data(luat_ht1621_conf_t *conf, uint8_t addr, uint8_t data);
  41. void luat_ht1621_lcd(luat_ht1621_conf_t *conf, int onoff);
  42. #endif