luat_keyboard_air105.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include "luat_base.h"
  2. #include "luat_keyboard.h"
  3. #include "app_interface.h"
  4. #define LUAT_LOG_TAG "keyboard"
  5. #include "luat_log.h"
  6. static int32_t kb_cb(void *pData, void *pParam) {
  7. luat_keyboard_irq_cb cb = (luat_keyboard_irq_cb)pParam;
  8. if (cb) {
  9. luat_keyboard_ctx_t ctx;
  10. ctx.port = 0;
  11. ctx.pin_data = (uint16_t) pData;
  12. ctx.state = (((uint32_t)pData) >> 16) & 0x1;
  13. cb(&ctx);
  14. }
  15. }
  16. int luat_keyboard_init(luat_keyboard_conf_t *conf) {
  17. // 按conf->port_conf 设置io复用
  18. if (conf->pin_conf & (1 << 0))
  19. GPIO_Iomux(GPIOD_12, 2); // keyboard0
  20. if (conf->pin_conf & (1 << 1))
  21. GPIO_Iomux(GPIOD_13, 2); // keyboard1
  22. if (conf->pin_conf & (1 << 2))
  23. GPIO_Iomux(GPIOD_14, 2); // keyboard2
  24. if (conf->pin_conf & (1 << 3))
  25. GPIO_Iomux(GPIOD_15, 2); // keyboard3
  26. if (conf->pin_conf & (1 << 4))
  27. GPIO_Iomux(GPIOE_00, 2); // keyboard4
  28. if (conf->pin_conf & (1 << 5))
  29. GPIO_Iomux(GPIOE_01, 2); // keyboard5
  30. if (conf->pin_conf & (1 << 6))
  31. GPIO_Iomux(GPIOE_02, 2); // keyboard6
  32. if (conf->pin_conf & (1 << 7))
  33. GPIO_Iomux(GPIOD_10, 2); // keyboard7
  34. if (conf->pin_conf & (1 << 8))
  35. GPIO_Iomux(GPIOD_11, 2); // keyboard8
  36. //---------------------------
  37. KB_Setup(conf->pin_map, 7, kb_cb, conf->cb);
  38. return 0;
  39. }
  40. int luat_keyboard_deinit(luat_keyboard_conf_t *conf) {
  41. KB_Stop();
  42. return 0;
  43. }