VSF Documented
Data Structures | Macros | Typedefs | Enumerations | Functions
vsf_template_i2c.h File Reference
#include "./vsf_template_hal_driver.h"
#include "hal/arch/vsf_arch.h"
#include "hal/driver/common/i2c/i2c_request.h"

Go to the source code of this file.

Data Structures

struct  vsf_i2c_status_t
 Predefined VSF I2C status that can be reimplemented in specific hal drivers. More...
 
struct  vsf_i2c_capability_t
 Predefined I2C capability structure that can be reimplemented in specific HAL drivers. More...
 
struct  vsf_i2c_isr_t
 I2C interrupt configuration. More...
 
struct  vsf_i2c_cfg_t
 I2C configuration. More...
 
struct  vsf_i2c_op_t
 I2C operation function pointers for multi-class support. More...
 
struct  vsf_i2c_t
 I2C instance structure for multi-class support. More...
 

Macros

#define VSF_I2C_CFG_MULTI_CLASS   ENABLED
 Enable multi-class support by default for maximum availability.
 
#define VSF_I2C_CFG_PREFIX   vsf
 In specific hardware drivers, either VSF_HW_I2C_COUNT or VSF_HW_I2C_MASK must be defined.
 
#define VSF_I2C_CFG_FUNCTION_RENAME   ENABLED
 Disable VSF_I2C_CFG_FUNCTION_RENAME to use original function names (e.g., vsf_i2c_init()) without prefix.
 
#define VSF_I2C_CFG_REIMPLEMENT_TYPE_MODE   DISABLED
 Enable macro VSF_I2C_CFG_REIMPLEMENT_TYPE_MODE in specific hardware drivers to redefine enum vsf_i2c_mode_t.
 
#define VSF_I2C_CFG_REIMPLEMENT_TYPE_CMD   DISABLED
 Enable macro VSF_I2C_CFG_REIMPLEMENT_TYPE_CMD in specific hardware drivers to redefine enum vsf_i2c_cmd_t.
 
#define VSF_I2C_CFG_REIMPLEMENT_TYPE_IRQ_MASK   DISABLED
 Enable macro VSF_I2C_CFG_REIMPLEMENT_TYPE_IRQ_MASK in specific hardware drivers to redefine enum vsf_i2c_irq_mask_t.
 
#define VSF_I2C_CFG_REIMPLEMENT_TYPE_STATUS   DISABLED
 Enable macro VSF_I2C_CFG_REIMPLEMENT_TYPE_STATUS in specific hardware drivers to redefine struct vsf_i2c_status_t. This allows hardware-specific status information to be included in the status structure.
 
#define VSF_I2C_CFG_REIMPLEMENT_TYPE_CTRL   DISABLED
 Enable macro VSF_I2C_CFG_REIMPLEMENT_TYPE_CTRL in specific hardware drivers to redefine enum vsf_i2c_ctrl_t. This allows hardware-specific control commands to be added to the control enumeration.
 
#define VSF_I2C_CFG_REIMPLEMENT_TYPE_CFG   DISABLED
 Enable macro VSF_I2C_CFG_REIMPLEMENT_TYPE_CFG in specific hardware drivers to redefine struct vsf_i2c_cfg_t. This allows hardware-specific configuration options to be added while maintaining compatibility with the base structure.
 
#define VSF_I2C_CFG_INHERIT_HAL_CAPABILITY   ENABLED
 Enable macro VSF_I2C_CFG_INHERIT_HAL_CAPABILITY in specific hardware drivers to incorporate HAL capability structure into vsf_i2c_capability_t.
 
#define VSF_I2C_APIS(__PREFIX_NAME)
 I2C API template, used to generate I2C type, specific prefix function declarations, etc.
 

Typedefs

typedef enum vsf_i2c_mode_t vsf_i2c_mode_t
 Predefined VSF I2C modes that can be reimplemented in specific HAL drivers.If we want to add optional modes in the specific driver, we need to provide one or more enum options, and a macro with the same name to determine if they are supported at runtime. If the feature supports more than one option, it also needs to provide the corresponding MASK option, so that the user can switch to different modes at compile-time.
 
typedef enum vsf_i2c_cmd_t vsf_i2c_cmd_t
 Predefined VSF I2C commands that can be reimplemented in specific HAL drivers.
 
typedef enum vsf_i2c_irq_mask_t vsf_i2c_irq_mask_t
 Predefined VSF I2C interrupt masks that can be reimplemented in specific HAL drivers.Even if the hardware doesn't support these interrupts, these interrupts must be kept:
 
typedef struct vsf_i2c_status_t vsf_i2c_status_t
 Predefined VSF I2C status that can be reimplemented in specific hal drivers.
 
typedef struct vsf_i2c_capability_t vsf_i2c_capability_t
 Predefined I2C capability structure that can be reimplemented in specific HAL drivers.
 
typedef struct vsf_i2c_t vsf_i2c_t
 I2C forward declaration.
 
