[GYRO] Refactor gyro driver for dual-gyro support
[inav.git] / lib / main / MAVLink / common / mavlink_msg_scaled_pressure2.h
blob1e7920b040d99ad54bdfdea8e74673ed12e9d93a
1 #pragma once
2 // MESSAGE SCALED_PRESSURE2 PACKING
4 #define MAVLINK_MSG_ID_SCALED_PRESSURE2 137
6 MAVPACKED(
7 typedef struct __mavlink_scaled_pressure2_t {
8 uint32_t time_boot_ms; /*< Timestamp (milliseconds since system boot)*/
9 float press_abs; /*< Absolute pressure (hectopascal)*/
10 float press_diff; /*< Differential pressure 1 (hectopascal)*/
11 int16_t temperature; /*< Temperature measurement (0.01 degrees celsius)*/
12 }) mavlink_scaled_pressure2_t;
14 #define MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN 14
15 #define MAVLINK_MSG_ID_SCALED_PRESSURE2_MIN_LEN 14
16 #define MAVLINK_MSG_ID_137_LEN 14
17 #define MAVLINK_MSG_ID_137_MIN_LEN 14
19 #define MAVLINK_MSG_ID_SCALED_PRESSURE2_CRC 195
20 #define MAVLINK_MSG_ID_137_CRC 195
24 #if MAVLINK_COMMAND_24BIT
25 #define MAVLINK_MESSAGE_INFO_SCALED_PRESSURE2 { \
26 137, \
27 "SCALED_PRESSURE2", \
28 4, \
29 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_scaled_pressure2_t, time_boot_ms) }, \
30 { "press_abs", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_scaled_pressure2_t, press_abs) }, \
31 { "press_diff", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_scaled_pressure2_t, press_diff) }, \
32 { "temperature", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_scaled_pressure2_t, temperature) }, \
33 } \
35 #else
36 #define MAVLINK_MESSAGE_INFO_SCALED_PRESSURE2 { \
37 "SCALED_PRESSURE2", \
38 4, \
39 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_scaled_pressure2_t, time_boot_ms) }, \
40 { "press_abs", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_scaled_pressure2_t, press_abs) }, \
41 { "press_diff", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_scaled_pressure2_t, press_diff) }, \
42 { "temperature", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_scaled_pressure2_t, temperature) }, \
43 } \
45 #endif
47 /**
48 * @brief Pack a scaled_pressure2 message
49 * @param system_id ID of this system
50 * @param component_id ID of this component (e.g. 200 for IMU)
51 * @param msg The MAVLink message to compress the data into
53 * @param time_boot_ms Timestamp (milliseconds since system boot)
54 * @param press_abs Absolute pressure (hectopascal)
55 * @param press_diff Differential pressure 1 (hectopascal)
56 * @param temperature Temperature measurement (0.01 degrees celsius)
57 * @return length of the message in bytes (excluding serial stream start sign)
59 static inline uint16_t mavlink_msg_scaled_pressure2_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
60 uint32_t time_boot_ms, float press_abs, float press_diff, int16_t temperature)
62 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
63 char buf[MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN];
64 _mav_put_uint32_t(buf, 0, time_boot_ms);
65 _mav_put_float(buf, 4, press_abs);
66 _mav_put_float(buf, 8, press_diff);
67 _mav_put_int16_t(buf, 12, temperature);
69 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN);
70 #else
71 mavlink_scaled_pressure2_t packet;
72 packet.time_boot_ms = time_boot_ms;
73 packet.press_abs = press_abs;
74 packet.press_diff = press_diff;
75 packet.temperature = temperature;
77 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN);
78 #endif
80 msg->msgid = MAVLINK_MSG_ID_SCALED_PRESSURE2;
81 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SCALED_PRESSURE2_MIN_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE2_CRC);
84 /**
85 * @brief Pack a scaled_pressure2 message on a channel
86 * @param system_id ID of this system
87 * @param component_id ID of this component (e.g. 200 for IMU)
88 * @param chan The MAVLink channel this message will be sent over
89 * @param msg The MAVLink message to compress the data into
90 * @param time_boot_ms Timestamp (milliseconds since system boot)
91 * @param press_abs Absolute pressure (hectopascal)
92 * @param press_diff Differential pressure 1 (hectopascal)
93 * @param temperature Temperature measurement (0.01 degrees celsius)
94 * @return length of the message in bytes (excluding serial stream start sign)
96 static inline uint16_t mavlink_msg_scaled_pressure2_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
97 mavlink_message_t* msg,
98 uint32_t time_boot_ms,float press_abs,float press_diff,int16_t temperature)
100 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
101 char buf[MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN];
102 _mav_put_uint32_t(buf, 0, time_boot_ms);
103 _mav_put_float(buf, 4, press_abs);
104 _mav_put_float(buf, 8, press_diff);
105 _mav_put_int16_t(buf, 12, temperature);
107 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN);
108 #else
109 mavlink_scaled_pressure2_t packet;
110 packet.time_boot_ms = time_boot_ms;
111 packet.press_abs = press_abs;
112 packet.press_diff = press_diff;
113 packet.temperature = temperature;
115 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN);
116 #endif
118 msg->msgid = MAVLINK_MSG_ID_SCALED_PRESSURE2;
119 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SCALED_PRESSURE2_MIN_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE2_CRC);
123 * @brief Encode a scaled_pressure2 struct
125 * @param system_id ID of this system
126 * @param component_id ID of this component (e.g. 200 for IMU)
127 * @param msg The MAVLink message to compress the data into
128 * @param scaled_pressure2 C-struct to read the message contents from
130 static inline uint16_t mavlink_msg_scaled_pressure2_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_scaled_pressure2_t* scaled_pressure2)
132 return mavlink_msg_scaled_pressure2_pack(system_id, component_id, msg, scaled_pressure2->time_boot_ms, scaled_pressure2->press_abs, scaled_pressure2->press_diff, scaled_pressure2->temperature);
136 * @brief Encode a scaled_pressure2 struct on a channel
138 * @param system_id ID of this system
139 * @param component_id ID of this component (e.g. 200 for IMU)
140 * @param chan The MAVLink channel this message will be sent over
141 * @param msg The MAVLink message to compress the data into
142 * @param scaled_pressure2 C-struct to read the message contents from
144 static inline uint16_t mavlink_msg_scaled_pressure2_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_scaled_pressure2_t* scaled_pressure2)
146 return mavlink_msg_scaled_pressure2_pack_chan(system_id, component_id, chan, msg, scaled_pressure2->time_boot_ms, scaled_pressure2->press_abs, scaled_pressure2->press_diff, scaled_pressure2->temperature);
150 * @brief Send a scaled_pressure2 message
151 * @param chan MAVLink channel to send the message
153 * @param time_boot_ms Timestamp (milliseconds since system boot)
154 * @param press_abs Absolute pressure (hectopascal)
155 * @param press_diff Differential pressure 1 (hectopascal)
156 * @param temperature Temperature measurement (0.01 degrees celsius)
158 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
160 static inline void mavlink_msg_scaled_pressure2_send(mavlink_channel_t chan, uint32_t time_boot_ms, float press_abs, float press_diff, int16_t temperature)
162 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
163 char buf[MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN];
164 _mav_put_uint32_t(buf, 0, time_boot_ms);
165 _mav_put_float(buf, 4, press_abs);
166 _mav_put_float(buf, 8, press_diff);
167 _mav_put_int16_t(buf, 12, temperature);
169 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SCALED_PRESSURE2, buf, MAVLINK_MSG_ID_SCALED_PRESSURE2_MIN_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE2_CRC);
170 #else
171 mavlink_scaled_pressure2_t packet;
172 packet.time_boot_ms = time_boot_ms;
173 packet.press_abs = press_abs;
174 packet.press_diff = press_diff;
175 packet.temperature = temperature;
177 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SCALED_PRESSURE2, (const char *)&packet, MAVLINK_MSG_ID_SCALED_PRESSURE2_MIN_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE2_CRC);
178 #endif
182 * @brief Send a scaled_pressure2 message
183 * @param chan MAVLink channel to send the message
184 * @param struct The MAVLink struct to serialize
186 static inline void mavlink_msg_scaled_pressure2_send_struct(mavlink_channel_t chan, const mavlink_scaled_pressure2_t* scaled_pressure2)
188 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
189 mavlink_msg_scaled_pressure2_send(chan, scaled_pressure2->time_boot_ms, scaled_pressure2->press_abs, scaled_pressure2->press_diff, scaled_pressure2->temperature);
190 #else
191 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SCALED_PRESSURE2, (const char *)scaled_pressure2, MAVLINK_MSG_ID_SCALED_PRESSURE2_MIN_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE2_CRC);
192 #endif
195 #if MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN <= MAVLINK_MAX_PAYLOAD_LEN
197 This varient of _send() can be used to save stack space by re-using
198 memory from the receive buffer. The caller provides a
199 mavlink_message_t which is the size of a full mavlink message. This
200 is usually the receive buffer for the channel, and allows a reply to an
201 incoming message with minimum stack space usage.
203 static inline void mavlink_msg_scaled_pressure2_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, float press_abs, float press_diff, int16_t temperature)
205 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
206 char *buf = (char *)msgbuf;
207 _mav_put_uint32_t(buf, 0, time_boot_ms);
208 _mav_put_float(buf, 4, press_abs);
209 _mav_put_float(buf, 8, press_diff);
210 _mav_put_int16_t(buf, 12, temperature);
212 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SCALED_PRESSURE2, buf, MAVLINK_MSG_ID_SCALED_PRESSURE2_MIN_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE2_CRC);
213 #else
214 mavlink_scaled_pressure2_t *packet = (mavlink_scaled_pressure2_t *)msgbuf;
215 packet->time_boot_ms = time_boot_ms;
216 packet->press_abs = press_abs;
217 packet->press_diff = press_diff;
218 packet->temperature = temperature;
220 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SCALED_PRESSURE2, (const char *)packet, MAVLINK_MSG_ID_SCALED_PRESSURE2_MIN_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE2_CRC);
221 #endif
223 #endif
225 #endif
227 // MESSAGE SCALED_PRESSURE2 UNPACKING
231 * @brief Get field time_boot_ms from scaled_pressure2 message
233 * @return Timestamp (milliseconds since system boot)
235 static inline uint32_t mavlink_msg_scaled_pressure2_get_time_boot_ms(const mavlink_message_t* msg)
237 return _MAV_RETURN_uint32_t(msg, 0);
241 * @brief Get field press_abs from scaled_pressure2 message
243 * @return Absolute pressure (hectopascal)
245 static inline float mavlink_msg_scaled_pressure2_get_press_abs(const mavlink_message_t* msg)
247 return _MAV_RETURN_float(msg, 4);
251 * @brief Get field press_diff from scaled_pressure2 message
253 * @return Differential pressure 1 (hectopascal)
255 static inline float mavlink_msg_scaled_pressure2_get_press_diff(const mavlink_message_t* msg)
257 return _MAV_RETURN_float(msg, 8);
261 * @brief Get field temperature from scaled_pressure2 message
263 * @return Temperature measurement (0.01 degrees celsius)
265 static inline int16_t mavlink_msg_scaled_pressure2_get_temperature(const mavlink_message_t* msg)
267 return _MAV_RETURN_int16_t(msg, 12);
271 * @brief Decode a scaled_pressure2 message into a struct
273 * @param msg The message to decode
274 * @param scaled_pressure2 C-struct to decode the message contents into
276 static inline void mavlink_msg_scaled_pressure2_decode(const mavlink_message_t* msg, mavlink_scaled_pressure2_t* scaled_pressure2)
278 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
279 scaled_pressure2->time_boot_ms = mavlink_msg_scaled_pressure2_get_time_boot_ms(msg);
280 scaled_pressure2->press_abs = mavlink_msg_scaled_pressure2_get_press_abs(msg);
281 scaled_pressure2->press_diff = mavlink_msg_scaled_pressure2_get_press_diff(msg);
282 scaled_pressure2->temperature = mavlink_msg_scaled_pressure2_get_temperature(msg);
283 #else
284 uint8_t len = msg->len < MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN? msg->len : MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN;
285 memset(scaled_pressure2, 0, MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN);
286 memcpy(scaled_pressure2, _MAV_PAYLOAD(msg), len);
287 #endif