本文整理汇总了C++中ReadReg函数的典型用法代码示例。如果您正苦于以下问题:C++ ReadReg函数的具体用法?C++ ReadReg怎么用?C++ ReadReg使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ReadReg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IS_Enabled_I2C
static error_code_t IS_Enabled_I2C(lpc17xx_i2c_config_t *config) {
error_code_t error = NO_ERROR;
uint32_t status;
switch (config->i2c_port) {
case I2C0:
error = ReadReg ( &(LPC_I2C0->I2CONSET), &status, 6, 6) ;
break;
case I2C1:
error = ReadReg ( &(LPC_I2C1->I2CONSET),&status, 6, 6) ;
break;
case I2C2:
error = ReadReg ( &(LPC_I2C2->I2CONSET),&status, 6, 6) ;
break;
}
if ( status == 0) {
return UNITIALIZED_I2C;
}
return error;
}
示例2: WaitForBusy
static inline int
WaitForBusy(struct IsdnCardState *cs)
{
int to = 130;
while (!(ReadReg(cs, HFCD_DATA, HFCD_STAT) & HFCD_BUSY) && to) {
udelay(1);
to--;
}
if (!to)
printk(KERN_WARNING "HiSax: WaitForBusy timeout\n");
return (to);
}
示例3: SetAxis
/*******************************************************************************
* Function Name : SetAxis
* Description : Enable/Disable LSM303DLHC Axis
* Input : X_ENABLE/X_DISABLE | Y_ENABLE/Y_DISABLE | Z_ENABLE/Z_DISABLE
* Output : None
* Note : You MUST use all input variable in the argument, as example
* Return : Status [MEMS_ERROR, MEMS_SUCCESS]
*******************************************************************************/
status_t SetAxis(Axis_t axis) {
u8_t value;
if( !ReadReg(ACC_I2C_ADDRESS, CTRL_REG1_A, &value) )
return MEMS_ERROR;
value &= 0xF8;
value |= (0x07 & axis);
if( !WriteReg(ACC_I2C_ADDRESS, CTRL_REG1_A, value) )
return MEMS_ERROR;
return MEMS_SUCCESS;
}
示例4: b1pciv4_detect
int b1pciv4_detect(avmcard *card)
{
int ret, i;
if ((ret = b1dma_detect(card)) != 0)
return ret;
for (i=0; i < 5 ; i++) {
if (WriteReg(card, 0x80A00000, 0x21) != 0)
return 6;
if ((ReadReg(card, 0x80A00000) & 0x01) != 0x01)
return 7;
}
for (i=0; i < 5 ; i++) {
if (WriteReg(card, 0x80A00000, 0x20) != 0)
return 8;
if ((ReadReg(card, 0x80A00000) & 0x01) != 0x00)
return 9;
}
return 0;
}
示例5: FIFOModeEnable
/*******************************************************************************
* Function Name : FIFOModeEnable
* Description : Sets Fifo Modality
* Input :
* Output : None
* Return : Status [MEMS_ERROR, MEMS_SUCCESS]
*******************************************************************************/
status_t FIFOModeEnable(FifoMode_t fm) {
u8_t value;
if(fm == FIFO_DISABLE) {
if( !ReadReg(CTRL_REG5, &value) )
return MEMS_ERROR;
value &= 0xBF;
if( !WriteReg(CTRL_REG5, value) )
return MEMS_ERROR;
}
else {
if( !ReadReg(CTRL_REG5, &value) )
return MEMS_ERROR;
value &= 0xBF;
value |= MEMS_SET<<FIFO_EN;
if( !WriteReg(CTRL_REG5, value) )
return MEMS_ERROR;
if( !ReadReg(FIFO_CTRL_REG, &value) )
return MEMS_ERROR;
value &= 0x1f;
value |= (fm<<FM0);
if( !WriteReg(FIFO_CTRL_REG, value) )
return MEMS_ERROR;
}
return MEMS_SUCCESS;
}
示例6: SetHPFMode
/*******************************************************************************
* Function Name : SetHPFMode
* Description : Set High Pass Filter Modality
* Input : HPM_NORMAL_MODE_RES/HPM_REF_SIGNAL/HPM_NORMAL_MODE/HPM_AUTORESET_INT
* Output : None
* Return : Status [MEMS_ERROR, MEMS_SUCCESS]
*******************************************************************************/
status_t SetHPFMode(HPFMode_t hpm) {
u8_t value;
if( !ReadReg(ACC_I2C_ADDRESS, CTRL_REG2_A, &value) )
return MEMS_ERROR;
value &= 0x3F;
value |= (hpm<<HPM);
if( !WriteReg(ACC_I2C_ADDRESS, CTRL_REG2_A, value) )
return MEMS_ERROR;
return MEMS_SUCCESS;
}
示例7: HPFAOI2Enable
/*******************************************************************************
* Function Name : HPFAOI2
* Description : Enable/Disable High Pass Filter for AOI on INT_2
* Input : MEMS_ENABLE/MEMS_DISABLE
* Output : None
* Return : Status [MEMS_ERROR, MEMS_SUCCESS]
*******************************************************************************/
status_t HPFAOI2Enable(State_t hpfe) {
u8_t value;
if( !ReadReg(ACC_I2C_ADDRESS, CTRL_REG2_A, &value) )
return MEMS_ERROR;
value &= 0xFD;
value |= (hpfe<<HPIS2);
if( !WriteReg(ACC_I2C_ADDRESS, CTRL_REG2_A, value) )
return MEMS_ERROR;
return MEMS_SUCCESS;
}
示例8: SetSelfTest
/*******************************************************************************
* Function Name : SetSelfTest
* Description : Set Self Test Modality
* Input : SELF_TEST_DISABLE/ST_0/ST_1
* Output : None
* Return : Status [MEMS_ERROR, MEMS_SUCCESS]
*******************************************************************************/
status_t SetSelfTest(SelfTest_t st) {
u8_t value;
if( !ReadReg(ACC_I2C_ADDRESS, CTRL_REG4_A, &value) )
return MEMS_ERROR;
value &= 0xF9;
value |= (st<<ST);
if( !WriteReg(ACC_I2C_ADDRESS, CTRL_REG4_A, value) )
return MEMS_ERROR;
return MEMS_SUCCESS;
}
示例9: SetBLE
/*******************************************************************************
* Function Name : SetBLE
* Description : Set Endianess (MSB/LSB)
* Input : BLE_LSB / BLE_MSB
* Output : None
* Return : Status [MEMS_ERROR, MEMS_SUCCESS]
*******************************************************************************/
status_t SetBLE(Endianess_t ble) {
u8_t value;
if( !ReadReg(ACC_I2C_ADDRESS, CTRL_REG4_A, &value) )
return MEMS_ERROR;
value &= 0xBF;
value |= (ble<<BLE);
if( !WriteReg(ACC_I2C_ADDRESS, CTRL_REG4_A, value) )
return MEMS_ERROR;
return MEMS_SUCCESS;
}
示例10: SetHPFMode
/*******************************************************************************
* Function Name : SetHPFMode
* Description : Set High Pass Filter Modality
* Input : HPM_NORMAL_MODE_RES/HPM_REF_SIGNAL/HPM_NORMAL_MODE/HPM_AUTORESET_INT
* Output : None
* Return : Status [MEMS_ERROR, MEMS_SUCCESS]
*******************************************************************************/
status_t SetHPFMode(HPFMode_t hpf) {
u8_t value;
if( !ReadReg(CTRL_REG2, &value) )
return MEMS_ERROR;
value &= 0xCF;
value |= (hpf<<HPM);
if( !WriteReg(CTRL_REG2, value) )
return MEMS_ERROR;
return MEMS_SUCCESS;
}
示例11: SetInt2Pin
/*******************************************************************************
* Function Name : SetInt2Pin
* Description : Set Interrupt2 pin Function
* Input : I2_DRDY_ON_INT2_ENABLE/DISABLE |
WTM_ON_INT2_ENABLE/DISABLE |
OVERRUN_ON_INT2_ENABLE/DISABLE |
EMPTY_ON_INT2_ENABLE/DISABLE
* Output : None
* Return : Status [MEMS_ERROR, MEMS_SUCCESS]
*******************************************************************************/
status_t SetInt2Pin(Int2PinConf_t pinConf) {
u8_t value;
if( !ReadReg(CTRL_REG3, &value) )
return MEMS_ERROR;
value &= 0xF0;
value |= pinConf;
if( !WriteReg(CTRL_REG3, value) )
return MEMS_ERROR;
return MEMS_SUCCESS;
}
示例12: Int1LatchEnable
/*******************************************************************************
* Function Name : Int1LatchEnable
* Description : Enable Interrupt 1 Latching function
* Input : ENABLE/DISABLE
* Output : None
* Return : Status [MEMS_ERROR, MEMS_SUCCESS]
*******************************************************************************/
status_t Int1LatchEnable(State_t latch) {
u8_t value;
if( !ReadReg(ACC_I2C_ADDRESS, CTRL_REG5_A, &value) )
return MEMS_ERROR;
value &= 0xF7;
value |= latch<<LIR_INT1;
if( !WriteReg(ACC_I2C_ADDRESS, CTRL_REG5_A, value) )
return MEMS_ERROR;
return MEMS_SUCCESS;
}
示例13: SetModeMag
/*******************************************************************************
* Function Name : SetModeMag
* Description : Sets LSM303DLHC Magnetometer Modality
* Input : Modality (CONTINUOUS_MODE, or SINGLE_MODE, or SLEEP_MODE)
* Output : None
* Return : Status [MEMS_ERROR, MEMS_SUCCESS]
*******************************************************************************/
status_t SetModeMag(Mode_M_t Mode){
u8_t value;
if( !ReadReg(MAG_I2C_ADDRESS, MR_REG_M, &value) )
return MEMS_ERROR;
value &= 0x00; //bit<7-3> must be =0 for correct working
value |= Mode<<MODE_SEL_M;
if( !WriteReg(MAG_I2C_ADDRESS, MR_REG_M, value) )
return MEMS_ERROR;
return MEMS_SUCCESS;
}
示例14: SetGainMag
/*******************************************************************************
* Function Name : SetGainMag
* Description : Sets LSM303DLHC Magnetometer Gain
* Input : GAIN_1100_M or GAIN_855_M or GAIN_670_M or GAIN_450_M....
* Output : None
* Return : Status [MEMS_ERROR, MEMS_SUCCESS]
*******************************************************************************/
status_t SetGainMag(GAIN_M_t Gain){
u8_t value;
if( !ReadReg(MAG_I2C_ADDRESS, CRB_REG_M, &value) )
return MEMS_ERROR;
value &= 0x00; //bit<4-0> must be =0 for correct working
value |= Gain<<GN_CFG;
if( !WriteReg(MAG_I2C_ADDRESS, CRB_REG_M, value) )
return MEMS_ERROR;
return MEMS_SUCCESS;
}
示例15: SetTemperature
/*******************************************************************************
* Function Name : SetTemperature
* Description : Sets LSM303DLHC Output Temperature
* Input : MEMS_ENABLE, MEMS_DISABLE
* Output : None
* Return : Status [MEMS_ERROR, MEMS_SUCCESS]
*******************************************************************************/
status_t SetTemperature(State_t state){
u8_t value;
if( !ReadReg(MAG_I2C_ADDRESS, CRA_REG_M, &value) )
return MEMS_ERROR;
value &= 0x7F;
value |= state<<TEMP_EN;
if( !WriteReg(MAG_I2C_ADDRESS, CRA_REG_M, value) )
return MEMS_ERROR;
return MEMS_SUCCESS;
}