typedef void vsf_i2c_isr_handler_t(void *target_ptr, vsf_i2c_t *i2c_ptr, vsf_i2c_irq_mask_t irq_mask)
 I2C interrupt callback function prototype.
 
typedef struct vsf_i2c_isr_t vsf_i2c_isr_t
 I2C interrupt configuration.
 
typedef struct vsf_i2c_cfg_t vsf_i2c_cfg_t
 I2C configuration.
 
typedef enum vsf_i2c_ctrl_t vsf_i2c_ctrl_t
 I2C control commands for hardware-specific operations.
 
typedef struct vsf_i2c_op_t vsf_i2c_op_t
 I2C operation function pointers for multi-class support.
 

Enumerations

enum  vsf_i2c_mode_t {
  VSF_I2C_MODE_MASTER = (0x1ul << 28) ,
  VSF_I2C_MODE_SLAVE = (0x0ul << 28) ,
  VSF_I2C_SPEED_STANDARD_MODE = (0x0ul << 29) ,
  VSF_I2C_SPEED_FAST_MODE = (0x1ul << 29) ,
  VSF_I2C_SPEED_FAST_MODE_PLUS = (0x2ul << 29) ,
  VSF_I2C_SPEED_HIGH_SPEED_MODE = (0x3ul << 29) ,
  VSF_I2C_ADDR_7_BITS = (0x0ul << 31) ,
  VSF_I2C_ADDR_10_BITS = (0x1ul << 31)
}
 Predefined VSF I2C modes that can be reimplemented in specific HAL drivers.If we want to add optional modes in the specific driver, we need to provide one or more enum options, and a macro with the same name to determine if they are supported at runtime. If the feature supports more than one option, it also needs to provide the corresponding MASK option, so that the user can switch to different modes at compile-time. More...
 
enum  {
  VSF_I2C_MODE_MASK ,
  VSF_I2C_SPEED_MASK ,
  VSF_I2C_ADDR_MASK ,
  VSF_I2C_MODE_ALL_BITS_MASK
}
 I2C mode masks for different operation modes and configurations. These masks are used to extract or set specific mode bits from the I2C mode value. More...
 
enum  vsf_i2c_cmd_t {
  VSF_I2C_CMD_WRITE = (0x00ul << 0) ,
  VSF_I2C_CMD_READ = (0x01ul << 0) ,
  VSF_I2C_CMD_START = (0x00ul << 28) ,
  VSF_I2C_CMD_STOP = (0x00ul << 29) ,
  VSF_I2C_CMD_RESTART = (0x01ul << 30) ,
  VSF_I2C_CMD_7_BITS = (0x00ul << 31) ,
  VSF_I2C_CMD_10_BITS = (0x01ul << 31)
}
 Predefined VSF I2C commands that can be reimplemented in specific HAL drivers. More...
 
enum  {
  VSF_I2C_CMD_RW_MASK = VSF_I2C_CMD_WRITE | VSF_I2C_CMD_READ ,
  VSF_I2C_CMD_BITS_MASK ,
  VSF_I2C_CMD_ALL_BITS_MASK
}
 I2C command masks for different command types and configurations. These masks are used to extract or set specific command bits. More...
 
enum  vsf_i2c_irq_mask_t {
  VSF_I2C_IRQ_MASK_MASTER_TX = (0x1ul << 0) ,
  VSF_I2C_IRQ_MASK_MASTER_RX = (0x1ul << 1) ,
  VSF_I2C_IRQ_MASK_MASTER_TRANSFER_COMPLETE = (0x1ul << 2) ,
  VSF_I2C_IRQ_MASK_MASTER_ARBITRATION_LOST = (0x1ul << 3) ,
  VSF_I2C_IRQ_MASK_MASTER_ADDRESS_NACK = (0x1ul << 4) ,
  VSF_I2C_IRQ_MASK_MASTER_TX_NACK_DETECT = (0x1ul << 5) ,
  VSF_I2C_IRQ_MASK_MASTER_ERR = (0x1ul << 6) ,
  VSF_I2C_IRQ_MASK_MASTER_START_OR_RESTART_DETECT = (0x1ul << 7) ,
  VSF_I2C_IRQ_MASK_MASTER_STOP_DETECT = (0x1ul << 8) ,
  VSF_I2C_IRQ_MASK_SLAVE_START_OR_RESTART_DETECT = (0x1ul << 9) ,
  VSF_I2C_IRQ_MASK_SLAVE_STOP_DETECT = (0x1ul << 10) ,
  VSF_I2C_IRQ_MASK_SLAVE_TX = (0x1ul << 11) ,
  VSF_I2C_IRQ_MASK_SLAVE_RX = (0x1ul << 12) ,
  VSF_I2C_IRQ_MASK_SLAVE_TRANSFER_COMPLETE = (0x1ul << 13) ,
  VSF_I2C_IRQ_MASK_SLAVE_ERR = (0x1ul << 14)
}
 Predefined VSF I2C interrupt masks that can be reimplemented in specific HAL drivers.Even if the hardware doesn't support these interrupts, these interrupts must be kept: More...
 
enum  { VSF_I2C_IRQ_ALL_BITS_MASK }
 
