Header file containing functions prototypes of I2C HAL library. More...
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) |
No error More... | |
#define | HAL_I2C_ERROR_ARB_LOST (0x00000002U) |
Arbitration lost error More... | |
#define | HAL_I2C_ERROR_NOACK (0x00000004U) |
No acknowledge error More... | |
#define | HAL_I2C_ERROR_OVER (0x00000008U) |
RX_OVER error More... | |
#define | HAL_I2C_ERROR_DMA (0x00000010U) |
DMA transfer error More... | |
#define | HAL_I2C_ERROR_TIMEOUT (0x00000020U) |
Timeout error More... | |
#define | I2C_SPEED_100K LL_I2C_SPEED_100K |
Standard speed. More... | |
#define | I2C_SPEED_400K LL_I2C_SPEED_400K |
Fast speed. More... | |
#define | I2C_SPEED_1000K LL_I2C_SPEED_1000K |
Fast Plus speed. More... | |
#define | I2C_SPEED_2000K LL_I2C_SPEED_2000K |
High speed. More... | |
#define | I2C_ADDRESSINGMODE_7BIT (0x00000001U) |
7-bit addressing mode. More... | |
#define | I2C_ADDRESSINGMODE_10BIT (0x00000002U) |
10-bit addressing mode. More... | |
#define | I2C_GENERALCALL_DISABLE (0x00000000U) |
General call mode disable. More... | |
#define | I2C_GENERALCALL_ENABLE (0x00000001U) |
General call mode enable. More... | |
#define | I2C_MEMADD_SIZE_8BIT (0x00000001U) |
8-bit memory address. More... | |
#define | I2C_MEMADD_SIZE_16BIT (0x00000002U) |
16-bit memory address. More... | |
#define | I2C_FIRST_FRAME (0x00000000U) |
First transfer frame. More... | |
#define | I2C_FIRST_AND_NEXT_FRAME (0x00000001U) |
First and next transfer frames. More... | |
#define | I2C_NEXT_FRAME (0x00000002U) |
Next transfer frame. More... | |
#define | I2C_FIRST_AND_LAST_FRAME (0x00000003U) |
First and last transfer frames. More... | |
#define | I2C_LAST_FRAME (0x00000004U) |
Last transfer frame. More... | |
#define | I2C_TIMING_SS_SCL_LOW (0x00000000U) |
Standard speed(0, 100K] SCL low time. More... | |
#define | I2C_TIMING_SS_SCL_HIGH (0x00000001U) |
Standard speed(0, 100K] SCL high time. More... | |
#define | I2C_TIMING_FS_SCL_LOW (0x00000002U) |
Fast and fast puls speed(100K, 1000K] SCL low time. More... | |
#define | I2C_TIMING_FS_SCL_HIGH (0x00000003U) |
Fast and fast puls speed(100K, 1000K] SCL high time. More... | |
#define | I2C_TIMING_HS_SCL_LOW (0x00000004U) |
High speed(1000K, 3400K] SCL low time. More... | |
#define | I2C_TIMING_HS_SCL_HIGH (0x00000005U) |
High speed(1000K, 3400K] SCL high time. More... | |
#define | I2C_TIMING_FS_SPK (0x00000006U) |
Fast and fast puls speed(100K, 1000K] spike suppression time. More... | |
#define | I2C_TIMING_HS_SPK (0x00000007U) |
High speed(1000K, 3400K] spike suppression time. More... | |
#define | I2C_TIMING_SDA_TX_HOLD (0x00000008U) |
SDA hold time when TX. More... | |
#define | I2C_TIMING_SDA_RX_HOLD (0x00000009U) |
SDA hold time when RX. More... | |
#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_LISTEN = 0x28U, HAL_I2C_STATE_BUSY_TX_LISTEN = 0x29U, HAL_I2C_STATE_BUSY_RX_LISTEN = 0x2AU, 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_MEM = 0x40U } |
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_sequential_transmit_it (i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size, uint32_t xfer_options) |
Sequentially transmit in master I2C mode an amount of data in non-blocking mode with Interrupt. More... | |
hal_status_t | hal_i2c_master_sequential_receive_it (i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size, uint32_t xfer_options) |
Sequentially receive in master I2C mode an amount of data in non-blocking mode with Interrupt. More... | |
hal_status_t | hal_i2c_slave_sequential_transmit_it (i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size, uint32_t xfer_options) |
Sequential transmit in slave/device I2C mode an amount of data in non-blocking mode with Interrupt. More... | |
hal_status_t | hal_i2c_slave_sequential_receive_it (i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size, uint32_t xfer_options) |
Sequential receive in slave/device I2C mode an amount of data in non-blocking mode with Interrupt. More... | |
hal_status_t | hal_i2c_enable_listen_it (i2c_handle_t *p_i2c) |
Enable the Master Read Request listen mode with Interrupt. More... | |
hal_status_t | hal_i2c_disable_listen_it (i2c_handle_t *p_i2c) |
Disable the Master Read Request listen mode with Interrupt. 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_mem_tx_cplt_callback (i2c_handle_t *p_i2c) |
Memory Tx Transfer completed callback. More... | |
void | hal_i2c_mem_rx_cplt_callback (i2c_handle_t *p_i2c) |
Memory Rx Transfer completed callback. More... | |
void | hal_i2c_listen_cplt_callback (i2c_handle_t *p_i2c) |
Listen Complete 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 (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. 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. 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. More... | |
Header file containing functions prototypes of I2C HAL library.
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 gr55xx_hal_i2c.h.