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);
    }
}
/*
 *  ======== SENSORTAG_CC2650_initGPIO ========
 */
Void SENSORTAG_CC2650_initGPIO(Void)
{
	Bits32 pin;
  
	/* Power up the GPIO module. */
	GPIO_open();

  /* Setup the LED1 (red) GPIO pin. */
	pin = gpioHWAttrs[SENSORTAG_CC2650_LED1].pin;
  IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_OUTPUT);
  GPIODirModeSet(pin, GPIO_DIR_MODE_OUT);
  
  /* Setup the LED2 (green) GPIO pin. */
	pin = gpioHWAttrs[SENSORTAG_CC2650_LED2].pin;
  IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_OUTPUT);
  GPIODirModeSet(pin, GPIO_DIR_MODE_OUT);

  /* Setup the Button1 GPIO pin. */
	pin = gpioHWAttrs[SENSORTAG_CC2650_BUTTON1].pin;
  IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_INPUT);
  GPIODirModeSet(pin, GPIO_DIR_MODE_IN);
  IOCIOPortPullSet(PIN2IOID(pin), IOC_IOPULL_UP);
  
  /* Setup the Button2 GPIO pin. */
	pin = gpioHWAttrs[SENSORTAG_CC2650_BUTTON2].pin;
  IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_INPUT);
  GPIODirModeSet(pin, GPIO_DIR_MODE_IN);
  IOCIOPortPullSet(PIN2IOID(pin), IOC_IOPULL_UP);

  /* Setup the Reed relay GPIO pin. */
	pin = gpioHWAttrs[SENSORTAG_CC2650_REED_INT].pin;
  IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_INPUT);
  GPIODirModeSet(pin, GPIO_DIR_MODE_IN);
  IOCIOPortPullSet(PIN2IOID(pin), IOC_IOPULL_DOWN);

  /* Setup the FLASH_CS pin. */
	pin = gpioHWAttrs[SENSORTAG_CC2650_FLASH_CS].pin;
  IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_OUTPUT);
  GPIODirModeSet(pin, GPIO_DIR_MODE_OUT);
  IOCIOPortPullSet(PIN2IOID(pin), IOC_NO_IOPULL);

  /* Setup the BUZZER_EN pin. */
	pin = gpioHWAttrs[SENSORTAG_CC2650_BUZZER_EN].pin;
  IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_OUTPUT);
  GPIODirModeSet(pin, GPIO_DIR_MODE_OUT);

  /* Setup the MPU_POWER GPIO pin. */
	pin = gpioHWAttrs[SENSORTAG_CC2650_MPU_POWER].pin;
  IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_OUTPUT);
  GPIODirModeSet(pin, GPIO_DIR_MODE_OUT);

  /* Setup the MPU_INT GPIO pin. */
	pin = gpioHWAttrs[SENSORTAG_CC2650_MPU_INT].pin;
  IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_INPUT);
  GPIODirModeSet(pin, GPIO_DIR_MODE_IN);
  IOCIOPortPullSet(PIN2IOID(pin), IOC_IOPULL_DOWN);

  /* Setup the TMP_RDY GPIO pin. */
	pin = gpioHWAttrs[SENSORTAG_CC2650_TMP_RDY].pin;
  IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_INPUT);
  GPIODirModeSet(pin, GPIO_DIR_MODE_IN);

  /* Once GPIO_init is called, GPIO_config cannot be changed */
  GPIO_init();
  
  /* Set some of the IO pins */
  GPIO_write(SENSORTAG_CC2650_LED1, SENSORTAG_CC2650_LED_OFF);
  GPIO_write(SENSORTAG_CC2650_LED2, SENSORTAG_CC2650_LED_OFF);
  GPIO_write(SENSORTAG_CC2650_MPU_POWER, SENSORTAG_CC2650_MPU_POWER_ON);
  GPIO_write(SENSORTAG_CC2650_MIC_POWER, SENSORTAG_CC2650_MIC_POWER_OFF);
  GPIO_write(SENSORTAG_CC2650_FLASH_CS, SENSORTAG_CC2650_FLASH_CS_OFF);
}