enum  vsf_i2c_ctrl_t { __VSF_I2C_CTRL_DUMMP = 0 }
 I2C control commands for hardware-specific operations. More...
 

Functions

vsf_err_t vsf_i2c_init (vsf_i2c_t *i2c_ptr, vsf_i2c_cfg_t *cfg_ptr)
 Initialize a I2C instance.
 
void vsf_i2c_fini (vsf_i2c_t *i2c_ptr)
 Finalize a I2C instance.
 
fsm_rt_t vsf_i2c_enable (vsf_i2c_t *i2c_ptr)
 Enable a I2C instance.
 
fsm_rt_t vsf_i2c_disable (vsf_i2c_t *i2c_ptr)
 Disable a I2C instance.
 
void vsf_i2c_irq_enable (vsf_i2c_t *i2c_ptr, vsf_i2c_irq_mask_t irq_mask)
 I2C instance enables interrupts.
 
void vsf_i2c_irq_disable (vsf_i2c_t *i2c_ptr, vsf_i2c_irq_mask_t irq_mask)
 I2C instance disables interrupts.
 
vsf_i2c_status_t vsf_i2c_status (vsf_i2c_t *i2c_ptr)
 Get the status of I2C instance.
 
vsf_i2c_capability_t vsf_i2c_capability (vsf_i2c_t *i2c_ptr)
 Get the capabilities of I2C instance.
 
void vsf_i2c_master_fifo_transfer (vsf_i2c_t *i2c_ptr, uint16_t address, vsf_i2c_cmd_t cmd, uint_fast16_t count, uint8_t *buffer_ptr, vsf_i2c_cmd_t *cur_cmd_ptr, uint_fast16_t *offset_ptr)
 I2C instance as master mode performs a FIFO transfer.
 
uint_fast16_t vsf_i2c_slave_fifo_transfer (vsf_i2c_t *i2c_ptr, bool transmit_or_receive, uint_fast16_t count, uint8_t *buffer_ptr)
 I2C instance as slave mode performs a FIFO transfer.
 
vsf_err_t vsf_i2c_master_request (vsf_i2c_t *i2c_ptr, uint16_t address, vsf_i2c_cmd_t cmd, uint_fast16_t count, uint8_t *buffer_ptr)
 I2C instance as master mode requests a transfer.
 
vsf_err_t vsf_i2c_slave_request (vsf_i2c_t *i2c_ptr, bool transmit_or_receive, uint_fast16_t count, uint8_t *buffer_ptr)
 I2C instance as slave mode requests a transfer.
 
uint_fast16_t vsf_i2c_master_get_transferred_count (vsf_i2c_t *i2c_ptr)
 get the counter of transfers for current request by the I2C master
 
uint_fast16_t vsf_i2c_slave_get_transferred_count (vsf_i2c_t *i2c_ptr)
 get the counter of transfers for current request by the I2C slave
 
vsf_err_t vsf_i2c_ctrl (vsf_i2c_t *i2c_ptr, vsf_i2c_ctrl_t ctrl, void *param)
 Calls the specified I2C command.
 

Macro Definition Documentation

◆ VSF_I2C_CFG_MULTI_CLASS

#define VSF_I2C_CFG_MULTI_CLASS   ENABLED

Enable multi-class support by default for maximum availability.

◆ VSF_I2C_CFG_PREFIX

#define VSF_I2C_CFG_PREFIX   vsf

In specific hardware drivers, either VSF_HW_I2C_COUNT or VSF_HW_I2C_MASK must be defined.

In specific hardware drivers, either VSF_HW_I2C_COUNT or VSF_HW_I2C_MASK must be defined.

Macro VSF_I2C_CFG_PREFIX can be redefined in application code to specify a prefix for directly calling a specific driver. This allows applications to access different I2C implementations through unique function names.

◆ VSF_I2C_CFG_FUNCTION_RENAME

#define VSF_I2C_CFG_FUNCTION_RENAME   ENABLED

Disable VSF_I2C_CFG_FUNCTION_RENAME to use original function names (e.g., vsf_i2c_init()) without prefix.

◆ VSF_I2C_CFG_REIMPLEMENT_TYPE_MODE

#define VSF_I2C_CFG_REIMPLEMENT_TYPE_MODE   DISABLED

Enable macro VSF_I2C_CFG_REIMPLEMENT_TYPE_MODE in specific hardware drivers to redefine enum vsf_i2c_mode_t.

◆ VSF_I2C_CFG_REIMPLEMENT_TYPE_CMD

#define VSF_I2C_CFG_REIMPLEMENT_TYPE_CMD   DISABLED

Enable macro VSF_I2C_CFG_REIMPLEMENT_TYPE_CMD in specific hardware drivers to redefine enum vsf_i2c_cmd_t.

◆ VSF_I2C_CFG_REIMPLEMENT_TYPE_IRQ_MASK

#define VSF_I2C_CFG_REIMPLEMENT_TYPE_IRQ_MASK   DISABLED

