Commit for the 090810 release.
[pub/USBasp.git] / LUFA / Drivers / Board / USBKEY / Buttons.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2009.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, and distribute this software
13 and its documentation for any purpose and without fee is hereby
14 granted, provided that the above copyright notice appear in all
15 copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
20
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
28 this software.
29 */
30
31 /** \file
32 *
33 * Board specific Buttons driver header for the USBKEY.
34 *
35 * \note This file should not be included directly. It is automatically included as needed by the Buttons driver
36 * dispatch header located in LUFA/Drivers/Board/Buttons.h.
37 */
38
39 #ifndef __BUTTONS_USBKEY_H__
40 #define __BUTTONS_USBKEY_H__
41
42 /* Includes: */
43 #include <avr/io.h>
44 #include <stdbool.h>
45
46 #include "../../../Common/Common.h"
47
48 /* Enable C linkage for C++ Compilers: */
49 #if defined(__cplusplus)
50 extern "C" {
51 #endif
52
53 /* Preprocessor Checks: */
54 #if !defined(INCLUDE_FROM_BUTTONS_H)
55 #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.
56 #endif
57
58 /* Public Interface - May be used in end-application: */
59 /* Macros: */
60 /** Button mask for the first button on the board. */
61 #define BUTTONS_BUTTON1 (1 << 2)
62
63 /* Inline Functions: */
64 #if !defined(__DOXYGEN__)
65 static inline void Buttons_Init(void)
66 {
67 DDRE &= ~BUTTONS_BUTTON1;
68 PORTE |= BUTTONS_BUTTON1;
69 }
70
71 static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
72 static inline uint8_t Buttons_GetStatus(void)
73 {
74 return ((PINE & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);
75 }
76 #endif
77
78 /* Disable C linkage for C++ Compilers: */
79 #if defined(__cplusplus)
80 }
81 #endif
82
83 #endif
84