42 spiConfig.csSetupTimeUs = 50;
54 : slave(bus, cs, spiConfig), range(rangeToPressure(fsr)),
55 sensorSettings{fsr, iow, bwl, ntc, odr}
65 memcpy(&spiDataOut, &sensorSettings,
sizeof(spiDataOut));
75 ND015DDataExtended extendedData{};
76 uint8_t* data =
reinterpret_cast<uint8_t*
>(&extendedData);
79 memcpy(&extendedData, &sensorSettings,
sizeof(sensorSettings));
82 spi.
transfer(data,
sizeof(extendedData));
92 std::string(extendedData.model,
sizeof(extendedData.model));
94 std::replace(model.begin(), model.end(),
'\0',
'.');
97 "Sensor model mismatch: received {}, expected {} (. = \\0)",
106 sensorSettings.odr =
odr;
111 memcpy(&spiDataOut, &sensorSettings,
sizeof(spiDataOut));
117 sensorSettings.fsr =
fsr;
124 memcpy(&spiDataOut, &sensorSettings,
sizeof(spiDataOut));
151 sensorSettings.iow =
iow;
156 memcpy(&spiDataOut, &sensorSettings,
sizeof(spiDataOut));
162 sensorSettings.bwl =
bwl;
167 memcpy(&spiDataOut, &sensorSettings,
sizeof(spiDataOut));
173 sensorSettings.ntc =
ntc;
178 memcpy(&spiDataOut, &sensorSettings,
sizeof(spiDataOut));
188 memcpy(&spiDataOut, &sensorSettings,
sizeof(spiDataOut));
189 uint16_t spiDataIn = spi.
transfer16(spiDataOut);
192 (
static_cast<int16_t
>(spiDataIn) / (0.9 * pow(2, 15)) * range) *
193 Constants::PSI_TO_PASCAL;
#define LOG_ERR(logger,...)
void setIOWatchdog(IOWatchdogEnable iow)
Enables or disables the IO watchdog.
void setFullScaleRange(FullScaleRange fsr)
Sets the full-scale range for the sensor.
bool init() override
Initializes the sensor.
void setBWLimitFilter(BWLimitFilter bwl)
Sets the bandwidth limit filter for the sensor.
void setNotch(NotchEnable ntc)
Enables or disables the notch filter.
static SPIBusConfig getDefaultSPIConfig()
Constructs the default config for the SPI bus.
static float rangeToPressure(FullScaleRange fsr)
Converts the FullScale value to its corresponding range.
static const char MODEL_NAME[]
bool checkModelMatch()
Checks if the sensor model matches the expected model.
void setOutputDataRate(uint8_t odr)
function to set the output data rate
ND015XData sampleImpl() override
Read a data sample from the sensor. In case of errors, the method should return the last available co...
ND015D(SPIBusInterface &bus, miosix::GpioPin cs, SPIBusConfig spiConfig, FullScaleRange fsr=FullScaleRange::FS_2, IOWatchdogEnable iow=IOWatchdogEnable::DISABLED, BWLimitFilter bwl=BWLimitFilter::BWL_200, NotchEnable ntc=NotchEnable::ENABLED, uint8_t odr=0x1C)
Constructor for the ND015D sensor.
bool selfTest() override
Not implemented.
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.