Enable macro VSF_I2C_CFG_REIMPLEMENT_TYPE_IRQ_MASK in specific hardware drivers to redefine enum vsf_i2c_irq_mask_t.

◆ VSF_I2C_CFG_REIMPLEMENT_TYPE_STATUS

#define VSF_I2C_CFG_REIMPLEMENT_TYPE_STATUS   DISABLED

Enable macro VSF_I2C_CFG_REIMPLEMENT_TYPE_STATUS in specific hardware drivers to redefine struct vsf_i2c_status_t. This allows hardware-specific status information to be included in the status structure.

◆ VSF_I2C_CFG_REIMPLEMENT_TYPE_CTRL

#define VSF_I2C_CFG_REIMPLEMENT_TYPE_CTRL   DISABLED

Enable macro VSF_I2C_CFG_REIMPLEMENT_TYPE_CTRL in specific hardware drivers to redefine enum vsf_i2c_ctrl_t. This allows hardware-specific control commands to be added to the control enumeration.

◆ VSF_I2C_CFG_REIMPLEMENT_TYPE_CFG

#define VSF_I2C_CFG_REIMPLEMENT_TYPE_CFG   DISABLED

Enable macro VSF_I2C_CFG_REIMPLEMENT_TYPE_CFG in specific hardware drivers to redefine struct vsf_i2c_cfg_t. This allows hardware-specific configuration options to be added while maintaining compatibility with the base structure.

◆ VSF_I2C_CFG_INHERIT_HAL_CAPABILITY

#define VSF_I2C_CFG_INHERIT_HAL_CAPABILITY   ENABLED

Enable macro VSF_I2C_CFG_INHERIT_HAL_CAPABILITY in specific hardware drivers to incorporate HAL capability structure into vsf_i2c_capability_t.

◆ VSF_I2C_APIS

#define VSF_I2C_APIS (   __PREFIX_NAME)
Value:
__VSF_HAL_TEMPLATE_API(__PREFIX_NAME, vsf_err_t, i2c, init, VSF_MCONNECT(__PREFIX_NAME, _i2c_t) *i2c_ptr, vsf_i2c_cfg_t *cfg_ptr) \
__VSF_HAL_TEMPLATE_API(__PREFIX_NAME, void, i2c, fini, VSF_MCONNECT(__PREFIX_NAME, _i2c_t) *i2c_ptr) \
__VSF_HAL_TEMPLATE_API(__PREFIX_NAME, fsm_rt_t, i2c, enable, VSF_MCONNECT(__PREFIX_NAME, _i2c_t) *i2c_ptr) \
__VSF_HAL_TEMPLATE_API(__PREFIX_NAME, fsm_rt_t, i2c, disable, VSF_MCONNECT(__PREFIX_NAME, _i2c_t) *i2c_ptr) \
__VSF_HAL_TEMPLATE_API(__PREFIX_NAME, void, i2c, irq_enable, VSF_MCONNECT(__PREFIX_NAME, _i2c_t) *i2c_ptr, vsf_i2c_irq_mask_t irq_mask) \
__VSF_HAL_TEMPLATE_API(__PREFIX_NAME, void, i2c, irq_disable, VSF_MCONNECT(__PREFIX_NAME, _i2c_t) *i2c_ptr, vsf_i2c_irq_mask_t irq_mask) \
__VSF_HAL_TEMPLATE_API(__PREFIX_NAME, vsf_i2c_status_t, i2c, status, VSF_MCONNECT(__PREFIX_NAME, _i2c_t) *i2c_ptr) \
__VSF_HAL_TEMPLATE_API(__PREFIX_NAME, vsf_i2c_capability_t, i2c, capability, VSF_MCONNECT(__PREFIX_NAME, _i2c_t) *i2c_ptr) \
__VSF_HAL_TEMPLATE_API(__PREFIX_NAME, void, i2c, master_fifo_transfer, VSF_MCONNECT(__PREFIX_NAME, _i2c_t) *i2c_ptr, uint16_t address, \
vsf_i2c_cmd_t cmd, uint_fast16_t count, uint8_t* buffer_ptr, vsf_i2c_cmd_t *cur_cmd_ptr, uint_fast16_t *offset_ptr) \
__VSF_HAL_TEMPLATE_API(__PREFIX_NAME, vsf_err_t, i2c, master_request, VSF_MCONNECT(__PREFIX_NAME, _i2c_t) *i2c_ptr, uint16_t address, \
vsf_i2c_cmd_t cmd, uint_fast16_t count, uint8_t* buffer_ptr) \
__VSF_HAL_TEMPLATE_API(__PREFIX_NAME, uint_fast16_t, i2c, master_get_transferred_count, VSF_MCONNECT(__PREFIX_NAME, _i2c_t) *i2c_ptr) \
__VSF_HAL_TEMPLATE_API(__PREFIX_NAME, uint_fast16_t, i2c, slave_fifo_transfer, VSF_MCONNECT(__PREFIX_NAME, _i2c_t) *i2c_ptr, bool transmit_or_receive, \
uint_fast16_t count, uint8_t* buffer_ptr) \
__VSF_HAL_TEMPLATE_API(__PREFIX_NAME, vsf_err_t, i2c, slave_request, VSF_MCONNECT(__PREFIX_NAME, _i2c_t) *i2c_ptr, bool transmit_or_receive, \
uint_fast16_t count, uint8_t* buffer_ptr) \
__VSF_HAL_TEMPLATE_API(__PREFIX_NAME, uint_fast16_t, i2c, slave_get_transferred_count, VSF_MCONNECT(__PREFIX_NAME, _i2c_t) *i2c_ptr) \
__VSF_HAL_TEMPLATE_API(__PREFIX_NAME, vsf_err_t, i2c, ctrl, VSF_MCONNECT(__PREFIX_NAME, _i2c_t) *i2c_ptr, vsf_i2c_ctrl_t ctrl, void* param)
vsf_err_t
Definition __type.h:42
struct VSF_MCONNECT(VSF_FLASH_CFG_IMP_PREFIX, _flash_t)
Definition flash.c:53
vsf_i2c_cmd_t
Definition i2c.h:32
__le16 capability
Definition ieee80211.h:134
const i_spi_t vsf_spi_irq_mask_t irq_mask
Definition spi_interface.h:38
unsigned short uint16_t
Definition stdint.h:7
unsigned short uint_fast16_t
Definition stdint.h:25
unsigned char uint8_t
Definition stdint.h:5
Predefined I2C capability structure that can be reimplemented in specific HAL drivers.
Definition vsf_template_i2c.h:777
I2C configuration.
Definition vsf_template_i2c.h:881
Predefined VSF I2C status that can be reimplemented in specific hal drivers.
Definition vsf_template_i2c.h:757
fsm_rt_t
Definition vsf_fsm.h:315
vsf_i2c_ctrl_t
I2C control commands for hardware-specific operations.
Definition vsf_template_i2c.h:909
vsf_i2c_irq_mask_t
Predefined VSF I2C interrupt masks that can be reimplemented in specific HAL drivers....
Definition vsf_template_i2c.h:537
#define __VSF_HAL_TEMPLATE_API
Definition vsf_template_instance_declaration.h:57
uint8_t status
Definition vsf_tgui.h:144

