コード例 #1
0
/***************************************************************************
 *
 * Function : set_charge_backup_battery
 *
 * IN   : param, a value to write to the regiter RTCStatus
 * OUT  : 
 *
 * RET  : Return the value of register RTCStatus
 *
 * Notes : From register 0x0F0B, bits 5:5
 *
 **************************************************************************/
unsigned char set_charge_backup_battery( enum charge_backup_battery_enable param )
  {
    unsigned char value = 0;
    unsigned char old_value;

    old_value = I2CRead(RTC_STATUS_REG);

    /* 
     * 0: Current source to charge back up battery disabled in 
     * OFF mode 
     * 1: Current source to charge back up battery enabled in 
     * OFF mode 
     */ 
    switch( param ){
        case CHARGE_BACKUP_BATTERY_ENABLE_E: 
           value = old_value | CHARGE_BACKUP_BATTERY_ENABLE_PARAM_MASK; 
           break;
        case CHARGE_BACKUP_BATTERY_DISABLE_E: 
           value = old_value & ~ CHARGE_BACKUP_BATTERY_ENABLE_PARAM_MASK;
           break;
    }
  

    I2CWrite(RTC_STATUS_REG, value);

    return old_value;
  }
コード例 #2
0
/***************************************************************************
 *
 * Function : set_acc_detect21_comparator
 *
 * IN   : param, a value to write to the regiter AccDetect3
 * OUT  : 
 *
 * RET  : Return the value of register 0xAccDetect3
 *
 * Notes : From register 0x882, bits 4:4
 *
 **************************************************************************/
unsigned char set_acc_detect21_comparator( enum comparator21_enable param )
  {
    unsigned char value = 0;
    unsigned char old_value;

    old_value = I2CRead(ACC_DETECT_3_REG);

    /* 
     * 0: disable AccDetect21 comparator 
     * 1: enable AccDetect21 comparator 
     */ 
    switch( param ){
        case COMPARATOR_21_ENABLE_E: 
           value = old_value | ACC_DETECT_21_COMPARATOR_MASK; 
           break;
        case COMPARATOR_21_DISABLE_E: 
           value = old_value & ~ ACC_DETECT_21_COMPARATOR_MASK;
           break;
    }
  

    I2CWrite(ACC_DETECT_3_REG, value);

    return old_value;
  }
コード例 #3
0
/***************************************************************************
 *
 * Function : set_coulomb_counter_power_off
 *
 * IN   : param, a value to write to the regiter CoulombCounter
 * OUT  : 
 *
 * RET  : Return the value of register CoulombCounter
 *
 * Notes : From register 0x0F01, bits 0:0
 *
 **************************************************************************/
unsigned char set_coulomb_counter_power_off( enum coulomb_counter_power_off_enable param )
  {
    unsigned char value = 0;
    unsigned char old_value;

    old_value = I2CRead(COULOMB_COUNTER_REG);

    /* 
     * Note: Coulomb Counter always disable in PwrOff mode. 
     * 0: disable Coulomb Counter 
     * 1: enable Coulomb Counter 
     */ 
    switch( param ){
        case COULOMB_COUNTER_POWER_UP_E: 
           value = old_value | COULOMB_COUNTER_POWER_OFF_ENABLE_PARAM_MASK; 
           break;
        case COULOMB_COUNTER_POWER_DOWN_E: 
           value = old_value & ~ COULOMB_COUNTER_POWER_OFF_ENABLE_PARAM_MASK;
           break;
    }
  

    I2CWrite(COULOMB_COUNTER_REG, value);

    return old_value;
  }
コード例 #4
0
/***************************************************************************
 *
 * Function : set_ape_i2c_clock_pullup
 *
 * IN   : param, a value to write to the regiter I2cPadControl
 * OUT  : 
 *
 * RET  : Return the value of register I2cPadControl
 *
 * Notes : From register 0x1067, bits 2:2
 *
 **************************************************************************/
unsigned char set_ape_i2c_clock_pullup( enum ape_i2c_clock_pullup_enable param )
  {
    unsigned char value = 0;
    unsigned char old_value;

    old_value = I2CRead(I_2C_PAD_CONTROL_REG);

    /* 
     * 0: enable internal pull-up 
     * 1: Disable internal pull-up 
     */ 
    switch( param ){
        case APE_I_2C_CLOCK_PULLUP_DISABLE_E: 
           value = old_value | APE_I_2C_CLOCK_PULLUP_ENABLE_PARAM_MASK; 
           break;
        case APE_I_2C_CLOCK_PULLUP_ENABLE_E: 
           value = old_value & ~ APE_I_2C_CLOCK_PULLUP_ENABLE_PARAM_MASK;
           break;
    }
  

    I2CWrite(I_2C_PAD_CONTROL_REG, value);

    return old_value;
  }
