key.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 NO_KEY (1<<5)
  23. #define KEY_MASK (KEY_DOWN | KEY_ENTER | KEY_LEFT | KEY_RIGHT | KEY_UP)
  24. #define KEY_PFR (FM3_GPIO->PFR7)
  25. #define KEY_PCR (FM3_GPIO->PCR7)
  26. #define KEY_PDIR (FM3_GPIO->PDIR7)
  27. #define KEY_DDR (FM3_GPIO->DDR7)
  28. #define RT_DEVICE_CTRL_KEY_SCAN 0
  29. #define RT_DEVICE_CTRL_KEY_STATUS 1
  30. #define SET_BIT(byte, bit) ((byte) |= (1<<(bit)))
  31. #define CLR_BIT(byte, bit) ((byte) &= ~(1<<(bit)))
  32. #define TST_BIT(byte, bit) (((byte) & (1<<(bit)))?1:0)
  33. #define KEY_ENTER_GETVALUE() TST_BIT(KEY_PDIR, 1)
  34. #define KEY_DOWN_GETVALUE() TST_BIT(KEY_PDIR, 0)
  35. #define KEY_UP_GETVALUE() TST_BIT(KEY_PDIR, 4)
  36. #define KEY_RIGHT_GETVALUE() TST_BIT(KEY_PDIR, 3)
  37. #define KEY_LEFT_GETVALUE() TST_BIT(KEY_PDIR, 2)
  38. void rt_hw_key_init(void);
  39. #endif