bs8116a.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * The MIT License
  3. *
  4. * Copyright (c) 2019 Illusion Lee
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all
  14. * copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. * SOFTWARE.
  23. */
  24. #ifndef __BS8116A_H_
  25. #define __BS8116A_H_
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif /* __cplusplus */
  29. /* 使用的BS8116A芯片数量 需要使用者进行定义和赋值 */
  30. extern rt_uint8_t BS8116A_CHIP_NUMS;
  31. /* 按键参数结构体 */
  32. struct bs8116a_key_arg {
  33. rt_uint8_t *key_value; /* 键值对应关系数组 */
  34. rt_uint8_t key_size; /* 实际使用的按键个数 */
  35. rt_uint8_t *init_buff; /* 初始化芯片的参数数组 */
  36. };
  37. /* 中断配置结构体 */
  38. struct bs8116a_irq_arg {
  39. rt_uint8_t irq_pin_id; /* 中断引脚编号 */
  40. struct rt_i2c_bus_device *bus; /* i2c设备结构体 */
  41. struct bs8116a_key_arg *key; /* 按键参数结构体 */
  42. char bus_name[16]; /* 使用的i2c设备名 */
  43. };
  44. /* 申请i2c总线函数 */
  45. extern void keypad_init(struct bs8116a_irq_arg arg[]);
  46. /* 对BS8116A芯片进行初始化配置,需要在上电后的8秒内调用 */
  47. extern void init_buf_to_bus(struct bs8116a_irq_arg arg[]);
  48. /* 注册中断引脚 绑定中断函数 */
  49. extern void key_irq_entry(struct bs8116a_irq_arg arg[]);
  50. /* 回调用户定义的函数 需要使用者实现方法体 */
  51. extern void got_key_callback(rt_uint8_t key_code);
  52. #ifdef __cplusplus
  53. }
  54. #endif /* __cplusplus */
  55. #endif /* __BS8116A_H_ */