Skip to content

File hal_i2c_host.h

FileList > hal > hal_i2c_host.h

Go to the source code of this file

  • #include "assert.h"
  • #include "error_handling.h"
  • #include "i2c_common/i2c_platform_specific.h"

Public Types

Type Name
enum i2c_stop_bit_t

Public Functions

Type Name
void i2c_host_data_recv_irq (const void * hw, volatile bustransaction_t * transaction)
IRQ handler for I2C host data receive interrupt. Gets run when a host read action is executed. By defining this function inside a source file outside the Universal HALL, the default IRQ handler will be overridden and the compiler will automatically link your own custom implementation.
void i2c_host_data_send_irq (const void * hw, volatile bustransaction_t * transaction)
IRQ handler for I2C host data send interrupt. Gets run when a host write action is executed. By defining this function inside a -Obinarsource file outside the Universal HALL, the default IRQ handler will be overridden and the compiler will automatically link your own custom implementation.
uhal_status_t i2c_host_deinit (const i2c_periph_inst_t i2c_peripheral_num)
Function to de-initialize the specified HW peripheral (disables I2C on the HW peripheral).
uhal_status_t i2c_host_init (const i2c_periph_inst_t i2c_peripheral_num, const i2c_clock_sources_t clock_sources, const uint32_t periph_clk_freq, const uint32_t baud_rate_freq, const i2c_extra_opt_t extra_configuration_options)
Function to initialize the specified HW peripheral with I2C host functionality. To ensure platform compatibility use the default option as much as possible for each hw peripheral.
uhal_status_t i2c_host_read_blocking (const i2c_periph_inst_t i2c_peripheral_num, const uint16_t addr, uint8_t * read_buff, const size_t amount_of_bytes)
Function to execute a read blocking transaction (blocking means it will wait till the transaction is finished) This function does only work in host-mode.
uhal_status_t i2c_host_read_non_blocking (const i2c_periph_inst_t i2c_peripheral_num, const uint16_t addr, uint8_t * read_buff, const size_t amount_of_bytes)
Function to execute a read non-blocking transaction (non-blocking means it will not wait till the transaction is finished and stack the transactions in to a buffer) This function does only work in host-mode.
uhal_status_t i2c_host_write_blocking (const i2c_periph_inst_t i2c_peripheral_num, const uint16_t addr, const uint8_t * write_buff, const size_t size, const i2c_stop_bit_t stop_bit)
Function to execute a write blocking transaction (blocking means it will wait till the transaction is finished) This function does only work in host-mode.
uhal_status_t i2c_host_write_non_blocking (const i2c_periph_inst_t i2c_peripheral_num, const uint16_t addr, const uint8_t * write_buff, const size_t size, const i2c_stop_bit_t stop_bit)
Function to execute a write non-blocking transaction (non-blocking means it will not wait till the transaction is finished and stack them in a buffer or such) This function does only work in host-mode.

Macros

Type Name
define I2C_HOST_DEINIT (i2c_peripheral_num) /* multi line expression */
define I2C_HOST_INIT (i2c_peripheral_num, clock_sources, periph_clk_freq, baud_rate_freq, extra_configuration_options) /* multi line expression */
define I2C_HOST_READ_BLOCKING (i2c_peripheral_num, addr, read_buff, size) /* multi line expression */
define I2C_HOST_READ_NON_BLOCKING (i2c_peripheral_num, addr, read_buff, size) /* multi line expression */
define I2C_HOST_WRITE_BLOCKING (i2c_peripheral_num, addr, write_buff, size, stop_bit) /* multi line expression */
define I2C_HOST_WRITE_NON_BLOCKING (i2c_peripheral_num, addr, write_buff, size, stop_bit) /* multi line expression */

Public Types Documentation

enum i2c_stop_bit_t

enum i2c_stop_bit_t {
    I2C_NO_STOP_BIT,
    I2C_STOP_BIT
};

Public Functions Documentation

function i2c_host_data_recv_irq

IRQ handler for I2C host data receive interrupt. Gets run when a host read action is executed. By defining this function inside a source file outside the Universal HALL, the default IRQ handler will be overridden and the compiler will automatically link your own custom implementation.

void i2c_host_data_recv_irq (
    const void * hw,
    volatile bustransaction_t * transaction
) 

Parameters:

  • hw Handle to the HW peripheral on which the I2C bus is ran
  • transaction I2C transaction info about the current initialized transaction on the HW peripheral. The info will be automatically supplied when using the i2c_write and i2c_read functions below

Note:

Using your own custom IRQ handler might break the use of the write and read functions listed above


function i2c_host_data_send_irq

IRQ handler for I2C host data send interrupt. Gets run when a host write action is executed. By defining this function inside a -Obinarsource file outside the Universal HALL, the default IRQ handler will be overridden and the compiler will automatically link your own custom implementation.

void i2c_host_data_send_irq (
    const void * hw,
    volatile bustransaction_t * transaction
) 

Parameters:

  • hw Handle to the HW peripheral on which the I2C bus is ran
  • transaction I2C transaction info about the current initialized transaction on the HW peripheral. The info will be automatically supplied when using the i2c_write and i2c_read functions below.

Note:

Using your own custom IRQ handler might break the use of the write and read functions listed above


function i2c_host_deinit

