43 spiConfig.csSetupTimeUs = 50;
56 : slave(bus, cs, spiConfig), streamRx(streamRx), streamTx(streamTx),
57 timeoutDma(timeout), sensorSettings{odr, 0x7, iow, bwl, ntc}
64 : slave(bus, cs, spiConfig), streamRx(nullptr), streamTx(nullptr),
65 timeoutDma(
std::chrono::nanoseconds::zero()),
66 sensorSettings{odr, 0x7, iow, bwl, ntc}
76 memcpy(&spiDataOut, &sensorSettings,
sizeof(spiDataOut));
83 miosix::Thread::sleep(4);
92 ND015ADataExtended extendedData{};
93 uint8_t* data =
reinterpret_cast<uint8_t*
>(&extendedData);
96 memcpy(&extendedData, &sensorSettings,
sizeof(sensorSettings));
99 spi.
transfer(data,
sizeof(extendedData));
109 std::string(extendedData.model,
sizeof(extendedData.model));
111 std::replace(model.begin(), model.end(),
'\0',
'.');
114 "Sensor model mismatch: received {}, expected {} (. = \\0)",
123 sensorSettings.odr =
odr;
128 memcpy(&spiDataOut, &sensorSettings,
sizeof(spiDataOut));
134 sensorSettings.iow =
iow;
139 memcpy(&spiDataOut, &sensorSettings,
sizeof(spiDataOut));
145 sensorSettings.bwl =
bwl;
150 memcpy(&spiDataOut, &sensorSettings,
sizeof(spiDataOut));
156 sensorSettings.ntc =
ntc;
161 memcpy(&spiDataOut, &sensorSettings,
sizeof(spiDataOut));
174 memcpy(&spiDataOut, &sensorSettings,
sizeof(spiDataOut));
176 uint16_t spiDataIn = 0;
177 if (streamRx !=
nullptr && streamTx !=
nullptr)
181 spiDataIn = spi.
transfer16(spiDataOut, timeoutDma);
189 float normalizedPressure =
190 (
static_cast<float>(spiDataIn) - 0.05f * powf(2, 16)) /
191 (0.9f * powf(2, 16));
#define LOG_ERR(logger,...)
Simple RAII class to handle DMA streams.
bool init() override
Initializes the sensor.
void setBWLimitFilter(BWLimitFilter bwl)
Sets the bandwidth limit filter for the sensor.
void updateOffset(float offset)
Modify the offset of this sensor. The offset is stored as a int16_t and can be both postive or negati...
bool checkModelMatch()
Checks if the sensor model matches the expected model.
void setNotch(NotchEnable ntc)
Enables or disables the notch filter.
void setOffset(float offset)
Set the offset of this sensor. The offset is stored as a int16_t and can be both postive or negative.
bool selfTest() override
Not implemented.
static const char MODEL_NAME[]
static const int FULLSCALE
static SPIBusConfig getDefaultSPIConfig()
Constructs the default config for the SPI bus.
ND015XData sampleImpl() override
Read a data sample from the sensor. In case of errors, the method should return the last available co...
float getOffset()
Get the current offset of this sensor. The offset is stored as a int16_t and can be both postive or n...
void setIOWatchdog(IOWatchdogEnable iow)
function to enable the IO watchdog
ND015A(SPIBusInterface &bus, miosix::GpioPin cs, SPIBusConfig spiConfig, DMAStreamGuard *streamRx, DMAStreamGuard *streamTx, std::chrono::nanoseconds timeoutDma, IOWatchdogEnable iow=IOWatchdogEnable::DISABLED, BWLimitFilter bwl=BWLimitFilter::BWL_200, NotchEnable ntc=NotchEnable::ENABLED, uint8_t odr=0x1C)
Constructor for the ND015A sensor.
void setOutputDataRate(uint8_t odr)
function to set the output data rate
Interface for low level access of a SPI bus as a master.
Provides high-level access to the SPI Bus for a single spi transaction with dma.
uint16_t transfer16(uint16_t data, std::chrono::nanoseconds timeout=std::chrono::nanoseconds::zero())
Full duplex transmission of 16 bits on the bus.
Provides high-level access to the SPI Bus for a single transaction.
uint16_t transfer16(uint16_t data)
Full duplex transmission of one half word on the bus.
uint8_t transfer(uint8_t data)
Full duplex transmission of one byte on the bus.
@ MODE_1
CPOL = 1, CPHA = 0 -> Clock high when idle, sample on first edge.
uint64_t getTimestamp()
Returns the current timer value in microseconds.
Driver for the VN100S IMU.
uint64_t pressureTimestamp
SPI Bus configuration for a specific slave.
SPI::Mode mode
MSBit or LSBit first.