summaryrefslogtreecommitdiff
path: root/digital/zigbit/bitcloud/stack/Components/BSP/include/buttons.h
blob: 316c80d9ed7fc61f31ebcf3c56d280d87fd92736 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/***************************************************************************//**
  \file  buttons.h

  \brief The header file describes the buttons interface.

  \author
    Atmel Corporation: http://www.atmel.com \n
    Support email: avr@atmel.com

  Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
  Licensed under Atmel's Limited License Agreement (BitCloudTM).

  \internal
  History:
    29/05/07 E. Ivanov - Created
*******************************************************************************/

#ifndef _BSPBUTTONS_H
#define _BSPBUTTONS_H

/******************************************************************************
                   Includes section
******************************************************************************/
// \cond
#include <types.h>
// \endcond

/******************************************************************************
                   Define(s) section
******************************************************************************/
// \cond
#define BSP_KEY0 ((uint8_t)1 << 0)
#define BSP_KEY1 ((uint8_t)1 << 1)
#define BSP_KEY2 ((uint8_t)1 << 2)
#define BSP_KEY3 ((uint8_t)1 << 3)
#define BSP_KEY4 ((uint8_t)1 << 4)
#define BSP_KEY5 ((uint8_t)1 << 5)
#define BSP_KEY6 ((uint8_t)1 << 6)
#define BSP_KEY7 ((uint8_t)1 << 7)
// for avr32_evk1105
#define BSP_UP     0
#define BSP_DOWN   1
#define BSP_RIGHT  2
#define BSP_LEFT   3
#define BSP_ENTER  4
// \endcond

/******************************************************************************
                   Types section
******************************************************************************/

// \cond
typedef void (*BSP_ButtonsEventFunc_t)(uint8_t);
// \endcond

/******************************************************************************
                   Prototypes section
******************************************************************************/
/**************************************************************************//**
\brief Registers handlers for button events.
\param[in]
    pressed - the handler to process pressing of the button \n
    bn - button number.
\param[in]
    released - the handler to process releasing of the button \n
    bn - button number.
\return
  BC_FAIL - buttons module is busy, \n
  BC_SUCCESS - otherwise.
******************************************************************************/
result_t BSP_OpenButtons(void (*pressed)(uint8_t bn), void (*released)(uint8_t bn));

/**************************************************************************//**
\brief Cancel buttons handlers.
\return
  BC_FAIL - buttons module was not opened, \n
  BC_SUCCESS - otherwise.
******************************************************************************/
result_t BSP_CloseButtons(void);

/**************************************************************************//**
\brief Reads state of the buttons.
\return
    Current buttons state in a binary way. \n
    Bit 0 defines the state of button 1, \n
    bit 1 defines the state of button 2 (for meshbean). \n
    Bit 0 defines the state of up, \n
    bit 1 defines the state of down, \n
    bit 2 defines the state of right, \n
    bit 3 defines the state of left, \n
    bit 4 defines the state of enter(for avr32_evk1105).
******************************************************************************/
uint8_t BSP_ReadButtonsState(void);

#endif /* _BSPBUTTONS_H */
//eof buttons.h