SMART I2C async driver errors

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Running on an ATSAMC21E18A using the SMART-generated async I2C driver. I have interrupt handlers installed for the TX, RX, and Error interrupts. 


  //attach to Camera I2C
  errorCode = i2c_m_async_get_io_descriptor(Camera_i2c, &Camera_I2C_io);
  if (errorCode != ERR_NONE) {
    Error.Info.ErrorCode = FailCodes::FC_CameraHandler;
    loadError(__LINE__, errorCode);
    return;
  }    

  i2c_m_async_set_slaveaddr(Camera_i2c, (camera_I2C_address >> 1), I2C_M_SEVEN); //returns masked address
  
  //attach interrupt handlers
  errorCode = i2c_m_async_register_callback (Camera_i2c, I2C_M_ASYNC_ERROR, (FUNC_PTR)err_cb_I2C);
  if (errorCode != ERR_NONE) {
    Error.Info.ErrorCode = FailCodes::FC_CameraHandler;
    loadError(__LINE__, errorCode);
    return;
  }

  errorCode = i2c_m_async_register_callback (Camera_i2c, I2C_M_ASYNC_TX_COMPLETE, (FUNC_PTR)tx_cb_I2C);
  if (errorCode != ERR_NONE) {
    Error.Info.ErrorCode = FailCodes::FC_CameraHandler;
    loadError(__LINE__, errorCode);
    return;
  }

  errorCode = i2c_m_async_register_callback (Camera_i2c, I2C_M_ASYNC_RX_COMPLETE, (FUNC_PTR)rx_cb_I2C);
  if (errorCode != ERR_NONE) {
    Error.Info.ErrorCode = FailCodes::FC_CameraHandler;
    loadError(__LINE__, errorCode);
    return;
  }
  
  //enable
  errorCode = i2c_m_async_enable(Camera_i2c);
  if (errorCode != ERR_NONE) {
    Error.Info.ErrorCode = FailCodes::FC_CameraHandler;
    loadError(__LINE__, errorCode);
    return;
  } 

So far so good. 

The system is running in Master mode, and the target slave is removable - on a daughter card.

If I don't have a slave unit installed, the driver properly gives me an interrupt to the error handler with an error value of -2 (I2C_NACK). However, it won't shut off! It keeps continuously going to the interrupt handler and won't stop, hanging up the system. How do I shut the thing up? 

 

BTW, it would be very helpful if somewhere in the async documentation it told you where the error codes for the I2C actually were, which is in hpl_i2c_m_sync.h. Took me quite a while to actually find them.