Function to de-initialize the specified HW peripheral (disables I2C on the HW peripheral).

uhal_status_t i2c_host_deinit (
    const i2c_periph_inst_t i2c_peripheral_num
) 

Parameters:

  • i2c_peripheral_num I2C options used when configuring the HW peripheral.

function i2c_host_init

Function to initialize the specified HW peripheral with I2C host functionality. To ensure platform compatibility use the default option as much as possible for each hw peripheral.

uhal_status_t i2c_host_init (
    const i2c_periph_inst_t i2c_peripheral_num,
    const i2c_clock_sources_t clock_sources,
    const uint32_t periph_clk_freq,
    const uint32_t baud_rate_freq,
    const i2c_extra_opt_t extra_configuration_options
) 

Parameters:

  • i2c_peripheral_num The i2c peripheral to configure
  • clock_sources The clock source(s) to use..
  • periph_clk_freq The clock frequency of the peripheral (if multiple clocks are used this will be the fastest frequency).
  • baud_rate_freq The I2C Clock frequency to be used in transactions (only used in host mode, when in slave mode every value will be discarded).
  • extra_configuration_options The extra configuration options like: - DMA use
  • 4-Wire mode
  • IRQ priority

function i2c_host_read_blocking

Function to execute a read blocking transaction (blocking means it will wait till the transaction is finished) This function does only work in host-mode.

uhal_status_t i2c_host_read_blocking (
    const i2c_periph_inst_t i2c_peripheral_num,
    const uint16_t addr,
    uint8_t * read_buff,
    const size_t amount_of_bytes
) 

Parameters:

  • i2c_peripheral_num The i2c peripheral to use
  • addr The I2C address of the client device to write to
  • read_buff Pointer to the read buffer where all read bytes will be written
  • amount_of_bytes The amount of bytes which have to be read

function i2c_host_read_non_blocking

Function to execute a read non-blocking transaction (non-blocking means it will not wait till the transaction is finished and stack the transactions in to a buffer) This function does only work in host-mode.

uhal_status_t i2c_host_read_non_blocking (
    const i2c_periph_inst_t i2c_peripheral_num,
    const uint16_t addr,
    uint8_t * read_buff,
    const size_t amount_of_bytes
) 

Parameters:

  • i2c_peripheral_num The i2c peripheral to use
  • addr The I2C address of the client device to write to
  • read_buff Pointer to the read buffer where all read bytes will be written
  • amount_of_bytes The amount of bytes which have to be read

function i2c_host_write_blocking

Function to execute a write blocking transaction (blocking means it will wait till the transaction is finished) This function does only work in host-mode.

uhal_status_t i2c_host_write_blocking (
    const i2c_periph_inst_t i2c_peripheral_num,
    const uint16_t addr,
    const uint8_t * write_buff,
    const size_t size,
    const i2c_stop_bit_t stop_bit
) 

Parameters:

  • i2c_peripheral_num The i2c peripheral to use
  • addr The I2C address of the client device to write to
  • write_buff Pointer to the write buffer with all the bytes that have to be written
  • size The amount of bytes which have to be written
  • stop_bit Does this transaction end with or without a stop-bit: Value 1 is with stop-bit Value 0 is without stop-bit

function i2c_host_write_non_blocking

Function to execute a write non-blocking transaction (non-blocking means it will not wait till the transaction is finished and stack them in a buffer or such) This function does only work in host-mode.

uhal_status_t i2c_host_write_non_blocking (
    const i2c_periph_inst_t i2c_peripheral_num,
    const uint16_t addr,
    const uint8_t * write_buff,
    const size_t size,
    const i2c_stop_bit_t stop_bit
) 

Parameters:

  • i2c_peripheral_num The i2c peripheral to use
  • addr The I2C address of the client device to write to
  • write_buff Pointer to the write buffer with all the bytes that have to be written
  • size The amount of bytes which have to be written
  • stop_bit Does this transaction end with or without a stop-bit: Value 1 is with stop-bit Value 0 is without stop-bit

Macro Definition Documentation

define I2C_HOST_DEINIT

#define I2C_HOST_DEINIT (
    i2c_peripheral_num
) `/* multi line expression */`

define I2C_HOST_INIT

#define I2C_HOST_INIT (
    i2c_peripheral_num,
    clock_sources,
    periph_clk_freq,
    baud_rate_freq,
    extra_configuration_options
) `/* multi line expression */`

define I2C_HOST_READ_BLOCKING

#define I2C_HOST_READ_BLOCKING (
    i2c_peripheral_num,
    addr,
    read_buff,
    size
) `/* multi line expression */`

define I2C_HOST_READ_NON_BLOCKING

#define I2C_HOST_READ_NON_BLOCKING (
    i2c_peripheral_num,
    addr,
    read_buff,
    size
) `/* multi line expression */`

define I2C_HOST_WRITE_BLOCKING

#define I2C_HOST_WRITE_BLOCKING (
    i2c_peripheral_num,
    addr,
    write_buff,
    size,
    stop_bit
) `/* multi line expression */`

define I2C_HOST_WRITE_NON_BLOCKING

#define I2C_HOST_WRITE_NON_BLOCKING (
    i2c_peripheral_num,
    addr,
    write_buff,
    size,
    stop_bit
) `/* multi line expression */`


The documentation for this class was generated from the following file hal/hal_i2c_host.h