blob: e4766f02f7b3c18cb70e686166dec278f5d88a80 [file] [log] [blame]
Ben Tyneref320152020-01-09 10:31:23 -06001#include <libpdbg.h>
2
3#include <attn_handler.hpp>
Ben Tyner73ac3682020-01-09 10:46:47 -06004#include <attn_monitor.hpp>
Ben Tyneref320152020-01-09 10:31:23 -06005
6/**
7 * @brief Attention handler application main()
8 *
9 * This is the main interface to the Attention handler application, it will
10 * initialize the libgpd targets and start a gpio mointor.
11 *
12 * @return 0 = success
13 */
14int main()
15{
16 int rc = 0; // return code
17
Ben Tyner73ac3682020-01-09 10:46:47 -060018 gpiod_line* line; // gpio line to monitor
19
20 boost::asio::io_service io; // async io monitoring service
21
Ben Tyneref320152020-01-09 10:31:23 -060022 // initialize pdbg targets
23 pdbg_targets_init(nullptr);
24
Ben Tyner73ac3682020-01-09 10:46:47 -060025 // GPIO line configuration (falling edge, active low)
26 struct gpiod_line_request_config config
27 {
28 "attention", GPIOD_LINE_REQUEST_EVENT_FALLING_EDGE, 0
29 };
30
31 // get handle to attention GPIO line
32 line = gpiod_line_get("gpiochip0", 74);
33
34 if (nullptr == line)
35 {
36 rc = 1; // error
37 }
38 else
39 {
40 // Creating a vector of one gpio to monitor
41 std::vector<std::unique_ptr<attn::AttnMonitor>> gpios;
42 gpios.push_back(std::make_unique<attn::AttnMonitor>(line, config, io));
43
44 io.run(); // start GPIO monitor
45 }
46
Ben Tyneref320152020-01-09 10:31:23 -060047 return rc;
48}