コード例 #5
0
ファイル: LcdDisplay.c プロジェクト: Athuli7/Microchip
void LCDUpdate(void)
{
    #if defined(SENSOR_PORT_UART)
    LCDCommand[0] = LCD_SLAVEADDRESS << 1;
    LCDCommand[1] = LCD_WRITE_CMD;
    LCDCommand[2] = LCDCMD_FIRSTLINE_ADDRESS;
    LCDCommand[3] = 32;
    I2CWrite(4, 32);
    #else

    BYTE    i;

    DelayMs(10);
    SPIPut2(0x32);  //LCD Subsystem Write Data Command
    DelayMs(5);
    SPIPut2(0);     //Screen Address
    DelayMs(5);
    SPIPut2(32);    //Data length (16 + 3)
    for(i = 0; i < 32; i++)
    {
        DelayMs(5);
        if(LCDText[i] == 0)
        {
            SPIPut2(' ');
        }
        else
        {
            SPIPut2(LCDText[i]);
        }
    }

    DelayMs(300);
    #endif
}
コード例 #6
0
/***************************************************************************
 *
 * Function : set_modem_i2c_data_pullup
 *
 * IN   : param, a value to write to the regiter I2cPadControl
 * OUT  : 
 *
 * RET  : Return the value of register I2cPadControl
 *
 * Notes : From register 0x1067, bits 1:1
 *
 **************************************************************************/
unsigned char set_modem_i2c_data_pullup( enum modem_i2c_data_pullup_enable param )
  {
    unsigned char value = 0;
    unsigned char old_value;

    old_value = I2CRead(I_2C_PAD_CONTROL_REG);

    /* 
     * 0: enable internal pull-up 
     * 1: Disable internal pull-up 
     */ 
    switch( param ){
        case MODEM_I_2C_DATA_PULLUP_DISABLE_E: 
           value = old_value | MODEM_I_2C_DATA_PULLUP_ENABLE_PARAM_MASK; 
           break;
        case MODEM_I_2C_DATA_PULLUP_ENABLE_E: 
           value = old_value & ~ MODEM_I_2C_DATA_PULLUP_ENABLE_PARAM_MASK;
           break;
    }
  

    I2CWrite(I_2C_PAD_CONTROL_REG, value);

    return old_value;
  }
コード例 #7
0
/***************************************************************************
 *
 * Function : set_acc_detect1_comparator
 *
 * IN   : param, a value to write to the regiter AccDetect3
 * OUT  : 
 *
 * RET  : Return the value of register 0xAccDetect3
 *
 * Notes : From register 0x882, bits 0:0
 *
 **************************************************************************/
unsigned char set_acc_detect1_comparator( enum detect1_comparator_enable param )
  {
    unsigned char value = 0;
    unsigned char old_value;

    old_value = I2CRead(ACC_DETECT_3_REG);

    /* 
     * Note: doesn't turn On internal pull-up 
     * 0: disable AccDetect1 comparator 
     * 1: enable AccDetect1 comparator 
     */ 
    switch( param ){
        case DETECT_1_COMPARATOR_ENABLE_E: 
           value = old_value | ACC_DETECT_1_COMPARATOR_MASK; 
           break;
        case DETECT_1_COMPARATOR_DISABLE_E: 
           value = old_value & ~ ACC_DETECT_1_COMPARATOR_MASK;
           break;
    }
  

    I2CWrite(ACC_DETECT_3_REG, value);

    return old_value;
  }
コード例 #8
0
/***************************************************************************
 *
 * Function : set_acc_detect_pullup
 *
 * IN   : param, a value to write to the regiter AccDetect3
 * OUT  : 
 *
 * RET  : Return the value of register 0xAccDetect3
 *
 * Notes : From register 0x882, bits 3:3
 *
 **************************************************************************/
