key.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * File : key.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2011, RT-Thread Develop Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2011-03-06 lgnq
  13. */
  14. #ifndef __KEY_H__
  15. #define __KEY_H__
  16. #include "mb9bf506r.h"
  17. #define KEY_DOWN (1<<0)
  18. #define KEY_ENTER (1<<1)
  19. #define KEY_LEFT (1<<2)
  20. #define KEY_RIGHT (1<<3)
  21. #define KEY_UP (1<<4)
  22. #define KEY_MASK (KEY_DOWN | KEY_ENTER | KEY_LEFT | KEY_RIGHT | KEY_UP)
  23. #define KEY_PFR (FM3_GPIO->PFR7)
  24. #define KEY_PCR (FM3_GPIO->PCR7)
  25. #define KEY_PDIR (FM3_GPIO->PDIR7)
  26. #define KEY_DDR (FM3_GPIO->DDR7)
  27. #define RT_DEVICE_CTRL_KEY_SCAN 0
  28. #define RT_DEVICE_CTRL_KEY_STATUS 1
  29. #define SET_BIT(byte, bit) ((byte) |= (1<<(bit)))
  30. #define CLR_BIT(byte, bit) ((byte) &= ~(1<<(bit)))
  31. #define TST_BIT(byte, bit) (((byte) & (1<<(bit)))?1:0)
  32. #define KEY_ENTER_GETVALUE() TST_BIT(KEY_PDIR, 1)
  33. #define KEY_DOWN_GETVALUE() TST_BIT(KEY_PDIR, 0)
  34. #define KEY_UP_GETVALUE() TST_BIT(KEY_PDIR, 4)
  35. #define KEY_RIGHT_GETVALUE() TST_BIT(KEY_PDIR, 3)
  36. #define KEY_LEFT_GETVALUE() TST_BIT(KEY_PDIR, 2)
  37. void rt_hw_key_init(void);
  38. #endif