Dawn Framework
1.0
Universal data acquisition framework for embedded systems
dawn
src
porting
nuttx
buttons.cxx
1
// dawn/src/porting/nuttx/buttons.cxx
2
//
3
// SPDX-License-Identifier: Apache-2.0
4
//
5
6
#include <errno.h>
7
#include <fcntl.h>
8
#include <nuttx/input/buttons.h>
9
#include <sys/ioctl.h>
10
#include <unistd.h>
11
12
#include "dawn/debug.hxx"
13
#include "dawn/porting/config.hxx"
14
15
//***************************************************************************
16
// Public Functions
17
//***************************************************************************
18
19
//***************************************************************************
20
// Name: buttons_open
21
//***************************************************************************
22
23
int
buttons_open(
const
char
*path)
24
{
25
int
fd;
26
27
#ifdef CONFIG_DAWN_NUTTX_BOARDS_COMPAT
28
path =
"/dev/buttons"
;
29
#endif
30
31
fd = open(path, O_RDWR);
32
DAWNINFO(
"BUTTONS: open %s %d\n"
, path, fd);
33
if
(fd < 0)
34
{
35
DAWNERR(
"Failed to open BUTTONS file %s (error %d)\n"
, path, fd);
36
return
-EIO;
37
}
38
return
fd;
39
}
40
41
//***************************************************************************
42
// Name: buttons_close
43
//***************************************************************************
44
45
void
buttons_close(
int
fd)
46
{
47
if
(fd >= 0)
48
{
49
close(fd);
50
}
51
}
52
53
//***************************************************************************
54
// Name: buttons_read
55
//***************************************************************************
56
57
int
buttons_read(
int
fd, uint32_t *buttons)
58
{
59
return
static_cast<
int
>
(read(fd, buttons,
sizeof
(btn_buttonset_t)));
60
}
Generated by
1.9.8