unsigned char set_acc_detect_pullup( enum acc_detect_pullup_enable param )
  {
    unsigned char value = 0;
    unsigned char old_value;

    old_value = I2CRead(ACC_DETECT_3_REG);

    /* 
     * 0: disable AccDetect2 Pull-up 
     * 1: enable AccDetect2 Pull-up 
     */ 
    switch( param ){
        case ACC_DETECT_PULLUP_ENABLE_E: 
           value = old_value | ACC_DETECT_PULLUP_MASK; 
           break;
        case ACC_DETECT_PULLUP_DISABLE_E: 
           value = old_value & ~ ACC_DETECT_PULLUP_MASK;
           break;
    }
  

    I2CWrite(ACC_DETECT_3_REG, value);

    return old_value;
  }
コード例 #9
0
/***************************************************************************
 *
 * Function : set_rtc_read_request
 *
 * IN   : param, a value to write to the regiter RTCReadRequest
 * OUT  : 
 *
 * RET  : Return the value of register RTCReadRequest
 *
 * Notes : From register 0x0F02, bits 0:0
 *
 **************************************************************************/
unsigned char set_rtc_read_request( enum rtc_read_enable param )
  {
    unsigned char value = 0;
    unsigned char old_value;

    old_value = I2CRead(RTC_READ_REQUEST_REG);

    /* 
     * RTC data read transfer is required 
     * Cleared upon data transfert in watchtim register is done 
     */ 
    switch( param ){
        case RTC_READ_ENABLE_E: 
           value = old_value | RTC_READ_ENABLE_PARAM_MASK; 
           break;
        case RTC_READ_DISABLE_E: 
           value = old_value & ~ RTC_READ_ENABLE_PARAM_MASK;
           break;
    }
  

    I2CWrite(RTC_READ_REQUEST_REG, value);

    return old_value;
  }
コード例 #10
0
unsigned int L0_WriteCommandBytes(unsigned char slaveaddress, unsigned char length, unsigned char *pucDataBuffer)
{		
		slaveaddress = 0x64;
		I2CWrite(slaveaddress,pucDataBuffer,length);
		return length;

}
コード例 #11
0
/***************************************************************************
 *
 * Function : set_acc_detect_pullup_supply
 *
 * IN   : param, a value to write to the regiter AccDetect3
 * OUT  : 
 *
 * RET  : Return the value of register 0xAccDetect3
 *
 * Notes : From register 0x882, bits 1:1
 *
 **************************************************************************/
unsigned char set_acc_detect_pullup_supply( enum v21_supply_enable param )
  {
    unsigned char value = 0;
    unsigned char old_value;

    old_value = I2CRead(ACC_DETECT_3_REG);

    /* 
     * 0: disable AccDetect2 Pull-up 2.1v supply 
     * 1: enable AccDetect2 Pull-up 2.1v supply 
     */ 
    switch( param ){
        case V21_SUPPLY_ENABLE_E: 
           value = old_value | ACC_DETECT_PULLUP_SUPPLY_MASK; 
           break;
        case V21_SUPPLY_DISABLE_E: 
           value = old_value & ~ ACC_DETECT_PULLUP_SUPPLY_MASK;
           break;
    }
  

    I2CWrite(ACC_DETECT_3_REG, value);

    return old_value;
  }
