Skyward boardcore
Loading...
Searching...
No Matches
VN100Serial.h
Go to the documentation of this file.
1/* Copyright (c) 2021 Skyward Experimental Rocketry
2 * Author: Matteo Pignataro, Fabrizio Monti
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22
23#pragma once
24
40#include <sensors/Sensor.h>
42
43#include "VN100SerialData.h"
44
45namespace Boardcore
46{
47
51class VN100Serial : public Sensor<VN100SerialData>, public VNCommonSerial
52{
53public:
64 VN100Serial(USART& usart, int baudrate, CRCOptions crc,
65 std::chrono::milliseconds timeout);
66
67 bool init() override;
68
69 bool selfTest() override;
70
71protected:
75 VN100SerialData sampleImpl() override;
76
77private:
81 struct __attribute__((packed)) BinaryData
82 {
83 uint8_t group;
84 uint16_t group1;
85 float quaternionX;
86 float quaternionY;
87 float quaternionZ;
88 float quaternionW;
89 float angularX;
90 float angularY;
91 float angularZ;
92 float accelerationX;
93 float accelerationY;
94 float accelerationZ;
95 float magneticFieldX;
96 float magneticFieldY;
97 float magneticFieldZ;
98 float temperature;
99 float pressure;
100 uint16_t crc;
101 };
102
111 void buildBinaryData(const BinaryData& binData, VN100SerialData& data,
112 const uint64_t sampleTimestamp);
113
119 bool setBinaryOutput();
120
124 const char* askSampleCommand = "";
125};
126} // namespace Boardcore
void __attribute__((naked)) CAN1_RX0_IRQHandler()
Base sensor class with has to be extended by any sensor driver.
Definition Sensor.h:91
Driver for STM32F4 low level USART/UART peripheral.
Definition USART.h:170
Driver class for VN100 IMU.
Definition VN100Serial.h:52
bool init() override
Initialize the sensor.
bool selfTest() override
Check if the sensor is working.
VN100Serial(USART &usart, int baudrate, CRCOptions crc, std::chrono::milliseconds timeout)
Constructor.
VN100SerialData sampleImpl() override
Sample action implementation.
USART & usart
Serial interface that is needed to communicate with the sensor via ASCII codes.
This file includes all the types the logdecoder script will decode.