42 spiConfig.csSetupTimeUs = 50;
54 : slave(bus, cs, spiConfig), sensorSettings{0x7, iow, bwl, ntc, odr}
64 memcpy(&spiDataOut, &sensorSettings,
sizeof(spiDataOut));
74 ND015ADataExtended extendedData{};
75 uint8_t* data =
reinterpret_cast<uint8_t*
>(&extendedData);
78 memcpy(&extendedData, &sensorSettings,
sizeof(sensorSettings));
81 spi.
transfer(data,
sizeof(extendedData));
91 std::string(extendedData.model,
sizeof(extendedData.model));
93 std::replace(model.begin(), model.end(),
'\0',
'.');
96 "Sensor model mismatch: received {}, expected {} (. = \\0)",
105 sensorSettings.odr =
odr;
110 memcpy(&spiDataOut, &sensorSettings,
sizeof(spiDataOut));
116 sensorSettings.iow =
iow;
121 memcpy(&spiDataOut, &sensorSettings,
sizeof(spiDataOut));
127 sensorSettings.bwl =
bwl;
132 memcpy(&spiDataOut, &sensorSettings,
sizeof(spiDataOut));
138 sensorSettings.ntc =
ntc;
143 memcpy(&spiDataOut, &sensorSettings,
sizeof(spiDataOut));
153 memcpy(&spiDataOut, &sensorSettings,
sizeof(spiDataOut));
154 uint16_t spiDataIn = spi.
transfer16(spiDataOut);
157 ((spiDataIn - 0.05 * pow(2, 16)) / (0.9 * pow(2, 16)) * 15) *
158 Constants::PSI_TO_PASCAL;
#define LOG_ERR(logger,...)
bool init() override
Initializes the sensor.
void setBWLimitFilter(BWLimitFilter bwl)
Sets the bandwidth limit filter for the sensor.
bool checkModelMatch()
Checks if the sensor model matches the expected model.
void setNotch(NotchEnable ntc)
Enables or disables the notch filter.
bool selfTest() override
Not implemented.
static const char MODEL_NAME[]
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...
void setIOWatchdog(IOWatchdogEnable iow)
function to enable the IO watchdog
void setOutputDataRate(uint8_t odr)
function to set the output data rate
ND015A(SPIBusInterface &bus, miosix::GpioPin cs, SPIBusConfig spiConfig, IOWatchdogEnable iow=IOWatchdogEnable::DISABLED, BWLimitFilter bwl=BWLimitFilter::BWL_200, NotchEnable ntc=NotchEnable::ENABLED, uint8_t odr=0x1C)
Constructor for the ND015A sensor.
Interface for low level access of a SPI bus as a master.
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.
This file includes all the types the logdecoder script will decode.
uint64_t pressureTimestamp
SPI Bus configuration for a specific slave.
SPI::Mode mode
MSBit or LSBit first.