コード例 #12
0
EFI_STATUS
InitializeDS3231 (
  VOID
  )
{
  EFI_STATUS    Status;
  I2C_DEVICE    Dev;
  RTC_DS3231_CONTROL Temp;
  RTC_DS3231_HOURS   Hours;

  // Prepare the hardware
  (VOID)IdentifyDS3231();

  (VOID) CopyMem(&Dev, &gDS3231RtcDevice, sizeof(Dev));

  Status = I2CInit(Dev.Socket,Dev.Port,Normal);
  if (EFI_ERROR (Status)) {
    goto EXIT;
  }
  // Ensure interrupts are masked. We do not want RTC interrupts in UEFI
  Status = I2CRead(&Dev,DS3231_REGADDR_CONTROL,1,&Temp.u8);
  if (EFI_ERROR (Status)) {
    goto EXIT;
  }
  Temp.bits.INTCN = 0;
  Status = I2CWrite(&Dev,DS3231_REGADDR_CONTROL,1,&Temp.u8);
  if (EFI_ERROR (Status)) {
    goto EXIT;
  }

  MicroSecondDelay(2000);
  Status = I2CRead(&Dev,DS3231_REGADDR_HOURS,1,&Hours.u8);
  if (EFI_ERROR (Status)) {
    goto EXIT;
  }
  Hours.bits.Hour24_n = 0;
  Status = I2CWrite(&Dev,DS3231_REGADDR_HOURS,1,&Hours.u8);
  if (EFI_ERROR (Status)) {
    goto EXIT;
  }


  mDS3231Initialized = TRUE;

  EXIT:
  return Status;
}
コード例 #13
0
static ssize_t eamp_closeheadPhone()
{

	u8 temp_control_reg = 0;
	EAMP_PRINTK("eamp_closeheadPhone");
	I2CWrite(0x86, 0x40);	
	I2CWrite(0x87, 0x00);
	
	if(gsk_on)
	  {
	  	I2CWrite(0x85, 0x5f);	
		I2CWrite(0x87, 0x30);
		}
	
	ghp_on = false;
	return 0;
}
コード例 #14
0
ファイル: uart2.c プロジェクト: ecomptiago/EmbarcadosLab2
static void writeReg(uint8_t reg, uint8_t data)
{
    uint8_t buf[2];

    buf[0] = SUB_ADDR(channel, reg);
    buf[1] = data;
    I2CWrite(UART2_ADDR, buf, 2);
}
コード例 #15
0
bool RTIMULSM9DS0::setGyroCTRL2()
{
    if ((m_settings->m_LSM9DS0GyroHpf < LSM9DS0_GYRO_HPF_0) || (m_settings->m_LSM9DS0GyroHpf > LSM9DS0_GYRO_HPF_9)) {
        HAL_ERROR1("Illegal LSM9DS0 gyro high pass filter code %d\n", m_settings->m_LSM9DS0GyroHpf);
        return false;
    }
    return I2CWrite(m_gyroSlaveAddr,  LSM9DS0_GYRO_CTRL2, m_settings->m_LSM9DS0GyroHpf, "Failed to set LSM9DS0 gyro CTRL2");
}
コード例 #16
0
ファイル: pca9532.c プロジェクト: finklabs/epicsamples
/******************************************************************************
 *
 * Description:
 *    Set the blink period for PWM1. Valid values are 0 - 255 where 0
 *    means 152 Hz and 255 means 0.59 Hz. A value of 151 means 1 Hz.
 *
 * Params:
 *    [in]  period  - The period for PWM1
 *
 *****************************************************************************/