I2C API template, used to generate I2C type, specific prefix function declarations, etc.

Typedef Documentation

◆ vsf_i2c_mode_t

Predefined VSF I2C modes that can be reimplemented in specific HAL drivers.If we want to add optional modes in the specific driver, we need to provide one or more enum options, and a macro with the same name to determine if they are supported at runtime. If the feature supports more than one option, it also needs to provide the corresponding MASK option, so that the user can switch to different modes at compile-time.

◆ vsf_i2c_cmd_t

Predefined VSF I2C commands that can be reimplemented in specific HAL drivers.

◆ vsf_i2c_irq_mask_t

Predefined VSF I2C interrupt masks that can be reimplemented in specific HAL drivers.Even if the hardware doesn't support these interrupts, these interrupts must be kept:

◆ vsf_i2c_status_t

Predefined VSF I2C status that can be reimplemented in specific hal drivers.

◆ vsf_i2c_capability_t

Predefined I2C capability structure that can be reimplemented in specific HAL drivers.

Note
This structure defines the capabilities supported by the I2C interface.

◆ vsf_i2c_t

typedef struct vsf_i2c_t vsf_i2c_t

I2C forward declaration.

◆ vsf_i2c_isr_handler_t

typedef void vsf_i2c_isr_handler_t(void *target_ptr, vsf_i2c_t *i2c_ptr, vsf_i2c_irq_mask_t irq_mask)

I2C interrupt callback function prototype.

Note
It is called after interrupt occurs.
Parameters
target_ptrpointer of user.
i2c_ptrpointer of I2C instance.
irq_maskone or more value of enum vsf_i2c_irq_mask_t
Returns
None.
static void __user_i2c_irqhandler(void *target_ptr, vsf_i2c_t *i2c_ptr, enum irq_mask)
{
if (irq_mask & VSF_I2C_IRQ_MASK_MASTER_STARTED) {
// do something
}
if (irq_mask & VSF_I2C_IRQ_MASK_MASTER_STOPPED) {
// do something
}
}
I2C instance structure for multi-class support.
Definition vsf_template_i2c.h:976

◆ vsf_i2c_isr_t

typedef struct vsf_i2c_isr_t vsf_i2c_isr_t

I2C interrupt configuration.

◆ vsf_i2c_cfg_t

typedef struct vsf_i2c_cfg_t vsf_i2c_cfg_t

I2C configuration.

◆ vsf_i2c_ctrl_t

I2C control commands for hardware-specific operations.

Note
These commands provide additional control beyond basic data transfer

◆ vsf_i2c_op_t

typedef struct vsf_i2c_op_t vsf_i2c_op_t

I2C operation function pointers for multi-class support.

Note
These function pointers define the interface for I2C operations.

Enumeration Type Documentation

◆ vsf_i2c_mode_t

