Esempio n. 1
0
void HalI2CConfig(uint8_t newInterface, uint8_t address)
{
  slaveAddr = address;
#ifdef TI_DRIVERS_I2C_INCLUDED  
  // TBD: will this concept work with power management and TI RTOS style drivers?
  //      should driver be torn down and reopened??
  if (newInterface != interface) 
  {
    interface = newInterface;
    if (interface == BSP_I2C_INTERFACE_0)
    {
      IOCIOPortPullSet(BSP_IOD_SDA, IOC_NO_IOPULL);
      IOCIOPortPullSet(BSP_IOD_SCL, IOC_NO_IOPULL);
      IOCPinTypeI2c(I2C0_BASE, BSP_IOD_SDA, BSP_IOD_SCL);
      IOCPinTypeGpioInput(BSP_IOD_SDA_HP);
      IOCPinTypeGpioInput(BSP_IOD_SCL_HP);
    }
    else if (interface == BSP_I2C_INTERFACE_1)
    {
      IOCIOPortPullSet(BSP_IOD_SDA_HP, IOC_NO_IOPULL);
      IOCIOPortPullSet(BSP_IOD_SCL_HP, IOC_NO_IOPULL);
      IOCPinTypeI2c(I2C0_BASE, BSP_IOD_SDA_HP, BSP_IOD_SCL_HP);
      IOCPinTypeGpioInput(BSP_IOD_SDA);
      IOCPinTypeGpioInput(BSP_IOD_SCL);
    }
  }
#endif
}
Esempio n. 2
0
void bspI2cSelect(uint8_t newInterface, uint8_t address)
{
    /* Acquire I2C resource */
    Semaphore_pend(Semaphore_handle(&mutex),BIOS_WAIT_FOREVER);

#ifdef POWER_SAVING
    if (!checkI2cConstraint)
    {
        /* Prevent the system from entering standby while using I2C. */
        Power_setConstraint(Power_SB_DISALLOW);
        checkI2cConstraint = true;
    }
#endif

    slaveAddr = address;

    if (newInterface != interface)
    {
        interface = newInterface;

        I2C_close(I2Chandle);

        if (interface == BSP_I2C_INTERFACE_0)
        {
            i2cCC26xxHWAttrs[CC2650_I2C0].sdaPin = Board_I2C0_SDA0;
            i2cCC26xxHWAttrs[CC2650_I2C0].sclPin = Board_I2C0_SCL0;

            // Secondary I2C as GPIO
            IOCPinTypeGpioInput(Board_I2C0_SDA1);
            IOCPinTypeGpioInput(Board_I2C0_SCL1);
            IOCIOPortPullSet(Board_I2C0_SDA1, IOC_NO_IOPULL);
            IOCIOPortPullSet(Board_I2C0_SCL1, IOC_NO_IOPULL);
        }
        else if (interface == BSP_I2C_INTERFACE_1)
        {
            i2cCC26xxHWAttrs[CC2650_I2C0].sdaPin = Board_I2C0_SDA1;
            i2cCC26xxHWAttrs[CC2650_I2C0].sclPin = Board_I2C0_SCL1;

            // Primary I2C as GPIO
            IOCPinTypeGpioInput(Board_I2C0_SDA0);
            IOCPinTypeGpioInput(Board_I2C0_SCL0);
            IOCIOPortPullSet(Board_I2C0_SDA0, IOC_NO_IOPULL);
            IOCIOPortPullSet(Board_I2C0_SCL0, IOC_NO_IOPULL);
        }
        I2Chandle = I2C_open(Board_I2C, &I2CParams);
    }
}