-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUSBCommands.h
139 lines (122 loc) · 4.23 KB
/
USBCommands.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
* Copyright (c) 2016 Jari Saukkonen
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef USBCOMMANDS_H
#define USBCOMMANDS_H
enum USBCommand {
END = 0x00,
IDENTIFY = 0x01,
GETFACTORYSETTINGS = 0x02,
GETOUTPUTSETTINGS = 0x03,
GETSTATUS = 0x04,
GETRAWPOWERUSAGE = 0x05,
SETRELAY = 0x10,
SETPWMDUTY = 0x11,
RESETFUSE = 0x12,
CONFIGUREOUTPUT = 0x13,
CONFIGURESETTINGS = 0x14,
FACTORYRESET = 0xFA,
REBOOT_BOOTLOADER = 0xFB,
CALIBRATEOUTPUT = 0xFC
};
struct GetFactorySettingsResponse {
uint16_t firmwareVersion;
uint16_t serialNumber;
uint8_t fuseDelay;
uint8_t skyQualityOffset;
uint8_t features;
uint8_t boardRevision;
} __attribute__((__packed__));
struct FactoryResetCommand {
uint16_t serial;
uint16_t r6ohms;
uint16_t r7ohms;
uint8_t boardRevision;
} __attribute__((__packed__));
struct GetOutputSettingsCommand {
uint8_t outputNumber;
} __attribute__((__packed__));
struct GetOutputSettingsResponse {
char name[16];
uint8_t fuseCurrent;
uint8_t type;
} __attribute__((__packed__));
struct GetStatusResponse {
uint8_t relayIsOpenBits; // 1 = enabled, 0 = disabled
uint8_t fuseIsBlownBits; // 1 = blown, 0 = not blown
uint8_t pwmPercentages[6]; // 0-100
uint8_t inputVoltage; // *10, 120 = 12.0V
uint8_t outputPower[6]; // *10, 50 = 5.0A
uint8_t numberOfTemperatureProbes;
int16_t temperatureProbes[4]; // *10, -35 = -3.5 degrees Celsius
int16_t temperature; // *10, -35 = -3.5 degrees Celsius
int16_t dewpoint; // *10, -35 = -3.5 degrees Celsius
uint8_t humidity; // 0-100 (%)
uint16_t pressure; // *10, 10005 = 1000.5 hPa
uint8_t skyquality; // *10, 210 = 21.0 mag/arcsec^2
int16_t skytemperature; // *10, -35 = -3.5 degrees Celsius
int16_t skyambienttemperature; // *10, -35 = -3.5 degrees Celsius
uint8_t pthpresent; // 1 = pth sensor (BME280) present, 0 = absent
uint8_t skyqualitypresent; // 1 = sky quality sensor present, 0 = absent
uint8_t skytemperaturepresent; // 1 = sky temperature present, 0 = absent
uint32_t skyqualityfreq; // raw sky quality frequency, *10, 35 = 3.5 Hz
} __attribute__((__packed__));
struct GetRawPowerUsageResponse {
uint16_t rawValues[8];
} __attribute__((__packed__));
struct UpdateSettingsCommand {
uint8_t features;
uint8_t SkyQualityzeropoint;
uint8_t fusespeed;
} __attribute__((__packed__));
struct SetRelayCommand {
uint8_t outputNumber;
uint8_t enabled;
} __attribute__((__packed__));
struct SetPwmDutyCommand {
uint8_t outputNumber;
uint8_t duty; // 0-100
} __attribute__((__packed__));
struct ResetFuseCommand {
uint8_t outputNumber;
} __attribute__((__packed__));
struct ConfigureOutputCommand {
uint8_t outputNumber;
uint8_t outputType;
uint8_t fuseCurrent;
char name[16];
} __attribute__((__packed__));
struct ConfigureSettingsCommand {
uint8_t fuseDelay;
uint8_t skyQualityOffset;
uint8_t featureTempProbe;
uint8_t featureSkyQuality;
uint8_t featureAmbientPTH;
uint8_t featureSkyTemperature;
} __attribute__((__packed__));
struct CalibrateOutputCommand {
uint8_t outputNumber;
int8_t a;
uint8_t b;
uint8_t c;
} __attribute__((__packed__));
#endif