Functions
Peripheral State, Mode and Error functions
Peripheral Driver » HAL Driver » I2C » Functions

Peripheral State, Mode and Error functions. More...

## Functions
hal_i2c_state_t | hal_i2c_get_state (i2c_handle_t *p_i2c)
| Return the I2C handle state. More...
hal_i2c_mode_t | hal_i2c_get_mode (i2c_handle_t *p_i2c)
| Returns the I2C Master, Slave, Memory or no mode. More...
uint32_t | hal_i2c_get_error (i2c_handle_t *p_i2c)
| Return the I2C error code. More...
hal_status_t | hal_i2c_suspend_reg (i2c_handle_t *p_i2c)
| Suspend some registers related to I2C configuration before sleep. More...
hal_status_t | hal_i2c_resume_reg (i2c_handle_t *p_i2c)
| Restore some registers related to I2C configuration after sleep. This function must be used in conjunction with the hal_i2c_suspend_reg(). More...
hal_status_t | hal_i2c_timing_adjust (i2c_handle_t *p_i2c, uint32_t timing_type, int32_t delta)
| Adjust I2C timing value to adapt to real load. More...
hal_status_t | hal_i2c_timing_get (i2c_handle_t *p_i2c, uint32_t timing_type, uint32_t *p_timing_value)
| Get the I2C timing value. More...
hal_status_t | hal_i2c_master_transmit_receive (i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_tdata, uint16_t tsize, uint8_t *p_rdata, uint16_t rsize, uint32_t timeout)
| I2C MASTER transmit and receive data with only one bit. For Microsoft HID Over I2C protocol. More...
hal_status_t | hal_i2c_slave_receive_transmit (i2c_handle_t *p_i2c, uint8_t *p_tdata, uint16_t tsize, uint8_t *p_rdata, uint16_t rsize, uint32_t timeout)
| I2C SLAVE receive and transmit data with only one bit. Add for hal_i2c_master_transmit_receive. More...

## Detailed Description

Peripheral State, Mode and Error functions.

     ===============================================================================
                ##### Peripheral State, Mode and Error functions #####
     ===============================================================================
        [..]
        This subsection permit to get in run-time the status of the peripheral
        and the data flow.

## Function Documentation

## ◆ hal_i2c_get_error()

uint32_t hal_i2c_get_error | ( | i2c_handle_t * | p_i2c | ) |

Return the I2C error code.

Parameters

  [in] | p_i2c | Pointer to an I2C handle which contains the configuration information for the specified I2C.

Returns
  I2C Error Code

## ◆ hal_i2c_get_mode()

hal_i2c_mode_t hal_i2c_get_mode | ( | i2c_handle_t * | p_i2c | ) |

Returns the I2C Master, Slave, Memory or no mode.

Parameters

  [in] | p_i2c | Pointer to an I2C handle which contains the configuration information for the specified I2C.

Return values

  HAL_I2C_MODE_NONE | No I2C communication on going.
  HAL_I2C_MODE_MASTER | I2C communication is in Master Mode.
  HAL_I2C_MODE_SLAVE | I2C communication is in Slave Mode.
  HAL_I2C_MODE_MEM | I2C communication is in Memory Mode.

## ◆ hal_i2c_get_state()

hal_i2c_state_t hal_i2c_get_state | ( | i2c_handle_t * | p_i2c | ) |

Return the I2C handle state.

Parameters

  [in] | p_i2c | Pointer to an I2C handle which contains the configuration information for the specified I2C.

Return values

  HAL_I2C_STATE_RESET | Peripheral is not yet Initialized.
  HAL_I2C_STATE_READY | Peripheral Initialized and ready for use.
  HAL_I2C_STATE_BUSY | An internal process is ongoing.
  HAL_I2C_STATE_BUSY_TX | Data Transmission process is ongoing.
  HAL_I2C_STATE_BUSY_RX | Data Reception process is ongoing.
  HAL_I2C_STATE_LISTEN | Address Listen Mode is ongoing.
  HAL_I2C_STATE_BUSY_TX_LISTEN | Address Listen Mode and Data Transmission process is ongoing.
  HAL_I2C_STATE_BUSY_RX_LISTEN | Address Listen Mode and Data Reception process is ongoing.
  HAL_I2C_STATE_ABORT | Abort user request ongoing.
  HAL_I2C_STATE_TIMEOUT | Timeout state.
  HAL_I2C_STATE_ERROR | Error.

