dispatch.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2017-2020, Dataspeed Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Dataspeed Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 #ifndef _DATASPEED_PDS_CAN_DISPATCH_H
36 #define _DATASPEED_PDS_CAN_DISPATCH_H
37 #include <stdint.h>
38 
40 {
41 
42 enum {
43  REV_A = 1,
44  REV_B = 2,
45  REV_G = 7,
46  REV_H = 8,
47 };
48 
49 typedef struct {
50  // Master and slave status messages have the same structure.
51  // Hardware revision (enum): Rev A=1, {B-F}=2, G=7, {H-I}=8
52  uint8_t rev :4;
53  // Inverter Last Request (bool)
54  uint8_t inverter_request :1;
55  // Inverter Status (bool)
56  uint8_t inverter_status :1;
57  // Inverter Overloading (bool)
58  uint8_t inverter_overload :1;
59  // Inverter Over Temperature (bool)
60  uint8_t inverter_overtemp :1;
61  // Mode (enum)
62  // The current mode of the PDS.
63  uint8_t mode :4;
64  // Script (enum)
65  // The currently running script on the PDS, if any.
66  uint8_t script :4;
67  // Channel Status X (enum)
68  // The current status of channel X on the PDS.
69  // Union for master channels 1-12 and slave channels 13-24
70  union { struct {uint8_t status_01 :4; uint8_t status_02 :4;}; struct {uint8_t status_13 :4; uint8_t status_14 :4;}; };
71  union { struct {uint8_t status_03 :4; uint8_t status_04 :4;}; struct {uint8_t status_15 :4; uint8_t status_16 :4;}; };
72  union { struct {uint8_t status_05 :4; uint8_t status_06 :4;}; struct {uint8_t status_17 :4; uint8_t status_18 :4;}; };
73  union { struct {uint8_t status_07 :4; uint8_t status_08 :4;}; struct {uint8_t status_19 :4; uint8_t status_20 :4;}; };
74  union { struct {uint8_t status_09 :4; uint8_t status_10 :4;}; struct {uint8_t status_21 :4; uint8_t status_22 :4;}; };
75  union { struct {uint8_t status_11 :4; uint8_t status_12 :4;}; struct {uint8_t status_23 :4; uint8_t status_24 :4;}; };
76 } MsgStatus1;
77 
78 typedef struct {
79  // Master and slave status messages have the same structure.
80  // Board Temperature (float32)
81  // Internal board temperature, in Celsius.
82  int8_t board_temp;
83  // Thermocouple Temperature (float32)
84  // Thermocouple temperature, in Celsius.
85  int8_t thermocouple_temp;
86  // Voltage (float32)
87  // Voltage, in V.
88  uint16_t voltage :12;
89  // 4 Reserved/Unused bits.
90  uint16_t :4;
91 } MsgStatus2;
92 
93 typedef struct {
94  // Union for multiple messages with the same structure: Current1Master, Current2Master, Current3Master, Current1Slave, Current2Slave, Current3Slave
95  union { int16_t current_01; int16_t current_05; int16_t current_09; int16_t current_13; int16_t current_17; int16_t current_21; };
96  union { int16_t current_02; int16_t current_06; int16_t current_10; int16_t current_14; int16_t current_18; int16_t current_22; };
97  union { int16_t current_03; int16_t current_07; int16_t current_11; int16_t current_15; int16_t current_19; int16_t current_23; };
98  union { int16_t current_04; int16_t current_08; int16_t current_12; int16_t current_16; int16_t current_20; int16_t current_24; };
99 } MsgCurrent;
100 
101 typedef struct {
102  uint8_t channel;
103  uint8_t request;
105 
106 typedef struct {
107  uint8_t mode;
108 } MsgMode;
109 
110 typedef struct {
111  uint8_t script;
112 } MsgScript;
113 
114 #define BUILD_ASSERT(cond) do { (void) sizeof(char [1 - 2*!(cond)]); } while(0)
115 static void dispatchAssertSizes() {
116  BUILD_ASSERT(8 == sizeof(MsgCurrent));
117  BUILD_ASSERT(8 == sizeof(MsgStatus1));
118  BUILD_ASSERT(4 == sizeof(MsgStatus2));
119  BUILD_ASSERT(2 == sizeof(MsgRelay));
120  BUILD_ASSERT(1 == sizeof(MsgMode));
121  BUILD_ASSERT(1 == sizeof(MsgScript));
122 }
123 #undef BUILD_ASSERT
124 
125 enum {
126  ID_REQUEST = 0x410,
127  ID_MODE = 0x411,
128  ID_SCRIPT = 0x412,
129  ID_RESERVED1 = 0x413,
130  ID_RESERVED2 = 0x430,
131  ID_RESERVED3 = 0x431,
132  ID_RESERVED4 = 0x432,
136  ID_STATUS1_SLAVE3 = 0x423,
137  ID_CURRENT1_MASTER = 0x424,
140  ID_CURRENT1_SLAVE3 = 0x427,
141  ID_CURRENT2_MASTER = 0x428,
144  ID_CURRENT2_SLAVE3 = 0x42B,
145  ID_CURRENT3_MASTER = 0x42C,
148  ID_CURRENT3_SLAVE3 = 0x42F,
149  ID_STATUS2_MASTER = 0x43C,
150  ID_STATUS2_SLAVE1 = 0x43D,
151  ID_STATUS2_SLAVE2 = 0x43E,
152  ID_STATUS2_SLAVE3 = 0x43F,
153 };
154 
155 } //namespace dataspeed_pds_can
156 
157 #endif // _DATASPEED_PDS_CAN_DISPATCH_H
dataspeed_pds_can::ID_CURRENT1_SLAVE2
@ ID_CURRENT1_SLAVE2
Definition: dispatch.h:171
dataspeed_pds_can::ID_CURRENT2_SLAVE2
@ ID_CURRENT2_SLAVE2
Definition: dispatch.h:175
dataspeed_pds_can::ID_STATUS1_SLAVE2
@ ID_STATUS1_SLAVE2
Definition: dispatch.h:167
dataspeed_pds_can::ID_CURRENT2_SLAVE3
@ ID_CURRENT2_SLAVE3
Definition: dispatch.h:176
dataspeed_pds_can::ID_CURRENT3_SLAVE1
@ ID_CURRENT3_SLAVE1
Definition: dispatch.h:178
dataspeed_pds_can::MsgStatus1
Definition: dispatch.h:81
dataspeed_pds_can::ID_RESERVED3
@ ID_RESERVED3
Definition: dispatch.h:163
dataspeed_pds_can::ID_CURRENT1_SLAVE3
@ ID_CURRENT1_SLAVE3
Definition: dispatch.h:172
dataspeed_pds_can::ID_CURRENT2_SLAVE1
@ ID_CURRENT2_SLAVE1
Definition: dispatch.h:174
dataspeed_pds_can::REV_A
@ REV_A
Definition: dispatch.h:107
dataspeed_pds_can::ID_STATUS2_SLAVE2
@ ID_STATUS2_SLAVE2
Definition: dispatch.h:183
dataspeed_pds_can::ID_CURRENT3_MASTER
@ ID_CURRENT3_MASTER
Definition: dispatch.h:177
dataspeed_pds_can::ID_CURRENT1_MASTER
@ ID_CURRENT1_MASTER
Definition: dispatch.h:169
dataspeed_pds_can::ID_STATUS2_SLAVE1
@ ID_STATUS2_SLAVE1
Definition: dispatch.h:182
dataspeed_pds_can::ID_STATUS1_SLAVE1
@ ID_STATUS1_SLAVE1
Definition: dispatch.h:166
dataspeed_pds_can::MsgStatus2
Definition: dispatch.h:110
dataspeed_pds_can::ID_STATUS1_SLAVE3
@ ID_STATUS1_SLAVE3
Definition: dispatch.h:168
dataspeed_pds_can::ID_CURRENT3_SLAVE2
@ ID_CURRENT3_SLAVE2
Definition: dispatch.h:179
dataspeed_pds_can::ID_SCRIPT
@ ID_SCRIPT
Definition: dispatch.h:160
dataspeed_pds_can::MsgCurrent
Definition: dispatch.h:125
dataspeed_pds_can::ID_MODE
@ ID_MODE
Definition: dispatch.h:159
dataspeed_pds_can
Definition: dispatch.h:39
dataspeed_pds_can::ID_CURRENT2_MASTER
@ ID_CURRENT2_MASTER
Definition: dispatch.h:173
dataspeed_pds_can::ID_RESERVED1
@ ID_RESERVED1
Definition: dispatch.h:161
dataspeed_pds_can::REV_B
@ REV_B
Definition: dispatch.h:108
dataspeed_pds_can::ID_CURRENT1_SLAVE1
@ ID_CURRENT1_SLAVE1
Definition: dispatch.h:170
dataspeed_pds_can::dispatchAssertSizes
static void dispatchAssertSizes()
Definition: dispatch.h:147
dataspeed_pds_can::ID_STATUS2_MASTER
@ ID_STATUS2_MASTER
Definition: dispatch.h:181
dataspeed_pds_can::ID_RESERVED4
@ ID_RESERVED4
Definition: dispatch.h:164
dataspeed_pds_can::ID_RESERVED2
@ ID_RESERVED2
Definition: dispatch.h:162
dataspeed_pds_can::MsgScript
Definition: dispatch.h:142
BUILD_ASSERT
#define BUILD_ASSERT(cond)
Definition: dispatch.h:146
dataspeed_pds_can::REV_H
@ REV_H
Definition: dispatch.h:110
dataspeed_pds_can::ID_STATUS1_MASTER
@ ID_STATUS1_MASTER
Definition: dispatch.h:165
dataspeed_pds_can::REV_G
@ REV_G
Definition: dispatch.h:109
dataspeed_pds_can::ID_STATUS2_SLAVE3
@ ID_STATUS2_SLAVE3
Definition: dispatch.h:184
dataspeed_pds_can::ID_CURRENT3_SLAVE3
@ ID_CURRENT3_SLAVE3
Definition: dispatch.h:180
dataspeed_pds_can::MsgMode
Definition: dispatch.h:138
dataspeed_pds_can::ID_REQUEST
@ ID_REQUEST
Definition: dispatch.h:158
dataspeed_pds_can::MsgRelay
Definition: dispatch.h:133


dataspeed_pds_can
Author(s): Kevin Hallenbeck , Eric Myllyoja , Michael Lohrer
autogenerated on Wed Mar 2 2022 00:11:44