Classes | Macros | Typedefs | Enumerations | Functions
hal_i2c.h File Reference

Header file containing functions prototypes of I2C HAL library. More...

`#include "hal_dma.h"`
`#include "ll_i2c.h"`
`#include "hal_def.h"`
`#include "hal_pwr_mgmt.h"`

Go to the source code of this file.

## Classes
struct | _i2c_init
| I2C Configuration Structure definition. More...
struct | _i2c_handle
| I2C handle Structure definition. More...
struct | _hal_i2c_callback
| HAL_I2C Callback function definition. More...

## Macros
#define | HAL_I2C_ERROR_NONE (0x00000000U)
#define | HAL_I2C_ERROR_INVALID_PARAM (0x00000001U)
#define | HAL_I2C_ERROR_ARB_LOST (0x00000002U)
#define | HAL_I2C_ERROR_NOACK (0x00000004U)
#define | HAL_I2C_ERROR_OVER (0x00000008U)
#define | HAL_I2C_ERROR_SCL_STUCK_AT_LOW (0x00000010U)
#define | HAL_I2C_ERROR_SDA_STUCK_AT_LOW (0x00000020U)
#define | HAL_I2C_ERROR_DMA (0x00000040U)
#define | HAL_I2C_ERROR_TIMEOUT (0x00000080U)
#define | HAL_I2C_ERROR_NOTE (0x00000100U)
#define | I2C_SPEED_100K LL_I2C_SPEED_100K
#define | I2C_SPEED_400K LL_I2C_SPEED_400K
#define | I2C_SPEED_1000K LL_I2C_SPEED_1000K
#define | I2C_ADDRESSINGMODE_7BIT (0x00000001U)
#define | I2C_ADDRESSINGMODE_10BIT (0x00000002U)
#define | I2C_GENERALCALL_DISABLE (0x00000000U)
#define | I2C_GENERALCALL_ENABLE (0x00000001U)
#define | I2C_MEMADD_SIZE_8BIT (0x00000001U)
#define | I2C_MEMADD_SIZE_16BIT (0x00000002U)
#define | I2C_FIRST_FRAME (0x00000000U)
#define | I2C_FIRST_AND_NEXT_FRAME (0x00000001U)
#define | I2C_NEXT_FRAME (0x00000002U)
#define | I2C_FIRST_AND_LAST_FRAME (0x00000003U)
#define | I2C_LAST_FRAME (0x00000004U)
#define | I2C_DEFAULT_CONFIG
| I2C InitStruct default configuartion. More...
#define | __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_I2C_STATE_RESET)
| Reset I2C handle state. More...
#define | IS_I2C_SPEED(__SPEED__)
| Check if the I2C speed is valid. More...
#define | IS_I2C_ADDRESSING_MODE(__MODE__)
| Check if the I2C addressing mode is valid. More...
#define | IS_I2C_GENERAL_CALL(__CALL__)
| Check if the I2C general call mode is valid. More...
#define | IS_I2C_MEMADD_SIZE(__SIZE__)
| Check if the I2C memory address size is valid. More...
#define | IS_TRANSFER_REQUEST(__REQUEST__)
| Check if the I2C transfer request command is valid. More...
#define | IS_I2C_TRANSFER_OPTIONS_REQUEST(__REQUEST__)
| Check if the I2C transfer options request is valid. More...
#define | IS_I2C_SLV_ADDRESS(__ADDRESS__) ((__ADDRESS__) < 0x03FFU)
| Check if the I2C slave address is valid. More...
#define | IS_I2C_OWN_ADDRESS(__ADDRESS__)
| Check if the I2C own address is valid. More...
#define | I2C_MEM_ADD_MSB(__ADDRESS__) ((uint8_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0xFF00U))) >> 8U)))
| Get the Most Significant 8 Bits of memory address. More...
#define | I2C_MEM_ADD_LSB(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)(0x00FFU))))
| Get the Least Significant 8 Bits of memory address. More...

## Typedefs
typedef struct _i2c_init | i2c_init_t
| I2C Configuration Structure definition. More...
typedef struct _i2c_handle | i2c_handle_t
| I2C handle Structure definition. More...
typedef struct _hal_i2c_callback | hal_i2c_callback_t
| HAL_I2C Callback function definition. More...

## Enumerations
enum | hal_i2c_state_t { HAL_I2C_STATE_RESET = 0x00U, HAL_I2C_STATE_READY = 0x20U, HAL_I2C_STATE_BUSY = 0x24U, HAL_I2C_STATE_BUSY_TX = 0x21U, HAL_I2C_STATE_BUSY_RX = 0x22U, HAL_I2C_STATE_ABORT = 0x60U, HAL_I2C_STATE_TIMEOUT = 0xA0U, HAL_I2C_STATE_ERROR = 0xE0U }
| HAL I2C State Enumerations definition. More...
enum | hal_i2c_mode_t { HAL_I2C_MODE_NONE = 0x00U, HAL_I2C_MODE_MASTER = 0x10U, HAL_I2C_MODE_SLAVE = 0x20U }
| HAL I2C Mode Enumerations definition. More...

