Exemplo n.º 1
0
/*******************************************************************************
 * @fn          bspI2cSelect
 *
 * @brief       Select an I2C interface and slave
 *
 * @param       newInterface - selected interface
 * @param       address - slave address
  *
 * @return      true if success
 */
bool bspI2cSelect(uint8_t newInterface, uint8_t address)
{
  // Acquire I2C resource
  if (!Semaphore_pend(Semaphore_handle(&mutex),MS_2_TICKS(I2C_TIMEOUT)))
  {
    return false;
  }

  // Store new slave address
  slaveAddr = address;

  // Interface changed ?
  if (newInterface != interface)
  {
    // Store new interface
    interface = newInterface;

    // Shut down RTOS driver
    I2C_close(i2cHandle);

    // Sets custom to NULL, selects I2C interface 0
    I2C_Params_init(&i2cParams);

    // Assign I2C data/clock pins according to selected I2C interface 1
    if (interface == BSP_I2C_INTERFACE_1)
    {
      i2cParams.custom = (void*)&pinCfg1;
    }

    // Re-open RTOS driver with new bus pin assignment
    i2cHandle = I2C_open(Board_I2C, &i2cParams);
  }

  return true;
}
Exemplo n.º 2
0
/*******************************************************************************
 * @fn          i2c_sel_interfas
 * @brief       Selecciona interfas
 * @param       Interfas - 0 o 1=MPU
 * @param       dir - Esclavo
 * @return      ok Siempre
 */
bool i2c_sel_interface(uint8_t Interface, uint8_t dir)
{

  slaveAddr = dir;				//Dispositivo esclavo
  if (Interface != interface)	//no es la actual ya seleccionada?
  {
    interface = Interface;
    I2C_close(i2cHandle);		//Cierra apertura actual, si la hay

    // Sets custom to NULL, selects I2C interface 0
    I2C_Params_init(&i2cParams);

    // Assign I2C data/clock pins according to selected I2C interface 1
    if (interface == 1)
    {
      //i2cParams.custom = (void*)&pinCfg1; //así lo hacen en el sensor tag
    i2cParams.custom = (uintptr_t)&pinCfg1;	//Modifico para suprimir el warning de tipo, pues espera un puntero uint
    }

    // Re-open RTOS driver with new bus pin assignment
    i2cHandle = I2C_open(Board_I2C, &i2cParams);
  }

  return true;
}
Exemplo n.º 3
0
static PyObject *I2CDev_open(I2CDev *self, PyObject *args, PyObject *kwds) {
  uint8_t use_10bit_address;
  static char *kwlist[] = {"use_10bit_address", NULL};
  use_10bit_address = 0;
  if(!PyArg_ParseTupleAndKeywords(args, kwds, "|b", kwlist, 
                                  &use_10bit_address)) {
    return NULL;
  }

  if (self->i2c_fd > 0) I2C_close(self->i2c_fd);
  self->i2c_fd = I2C_open(self->bus_num);
  if (self->i2c_fd < 0) {
    PyErr_SetString(PyExc_IOError, "could not open I2C interface");
    return NULL;
  }
  
  if (use_10bit_address) {
    if (I2C_enable10BitAddressing(self->i2c_fd) < 0) {
      PyErr_SetString(PyExc_IOError, 
          "could not set I2C interface to 10-bit address mode");
      return NULL;
    }
  }
  else {
    if (I2C_disable10BitAddressing(self->i2c_fd) < 0) {
      PyErr_SetString(PyExc_IOError, 
          "could not set I2C interface to 10-bit address mode");
      return NULL;
    }
  }

  Py_INCREF(Py_None);
  return Py_None;
}
// Отключение кодека
uint16 aic3204_close(void) {
// Отключение кодека
	aic3204_set(1, 1); // Программный сброс кодека
	GPIO_OUT1 &= ~BIT10; // Аппаратуреый сброс: GPIO[26]=0
// Отключение звукового интерфейса
	I2S2->SCTL &= ~SCTL_ENABLE; // Запрет I2S2
	c5515_wait(100); // Ожидание завершения
	PCGCR1 |= PCGCR1_I2S2CG; // Снять тактирование I2S
// Отключение приборного интерфеса
	I2C_close(); // Отключить I2C
	return 0;
}
Exemplo n.º 5
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);
    }
}
Exemplo n.º 6
0
/*******************************************************************************
 * @fn          bspI2cReset
 *
 * @brief       Reset the RTOS I2C driver
 *
 * @param       none
 *
 * @return      none
 */
void bspI2cReset(void)
{
  // Acquire I2C resource */
  if (!Semaphore_pend(Semaphore_handle(&mutex),MS_2_TICKS(I2C_TIMEOUT)))
  {
    return;
  }

  // Close the driver
  I2C_close(i2cHandle);

  // Reset the I2C controller
  HapiResetPeripheral(PRCM_PERIPH_I2C0);

  // Reset local variables
  slaveAddr = 0xFF;
  interface = BSP_I2C_INTERFACE_0;

  // Open driver
  i2cHandle = I2C_open(Board_I2C, &i2cParams);

  // Release I2C resource
  Semaphore_post(Semaphore_handle(&mutex));
}
Exemplo n.º 7
0
void I2C_release(i2c_bus *bus) {
  bus->attached_devices--;
  if (bus->attached_devices == 0) {
    I2C_close(bus);
  }
}
Exemplo n.º 8
0
void TwoWire::end()
{
    begun = false;
    I2C_close(i2c);
}
Exemplo n.º 9
0
static PyObject *I2CDev_close(I2CDev *self, PyObject *args, PyObject *kwds) {
  if (self->i2c_fd > 0) I2C_close(self->i2c_fd);
  Py_INCREF(Py_None);
  return Py_None;
}
Exemplo n.º 10
0
void bspI2cReset(void)
{
    I2C_close(I2Chandle);
    I2Chandle = I2C_open(Board_I2C, &I2CParams);
}