资源简介
DPS310气压高度计程序。
代码片段和文件信息
#include “Dps310.h“
using namespace dps;
using namespace dps310;
int16_t Dps310::getContResults(float *tempBuffer
uint8_t &tempCount
float *prsBuffer
uint8_t &prsCount)
{
return DpsClass::getContResults(tempBuffer tempCount prsBuffer prsCount registers[FIFO_EMPTY]);
}
#ifndef DPS_DISABLESPI
int16_t Dps310::setInterruptSources(uint8_t intr_source uint8_t polarity)
{
//Interrupts are not supported with 4 Wire SPI
if (!m_SpiI2c & !m_threeWire)
{
return DPS__FAIL_UNKNOWN;
}
return writeByteBitfield(intr_source registers[INT_SEL]) || writeByteBitfield(polarity registers[INT_HL]);
}
#endif
void Dps310::init(void)
{
int16_t prodId = readByteBitfield(registers[PROD_ID]);
if (prodId < 0)
{
//Connected device is not a Dps310
m_initFail = 1U;
return;
}
m_productID = prodId;
int16_t revId = readByteBitfield(registers[REV_ID]);
if (revId < 0)
{
m_initFail = 1U;
return;
}
m_revisionID = revId;
//find out which temperature sensor is calibrated with coefficients...
int16_t sensor = readByteBitfield(registers[TEMP_SENSORREC]);
if (sensor < 0)
{
m_initFail = 1U;
return;
}
//...and use this sensor for temperature measurement
m_tempSensor = sensor;
if (writeByteBitfield((uint8_t)sensor registers[TEMP_SENSOR]) < 0)
{
m_initFail = 1U;
return;
}
//read coefficients
if (readcoeffs() < 0)
{
m_initFail = 1U;
return;
}
//set to standby for further configuration
standby();
//set measurement precision and rate to standard values;
configTemp(DPS__MEASUREMENT_RATE_4 DPS__OVERSAMPLING_RATE_8);
configPressure(DPS__MEASUREMENT_RATE_4 DPS__OVERSAMPLING_RATE_8);
//perform a first temperature measurement
//the most recent temperature will be saved internally
//and used for compensation when calculating pressure
float trash;
measureTempOnce(trash);
//make sure the DPS310 is in standby after initialization
standby();
// Fix IC with a fuse bit problem which lead to a wrong temperature
// Should not affect ICs without this problem
correctTemp();
}
int16_t Dps310::readcoeffs(void)
{
// TODO: remove magic number
uint8_t buffer[18];
//read COEF registers to buffer
int16_t ret = readBlock(coeffBlock buffer);
//compose coefficients from buffer content
m_c0Half = ((uint32_t)buffer[0] << 4) | (((uint32_t)buffer[1] >> 4) & 0x0F);
getTwosComplement(&m_c0Half 12);
//c0 is only used as c0*0.5 so c0_half is calculated immediately
m_c0Half = m_c0Half / 2U;
//now do the same thing for all other coefficients
m_c1 = (((uint32_t)buffer[1] & 0x0F) << 8) | (uint32_t)buffer[2];
getTwosComplement(&m_c1 12);
m_c00 = ((uint32_t)buffer[3] << 12) | ((uint32_t)buffer[4] << 4) | (((uint32_t)buffer[5] >> 4) & 0x0F);
getTwosComplement(&m_c00 20);
m_c10 = (((uint32_t)buffer[5] & 0x0F) << 16) | ((uint32_t)buffer[6] << 8) | (uint32_t)buffer[7];
getTwosComplement(&m_c10 20);
m_c01 = ((uint32_t)buffer[8] << 8) | (uint32_t)buffer[9];
getTwosComplement(&m_c01 16);
m_c
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\
文件 1720 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\.travis.yml
文件 3196 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\LICENSE.md
文件 5780 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\README.md
目录 0 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\examples\
目录 0 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\examples\i2c_background\
文件 3271 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\examples\i2c_background\i2c_background.ino
目录 0 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\examples\i2c_command\
文件 2189 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\examples\i2c_command\i2c_command.ino
目录 0 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\examples\i2c_interrupt\
文件 3241 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\examples\i2c_interrupt\i2c_interrupt.ino
目录 0 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\examples\spi_background\
文件 3188 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\examples\spi_background\spi_background.ino
目录 0 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\examples\spi_command\
文件 1979 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\examples\spi_command\spi_command.ino
目录 0 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\examples\spi_interrupt\
文件 3804 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\examples\spi_interrupt\spi_interrupt.ino
文件 1082 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\keywords.txt
文件 405 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\library.json
文件 547 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\library.properties
目录 0 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\src\
文件 4936 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\src\Dps310.cpp
文件 966 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\src\Dps310.h
文件 5801 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\src\Dps422.cpp
文件 1545 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\src\Dps422.h
文件 18050 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\src\DpsClass.cpp
文件 16176 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\src\DpsClass.h
目录 0 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\src\util\
文件 259 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\src\util\DpsRegister.h
文件 1189 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\src\util\dps310_config.h
文件 2180 2018-11-02 05:03 DPS310-Pressure-Sensor-dps310\src\util\dps422_config.h
............此处省略1个文件信息
- 上一篇:三菱FX3U插补画圆程序
- 下一篇:CAD的A4图框及标题栏
评论
共有 条评论