## ◆ hal_i2c_master_transmit_receive()

hal_status_t hal_i2c_master_transmit_receive | ( | i2c_handle_t * | p_i2c,
|  | uint16_t | dev_address,
|  | uint8_t * | p_tdata,
|  | uint16_t | tsize,
|  | uint8_t * | p_rdata,
|  | uint16_t | rsize,
|  | uint32_t | timeout
| ) |  |

I2C MASTER transmit and receive data with only one bit. For Microsoft HID Over I2C protocol.

Parameters

  [in] | p_i2c | Pointer to a I2C handle which contains the configuration
  [in] | dev_address | Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface
  [in] | p_tdata | Pointer to transmit data buffer
  [in] | tsize | Amount of data to be sent
  [in] | p_rdata | Pointer to receive data buffer
  [in] | rsize | Amount of data to be received
  [in] | timeout | Timeout duration

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error.

## ◆ hal_i2c_resume_reg()

hal_status_t hal_i2c_resume_reg | ( | i2c_handle_t * | p_i2c | ) |

Restore some registers related to I2C configuration after sleep. This function must be used in conjunction with the hal_i2c_suspend_reg().

Parameters

  [in] | p_i2c | Pointer to a I2C handle which contains the configuration information for the specified I2C module.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_i2c_slave_receive_transmit()

hal_status_t hal_i2c_slave_receive_transmit | ( | i2c_handle_t * | p_i2c,
|  | uint8_t * | p_tdata,
|  | uint16_t | tsize,
|  | uint8_t * | p_rdata,
|  | uint16_t | rsize,
|  | uint32_t | timeout
| ) |  |

I2C SLAVE receive and transmit data with only one bit. Add for hal_i2c_master_transmit_receive.

Parameters

  [in] | p_i2c | Pointer to a I2C handle which contains the configuration
  [in] | p_tdata | Pointer to transmit data buffer
  [in] | tsize | Amount of data to be sent
  [in] | p_rdata | Pointer to receive data buffer
  [in] | rsize | Amount of data to be received
  [in] | timeout | Timeout duration

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error.

## ◆ hal_i2c_suspend_reg()

hal_status_t hal_i2c_suspend_reg | ( | i2c_handle_t * | p_i2c | ) |

Suspend some registers related to I2C configuration before sleep.

Parameters

  [in] | p_i2c | Pointer to a I2C handle which contains the configuration information for the specified I2C module.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_i2c_timing_adjust()

hal_status_t hal_i2c_timing_adjust | ( | i2c_handle_t * | p_i2c,
|  | uint32_t | timing_type,
|  | int32_t | delta
| ) |  |

Adjust I2C timing value to adapt to real load.

Parameters

  [in] | p_i2c | Pointer to a I2C handle which contains the configuration information for the specified I2C module.
  [in] | timing_type | Timing type. See I2C_Timing_tpye.
  [in] | delta | timing change value(uinit: I2C work clock cycles).

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.

## ◆ hal_i2c_timing_get()

hal_status_t hal_i2c_timing_get | ( | i2c_handle_t * | p_i2c,
|  | uint32_t | timing_type,
|  | uint32_t * | p_timing_value
| ) |  |

Get the I2C timing value.

Parameters

  [in] | p_i2c | Pointer to a I2C handle which contains the configuration information for the specified I2C module.
  [in] | timing_type | Timing type. See I2C_Timing_tpye.
  [in] | p_timing_value | Pointer of I2C timing value(uinit: I2C work clock cycles).

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error.