iokey.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef DEVICE_IOKEY_H
  2. #define DEVICE_IOKEY_H
  3. #include "typedef.h"
  4. #include "device/device.h"
  5. // enum key_connect_way {
  6. // ONE_PORT_TO_LOW, //按键一个端口接低电平, 另一个端口接IO
  7. // ONE_PORT_TO_HIGH, //按键一个端口接高电平, 另一个端口接IO
  8. // DOUBLE_PORT_TO_IO, //按键两个端口接IO
  9. // };
  10. #define ONE_PORT_TO_LOW 0 //按键一个端口接低电平, 另一个端口接IO
  11. #define ONE_PORT_TO_HIGH 1 //按键一个端口接高电平, 另一个端口接IO
  12. #define DOUBLE_PORT_TO_IO 2 //按键两个端口接IO
  13. #define CUST_DOUBLE_PORT_TO_IO 3
  14. struct one_io_key {
  15. u8 port;
  16. };
  17. struct two_io_key {
  18. u8 in_port;
  19. u8 out_port;
  20. };
  21. union key_type {
  22. struct one_io_key one_io;
  23. struct two_io_key two_io;
  24. };
  25. struct iokey_port {
  26. union key_type key_type;
  27. u8 connect_way;
  28. u8 key_value;
  29. };
  30. struct iokey_platform_data {
  31. u8 enable;
  32. u8 num;
  33. const struct iokey_port *port;
  34. };
  35. //IOKEY API:
  36. extern int iokey_init(const struct iokey_platform_data *iokey_data);
  37. extern u8 io_get_key_value(void);
  38. #endif