SELKIELogger  1.0.0
LPMSTypes.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Swansea University
3  *
4  * This file is part of the SELKIELogger suite of tools.
5  *
6  * SELKIELogger is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the Free
8  * Software Foundation, either version 3 of the License, or (at your option)
9  * any later version.
10  *
11  * SELKIELogger is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this SELKIELogger product.
18  * If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef SELKIELoggerLPMS_Types
22 #define SELKIELoggerLPMS_Types
23 
30 #include <stdbool.h>
31 #include <stdint.h>
32 
33 #include "SELKIELoggerBase.h"
34 
36 
48 typedef struct {
49  uint16_t id;
50  uint16_t command;
51  uint16_t length;
52  uint16_t checksum;
53  uint8_t *data;
54 } lpms_message;
55 
56 // While it is unlikely that this wouldn't be true on any supported system, the
57 // entire library is based on this assumption holding.
58 _Static_assert(sizeof(float) == 4, "LPMS support requires 32bit floats");
59 
72 typedef struct {
73  uint32_t timestamp;
74  float accel_raw[3];
75  float accel_cal[3];
76  float gyro_raw[3];
77  float gyro_cal[3];
78  float gyro_aligned[3];
79  float mag_raw[3];
80  float mag_cal[3];
81  float omega[3];
82  float quaternion[4];
83  float euler_angles[3];
84  float accel_linear[3];
85  float pressure;
86  float altitude;
87  float temperature;
88  uint32_t present;
89 } lpms_data;
90 
100 #define LPMS_IMU_ACCEL_RAW 0
101 #define LPMS_IMU_ACCEL_CAL 1
102 #define LPMS_IMU_GYRO_RAW 3
103 #define LPMS_IMU_GYRO_CAL 5
104 #define LPMS_IMU_GYRO_ALIGN 7
105 #define LPMS_IMU_MAG_RAW 8
106 #define LPMS_IMU_MAG_CAL 9
107 #define LPMS_IMU_OMEGA 10
108 #define LPMS_IMU_QUATERNION 11
109 #define LPMS_IMU_EULER 12
110 #define LPMS_IMU_ACCEL_LINEAR 13
111 #define LPMS_IMU_PRESSURE 14
112 #define LPMS_IMU_ALTITUDE 15
113 #define LPMS_IMU_TEMPERATURE 16
114 
115 #define LPMS_HAS(x, y) (((x) & (1 << y)) == (1 << y))
117 
119 #endif
LPMS IMU data packet.
Definition: LPMSTypes.h:72
float altitude
Altitude [m].
Definition: LPMSTypes.h:86
float temperature
Temperature [Celsius].
Definition: LPMSTypes.h:87
uint32_t timestamp
Counted in 0.002s increments.
Definition: LPMSTypes.h:73
uint32_t present
Bitmask indicating set/valid members.
Definition: LPMSTypes.h:88
float pressure
Atmospheric pressure [kPa].
Definition: LPMSTypes.h:85
Represent LPMS message.
Definition: LPMSTypes.h:48
uint16_t length
Length of data, in bytes.
Definition: LPMSTypes.h:51
uint16_t checksum
Sum of all preceding message bytes.
Definition: LPMSTypes.h:52
uint8_t * data
Pointer to data array.
Definition: LPMSTypes.h:53
uint16_t id
Source/Destination Sensor ID.
Definition: LPMSTypes.h:49
uint16_t command
Message type.
Definition: LPMSTypes.h:50