Matt Spinler | b54357f | 2017-08-21 14:38:54 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <map> |
| 4 | #include <string> |
| 5 | #include <tuple> |
Matt Spinler | e7e432b | 2017-08-21 15:01:40 -0500 | [diff] [blame] | 6 | #include <vector> |
Matt Spinler | b54357f | 2017-08-21 14:38:54 -0500 | [diff] [blame] | 7 | |
| 8 | namespace witherspoon |
| 9 | { |
| 10 | namespace power |
| 11 | { |
Matt Spinler | 2d248ae | 2017-09-19 11:06:48 -0500 | [diff] [blame] | 12 | |
| 13 | class UCD90160; |
| 14 | |
Matt Spinler | b54357f | 2017-08-21 14:38:54 -0500 | [diff] [blame] | 15 | namespace ucd90160 |
| 16 | { |
| 17 | |
Matt Spinler | 2d248ae | 2017-09-19 11:06:48 -0500 | [diff] [blame] | 18 | /** |
| 19 | * Defines which extra analysis is required |
| 20 | * on failures, if any. |
| 21 | */ |
| 22 | enum class extraAnalysisType |
| 23 | { |
| 24 | none, |
| 25 | gpuPGOOD, |
| 26 | gpuOverTemp |
| 27 | }; |
| 28 | |
| 29 | /** |
| 30 | * Options for the GPIOs |
| 31 | * |
| 32 | * Used as a bitmask |
| 33 | */ |
| 34 | enum class optionFlags |
| 35 | { |
| 36 | none = 0, |
| 37 | shutdownOnFault = 1 |
| 38 | }; |
| 39 | |
| 40 | constexpr auto gpioNumField = 0; |
| 41 | constexpr auto gpioCalloutField = 1; |
| 42 | using GPIODefinition = std::tuple<gpio::gpioNum_t, std::string>; |
| 43 | using GPIODefinitions = std::vector<GPIODefinition>; |
| 44 | |
| 45 | constexpr auto gpioDevicePathField = 0; |
| 46 | constexpr auto gpioPolarityField = 1; |
| 47 | constexpr auto errorFunctionField = 2; |
| 48 | constexpr auto optionFlagsField = 3; |
| 49 | constexpr auto gpioDefinitionField = 4; |
| 50 | |
| 51 | using ErrorFunction = std::function<void(UCD90160&, const std::string&)>; |
| 52 | |
| 53 | using GPIOGroup = std::tuple< |
| 54 | std::string, gpio::Value, ErrorFunction, optionFlags, GPIODefinitions>; |
| 55 | |
| 56 | using GPIOAnalysis = std::map<extraAnalysisType, GPIOGroup>; |
| 57 | |
Matt Spinler | d998b73 | 2017-08-21 15:35:54 -0500 | [diff] [blame] | 58 | constexpr auto gpiNumField = 0; |
| 59 | constexpr auto pinIDField = 1; |
| 60 | constexpr auto gpiNameField = 2; |
| 61 | constexpr auto pollField = 3; |
Matt Spinler | 2d248ae | 2017-09-19 11:06:48 -0500 | [diff] [blame] | 62 | constexpr auto extraAnalysisField = 4; |
Matt Spinler | d998b73 | 2017-08-21 15:35:54 -0500 | [diff] [blame] | 63 | |
Matt Spinler | 2d248ae | 2017-09-19 11:06:48 -0500 | [diff] [blame] | 64 | using GPIConfig = std::tuple< |
| 65 | size_t, size_t, std::string, bool, extraAnalysisType>; |
Matt Spinler | d998b73 | 2017-08-21 15:35:54 -0500 | [diff] [blame] | 66 | |
| 67 | using GPIConfigs = std::vector<GPIConfig>; |
| 68 | |
Matt Spinler | e7e432b | 2017-08-21 15:01:40 -0500 | [diff] [blame] | 69 | using RailNames = std::vector<std::string>; |
Matt Spinler | b54357f | 2017-08-21 14:38:54 -0500 | [diff] [blame] | 70 | |
Matt Spinler | e7e432b | 2017-08-21 15:01:40 -0500 | [diff] [blame] | 71 | constexpr auto pathField = 0; |
| 72 | constexpr auto railNamesField = 1; |
Matt Spinler | d998b73 | 2017-08-21 15:35:54 -0500 | [diff] [blame] | 73 | constexpr auto gpiConfigField = 2; |
Matt Spinler | 2d248ae | 2017-09-19 11:06:48 -0500 | [diff] [blame] | 74 | constexpr auto gpioAnalysisField = 3; |
Matt Spinler | e7e432b | 2017-08-21 15:01:40 -0500 | [diff] [blame] | 75 | |
Matt Spinler | 2d248ae | 2017-09-19 11:06:48 -0500 | [diff] [blame] | 76 | using DeviceDefinition = std::tuple< |
| 77 | std::string, RailNames, GPIConfigs, GPIOAnalysis>; |
Matt Spinler | b54357f | 2017-08-21 14:38:54 -0500 | [diff] [blame] | 78 | |
| 79 | //Maps a device instance to its definition |
| 80 | using DeviceMap = std::map<size_t, DeviceDefinition>; |
| 81 | |
| 82 | } |
| 83 | } |
| 84 | } |