Predefined VSF I2C modes that can be reimplemented in specific HAL drivers.If we want to add optional modes in the specific driver, we need to provide one or more enum options, and a macro with the same name to determine if they are supported at runtime. If the feature supports more than one option, it also needs to provide the corresponding MASK option, so that the user can switch to different modes at compile-time.

Enumerator
VSF_I2C_MODE_MASTER 

Select master mode for I2C operation. The device initiates and controls the I2C bus communication.

VSF_I2C_MODE_SLAVE 

Select slave mode for I2C operation. The device responds to I2C bus commands from master devices.

VSF_I2C_SPEED_STANDARD_MODE 

Standard mode, up to 100 kbit/s. The lowest I2C speed specification, compatible with most devices.

VSF_I2C_SPEED_FAST_MODE 

Fast mode, up to 400 kbit/s. Commonly used medium speed I2C mode.

VSF_I2C_SPEED_FAST_MODE_PLUS 

Fast mode plus, up to 1 Mbit/s. Enhanced fast mode for higher throughput applications.

VSF_I2C_SPEED_HIGH_SPEED_MODE 

High speed mode, up to 3.4 Mbit/s. Highest specified I2C speed for performance-critical applications.

VSF_I2C_ADDR_7_BITS 

7-bit address mode. Standard addressing mode supporting up to 128 unique devices.

VSF_I2C_ADDR_10_BITS 

10-bit address mode. Extended addressing mode supporting up to 1024 unique devices.

◆ anonymous enum

anonymous enum

I2C mode masks for different operation modes and configurations. These masks are used to extract or set specific mode bits from the I2C mode value.

Enumerator
VSF_I2C_MODE_MASK 

Mask for master/slave mode selection. Extracts VSF_I2C_MODE_MASTER and VSF_I2C_MODE_SLAVE bits.

VSF_I2C_SPEED_MASK 

Mask for I2C speed mode configuration. Extracts all speed mode bits (standard, fast, fast plus, high speed).

VSF_I2C_ADDR_MASK 

Mask for I2C address mode selection. Extracts VSF_I2C_ADDR_7_BITS and VSF_I2C_ADDR_10_BITS bits.

VSF_I2C_MODE_ALL_BITS_MASK 

Combined mask for all I2C mode configuration bits. Includes mode, speed, and address mode masks.

◆ vsf_i2c_cmd_t

Predefined VSF I2C commands that can be reimplemented in specific HAL drivers.

Enumerator
VSF_I2C_CMD_WRITE 

Write command for I2C data transfer. Used to write data on the I2C bus.

VSF_I2C_CMD_READ 

Read command for I2C data transfer. Used to read data from the I2C bus.

VSF_I2C_CMD_START 

Start condition command. Generates a START condition on the I2C bus to begin a new transaction.

VSF_I2C_CMD_STOP 

Stop condition command. Generates a STOP condition on the I2C bus to end the current transaction.

VSF_I2C_CMD_RESTART 

Restart condition command. Generates a repeated START condition without releasing the bus. Used for changing direction or slave address within a transaction.

VSF_I2C_CMD_7_BITS 

7-bit addressing mode command. Configures the I2C transaction to use 7-bit slave addressing.

VSF_I2C_CMD_10_BITS 

10-bit addressing mode command. Configures the I2C transaction to use 10-bit slave addressing.

◆ anonymous enum

anonymous enum

I2C command masks for different command types and configurations. These masks are used to extract or set specific command bits.

Enumerator
VSF_I2C_CMD_RW_MASK 

Mask for read/write command selection. Extracts VSF_I2C_CMD_WRITE and VSF_I2C_CMD_READ bits.

VSF_I2C_CMD_BITS_MASK 

Mask for I2C address bits configuration. Extracts VSF_I2C_CMD_7_BITS and VSF_I2C_CMD_10_BITS bits.

VSF_I2C_CMD_ALL_BITS_MASK 

Combined mask for all I2C command bits. Includes read/write, start/stop/restart, and address bits masks.

◆ vsf_i2c_irq_mask_t

Predefined VSF I2C interrupt masks that can be reimplemented in specific HAL drivers.Even if the hardware doesn't support these interrupts, these interrupts must be kept:

Enumerator
VSF_I2C_IRQ_MASK_MASTER_TX 

Master mode: Transmit FIFO threshold interrupt. Triggered when transmit FIFO level falls below threshold in master mode. Note: Some devices have fixed threshold of 1. Only valid in master mode.

VSF_I2C_IRQ_MASK_MASTER_RX 

Master mode: Receive FIFO threshold interrupt. Triggered when receive FIFO level exceeds threshold in master mode. Note: Some devices have fixed threshold of 1. Only valid in master mode.

VSF_I2C_IRQ_MASK_MASTER_TRANSFER_COMPLETE 

Master mode: Transfer completion interrupt. Triggered when the current transfer operation is completed in master mode. Only valid in master mode.

VSF_I2C_IRQ_MASK_MASTER_ARBITRATION_LOST 

Master mode: Arbitration lost interrupt. Triggered when the master loses arbitration in multi-master mode. Only valid in master mode.

