Functions
Functions
Peripheral Driver » APP DRIVER » IIC

## Functions
uint16_t | app_i2c_init (app_i2c_params_t *p_params, app_i2c_evt_handler_t evt_handler)
| Initialize the APP I2C DRIVER according to the specified parameters in the app_i2c_params_t and app_i2c_evt_handler_t. More...
uint16_t | app_i2c_deinit (app_i2c_id_t id)
| De-initialize the APP I2C DRIVER peripheral. More...
uint16_t | app_i2c_receive_sync (app_i2c_id_t id, uint16_t target_address, uint8_t *p_data, uint16_t size, uint32_t timeout)
| Receive in master or slave mode an amount of data in blocking mode. More...
uint16_t | app_i2c_receive_async (app_i2c_id_t id, uint16_t target_address, uint8_t *p_data, uint16_t size)
| Receive in master or slave mode an amount of data in non-blocking mode with Interrupt/DMA. More...
uint16_t | app_i2c_transmit_sync (app_i2c_id_t id, uint16_t target_address, uint8_t *p_data, uint16_t size, uint32_t timeout)
| Transmits in master or slave mode an amount of data in blocking mode. More...
uint16_t | app_i2c_transmit_async (app_i2c_id_t id, uint16_t target_address, uint8_t *p_data, uint16_t size)
| Transmits in master or slave mode an amount of data in non-blocking mode with Interrupt/DMA. More...
uint16_t | app_i2c_mem_read_sync (app_i2c_id_t id, uint16_t dev_address, uint16_t mem_address, uint16_t mem_addr_size, uint8_t *p_data, uint16_t size, uint32_t timeout)
| Read an amount of data in blocking mode from a specific memory address. More...
uint16_t | app_i2c_mem_read_async (app_i2c_id_t id, uint16_t dev_address, uint16_t mem_address, uint16_t mem_addr_size, uint8_t *p_data, uint16_t size)
| Read an amount of data in non-blocking mode with Interrupt/DMA from a specific memory address. More...
uint16_t | app_i2c_mem_write_sync (app_i2c_id_t id, uint16_t dev_address, uint16_t mem_address, uint16_t mem_addr_size, uint8_t *p_data, uint16_t size, uint32_t timeout)
| Write an amount of data in blocking mode to a specific memory address. More...
uint16_t | app_i2c_mem_write_async (app_i2c_id_t id, uint16_t dev_address, uint16_t mem_address, uint16_t mem_addr_size, uint8_t *p_data, uint16_t size)
| Write an amount of data in non-blocking mode with Interrupt/DMA to a specific memory address. More...
i2c_handle_t * | app_i2c_get_handle (app_i2c_id_t id)
| Return the I2C handle. More...
uint16_t | app_i2c_master_abort_it (app_i2c_id_t id)
| Abort a master I2C IT or DMA process communication with Interrupt. More...
uint16_t | app_i2c_timing_adjust (app_i2c_id_t id, uint32_t timing_type, int32_t delta)
| Adjust I2C timing value to adapt to real load. More...
uint16_t | app_i2c_timing_get (app_i2c_id_t id, uint32_t timing_type, uint32_t *p_timing_value)
| Get I2C timing value. More...
uint16_t | app_i2c_transmit_receive_sync (app_i2c_id_t id, uint16_t dev_address, uint8_t *p_tdata, uint16_t tsize, uint8_t *p_rdata, uint16_t rsize, uint32_t timeout)
| Transmits than receives in master mode or receives than transmits in slave mode with only one stop bit. More...
uint16_t | app_i2c_dma_init (app_i2c_params_t *p_params)
| Initialize the APP I2C DRIVER according to the specified parameters in the app_i2c_params_t and app_i2c_evt_handler_t. More...
uint16_t | app_i2c_dma_deinit (app_i2c_id_t id)
| De-initialize the APP I2C DRIVER peripheral. More...
uint16_t | app_i2c_dma_receive_async (app_i2c_id_t id, uint16_t target_address, uint8_t *p_data, uint16_t size)
| Receive in master or slave mode an amount of data in non-blocking mode with Interrupt/DMA. More...
uint16_t | app_i2c_dma_transmit_async (app_i2c_id_t id, uint16_t target_address, uint8_t *p_data, uint16_t size)
| Transmits in master or slave mode an amount of data in non-blocking mode with Interrupt/DMA. More...
uint16_t | app_i2c_dma_mem_read_async (app_i2c_id_t id, uint16_t dev_address, uint16_t mem_address, uint16_t mem_addr_size, uint8_t *p_data, uint16_t size)
| Read an amount of data in non-blocking mode with Interrupt/DMA from a specific memory address. More...
uint16_t | app_i2c_dma_mem_write_async (app_i2c_id_t id, uint16_t dev_address, uint16_t mem_address, uint16_t mem_addr_size, uint8_t *p_data, uint16_t size)
| Write an amount of data in non-blocking mode with Interrupt/DMA to a specific memory address. More...

