blob: 78b5ea7460aad94cc6999c53ca34524af4cdd133 [file] [log] [blame]
Matt Spinlerb54357f2017-08-21 14:38:54 -05001#pragma once
2
3#include <map>
4#include <string>
5#include <tuple>
Matt Spinlere7e432b2017-08-21 15:01:40 -05006#include <vector>
Matt Spinlerb54357f2017-08-21 14:38:54 -05007
8namespace witherspoon
9{
10namespace power
11{
Matt Spinler2d248ae2017-09-19 11:06:48 -050012
13class UCD90160;
14
Matt Spinlerb54357f2017-08-21 14:38:54 -050015namespace ucd90160
16{
17
Matt Spinler2d248ae2017-09-19 11:06:48 -050018/**
19 * Defines which extra analysis is required
20 * on failures, if any.
21 */
22enum class extraAnalysisType
23{
24 none,
25 gpuPGOOD,
26 gpuOverTemp
27};
28
29/**
30 * Options for the GPIOs
31 *
32 * Used as a bitmask
33 */
34enum class optionFlags
35{
36 none = 0,
37 shutdownOnFault = 1
38};
39
40constexpr auto gpioNumField = 0;
41constexpr auto gpioCalloutField = 1;
42using GPIODefinition = std::tuple<gpio::gpioNum_t, std::string>;
43using GPIODefinitions = std::vector<GPIODefinition>;
44
45constexpr auto gpioDevicePathField = 0;
46constexpr auto gpioPolarityField = 1;
47constexpr auto errorFunctionField = 2;
48constexpr auto optionFlagsField = 3;
49constexpr auto gpioDefinitionField = 4;
50
51using ErrorFunction = std::function<void(UCD90160&, const std::string&)>;
52
53using GPIOGroup = std::tuple<
54 std::string, gpio::Value, ErrorFunction, optionFlags, GPIODefinitions>;
55
56using GPIOAnalysis = std::map<extraAnalysisType, GPIOGroup>;
57
Matt Spinlerd998b732017-08-21 15:35:54 -050058constexpr auto gpiNumField = 0;
59constexpr auto pinIDField = 1;
60constexpr auto gpiNameField = 2;
61constexpr auto pollField = 3;
Matt Spinler2d248ae2017-09-19 11:06:48 -050062constexpr auto extraAnalysisField = 4;
Matt Spinlerd998b732017-08-21 15:35:54 -050063
Matt Spinler2d248ae2017-09-19 11:06:48 -050064using GPIConfig = std::tuple<
65 size_t, size_t, std::string, bool, extraAnalysisType>;
Matt Spinlerd998b732017-08-21 15:35:54 -050066
67using GPIConfigs = std::vector<GPIConfig>;
68
Matt Spinlere7e432b2017-08-21 15:01:40 -050069using RailNames = std::vector<std::string>;
Matt Spinlerb54357f2017-08-21 14:38:54 -050070
Matt Spinlere7e432b2017-08-21 15:01:40 -050071constexpr auto pathField = 0;
72constexpr auto railNamesField = 1;
Matt Spinlerd998b732017-08-21 15:35:54 -050073constexpr auto gpiConfigField = 2;
Matt Spinler2d248ae2017-09-19 11:06:48 -050074constexpr auto gpioAnalysisField = 3;
Matt Spinlere7e432b2017-08-21 15:01:40 -050075
Matt Spinler2d248ae2017-09-19 11:06:48 -050076using DeviceDefinition = std::tuple<
77 std::string, RailNames, GPIConfigs, GPIOAnalysis>;
Matt Spinlerb54357f2017-08-21 14:38:54 -050078
79//Maps a device instance to its definition
80using DeviceMap = std::map<size_t, DeviceDefinition>;
81
82}
83}
84}