VSF_I2C_IRQ_MASK_MASTER_ADDRESS_NACK 

Master mode: Address NACK detection interrupt. Triggered when a NACK is received after sending the address in master mode. Only valid in master mode.

VSF_I2C_IRQ_MASK_MASTER_TX_NACK_DETECT 

Master mode: data transmit NACK detection interrupt. Triggered when a NACK is received during master transmission. Only valid in master mode.

VSF_I2C_IRQ_MASK_MASTER_ERR 

Master mode: Error interrupt. Triggered on any error condition in master mode. Only valid in master mode.

VSF_I2C_IRQ_MASK_MASTER_START_OR_RESTART_DETECT 

Slave mode: START or RESTART condition detection interrupt. Triggered when START condition is detected while in slave mode. Only valid in slave mode.

VSF_I2C_IRQ_MASK_MASTER_STOP_DETECT 

Master mode: Start condition detection interrupt. Triggered when the master device generates a START condition on the I2C bus. Only valid in master mode.

VSF_I2C_IRQ_MASK_SLAVE_START_OR_RESTART_DETECT 

Slave mode: Repeated START condition detection interrupt. Triggered when repeated START condition is detected while in slave mode. Only valid in slave mode.

VSF_I2C_IRQ_MASK_SLAVE_STOP_DETECT 

Slave mode: STOP condition detection interrupt. Triggered when STOP condition is detected while in slave mode. Only valid in slave mode.

VSF_I2C_IRQ_MASK_SLAVE_TX 

Slave mode: Transmit FIFO threshold interrupt. Triggered when transmit FIFO level falls below threshold in slave mode. Note: Some devices have fixed threshold of 1. Only valid in slave mode.

VSF_I2C_IRQ_MASK_SLAVE_RX 

Slave mode: Receive FIFO threshold interrupt. Triggered when receive FIFO level exceeds threshold in slave mode. Note: Some devices have fixed threshold of 1. Only valid in slave mode.

VSF_I2C_IRQ_MASK_SLAVE_TRANSFER_COMPLETE 

Slave mode: Transfer completion interrupt. Triggered when the current transfer operation is completed in slave mode. Only valid in slave mode.

VSF_I2C_IRQ_MASK_SLAVE_ERR 

Slave mode: Error interrupt. Triggered on any error condition in slave mode. Only valid in slave mode.

◆ anonymous enum

anonymous enum
Enumerator
VSF_I2C_IRQ_ALL_BITS_MASK 

◆ vsf_i2c_ctrl_t

I2C control commands for hardware-specific operations.

Note
These commands provide additional control beyond basic data transfer
Enumerator
__VSF_I2C_CTRL_DUMMP 

Placeholder enum member to avoid empty enum error

Function Documentation

◆ vsf_i2c_init()

vsf_err_t vsf_i2c_init ( vsf_i2c_t i2c_ptr,
vsf_i2c_cfg_t cfg_ptr 
)
extern

Initialize a I2C instance.

Parameters
[in]i2c_ptra pointer to structure vsf_i2c_t
[in]cfg_ptra pointer to configuration structure vsf_i2c_cfg_t
Returns
vsf_err_t: VSF_ERR_NONE if initialization successful, otherwise returns error code
Note
It is not necessary to call vsf_i2c_fini() to deinitialization. vsf_i2c_init() should be called before any other I2C API except vsf_i2c_capability().

◆ vsf_i2c_fini()

void vsf_i2c_fini ( vsf_i2c_t i2c_ptr)
extern

Finalize a I2C instance.

Parameters
[in]i2c_ptra pointer to structure vsf_i2c_t
Returns
none

◆ vsf_i2c_enable()

fsm_rt_t vsf_i2c_enable ( vsf_i2c_t i2c_ptr)
extern

Enable a I2C instance.

Parameters
[in]i2c_ptra pointer to structure vsf_i2c_t
Returns
fsm_rt_t: fsm_rt_cpl if I2C was enabled, fsm_rt_on_going if I2C is still enabling

◆ vsf_i2c_disable()

fsm_rt_t vsf_i2c_disable ( vsf_i2c_t i2c_ptr)
extern

Disable a I2C instance.

Parameters
[in]i2c_ptra pointer to structure vsf_i2c_t
Returns
fsm_rt_t: fsm_rt_cpl if I2C was disabled, fsm_rt_on_going if I2C is still disabling

◆ vsf_i2c_irq_enable()

void vsf_i2c_irq_enable ( vsf_i2c_t i2c_ptr,
vsf_i2c_irq_mask_t  irq_mask 
)
extern

I2C instance enables interrupts.

Parameters
[in]i2c_ptra pointer to structure vsf_i2c_t
[in]irq_maskone or more values of enum vsf_i2c_irq_mask_t
Returns
none

◆ vsf_i2c_irq_disable()

void vsf_i2c_irq_disable ( vsf_i2c_t i2c_ptr,
vsf_i2c_irq_mask_t  irq_mask 
)
extern

I2C instance disables interrupts.