## Functions
hal_status_t | hal_i2c_init (i2c_handle_t *p_i2c)
| Initializes the I2C according to the specified parameters in the i2c_init_t and initialize the associated handle. More...
hal_status_t | hal_i2c_deinit (i2c_handle_t *p_i2c)
| De-initialize the I2C peripheral. More...
void | hal_i2c_msp_init (i2c_handle_t *p_i2c)
| Initialize the I2C MSP. More...
void | hal_i2c_msp_deinit (i2c_handle_t *p_i2c)
| De-initialize the I2C MSP. More...
hal_status_t | hal_i2c_master_transmit (i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size, uint32_t timeout)
| Transmits in master mode an amount of data in blocking mode. More...
hal_status_t | hal_i2c_master_receive (i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size, uint32_t timeout)
| Receives in master mode an amount of data in blocking mode. More...
hal_status_t | hal_i2c_slave_transmit (i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size, uint32_t timeout)
| Transmits in slave mode an amount of data in blocking mode. More...
hal_status_t | hal_i2c_slave_receive (i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size, uint32_t timeout)
| Receive in slave mode an amount of data in blocking mode. More...
hal_status_t | hal_i2c_mem_write (i2c_handle_t *p_i2c, 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...
hal_status_t | hal_i2c_mem_read (i2c_handle_t *p_i2c, 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...
hal_status_t | hal_i2c_master_transmit_it (i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size)
| Transmit in master mode an amount of data in non-blocking mode with Interrupt. More...
hal_status_t | hal_i2c_master_receive_it (i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size)
| Receive in master mode an amount of data in non-blocking mode with Interrupt. More...
hal_status_t | hal_i2c_slave_transmit_it (i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size)
| Transmit in slave mode an amount of data in non-blocking mode with Interrupt. More...
hal_status_t | hal_i2c_slave_receive_it (i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size)
| Receive in slave mode an amount of data in non-blocking mode with Interrupt. More...
hal_status_t | hal_i2c_mem_write_it (i2c_handle_t *p_i2c, 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 to a specific memory address. More...
hal_status_t | hal_i2c_mem_read_it (i2c_handle_t *p_i2c, 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 from a specific memory address. More...
hal_status_t | hal_i2c_master_abort_it (i2c_handle_t *p_i2c)
| Abort a master I2C IT or DMA process communication with Interrupt. More...
hal_status_t | hal_i2c_master_transmit_dma (i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size)
| Transmit in master mode an amount of data in non-blocking mode with DMA. More...
hal_status_t | hal_i2c_master_receive_dma (i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size)
| Receive in master mode an amount of data in non-blocking mode with DMA. More...
hal_status_t | hal_i2c_slave_transmit_dma (i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size)
| Transmit in slave mode an amount of data in non-blocking mode with DMA. More...
hal_status_t | hal_i2c_slave_receive_dma (i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size)
| Receive in slave mode an amount of data in non-blocking mode with DMA. More...
hal_status_t | hal_i2c_mem_write_dma (i2c_handle_t *p_i2c, 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 DMA to a specific memory address. More...
hal_status_t | hal_i2c_mem_read_dma (i2c_handle_t *p_i2c, uint16_t dev_address, uint16_t mem_address, uint16_t mem_addr_size, uint8_t *p_data, uint16_t size)
| Reads an amount of data in non-blocking mode with DMA from a specific memory address. More...
void | hal_i2c_irq_handler (i2c_handle_t *p_i2c)
| This function handles I2C event interrupt request. More...
void | hal_i2c_master_tx_cplt_callback (i2c_handle_t *p_i2c)
| Master Tx Transfer completed callback. More...
void | hal_i2c_master_rx_cplt_callback (i2c_handle_t *p_i2c)
| Master Rx Transfer completed callback. More...
void | hal_i2c_slave_tx_cplt_callback (i2c_handle_t *p_i2c)
| Slave Tx Transfer completed callback. More...
void | hal_i2c_slave_rx_cplt_callback (i2c_handle_t *p_i2c)
| Slave Rx Transfer completed callback. More...
void | hal_i2c_error_callback (i2c_handle_t *p_i2c)
| I2C error callback. More...
void | hal_i2c_abort_cplt_callback (i2c_handle_t *p_i2c)
| I2C abort callback. More...
hal_i2c_state_t | hal_i2c_get_state (const i2c_handle_t *p_i2c)
| Return the I2C handle state. More...
hal_i2c_mode_t | hal_i2c_get_mode (const i2c_handle_t *p_i2c)
| Returns the I2C Master, Slave, Memory or no mode. More...
uint32_t | hal_i2c_get_error (const i2c_handle_t *p_i2c)
| Return the I2C error code. More...
uint32_t | hal_i2c_sda_at_low_is_not_recovered (const i2c_handle_t *p_i2c)
| Return i2c sda at low is not recovered flag. More...
void | hal_i2c_suspend_reg (i2c_handle_t *p_i2c)
| Suspend some registers related to I2C configuration before sleep. More...
void | 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_pm_status_t | hal_pm_i2c_suspend (i2c_handle_t *p_i2c)
| Suspend the specified I2C. More...
void | hal_pm_i2c_resume (i2c_handle_t *p_i2c)
| Resume the specified I2C. More...
hal_status_t | hal_i2c_speed_config (i2c_handle_t *p_i2c, uint32_t speed, uint32_t scl_fall_time, uint32_t scl_rise_time)
| Configure the I2C transmit rate for I2C. More...

## Detailed Description

Header file containing functions prototypes of I2C HAL library.

Author
  BLE Driver Team

Attention
  #####Copyright (c) 2019 GOODIX All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of GOODIX nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file hal_i2c.h.