Skyward boardcore
Loading...
Searching...
No Matches
LPS331AP.h
Go to the documentation of this file.
1
/* Copyright (c) 2023 Skyward Experimental Rocketry
2
* Author: Alberto Nidasio
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
25
#include <
diagnostic/PrintLogger.h
>
26
#include <
drivers/i2c/I2C.h
>
27
#include <
sensors/Sensor.h
>
28
29
#include "
LPS331APData.h
"
30
31
namespace
Boardcore
32
{
33
34
class
LPS331AP
:
public
Sensor
<LPS331APData>
35
{
36
public
:
37
enum class
ODR
: uint8_t
38
{
39
ODR_1HZ
= 0x01,
40
ODR_7Hz
= 0x05,
41
ODR_12_5Hz
= 0x06,
42
ODR_25Hz
= 0x07,
43
};
44
45
explicit
LPS331AP
(
I2C
& bus,
ODR
odr =
ODR::ODR_25Hz
);
46
47
bool
init
()
override
;
48
49
bool
selfTest
()
override
;
50
51
protected
:
52
LPS331APData
sampleImpl
()
override
;
53
54
private
:
55
bool
checkWhoAmI();
56
57
static
constexpr
uint8_t WHO_AM_I_VAL = 0x58;
58
59
enum
Registers
: uint8_t
60
{
61
REG_WHO_AM_I = 0x8f,
62
REG_RES_CONF = 0x10,
63
REG_CTRL_REG1 = 0x20,
64
REG_PRESS_XLSB = 0x28,
65
};
66
67
I2C& bus;
68
I2CDriver::I2CSlaveConfig slaveConfig{0x5c,
I2CDriver::Addressing::BIT7
,
69
I2CDriver::Speed::STANDARD
};
70
71
ODR
odr;
72
73
PrintLogger logger =
Logging::getLogger
(
"lps331ap"
);
74
};
75
76
}
// namespace Boardcore
I2C.h
LPS331APData.h
PrintLogger.h
Sensor.h
Boardcore::I2CDriver::BIT7
@ BIT7
Definition
I2CDriver.h:79
Boardcore::I2CDriver::STANDARD
@ STANDARD
Definition
I2CDriver.h:67
Boardcore::I2C
High level driver for the I2C peripherals.
Definition
I2C.h:40
Boardcore::LPS331AP
Definition
LPS331AP.h:35
Boardcore::LPS331AP::sampleImpl
LPS331APData sampleImpl() override
Read a data sample from the sensor. In case of errors, the method should return the last available co...
Definition
LPS331AP.cpp:62
Boardcore::LPS331AP::ODR
ODR
Definition
LPS331AP.h:38
Boardcore::LPS331AP::ODR::ODR_12_5Hz
@ ODR_12_5Hz
Boardcore::LPS331AP::ODR::ODR_25Hz
@ ODR_25Hz
Boardcore::LPS331AP::ODR::ODR_7Hz
@ ODR_7Hz
Boardcore::LPS331AP::ODR::ODR_1HZ
@ ODR_1HZ
Boardcore::LPS331AP::init
bool init() override
Initialize the sensor.
Definition
LPS331AP.cpp:33
Boardcore::LPS331AP::selfTest
bool selfTest() override
Check if the sensor is working.
Definition
LPS331AP.cpp:60
Boardcore::Logging::getLogger
static PrintLogger getLogger(const string &name)
Definition
PrintLogger.h:103
Boardcore::Sensor
Base sensor class with has to be extended by any sensor driver.
Definition
Sensor.h:91
Boardcore::SX1278::Fsk::Registers
Registers
Definition
SX1278Defs.h:443
Boardcore
Driver for the VN100S IMU.
Definition
ActiveObject.h:31
Boardcore::LPS331APData
Definition
LPS331APData.h:33
src
shared
sensors
LPS331AP
LPS331AP.h
Generated by
1.9.8