## Detailed Description

## Function Documentation

## ◆ app_i2c_deinit()

uint16_t app_i2c_deinit | ( | app_i2c_id_t | id | ) |

De-initialize the APP I2C DRIVER peripheral.

Parameters

  [in] | id | De-initialize for a specific ID.

Returns
  Result of De-initialization.

## ◆ app_i2c_dma_deinit()

uint16_t app_i2c_dma_deinit | ( | app_i2c_id_t | id | ) |

De-initialize the APP I2C DRIVER peripheral.

Parameters

  [in] | id | De-initialize for a specific ID.

Returns
  Result of De-initialization.

## ◆ app_i2c_dma_init()

uint16_t app_i2c_dma_init | ( | app_i2c_params_t * | p_params | ) |

Initialize the APP I2C DRIVER according to the specified parameters in the app_i2c_params_t and app_i2c_evt_handler_t.

Note
  If interrupt mode is set, you can use blocking mode. Conversely, if blocking mode is set, you can't use interrupt mode.

Parameters

  [in] | p_params | Pointer to app_i2c_params_t parameter which contains the configuration information for the specified I2C module.

Returns
  Result of initialization.

## ◆ app_i2c_dma_mem_read_async()

uint16_t app_i2c_dma_mem_read_async | ( | app_i2c_id_t | id,
|  | uint16_t | dev_address,
|  | uint16_t | mem_address,
|  | uint16_t | mem_addr_size,
|  | uint8_t * | p_data,
|  | uint16_t | size
| ) |  |

Read an amount of data in non-blocking mode with Interrupt/DMA from a specific memory address.

Parameters

  [in] | id | which I2C module want to read.
  [in] | dev_address | Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface
  [in] | mem_address | Internal memory address
  [in] | mem_addr_size | Size of internal memory address
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent

Returns
  Result of operation.

## ◆ app_i2c_dma_mem_write_async()

uint16_t app_i2c_dma_mem_write_async | ( | app_i2c_id_t | id,
|  | uint16_t | dev_address,
|  | uint16_t | mem_address,
|  | uint16_t | mem_addr_size,
|  | uint8_t * | p_data,
|  | uint16_t | size
| ) |  |

Write an amount of data in non-blocking mode with Interrupt/DMA to a specific memory address.

Parameters

  [in] | id | which I2C module want to write.
  [in] | dev_address | Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface
  [in] | mem_address | Internal memory address
  [in] | mem_addr_size | Size of internal memory address
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent

Returns
  Result of operation.

## ◆ app_i2c_dma_receive_async()

uint16_t app_i2c_dma_receive_async | ( | app_i2c_id_t | id,
|  | uint16_t | target_address,
|  | uint8_t * | p_data,
|  | uint16_t | size
| ) |  |

Receive in master or slave mode an amount of data in non-blocking mode with Interrupt/DMA.

Parameters

  [in] | id | which I2C module want to receive.
  [in] | target_address | Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface.
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent

Returns
  Result of operation.

## ◆ app_i2c_dma_transmit_async()