Parameters
[in]i2c_ptra pointer to structure vsf_i2c_t
[in]irq_maskone or more values of enum vsf_i2c_irq_mask_t
Returns
none

◆ vsf_i2c_status()

vsf_i2c_status_t vsf_i2c_status ( vsf_i2c_t i2c_ptr)
extern

Get the status of I2C instance.

Parameters
[in]i2c_ptra pointer to structure vsf_i2c_t
Returns
vsf_i2c_status_t: all status of current I2C

◆ vsf_i2c_capability()

vsf_i2c_capability_t vsf_i2c_capability ( vsf_i2c_t i2c_ptr)
extern

Get the capabilities of I2C instance.

Parameters
[in]i2c_ptra pointer to structure vsf_i2c_t
Returns
vsf_i2c_capability_t: all capabilities of current I2C vsf_i2c_capability_t

◆ vsf_i2c_master_fifo_transfer()

void vsf_i2c_master_fifo_transfer ( vsf_i2c_t i2c_ptr,
uint16_t  address,
vsf_i2c_cmd_t  cmd,
uint_fast16_t  count,
uint8_t buffer_ptr,
vsf_i2c_cmd_t cur_cmd_ptr,
uint_fast16_t offset_ptr 
)
extern

I2C instance as master mode performs a FIFO transfer.

Parameters
[in,out]i2c_ptra pointer to structure vsf_i2c_t
[in]addressaddress of I2C transfer
[in]cmdI2C command
[in]countnumber of data to transfer
[in,out]buffer_ptrI2C transfer buffer
[in,out]cur_cmd_ptrcurrent I2C command pointer
[in,out]offset_ptrcurrent offset pointer
Returns
uint_fast16_t: number of bytes transferred from current I2C

◆ vsf_i2c_slave_fifo_transfer()

uint_fast16_t vsf_i2c_slave_fifo_transfer ( vsf_i2c_t i2c_ptr,
bool  transmit_or_receive,
uint_fast16_t  count,
uint8_t buffer_ptr 
)
extern

I2C instance as slave mode performs a FIFO transfer.

Parameters
[in,out]i2c_ptra pointer to structure vsf_i2c_t
[in]transmit_or_receivetrue for transmit, false for receive
[in]countnumber of data to transfer
[in,out]buffer_ptrI2C transfer buffer
[in,out]offset_ptrcurrent offset pointer
Returns
uint_fast16_t: number of bytes transferred from current I2C

◆ vsf_i2c_master_request()

vsf_err_t vsf_i2c_master_request ( vsf_i2c_t i2c_ptr,
uint16_t  address,
vsf_i2c_cmd_t  cmd,
uint_fast16_t  count,
uint8_t buffer_ptr 
)
extern

I2C instance as master mode requests a transfer.

Parameters
[in,out]i2c_ptra pointer to structure vsf_i2c_t
[in]addressaddress of I2C transfer
[in]cmdI2C command
[in]countnumber of data to transfer
[in,out]buffer_ptrI2C transfer buffer
Returns
vsf_err_t: VSF_ERR_NONE if successful, or a negative error code

◆ vsf_i2c_slave_request()

vsf_err_t vsf_i2c_slave_request ( vsf_i2c_t i2c_ptr,
bool  transmit_or_receive,
uint_fast16_t  count,
uint8_t buffer_ptr 
)
extern

I2C instance as slave mode requests a transfer.

Parameters
[in,out]i2c_ptra pointer to structure vsf_i2c_t
[in]transmit_or_receivetrue for transmit, false for receive
[in]countnumber of data to transfer
[in,out]buffer_ptrI2C transfer buffer
Returns
vsf_err_t: VSF_ERR_NONE if successful, or a negative error code

◆ vsf_i2c_master_get_transferred_count()

uint_fast16_t vsf_i2c_master_get_transferred_count ( vsf_i2c_t i2c_ptr)
extern

get the counter of transfers for current request by the I2C master

Parameters
[in]i2c_ptra pointer to structure vsf_i2c_t
Returns
uint_fast16_t: number of data transferred
Note
This API can be used between slave NAK and the next transmission

◆ vsf_i2c_slave_get_transferred_count()

uint_fast16_t vsf_i2c_slave_get_transferred_count ( vsf_i2c_t i2c_ptr)
extern

get the counter of transfers for current request by the I2C slave

Parameters
[in]i2c_ptra pointer to structure vsf_i2c_t
Returns
uint_fast16_t: number of data transferred

◆ vsf_i2c_ctrl()

vsf_err_t vsf_i2c_ctrl ( vsf_i2c_t i2c_ptr,
vsf_i2c_ctrl_t  ctrl,
void *  param 
)
extern

Calls the specified I2C command.

Parameters
[in]i2c_ptra pointer to structure vsf_i2c_t
[in]ctrlI2C control command vsf_i2c_ctrl_t
[in,out]paramthe parameter of the command, its use is determined by the command
Returns
vsf_err_t: returns VSF_ERR_NONE if successful, or a negative error code
Generated from commit: vsfteam/vsf@2b286be