void pca9532_setBlink1Period(uint8_t period)
{
    uint8_t buf[2];

    buf[0] = PCA9532_PSC1;
    buf[1] = period;
    I2CWrite(PCA9532_I2C_ADDR, buf, 2);
}
コード例 #17
0
ファイル: Storage.c プロジェクト: txl0591/InputDevices
/*************************************************
  Function:		StorageClear
  Description:  
  Input:		
  Output:		
  Return:		
  Others:
*************************************************/
void StorageClear(void)
{
    mSysParam.Init = 1;
    mSysParam.BeepEnable = 1;
    mSysParam.DataNum = 0;
    StorageInitInfo();
    I2CWrite(I2C_ADDR_W, ADDRESS_INIT, (unsigned char*)(&mSysParam), sizeof(SYS_PARAM));
}
コード例 #18
0
ファイル: acc.c プロジェクト: TiddoLangerak/mmc_test
static void setModeControl(uint8_t mctl)
{
    uint8_t buf[2];

    buf[0] = ACC_ADDR_MCTL;
    buf[1] = mctl;
    I2CWrite(ACC_I2C_ADDR, buf, 2);
}
コード例 #19
0
ファイル: ddc.c プロジェクト: HBelusca/NasuTek-Odyssey
BOOLEAN NTAPI
VideoPortDDCMonitorHelper(
   PVOID HwDeviceExtension,
   PVOID I2CFunctions,
   PUCHAR pEdidBuffer,
   ULONG EdidBufferSize
   )
{
   PDDC_CONTROL ddc = (PDDC_CONTROL)I2CFunctions;
   PI2C_CALLBACKS i2c = &ddc->I2CCallbacks;
   INT Count, i;
   PUCHAR pBuffer = (PUCHAR)pEdidBuffer;
   BOOL Ack;

   TRACE_(VIDEOPRT, "VideoPortDDCMonitorHelper()\n");

   ASSERT_IRQL_LESS_OR_EQUAL(PASSIVE_LEVEL);
   if (ddc->Size != sizeof (ddc))
     {
        WARN_(VIDEOPRT, "ddc->Size != %d (%d)\n", sizeof (ddc), ddc->Size);
        return FALSE;
     }

   /* select eeprom */
   if (!I2CStart(HwDeviceExtension, i2c, DDC_EEPROM_ADDRESS | WRITE))
     return FALSE;
   /* set address */
   if (!I2CWrite(HwDeviceExtension, i2c, 0x00))
     return FALSE;
   /* change into read mode */
   if (!I2CRepStart(HwDeviceExtension, i2c, DDC_EEPROM_ADDRESS | READ))
     return FALSE;
   /* read eeprom */
   RtlZeroMemory(pEdidBuffer, EdidBufferSize);
   Count = min(128, EdidBufferSize);
   for (i = 0; i < Count; i++)
     {
        Ack = ((i + 1) < Count);
        pBuffer[i] = I2CRead(HwDeviceExtension, i2c, Ack);
     }
   I2CStop(HwDeviceExtension, i2c);

   /* check EDID header */
   if (pBuffer[0] != 0x00 || pBuffer[1] != 0xff ||
       pBuffer[2] != 0xff || pBuffer[3] != 0xff ||
       pBuffer[4] != 0xff || pBuffer[5] != 0xff ||
       pBuffer[6] != 0xff || pBuffer[7] != 0x00)
     {
        WARN_(VIDEOPRT, "VideoPortDDCMonitorHelper(): Invalid EDID header!\n");
        return FALSE;
     }

   INFO_(VIDEOPRT, "VideoPortDDCMonitorHelper(): EDID version %d rev. %d\n", pBuffer[18], pBuffer[19]);
   INFO_(VIDEOPRT, "VideoPortDDCMonitorHelper() - SUCCESS!\n");
   return TRUE;
}
コード例 #20
0
ファイル: uart2.c プロジェクト: ecomptiago/EmbarcadosLab2
static uint8_t readReg(uint8_t reg)
{
    uint8_t buf[1];

    buf[0] = SUB_ADDR(channel, reg);
    I2CWrite(UART2_ADDR, buf, 1);
    I2CRead(UART2_ADDR, buf, 1);

    return buf[0];
}
コード例 #21
0
int main(void) {
	int fd;
	char device[20];
	int count;
	
	printf("open device...\n");
	sprintf(device, "/dev/i2c-1");
	if ((fd = open(device, O_RDWR)) < 0) {
		fprintf(stderr, "Failed to open i2c bus '%s'\n", device);
        exit(1);
	}
	printf("set slave ...\n");
    if (ioctl(fd, I2C_SLAVE, SlaveAddr) < 0) {
		fprintf(stderr,
		"Failed to acquire i2c bus access or talk to slave %X\n", SlaveAddr);
		close(fd);
		exit(2);
	}

	printf("switch to iocon.bank 1 ...\n");
	I2CWrite(fd, MCP_IOCON, 0x80);	
	printf("start output dark...\n");
	I2CWrite(fd, MCP_PortA | MCP_Write, Seg7_Digi1_Off | Seg7_Digi2_Off);

	printf("write direction output ...\n");
	I2CWrite(fd, MCP_PortA | MCP_Direction, 0x00);

	printf("count up both digits ...\n");
	for (count=0; count<=9; count++){
		I2CWrite(fd, MCP_PortA | MCP_Write, count | Seg7_Dot_Off);
		usleep(300000);
	}
	printf("count up digit 2 ...\n");
	for (count=0; count<=9; count++){
		I2CWrite(fd, MCP_PortA | MCP_Write, count | Seg7_Digi1_Off | Seg7_Dot_Off);
		usleep(300000);
	}
	printf("count up digit 1 ...\n");
	for (count=0; count<=9; count++){
		I2CWrite(fd, MCP_PortA | MCP_Write, count | Seg7_Digi2_Off | Seg7_Dot_Off);
		usleep(300000);
	}
	printf("show 04 Hz ...\n");
	MultiplexWrite(fd, 0, 4, 250000, 3000000);
	printf("show 10 Hz ...\n");
	MultiplexWrite(fd, 1, 0, 100000, 3000000);
	printf("show 21 Hz ...\n");
	MultiplexWrite(fd, 2, 1, 47600,  3000000);
	printf("show 43 Hz ...\n");
	MultiplexWrite(fd, 4, 3, 23200,  3000000);
	printf("show 98 Hz ...\n");
	MultiplexWrite(fd, 9, 8, 10200,  3000000);
	printf("switch off both digits ...\n");

	I2CWrite(fd, MCP_PortA | MCP_Write, Seg7_Digi1_Off | Seg7_Digi2_Off);	
	close(fd);
	return 0;
}
コード例 #22
0
ファイル: acc.c プロジェクト: TiddoLangerak/mmc_test
static uint8_t getStatus(void)
{
    uint8_t buf[1];

    buf[0] = ACC_ADDR_STATUS;
    I2CWrite(ACC_I2C_ADDR, buf, 1);
    I2CRead(ACC_I2C_ADDR, buf, 1);

    return buf[0];
}
コード例 #23
0
ファイル: acc.c プロジェクト: TiddoLangerak/mmc_test
static uint8_t getModeControl(void)
{
    uint8_t buf[1];

    buf[0] = ACC_ADDR_MCTL;
    I2CWrite(ACC_I2C_ADDR, buf, 1);
    I2CRead(ACC_I2C_ADDR, buf, 1);

    return buf[0];
}
コード例 #24
0
static ssize_t eamp_setDevice(unsigned long int param)
{
    EAMP_PRINTK("set Device (%u)", param);
    set_device = param;
	if (set_mode == 2) {
		agc_fixed_gain = AGC_FIXED_GAIN_VOICE;
		I2CWrite(AGC_FIXED_GAIN_CONTROL, register_setting_mode ? register_setting_mode:agc_fixed_gain);
		EAMP_PRINTK("eamp_setDevice : set agc gain VOICE = 0x%x\n", agc_fixed_gain);
	} else if (set_device == DEVICE_OUT_SPEAKER_HEADSET_R) {
		agc_fixed_gain = AGC_FIXED_GAIN_COMBO_RING;
		I2CWrite(AGC_FIXED_GAIN_CONTROL, register_setting_mode ? register_setting_mode:agc_fixed_gain);
		EAMP_PRINTK("eamp_setDevice : set agc gain COMBO_PATH = 0x%x\n", agc_fixed_gain);
	} else {
		agc_fixed_gain = AGC_FIXED_GAIN_AUDIO;
		I2CWrite(AGC_FIXED_GAIN_CONTROL, register_setting_mode ? register_setting_mode:agc_fixed_gain);
		EAMP_PRINTK("eamp_setDevice : set agc gain AUDIO = 0x%x\n", agc_fixed_gain);
	}
    return 0;
}
コード例 #25
0
ファイル: LcdDisplay.c プロジェクト: cnkker/Microchip
void LCDBacklightON(void)
{
#if defined(SENSOR_PORT_UART)
    LCDCommand[0] = LCD_SLAVEADDRESS << 1;
    LCDCommand[1] = 0x44;
    LCDCommand[2] = 0x00;

    I2CWrite(3, 0);
    DelayMs(200);

    LCDCommand[0] = LCD_SLAVEADDRESS << 1;
    LCDCommand[1] = 0x42;
    LCDCommand[2] = 0x00;

    I2CWrite(3, 0);
    DelayMs(200);
#else
#endif
}
コード例 #26
0
ファイル: Storage.c プロジェクト: txl0591/InputDevices
/*************************************************
 Function:		StorageSetParamIndex
 Descroption:	 
 Input: 
	1.Index
	2.Info
	3.Data
	4.THData
 Output: 
 Return: 	
 Other:  
*************************************************/
INT8U StorageSetParamIndex(INT8U Index, PINFO_PARAM Info, INT8U* Data, INT8U* THData)
{
    unsigned int SubAddr = ADDRESS_DATA(Index);
    if(NULL == Info || NULL == Data || NULL == THData)
    {
        return FALSE;
    }

    if(Index > mSysParam.DataNum)
    {
        return FALSE;
    }
    I2CWrite(I2C_ADDR_W, SubAddr, (unsigned char*)Info, sizeof(INFO_PARAM));
    SubAddr += sizeof(INFO_PARAM);
    I2CWrite(I2C_ADDR_W, SubAddr, (unsigned char*)Data, (16*Info->Num));
    SubAddr += (16*Info->Num);
    I2CWrite(I2C_ADDR_W, SubAddr, (unsigned char*)THData, Info->Num);    
    return 0;
}
コード例 #27
0
bool RTIMUGD20HM303DLHC::setCompassCRB()
{
    unsigned char crb;

    //  convert FSR to uT

    switch (m_settings->m_GD20HM303DLHCCompassFsr) {
    case LSM303DLHC_COMPASS_FSR_1_3:
        crb = 0x20;
        m_compassScaleXY = (RTFLOAT)100 / (RTFLOAT)1100;
        m_compassScaleZ = (RTFLOAT)100 / (RTFLOAT)980;
        break;

    case LSM303DLHC_COMPASS_FSR_1_9:
        crb = 0x40;
        m_compassScaleXY = (RTFLOAT)100 / (RTFLOAT)855;
        m_compassScaleZ = (RTFLOAT)100 / (RTFLOAT)760;
       break;

    case LSM303DLHC_COMPASS_FSR_2_5:
        crb = 0x60;
        m_compassScaleXY = (RTFLOAT)100 / (RTFLOAT)670;
        m_compassScaleZ = (RTFLOAT)100 / (RTFLOAT)600;
        break;

    case LSM303DLHC_COMPASS_FSR_4:
        crb = 0x80;
        m_compassScaleXY = (RTFLOAT)100 / (RTFLOAT)450;
        m_compassScaleZ = (RTFLOAT)100 / (RTFLOAT)400;
        break;

    case LSM303DLHC_COMPASS_FSR_4_7:
        crb = 0xa0;
        m_compassScaleXY = (RTFLOAT)100 / (RTFLOAT)400;
        m_compassScaleZ = (RTFLOAT)100 / (RTFLOAT)355;
        break;

    case LSM303DLHC_COMPASS_FSR_5_6:
        crb = 0xc0;
        m_compassScaleXY = (RTFLOAT)100 / (RTFLOAT)330;
        m_compassScaleZ = (RTFLOAT)100 / (RTFLOAT)295;
        break;

    case LSM303DLHC_COMPASS_FSR_8_1:
        crb = 0xe0;
        m_compassScaleXY = (RTFLOAT)100 / (RTFLOAT)230;
        m_compassScaleZ = (RTFLOAT)100 / (RTFLOAT)205;
        break;

    default:
        return false;
    }

    return I2CWrite(m_compassSlaveAddr,  LSM303DLHC_CRB_M, crb);
}
コード例 #28
0
ファイル: AD7152.c プロジェクト: EJ-Esteban/Tempo4000_stuff
int writeRegCDC(char rAddr, int value) {

	unsigned char cmd[2];
	cmd[0] = rAddr;
	cmd[1] = value;
	I2CWrite(2, &cmd[0]);
	while (isBusy())
		;

	return 1;
}
コード例 #29
0
static ssize_t eamp_setRegister(unsigned long int param)
{
    AMP_Control * p = (AMP_Control*)param;

    EAMP_PRINTK("");

    if(p->param1 >7)
        return -1;

    return I2CWrite(p->param1,p->param2);
}
コード例 #30
0
bool RTIMULSM9DS0::setGyroSampleRate()
{
    unsigned char ctrl1;

    switch (m_settings->m_LSM9DS0GyroSampleRate) {
    case LSM9DS0_GYRO_SAMPLERATE_95:
        ctrl1 = 0x0f;
        m_sampleRate = 95;
        break;

    case LSM9DS0_GYRO_SAMPLERATE_190:
        ctrl1 = 0x4f;
        m_sampleRate = 190;
        break;

    case LSM9DS0_GYRO_SAMPLERATE_380:
        ctrl1 = 0x8f;
        m_sampleRate = 380;
        break;

    case LSM9DS0_GYRO_SAMPLERATE_760:
        ctrl1 = 0xcf;
        m_sampleRate = 760;
        break;

    default:
        HAL_ERROR1("Illegal LSM9DS0 gyro sample rate code %d\n", m_settings->m_LSM9DS0GyroSampleRate);
        return false;
    }

    m_sampleInterval = (uint64_t)1000000 / m_sampleRate;

    switch (m_settings->m_LSM9DS0GyroBW) {
    case LSM9DS0_GYRO_BANDWIDTH_0:
        ctrl1 |= 0x00;
        break;

    case LSM9DS0_GYRO_BANDWIDTH_1:
        ctrl1 |= 0x10;
        break;

    case LSM9DS0_GYRO_BANDWIDTH_2:
        ctrl1 |= 0x20;
        break;

    case LSM9DS0_GYRO_BANDWIDTH_3:
        ctrl1 |= 0x30;
        break;

    }

    return (I2CWrite(m_gyroSlaveAddr, LSM9DS0_GYRO_CTRL1, ctrl1, "Failed to set LSM9DS0 gyro CTRL1"));
}