VSF Documented
|
#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. | |
#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.
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.
#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.
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 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.
target_ptr | pointer of user. |
i2c_ptr | pointer of I2C instance. |
irq_mask | one or more value of enum vsf_i2c_irq_mask_t |
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.
enum 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.
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.
enum vsf_i2c_cmd_t |
Predefined VSF I2C commands that can be reimplemented in specific HAL drivers.
anonymous enum |
I2C command masks for different command types and configurations. These masks are used to extract or set specific command bits.
enum 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:
enum vsf_i2c_ctrl_t |
|
extern |
Initialize a I2C instance.
[in] | i2c_ptr | a pointer to structure vsf_i2c_t |
[in] | cfg_ptr | a pointer to configuration structure vsf_i2c_cfg_t |
|
extern |
Enable a I2C instance.
[in] | i2c_ptr | a pointer to structure vsf_i2c_t |
Disable a I2C instance.
[in] | i2c_ptr | a pointer to structure vsf_i2c_t |
|
extern |
I2C instance enables interrupts.
[in] | i2c_ptr | a pointer to structure vsf_i2c_t |
[in] | irq_mask | one or more values of enum vsf_i2c_irq_mask_t |
|
extern |
I2C instance disables interrupts.
[in] | i2c_ptr | a pointer to structure vsf_i2c_t |
[in] | irq_mask | one or more values of enum vsf_i2c_irq_mask_t |
|
extern |
Get the status of I2C instance.
[in] | i2c_ptr | a pointer to structure vsf_i2c_t |
|
extern |
Get the capabilities of I2C instance.
[in] | i2c_ptr | a pointer to structure vsf_i2c_t |
|
extern |
I2C instance as master mode performs a FIFO transfer.
[in,out] | i2c_ptr | a pointer to structure vsf_i2c_t |
[in] | address | address of I2C transfer |
[in] | cmd | I2C command |
[in] | count | number of data to transfer |
[in,out] | buffer_ptr | I2C transfer buffer |
[in,out] | cur_cmd_ptr | current I2C command pointer |
[in,out] | offset_ptr | current offset pointer |
|
extern |
I2C instance as slave mode performs a FIFO transfer.
[in,out] | i2c_ptr | a pointer to structure vsf_i2c_t |
[in] | transmit_or_receive | true for transmit, false for receive |
[in] | count | number of data to transfer |
[in,out] | buffer_ptr | I2C transfer buffer |
[in,out] | offset_ptr | current offset pointer |
|
extern |
I2C instance as master mode requests a transfer.
[in,out] | i2c_ptr | a pointer to structure vsf_i2c_t |
[in] | address | address of I2C transfer |
[in] | cmd | I2C command |
[in] | count | number of data to transfer |
[in,out] | buffer_ptr | I2C transfer buffer |
|
extern |
I2C instance as slave mode requests a transfer.
[in,out] | i2c_ptr | a pointer to structure vsf_i2c_t |
[in] | transmit_or_receive | true for transmit, false for receive |
[in] | count | number of data to transfer |
[in,out] | buffer_ptr | I2C transfer buffer |
|
extern |
get the counter of transfers for current request by the I2C master
[in] | i2c_ptr | a pointer to structure vsf_i2c_t |
|
extern |
get the counter of transfers for current request by the I2C slave
[in] | i2c_ptr | a pointer to structure vsf_i2c_t |
|
extern |
Calls the specified I2C command.
[in] | i2c_ptr | a pointer to structure vsf_i2c_t |
[in] | ctrl | I2C control command vsf_i2c_ctrl_t |
[in,out] | param | the parameter of the command, its use is determined by the command |