18#ifndef __VSF_TEMPLATE_I2C_H__
19#define __VSF_TEMPLATE_I2C_H__
33#ifndef VSF_I2C_CFG_MULTI_CLASS
34# define VSF_I2C_CFG_MULTI_CLASS ENABLED
37#if defined(VSF_HW_I2C_COUNT) && !defined(VSF_HW_I2C_MASK)
38# define VSF_HW_I2C_MASK VSF_HAL_COUNT_TO_MASK(VSF_HW_I2C_COUNT)
41#if defined(VSF_HW_I2C_MASK) && !defined(VSF_HW_I2C_COUNT)
42# define VSF_HW_I2C_COUNT VSF_HAL_MASK_TO_COUNT(VSF_HW_I2C_MASK)
46#ifndef VSF_I2C_CFG_PREFIX
47# if VSF_I2C_CFG_MULTI_CLASS == ENABLED
48# define VSF_I2C_CFG_PREFIX vsf
49# elif defined(VSF_HW_I2C_COUNT) && (VSF_HW_I2C_COUNT != 0)
50# define VSF_I2C_CFG_PREFIX vsf_hw
52# define VSF_I2C_CFG_PREFIX vsf
56#ifndef VSF_I2C_CFG_FUNCTION_RENAME
57# define VSF_I2C_CFG_FUNCTION_RENAME ENABLED
60#ifndef VSF_I2C_CFG_REQUEST_TEMPLATE
61# define VSF_I2C_CFG_REQUEST_TEMPLATE DISABLED
64#ifndef VSF_I2C_CFG_REIMPLEMENT_TYPE_MODE
65# define VSF_I2C_CFG_REIMPLEMENT_TYPE_MODE DISABLED
68#ifndef VSF_I2C_CFG_REIMPLEMENT_TYPE_CMD
69# define VSF_I2C_CFG_REIMPLEMENT_TYPE_CMD DISABLED
72#ifndef VSF_I2C_CFG_REIMPLEMENT_TYPE_IRQ_MASK
73# define VSF_I2C_CFG_REIMPLEMENT_TYPE_IRQ_MASK DISABLED
76#ifndef VSF_I2C_CFG_REIMPLEMENT_TYPE_STATUS
77# define VSF_I2C_CFG_REIMPLEMENT_TYPE_STATUS DISABLED
83#if VSF_I2C_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
84# define VSF_I2C_CFG_REIMPLEMENT_TYPE_CFG DISABLED
90#if VSF_I2C_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
91# define VSF_I2C_CFG_REIMPLEMENT_TYPE_CAPABILITY DISABLED
95#ifndef VSF_I2C_CFG_INHERT_HAL_CAPABILITY
96# define VSF_I2C_CFG_INHERT_HAL_CAPABILITY ENABLED
101#define VSF_I2C_APIS(__PREFIX_NAME) \
102 __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) \
103 __VSF_HAL_TEMPLATE_API(__PREFIX_NAME, void, i2c, fini, VSF_MCONNECT(__PREFIX_NAME, _i2c_t) *i2c_ptr) \
104 __VSF_HAL_TEMPLATE_API(__PREFIX_NAME, fsm_rt_t, i2c, enable, VSF_MCONNECT(__PREFIX_NAME, _i2c_t) *i2c_ptr) \
105 __VSF_HAL_TEMPLATE_API(__PREFIX_NAME, fsm_rt_t, i2c, disable, VSF_MCONNECT(__PREFIX_NAME, _i2c_t) *i2c_ptr) \
106 __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) \
107 __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) \
108 __VSF_HAL_TEMPLATE_API(__PREFIX_NAME, vsf_i2c_status_t, i2c, status, VSF_MCONNECT(__PREFIX_NAME, _i2c_t) *i2c_ptr) \
109 __VSF_HAL_TEMPLATE_API(__PREFIX_NAME, vsf_i2c_capability_t, i2c, capability, VSF_MCONNECT(__PREFIX_NAME, _i2c_t) *i2c_ptr) \
110 __VSF_HAL_TEMPLATE_API(__PREFIX_NAME, uint_fast32_t, i2c, get_transferred_count, VSF_MCONNECT(__PREFIX_NAME, _i2c_t) *i2c_ptr) \
111 __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, uint16_t count, uint8_t* buffer_ptr)
115#if VSF_I2C_CFG_REIMPLEMENT_TYPE_MODE == DISABLED
152#if VSF_I2C_CFG_REIMPLEMENT_TYPE_CMD == DISABLED
193#if VSF_I2C_CFG_REIMPLEMENT_TYPE_IRQ_MASK == DISABLED
221#if VSF_I2C_CFG_REIMPLEMENT_TYPE_STATUS == DISABLED
230#if VSF_I2C_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
232#if VSF_I2C_CFG_INHERT_HAL_CAPABILITY == ENABLED
251#if VSF_I2C_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
327#undef __VSF_HAL_TEMPLATE_API
328#define __VSF_HAL_TEMPLATE_API VSF_HAL_TEMPLATE_API_FP
333#if VSF_I2C_CFG_MULTI_CLASS == ENABLED
517#if VSF_I2C_CFG_FUNCTION_RENAME == ENABLED
518# define __vsf_i2c_t VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_t)
519# define vsf_i2c_init(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_init) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
520# define vsf_i2c_fini(__I2C) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_fini) ((__vsf_i2c_t *)(__I2C))
521# define vsf_i2c_enable(__I2C) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_enable) ((__vsf_i2c_t *)(__I2C))
522# define vsf_i2c_disable(__I2C) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_disable) ((__vsf_i2c_t *)(__I2C))
523# define vsf_i2c_irq_enable(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_irq_enable) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
524# define vsf_i2c_irq_disable(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_irq_disable) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
525# define vsf_i2c_status(__I2C) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_status) ((__vsf_i2c_t *)(__I2C))
526# define vsf_i2c_capability(__I2C) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_capability) ((__vsf_i2c_t *)(__I2C))
527# define vsf_i2c_master_request(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_master_request) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
528# define vsf_i2c_get_transferred_count(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_get_transferred_count) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
vsf_err_t
Definition __type.h:42
vsf_arch_prio_t
Definition cortex_a_generic.h:88
vsf_i2c_cmd_t
Definition i2c.h:32
unsigned short uint16_t
Definition lvgl.h:41
unsigned int uint32_t
Definition lvgl.h:43
unsigned char uint8_t
Definition lvgl.h:40
const i_spi_t vsf_spi_irq_mask_t irq_mask
Definition spi_interface.h:38
unsigned int uint_fast32_t
Definition stdint.h:27
Definition vsf_template_i2c.h:231
uint8_t support_restart
Definition vsf_template_i2c.h:241
uint16_t min_transfer_size
Definition vsf_template_i2c.h:247
uint8_t support_no_stop_restart
Definition vsf_template_i2c.h:240
inherit(vsf_peripheral_capability_t) vsf_i2c_irq_mask_t irq_mask
uint16_t max_transfer_size
Definition vsf_template_i2c.h:245
uint8_t support_no_start
Definition vsf_template_i2c.h:239
i2c configuration
Definition vsf_template_i2c.h:314
uint16_t slave_addr
Definition vsf_template_i2c.h:321
vsf_i2c_mode_t mode
Definition vsf_template_i2c.h:315
vsf_i2c_isr_t isr
Definition vsf_template_i2c.h:319
uint32_t clock_hz
Definition vsf_template_i2c.h:317
i2c interrupt configuration
Definition vsf_template_i2c.h:298
vsf_i2c_isr_handler_t * handler_fn
Definition vsf_template_i2c.h:299
void * target_ptr
Definition vsf_template_i2c.h:301
vsf_arch_prio_t prio
Definition vsf_template_i2c.h:303
Definition vsf_template_i2c.h:326
Definition vsf_template_i2c.h:222
Definition vsf_template_i2c.h:334
const vsf_i2c_op_t * op
Definition vsf_template_i2c.h:335
Definition vsf_template_hal_driver.h:203
Definition vsf_template_hal_driver.h:196
vk_av_control_value_t value
Definition vsf_audio.h:171
fsm_rt_t
Definition vsf_fsm.h:315
#define vsf_i2c_fini(__I2C)
Definition vsf_template_i2c.h:520
#define vsf_i2c_master_request(__I2C,...)
Definition vsf_template_i2c.h:527
#define vsf_i2c_disable(__I2C)
Definition vsf_template_i2c.h:522
struct vsf_i2c_status_t vsf_i2c_status_t
#define vsf_i2c_irq_enable(__I2C,...)
Definition vsf_template_i2c.h:523
@ VSF_I2C_CMD_STOP_RESTART_MASK
Definition vsf_template_i2c.h:181
@ VSF_I2C_CMD_RW_MASK
Definition vsf_template_i2c.h:171
@ VSF_I2C_CMD_RW_COUNT
Definition vsf_template_i2c.h:170
@ VSF_I2C_CMD_STOP_RESTART_COUNT
Definition vsf_template_i2c.h:180
@ VSF_I2C_CMD_START_COUNT
Definition vsf_template_i2c.h:177
@ VSF_I2C_CMD_BITS_COUNT
Definition vsf_template_i2c.h:173
@ VSF_I2C_CMD_START_MASK
Definition vsf_template_i2c.h:178
@ VSF_I2C_CMD_BITS_MASK
Definition vsf_template_i2c.h:174
@ VSF_I2C_CMD_ALL_BITS_MASK
Definition vsf_template_i2c.h:186
@ VSF_I2C_CMD_MASK_COUNT
Definition vsf_template_i2c.h:185
#define vsf_i2c_status(__I2C)
Definition vsf_template_i2c.h:525
vsf_i2c_mode_t
Definition vsf_template_i2c.h:116
@ VSF_I2C_MODE_MASTER
Definition vsf_template_i2c.h:117
@ VSF_I2C_SPEED_HIGH_SPEED_MODE
Definition vsf_template_i2c.h:124
@ VSF_I2C_MODE_SLAVE
Definition vsf_template_i2c.h:118
@ VSF_I2C_SPEED_STANDARD_MODE
Definition vsf_template_i2c.h:121
@ VSF_I2C_ADDR_7_BITS
Definition vsf_template_i2c.h:126
@ VSF_I2C_SPEED_FAST_MODE_PLUS
Definition vsf_template_i2c.h:123
@ VSF_I2C_SPEED_FAST_MODE
Definition vsf_template_i2c.h:122
@ VSF_I2C_ADDR_10_BITS
Definition vsf_template_i2c.h:127
#define vsf_i2c_irq_disable(__I2C,...)
Definition vsf_template_i2c.h:524
@ VSF_I2C_MODE_MASK
Definition vsf_template_i2c.h:133
@ VSF_I2C_ADDR_MASK
Definition vsf_template_i2c.h:143
@ VSF_I2C_MODE_ALL_BITS_MASK
Definition vsf_template_i2c.h:147
@ VSF_I2C_ADDR_COUNT
Definition vsf_template_i2c.h:142
@ VSF_I2C_SPEED_MASK
Definition vsf_template_i2c.h:137
@ VSF_I2C_SPEED_COUNT
Definition vsf_template_i2c.h:136
@ VSF_I2C_MODE_MASK_COUNT
Definition vsf_template_i2c.h:146
@ VSF_I2C_MODE_COUNT
Definition vsf_template_i2c.h:132
@ VSF_I2C_IRQ_ALL_BITS_MASK
Definition vsf_template_i2c.h:210
@ VSF_I2C_IRQ_COUNT
Definition vsf_template_i2c.h:209
#define vsf_i2c_init(__I2C,...)
Definition vsf_template_i2c.h:519
vsf_i2c_cmd_t
Definition vsf_template_i2c.h:153
@ VSF_I2C_CMD_10_BITS
Definition vsf_template_i2c.h:165
@ VSF_I2C_CMD_7_BITS
Definition vsf_template_i2c.h:164
@ VSF_I2C_CMD_NO_START
Definition vsf_template_i2c.h:158
@ VSF_I2C_CMD_STOP
Definition vsf_template_i2c.h:160
@ VSF_I2C_CMD_NO_STOP_RESTART
Definition vsf_template_i2c.h:162
@ VSF_I2C_CMD_RESTART
Definition vsf_template_i2c.h:161
@ VSF_I2C_CMD_WRITE
Definition vsf_template_i2c.h:154
@ VSF_I2C_CMD_READ
Definition vsf_template_i2c.h:155
@ VSF_I2C_CMD_START
Definition vsf_template_i2c.h:157
#define vsf_i2c_enable(__I2C)
Definition vsf_template_i2c.h:521
vsf_i2c_irq_mask_t
Definition vsf_template_i2c.h:194
@ VSF_I2C_IRQ_MASK_MASTER_STOP_DETECT
Definition vsf_template_i2c.h:197
@ VSF_I2C_IRQ_MASK_MASTER_ERROR
Definition vsf_template_i2c.h:201
@ VSF_I2C_IRQ_MASK_MASTER_TRANSFER_COMPLETE
Definition vsf_template_i2c.h:203
@ VSF_I2C_IRQ_MASK_MASTER_TX_EMPTY
Definition vsf_template_i2c.h:200
@ VSF_I2C_IRQ_MASK_MASTER_NACK_DETECT
Definition vsf_template_i2c.h:198
@ VSF_I2C_IRQ_MASK_MASTER_STOPPED
Definition vsf_template_i2c.h:196
@ VSF_I2C_IRQ_MASK_MASTER_ADDRESS_NACK
Definition vsf_template_i2c.h:204
@ VSF_I2C_IRQ_MASK_MASTER_ARBITRATION_LOST
Definition vsf_template_i2c.h:199
@ VSF_I2C_IRQ_MASK_MASTER_STARTED
Definition vsf_template_i2c.h:195
#define vsf_i2c_get_transferred_count(__I2C,...)
Definition vsf_template_i2c.h:528
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.
Definition vsf_template_i2c.h:287
#define vsf_i2c_capability(__I2C)
Definition vsf_template_i2c.h:526
#define VSF_I2C_APIS(__PREFIX_NAME)
Definition vsf_template_i2c.h:101