uint16_t app_i2c_dma_transmit_async | ( | app_i2c_id_t | id,
|  | uint16_t | target_address,
|  | uint8_t * | p_data,
|  | uint16_t | size
| ) |  |

Transmits in master or slave mode an amount of data in non-blocking mode with Interrupt/DMA.

Parameters

  [in] | id | which I2C module want to transmit.
  [in] | target_address | Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface.
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent

Returns
  Result of operation.

## ◆ app_i2c_get_handle()

i2c_handle_t* app_i2c_get_handle | ( | app_i2c_id_t | id | ) |

Return the I2C handle.

Parameters

  [in] | id | I2C Channel ID.

Returns
  Pointer to the specified ID's I2C handle.

## ◆ app_i2c_init()

uint16_t app_i2c_init | ( | app_i2c_params_t * | p_params,
|  | app_i2c_evt_handler_t | evt_handler
| ) |  |

Initialize the APP I2C DRIVER according to the specified parameters in the app_i2c_params_t and app_i2c_evt_handler_t.

Note
  If interrupt mode is set, you can use blocking mode. Conversely, if blocking mode is set, you can't use interrupt mode.

Parameters

  [in] | p_params | Pointer to app_i2c_params_t parameter which contains the configuration information for the specified I2C module.
  [in] | evt_handler | I2C user callback function.

Returns
  Result of initialization.

## ◆ app_i2c_master_abort_it()

uint16_t app_i2c_master_abort_it | ( | app_i2c_id_t | id | ) |

Abort a master I2C IT or DMA process communication with Interrupt.

Parameters

  [in] | id | I2C Channel ID.

Returns
  Result of operation.

## ◆ app_i2c_mem_read_async()

uint16_t app_i2c_mem_read_async | ( | app_i2c_id_t | id,
|  | uint16_t | dev_address,
|  | uint16_t | mem_address,
|  | uint16_t | mem_addr_size,
|  | uint8_t * | p_data,
|  | uint16_t | size
| ) |  |

Read an amount of data in non-blocking mode with Interrupt/DMA from a specific memory address.

Parameters

  [in] | id | which I2C module want to read.
  [in] | dev_address | Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface
  [in] | mem_address | Internal memory address
  [in] | mem_addr_size | Size of internal memory address
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent

Returns
  Result of operation.

## ◆ app_i2c_mem_read_sync()

uint16_t app_i2c_mem_read_sync | ( | app_i2c_id_t | id,
|  | uint16_t | dev_address,
|  | uint16_t | mem_address,
|  | uint16_t | mem_addr_size,
|  | uint8_t * | p_data,
|  | uint16_t | size,
|  | uint32_t | timeout
| ) |  |

Read an amount of data in blocking mode from a specific memory address.

Parameters

  [in] | id | which I2C module want to read.
  [in] | dev_address | Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface
  [in] | mem_address | Internal memory address
  [in] | mem_addr_size | Size of internal memory address
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent
  [in] | timeout | Timeout duration

Returns
  Result of operation.

## ◆ app_i2c_mem_write_async()

uint16_t app_i2c_mem_write_async | ( | app_i2c_id_t | id,
|  | uint16_t | dev_address,
|  | uint16_t | mem_address,
|  | uint16_t | mem_addr_size,
|  | uint8_t * | p_data,
|  | uint16_t | size
| ) |  |

Write an amount of data in non-blocking mode with Interrupt/DMA to a specific memory address.

Parameters

  [in] | id | which I2C module want to write.
  [in] | dev_address | Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface
  [in] | mem_address | Internal memory address
  [in] | mem_addr_size | Size of internal memory address
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent

Returns
  Result of operation.

## ◆ app_i2c_mem_write_sync()

uint16_t app_i2c_mem_write_sync | ( | app_i2c_id_t | id,
|  | uint16_t | dev_address,
|  | uint16_t | mem_address,
|  | uint16_t | mem_addr_size,
|  | uint8_t * | p_data,
|  | uint16_t | size,
|  | uint32_t | timeout
| ) |  |

