本文整理汇总了C++中MLSLSerialWriteSingle函数的典型用法代码示例。如果您正苦于以下问题:C++ MLSLSerialWriteSingle函数的具体用法?C++ MLSLSerialWriteSingle怎么用?C++ MLSLSerialWriteSingle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MLSLSerialWriteSingle函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lis331dlh_set_fsr
/**
* Set the full scale range of the accels
*
* @param config pointer to configuration
* @param fsr requested full scale range
*/
static int lis331dlh_set_fsr(void *mlsl_handle,
struct ext_slave_platform_data *pdata,
struct lis331dlh_config *config,
int apply,
long fsr)
{
unsigned char reg1 = 0x40;
int result = ML_SUCCESS;
if (fsr <= 2048) {
config->fsr = 2048;
} else if (fsr <= 4096) {
reg1 |= 0x30;
config->fsr = 4096;
} else {
reg1 |= 0x10;
config->fsr = 8192;
}
lis331dlh_set_ths(mlsl_handle, pdata,
config, apply, config->ths);
MPL_LOGV("FSR: %d\n", config->fsr);
if (apply)
result = MLSLSerialWriteSingle(mlsl_handle, pdata->address,
LIS331_CTRL_REG4, reg1);
return result;
}
示例2: bma250_set_fsr
/**
* @brief Set the full scale range of the accels
*
* @param mlsl_handle
* the handle to the serial channel the device is connected to.
* @param pdata
* a pointer to the slave platform data.
* @param config
* pointer to configuration.
* @param apply
* whether to apply immediately or save the settings to be applied
* at the next resume.
* @param fsr
* requested full scale range.
*
* @return ML_SUCCESS if successful or a non-zero error code.
*/
static int bma250_set_fsr(void *mlsl_handle,
struct ext_slave_platform_data *pdata,
struct bma250_config *config,
int apply,
long fsr)
{
int result = ML_SUCCESS;
unsigned char reg_fsr_mask;
if (fsr <= 2000) {
reg_fsr_mask = 0x03;
config->fsr = 2000;
} else if (fsr <= 4000) {
reg_fsr_mask = 0x05;
config->fsr = 4000;
} else if (fsr <= 8000) {
reg_fsr_mask = 0x08;
config->fsr = 8000;
} else { /* 8001 -> oo */
reg_fsr_mask = 0x0C;
config->fsr = 16000;
}
if (apply) {
MPL_LOGV("FSR: %d\n", config->fsr);
result = MLSLSerialWriteSingle(mlsl_handle, pdata->address,
BMA250_FSR_REG, reg_fsr_mask);
ERROR_CHECK(result);
}
return result;
}
示例3: ami30x_read
int ami30x_read(void *mlsl_handle,
struct ext_slave_descr *slave,
struct ext_slave_platform_data *pdata, unsigned char *data)
{
unsigned char stat;
int result = ML_SUCCESS;
/* Read status reg and check if data ready (DRDY) */
result =
MLSLSerialRead(mlsl_handle, pdata->address, AMI30X_REG_STAT1,
1, &stat);
ERROR_CHECK(result);
if (stat & 0x40) {
result =
MLSLSerialRead(mlsl_handle, pdata->address,
AMI30X_REG_DATAX, 6,
(unsigned char *) data);
ERROR_CHECK(result);
/* start another measurement */
result =
MLSLSerialWriteSingle(mlsl_handle, pdata->address,
AMI30X_REG_CNTL3,
AMI30X_BIT_CNTL3_F0RCE);
ERROR_CHECK(result);
return ML_SUCCESS;
}
return ML_ERROR_COMPASS_DATA_NOT_READY;
}
示例4: hscdtd004a_read
int hscdtd004a_read(void *mlsl_handle,
struct ext_slave_descr *slave,
struct ext_slave_platform_data *pdata,
unsigned char *data)
{
unsigned char stat;
tMLError result = ML_SUCCESS;
int status = ML_SUCCESS;
/* Read status reg. to check if data is ready */
result =
MLSLSerialRead(mlsl_handle, pdata->address,
COMPASS_HSCDTD004A_STAT, 1, &stat);
ERROR_CHECK(result);
if (stat & 0x48) {
result =
MLSLSerialRead(mlsl_handle, pdata->address,
COMPASS_HSCDTD004A_DATAX, 6,
(unsigned char *) data);
ERROR_CHECK(result);
status = ML_SUCCESS;
} else if (stat & 0x68) {
status = ML_ERROR_COMPASS_DATA_OVERFLOW;
} else {
status = ML_ERROR_COMPASS_DATA_NOT_READY;
}
/* trigger next measurement read */
result =
MLSLSerialWriteSingle(mlsl_handle, pdata->address,
COMPASS_HSCDTD004A_CTRL3, 0x40);
ERROR_CHECK(result);
return status;
}
示例5: ak8975_read
int ak8975_read(void *mlsl_handle,
struct ext_slave_descr *slave,
struct ext_slave_platform_data *pdata, unsigned char *data)
{
unsigned char regs[6];
int result = ML_SUCCESS;
int status = ML_SUCCESS;
mpu_dbg("%s\n", __func__);
result = MLSLSerialRead(mlsl_handle, pdata->address,
AK8975_REG_HXL, 6, regs);
ERROR_CHECK(result);
memcpy(data, ®s[0], 6);
status = ML_SUCCESS;
/*
* trigger next measurement if:
* - stat is non zero;
* - if stat is zero and stat2 is non zero.
* Won't trigger if data is not ready and there was no error.
*/
result = MLSLSerialWriteSingle(mlsl_handle, pdata->address,
AK8975_REG_CNTL,
AK8975_CNTL_MODE_SINGLE_MEASUREMENT);
ERROR_CHECK(result);
return status;
}
示例6: bma250_suspend
static int bma250_suspend(void *mlsl_handle,
struct ext_slave_descr *slave,
struct ext_slave_platform_data *pdata)
{
int result = 0;
unsigned char ctrl_reg;
unsigned char int_reg;
struct bma250_private_data *private_data = pdata->private_data;
ctrl_reg = private_data->suspend.ctrl_reg;
int_reg = private_data->suspend.int_reg;
private_data->state = 1;
if (!private_data->suspend.power_mode) {
result = MLSLSerialWriteSingle(mlsl_handle, pdata->address,
BOSCH_PWR_REG, 0x80);
ERROR_CHECK(result);
}
return result;
}
示例7: bma250_resume
static int bma250_resume(void *mlsl_handle,
struct ext_slave_descr *slave,
struct ext_slave_platform_data *pdata)
{
int result;
unsigned char ctrl_reg;
unsigned char bw_reg;
unsigned char int_reg;
struct bma250_private_data *private_data = pdata->private_data;
ctrl_reg = private_data->resume.ctrl_reg;
bw_reg = private_data->resume.bw_reg;
int_reg = private_data->resume.int_reg;
private_data->state = 0;
result = MLSLSerialWriteSingle(mlsl_handle, pdata->address,
BMA250_REG_SOFT_RESET, 0xB6); /* BMA250: Software reset */
ERROR_CHECK(result);
MLOSSleep(1);
result = MLSLSerialWriteSingle(mlsl_handle, pdata->address,
BOSCH_CTRL_REG, ctrl_reg);
ERROR_CHECK(result);
result = MLSLSerialWriteSingle(mlsl_handle, pdata->address,
BMA250_BW_REG, bw_reg);
ERROR_CHECK(result);
/* TODO Use irq when necessary */
/*result = MLSLSerialWriteSingle(mlsl_handle, pdata->address,
BOSCH_INT_REG, int_reg);
ERROR_CHECK(result);*/
if (!private_data->resume.power_mode) {
result = MLSLSerialWriteSingle(mlsl_handle, pdata->address,
BOSCH_PWR_REG, 0x80);
ERROR_CHECK(result);
} else {
result = set_normal_mode(mlsl_handle, pdata);
ERROR_CHECK(result);
}
return result;
}
示例8: bma250_suspend
static int bma250_suspend(void *mlsl_handle,
struct ext_slave_descr *slave,
struct ext_slave_platform_data *pdata)
{
int result;
result = MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x14, 0xb6); /* BMA250 : Software reset */
return result;
}
示例9: dmp_start
/**
* @brief Starts the DMP running
*
* @return ML_SUCCESS or non-zero error code
*/
static int dmp_start(struct mldl_cfg *pdata, void *mlsl_handle)
{
unsigned char userCtrlReg;
int result;
if (pdata->dmp_is_running == pdata->dmp_enable)
return ML_SUCCESS;
result = MLSLSerialRead(mlsl_handle, pdata->addr,
MPUREG_USER_CTRL, 1, &userCtrlReg);
ERROR_CHECK(result);
result = MLSLSerialWriteSingle(mlsl_handle, pdata->addr,
MPUREG_USER_CTRL,
((userCtrlReg & (~BIT_FIFO_EN))
| BIT_FIFO_RST));
ERROR_CHECK(result);
result = MLSLSerialWriteSingle(mlsl_handle, pdata->addr,
MPUREG_USER_CTRL, userCtrlReg);
ERROR_CHECK(result);
result = MLSLSerialRead(mlsl_handle, pdata->addr,
MPUREG_USER_CTRL, 1, &userCtrlReg);
ERROR_CHECK(result);
if (pdata->dmp_enable)
userCtrlReg |= BIT_DMP_EN;
else
userCtrlReg &= ~BIT_DMP_EN;
if (pdata->fifo_enable)
userCtrlReg |= BIT_FIFO_EN;
else
userCtrlReg &= ~BIT_FIFO_EN;
userCtrlReg |= BIT_DMP_RST;
result = MLSLSerialWriteSingle(mlsl_handle, pdata->addr,
MPUREG_USER_CTRL, userCtrlReg);
ERROR_CHECK(result);
pdata->dmp_is_running = pdata->dmp_enable;
return result;
}
示例10: lsm303dlha_resume
int lsm303dlha_resume(void *mlsl_handle,
struct ext_slave_descr *slave,
struct ext_slave_platform_data *pdata)
{
int result = ML_SUCCESS;
unsigned char reg;
result =
MLSLSerialRead(mlsl_handle, pdata->address, ACCEL_ST_SLEEP_REG,
1, ®);
ERROR_CHECK(result);
reg |= 0x27;
/*wake up if sleeping */
result =
MLSLSerialWriteSingle(mlsl_handle, pdata->address,
ACCEL_ST_SLEEP_REG, reg);
ERROR_CHECK(result);
result =
MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x20, 0x37);
ERROR_CHECK(result);
MLOSSleep(500);
reg = 0x40;
/* Full Scale */
reg &= ~ACCEL_ST_CTRL_MASK;
if (slave->range.mantissa == 2
&& slave->range.fraction == 480) {
reg |= 0x00;
} else if (slave->range.mantissa == 4
&& slave->range.fraction == 960) {
reg |= 0x10;
} else if (slave->range.mantissa == 8
&& slave->range.fraction == 1920) {
reg |= 0x30;
}
result =
MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x23, reg);
ERROR_CHECK(result);
/* Configure high pass filter */
result =
MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x21, 0x0F);
ERROR_CHECK(result);
result =
MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x32, 0x00);
ERROR_CHECK(result);
/* Configure INT1_DURATION */
result =
MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x33, 0x7F);
ERROR_CHECK(result);
/* Configure INT1_CFG */
result =
MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x30, 0x95);
ERROR_CHECK(result);
MLOSSleep(50);
return result;
}
示例11: cma3000_suspend
int cma3000_suspend(void *mlsl_handle,
struct ext_slave_descr *slave,
struct ext_slave_platform_data *pdata)
{
int result;
/* RAM reset */
result =
MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x1d, 0xcd);
return result;
}
示例12: bma250_resume
static int bma250_resume(void * mlsl_handle,
struct ext_slave_descr *slave,
struct ext_slave_platform_data *pdata)
{
int result;
unsigned char reg = 0;
/* Soft reset */
result = MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x14, 0xb6 ); /* BMA250 : Software reset */
ERROR_CHECK(result);
MLOSSleep(10);
result = MLSLSerialRead(mlsl_handle, pdata->address, ACCEL_BMA250_CTRL_REG, 1, ®);
ERROR_CHECK(result);
/* BMA250 : Full Scale */
reg &= ~ACCEL_BMA250_CTRL_MASK;
reg |= 0x00;
if (slave->range.mantissa==2) {
reg |= 0x03;
} else if (slave->range.mantissa==4) {
reg |= 0x05;
} else if (slave->range.mantissa==8) {
reg |= 0x08;
}
result = MLSLSerialWriteSingle(mlsl_handle, pdata->address, ACCEL_BMA250_CTRL_REG, reg );
ERROR_CHECK(result);
result = MLSLSerialRead(mlsl_handle, pdata->address, ACCEL_BMA250_BW_REG, 1, ®);
ERROR_CHECK(result);
reg &= ~ACCEL_BMA250_BW_MASK;
reg |= 0x00;
/* BMA250: Bandwidth */
reg |= 0x0d; // bw=250
result = MLSLSerialWriteSingle(mlsl_handle, pdata->address, ACCEL_BMA250_BW_REG, reg );
ERROR_CHECK(result);
return result;
}
示例13: kxtf9_resume
static int kxtf9_resume(void *mlsl_handle,
struct ext_slave_descr *slave,
struct ext_slave_platform_data *pdata)
{
int result = ML_SUCCESS;
unsigned char reg;
printk("accelerometer sensor resume : kxtf9_resume\n");
/* RAM reset */
result =
MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x1d, 0xcd);
ERROR_CHECK(result);
MLOSSleep(10);
/* Wake up */
result =
MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x1b, 0x42);
ERROR_CHECK(result);
/* INT_CTRL_REG1: */
result =
MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x1e, 0x14);
ERROR_CHECK(result);
/* WUF_THRESH: */
result =
MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x5a, 0x00);
ERROR_CHECK(result);
/* DATA_CTRL_REG */
result =
MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x21, 0x04);
ERROR_CHECK(result);
/* WUF_TIMER */
result =
MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x29, 0x02);
ERROR_CHECK(result);
/* Full Scale */
reg = 0xc2;
reg &= ~ACCEL_KIONIX_CTRL_MASK;
reg |= 0x00;
if (slave->range.mantissa == 4)
reg |= 0x08;
else if (slave->range.mantissa == 8)
reg |= 0x10;
else {
slave->range.mantissa = 2;
reg |= 0x00;
}
slave->range.fraction = 0;
/* Normal operation */
result =
MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x1b, reg);
ERROR_CHECK(result);
MLOSSleep(50);
return ML_SUCCESS;
}
示例14: kxsd9_suspend
static int kxsd9_suspend(void *mlsl_handle,
struct ext_slave_descr *slave,
struct ext_slave_platform_data *pdata)
{
int result;
/* CTRL_REGB: low-power standby mode */
result =
MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x0d, 0x0);
ERROR_CHECK(result);
return result;
}
示例15: bma150_suspend
static int bma150_suspend(void *mlsl_handle,
struct ext_slave_descr *slave,
struct ext_slave_platform_data *pdata)
{
int result;
result =
MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x0a, 0x01);
MLOSSleep(3); /* 3 ms powerup time maximum */
ERROR_CHECK(result);
return result;
}