Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
hal_i2c_master.h File Reference

API for I2C master HAL layer. More...

#include <stdbool.h>
#include <stdint.h>
#include "hal_target.h"
Include dependency graph for hal_i2c_master.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  hal_i2c_master_handle_register_t
 
struct  hal_i2c_master_config_t
 I2C Master HAL init configuration structure, consisted of the following fields : More...
 
struct  hal_i2c_master_t
 I2C Master HAL context structure, consisted of the following fields : More...
 

Enumerations

enum  hal_i2c_master_err_t { HAL_I2C_MASTER_SUCCESS = 0 , HAL_I2C_MASTER_WRONG_PINS , HAL_I2C_MASTER_MODULE_ERROR , HAL_I2C_MASTER_ERROR = (-1) }
 
enum  hal_i2c_master_timeout_t {
  HAL_I2C_MASTER_TIMEOUT_START = 1300 , HAL_I2C_MASTER_TIMEOUT_STOP , HAL_I2C_MASTER_TIMEOUT_WRITE , HAL_I2C_MASTER_TIMEOUT_READ ,
  HAL_I2C_MASTER_ARBITRATION_LOST , HAL_I2C_MASTER_TIMEOUT_INIT
}
 
enum  hal_i2c_master_speed_t { HAL_I2C_MASTER_SPEED_STANDARD = 0 , HAL_I2C_MASTER_SPEED_FULL , HAL_I2C_MASTER_SPEED_FAST }
 

Functions

err_t hal_i2c_master_open (handle_t *handle, bool hal_obj_open_state)
 Open the I2C Master HAL object. More...
 
void hal_i2c_master_set_slave_address (handle_t *handle, hal_i2c_master_config_t *config)
 Set I2C slave address. More...
 
err_t hal_i2c_master_write (handle_t handle, uint8_t *write_data_buf, size_t len_write_data)
 Write data to the I2C bus. More...
 
err_t hal_i2c_master_read (handle_t handle, uint8_t *read_data_buf, size_t len_read_data)
 Read data from the I2C bus. More...
 
err_t hal_i2c_master_write_then_read (handle_t handle, uint8_t *write_data_buf, size_t len_write_data, uint8_t *read_data_buf, size_t len_read_data)
 Write data followed by read. More...
 
err_t hal_i2c_master_close (handle_t *handle)
 Closes I2C Master HAL object. More...
 
void hal_i2c_master_configure_default (hal_i2c_master_config_t *config)
 Configure I2C Master HAL configuration structure. More...
 
err_t hal_i2c_master_set_speed (handle_t *handle, hal_i2c_master_config_t *config)
 Set I2C master module speed. More...
 
void hal_i2c_master_set_timeout (handle_t *handle, hal_i2c_master_config_t *config)
 Set I2C master timeout value. More...
 

Detailed Description

API for I2C master HAL layer.

Enumeration Type Documentation

◆ hal_i2c_master_err_t

Return values.

Enumerator
HAL_I2C_MASTER_SUCCESS 

Success.

HAL_I2C_MASTER_WRONG_PINS 

Wrong pins selected.

HAL_I2C_MASTER_MODULE_ERROR 

Object wasn't closed.

HAL_I2C_MASTER_ERROR 

Error.

◆ hal_i2c_master_speed_t

Predefined enum values for I2C transmission rates.

Enumerator
HAL_I2C_MASTER_SPEED_STANDARD 

Speed set at 100K.

HAL_I2C_MASTER_SPEED_FULL 

Speed set at 400K.

HAL_I2C_MASTER_SPEED_FAST 

Speed set at 1M.

◆ hal_i2c_master_timeout_t

Predefined enum values for timeout occurrences.

Enumerator
HAL_I2C_MASTER_TIMEOUT_START 

Start signal generation failed.

HAL_I2C_MASTER_TIMEOUT_STOP 

Stop signal generation failed.

HAL_I2C_MASTER_TIMEOUT_WRITE 

I2C bus write failed.

HAL_I2C_MASTER_TIMEOUT_READ 

I2C bus read failed.

HAL_I2C_MASTER_ARBITRATION_LOST 

I2C Master arbitration lost.

HAL_I2C_MASTER_TIMEOUT_INIT 

I2C HW initialization failed.