Write an amount of data in blocking mode to a specific memory address.

Parameters

  [in] | id | which I2C module want to write.
  [in] | dev_address | Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface
  [in] | mem_address | Internal memory address
  [in] | mem_addr_size | Size of internal memory address
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent
  [in] | timeout | Timeout duration

Returns
  Result of operation.

## ◆ app_i2c_receive_async()

uint16_t app_i2c_receive_async | ( | app_i2c_id_t | id,
|  | uint16_t | target_address,
|  | uint8_t * | p_data,
|  | uint16_t | size
| ) |  |

Receive in master or slave mode an amount of data in non-blocking mode with Interrupt/DMA.

Parameters

  [in] | id | which I2C module want to receive.
  [in] | target_address | Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface.
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent

Returns
  Result of operation.

## ◆ app_i2c_receive_sync()

uint16_t app_i2c_receive_sync | ( | app_i2c_id_t | id,
|  | uint16_t | target_address,
|  | uint8_t * | p_data,
|  | uint16_t | size,
|  | uint32_t | timeout
| ) |  |

Receive in master or slave mode an amount of data in blocking mode.

Parameters

  [in] | id | which I2C module want to receive.
  [in] | target_address | Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface.
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent
  [in] | timeout | Timeout duration

Returns
  Result of operation.

## ◆ app_i2c_timing_adjust()

uint16_t app_i2c_timing_adjust | ( | app_i2c_id_t | id,
|  | uint32_t | timing_type,
|  | int32_t | delta
| ) |  |

Adjust I2C timing value to adapt to real load.

Parameters

  [in] | id | I2C Channel ID.
  [in] | timing_type | Timing type. See I2C_Timing_type.
  [in] | delta | timing change value(unit: I2C work clock cycles).

Returns
  Result of operation.

## ◆ app_i2c_timing_get()

uint16_t app_i2c_timing_get | ( | app_i2c_id_t | id,
|  | uint32_t | timing_type,
|  | uint32_t * | p_timing_value
| ) |  |

Get I2C timing value.

Parameters

  [in] | id | I2C Channel ID.
  [in] | timing_type | Timing type. See I2C_Timing_type.
  [in] | p_timing_value | Pointer of I2C timing value(unit: I2C work clock cycles).

Returns
  Result of operation.

## ◆ app_i2c_transmit_async()

uint16_t app_i2c_transmit_async | ( | app_i2c_id_t | id,
|  | uint16_t | target_address,
|  | uint8_t * | p_data,
|  | uint16_t | size
| ) |  |

Transmits in master or slave mode an amount of data in non-blocking mode with Interrupt/DMA.

Parameters

  [in] | id | which I2C module want to transmit.
  [in] | target_address | Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface.
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent

Returns
  Result of operation.

## ◆ app_i2c_transmit_receive_sync()

uint16_t app_i2c_transmit_receive_sync | ( | app_i2c_id_t | id,
|  | uint16_t | dev_address,
|  | uint8_t * | p_tdata,
|  | uint16_t | tsize,
|  | uint8_t * | p_rdata,
|  | uint16_t | rsize,
|  | uint32_t | timeout
| ) |  |

Transmits than receives in master mode or receives than transmits in slave mode with only one stop bit.

Parameters

  [in] | id | which I2C module want to transmit.
  [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 received data buffer
  [in] | rsize | Amount of data to be receive
  [in] | timeout | Timeout duration

Returns
  Result of operation.

## ◆ app_i2c_transmit_sync()

uint16_t app_i2c_transmit_sync | ( | app_i2c_id_t | id,
|  | uint16_t | target_address,
|  | uint8_t * | p_data,
|  | uint16_t | size,
|  | uint32_t | timeout
| ) |  |

Transmits in master or slave mode an amount of data in blocking mode.

Parameters

  [in] | id | which I2C module want to transmit.
  [in] | target_address | Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface.
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent
  [in] | timeout | Timeout duration

Returns
  Result of operation.