VSF Documented
vsf_template_i2c.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __VSF_TEMPLATE_I2C_H__
19#define __VSF_TEMPLATE_I2C_H__
20
21/*============================ INCLUDES ======================================*/
22
24#include "hal/arch/vsf_arch.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/*============================ MACROS ========================================*/
31
38#ifndef VSF_I2C_CFG_MULTI_CLASS
39# define VSF_I2C_CFG_MULTI_CLASS ENABLED
40#endif
41
50#if defined(VSF_HW_I2C_COUNT) && !defined(VSF_HW_I2C_MASK)
51# define VSF_HW_I2C_MASK VSF_HAL_COUNT_TO_MASK(VSF_HW_I2C_COUNT)
52#endif
53
62#if !defined(VSF_HW_I2C_COUNT) && defined(VSF_HW_I2C_MASK)
63# define VSF_HW_I2C_COUNT VSF_HAL_MASK_TO_COUNT(VSF_HW_I2C_MASK)
64#endif
65
76#ifndef VSF_I2C_CFG_PREFIX
77# if VSF_I2C_CFG_MULTI_CLASS == ENABLED
78# define VSF_I2C_CFG_PREFIX vsf
79# elif defined(VSF_HW_I2C_COUNT) && (VSF_HW_I2C_COUNT != 0)
80# define VSF_I2C_CFG_PREFIX vsf_hw
81# else
82# define VSF_I2C_CFG_PREFIX vsf
83# endif
84#endif
85
94#ifndef VSF_I2C_CFG_FUNCTION_RENAME
95# define VSF_I2C_CFG_FUNCTION_RENAME ENABLED
96#endif
97
106#ifndef VSF_I2C_CFG_REIMPLEMENT_TYPE_MODE
107# define VSF_I2C_CFG_REIMPLEMENT_TYPE_MODE DISABLED
108#endif
109
118#ifndef VSF_I2C_CFG_REIMPLEMENT_TYPE_CMD
119# define VSF_I2C_CFG_REIMPLEMENT_TYPE_CMD DISABLED
120#endif
121
130#ifndef VSF_I2C_CFG_REIMPLEMENT_TYPE_IRQ_MASK
131# define VSF_I2C_CFG_REIMPLEMENT_TYPE_IRQ_MASK DISABLED
132#endif
133
144#ifndef VSF_I2C_CFG_REIMPLEMENT_TYPE_STATUS
145# define VSF_I2C_CFG_REIMPLEMENT_TYPE_STATUS DISABLED
146#endif
147
158#ifndef VSF_I2C_CFG_REIMPLEMENT_TYPE_CTRL
159# define VSF_I2C_CFG_REIMPLEMENT_TYPE_CTRL DISABLED
160#endif
161
173#ifndef VSF_I2C_CFG_REIMPLEMENT_TYPE_CFG
174# define VSF_I2C_CFG_REIMPLEMENT_TYPE_CFG DISABLED
175#endif
176
185#ifndef VSF_I2C_CFG_INHERIT_HAL_CAPABILITY
186# define VSF_I2C_CFG_INHERIT_HAL_CAPABILITY ENABLED
187#endif
188
189/*============================ MACROFIED FUNCTIONS ===========================*/
190
197#define VSF_I2C_APIS(__prefix_name) \
198 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, i2c, init, VSF_MCONNECT(__prefix_name, _t) *i2c_ptr, vsf_i2c_cfg_t *cfg_ptr) \
199 __VSF_HAL_TEMPLATE_API(__prefix_name, void, i2c, fini, VSF_MCONNECT(__prefix_name, _t) *i2c_ptr) \
200 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, i2c, get_configuration, VSF_MCONNECT(__prefix_name, _t) *i2c_ptr, vsf_i2c_cfg_t *cfg_ptr) \
201 __VSF_HAL_TEMPLATE_API(__prefix_name, fsm_rt_t, i2c, enable, VSF_MCONNECT(__prefix_name, _t) *i2c_ptr) \
202 __VSF_HAL_TEMPLATE_API(__prefix_name, fsm_rt_t, i2c, disable, VSF_MCONNECT(__prefix_name, _t) *i2c_ptr) \
203 __VSF_HAL_TEMPLATE_API(__prefix_name, void, i2c, irq_enable, VSF_MCONNECT(__prefix_name, _t) *i2c_ptr, vsf_i2c_irq_mask_t irq_mask) \
204 __VSF_HAL_TEMPLATE_API(__prefix_name, void, i2c, irq_disable, VSF_MCONNECT(__prefix_name, _t) *i2c_ptr, vsf_i2c_irq_mask_t irq_mask) \
205 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_i2c_status_t, i2c, status, VSF_MCONNECT(__prefix_name, _t) *i2c_ptr) \
206 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_i2c_capability_t, i2c, capability, VSF_MCONNECT(__prefix_name, _t) *i2c_ptr) \
207 __VSF_HAL_TEMPLATE_API(__prefix_name, fsm_rt_t, i2c, master_fifo_transfer, VSF_MCONNECT(__prefix_name, _t) *i2c_ptr, uint16_t address, \
208 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) \
209 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, i2c, master_request, VSF_MCONNECT(__prefix_name, _t) *i2c_ptr, uint16_t address, \
210 vsf_i2c_cmd_t cmd, uint_fast16_t count, uint8_t* buffer_ptr) \
211 __VSF_HAL_TEMPLATE_API(__prefix_name, uint_fast16_t, i2c, master_get_transferred_count, VSF_MCONNECT(__prefix_name, _t) *i2c_ptr) \
212 __VSF_HAL_TEMPLATE_API(__prefix_name, uint_fast16_t, i2c, slave_fifo_transfer, VSF_MCONNECT(__prefix_name, _t) *i2c_ptr, bool transmit_or_receive, \
213 uint_fast16_t count, uint8_t* buffer_ptr) \
214 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, i2c, slave_request, VSF_MCONNECT(__prefix_name, _t) *i2c_ptr, bool transmit_or_receive, \
215 uint_fast16_t count, uint8_t* buffer_ptr) \
216 __VSF_HAL_TEMPLATE_API(__prefix_name, uint_fast16_t, i2c, slave_get_transferred_count, VSF_MCONNECT(__prefix_name, _t) *i2c_ptr) \
217 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, i2c, ctrl, VSF_MCONNECT(__prefix_name, _t) *i2c_ptr, vsf_i2c_ctrl_t ctrl, void* param) \
218 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_i2c_irq_mask_t, i2c, irq_clear, VSF_MCONNECT(__prefix_name, _t) *i2c_ptr, vsf_i2c_irq_mask_t irq_mask)
219
220/*============================ TYPES =========================================*/
221
238#if VSF_I2C_CFG_REIMPLEMENT_TYPE_MODE == DISABLED
239typedef enum vsf_i2c_mode_t {
248 VSF_I2C_MODE_MASTER = (0x1ul << 28),
249
258 VSF_I2C_MODE_SLAVE = (0x0ul << 28),
259
269
278 VSF_I2C_SPEED_FAST_MODE = (0x1ul << 29),
279
289
299
308 VSF_I2C_ADDR_7_BITS = (0x0ul << 31),
309
318 VSF_I2C_ADDR_10_BITS = (0x1ul << 31),
320#endif
321
330enum {
341
354
365
377};
378
385#if VSF_I2C_CFG_REIMPLEMENT_TYPE_CMD == DISABLED
386typedef enum vsf_i2c_cmd_t {
395 VSF_I2C_CMD_WRITE = (0x00ul << 0),
396
405 VSF_I2C_CMD_READ = (0x01ul << 0),
406
415 VSF_I2C_CMD_START = (0x01ul << 28),
416
425 VSF_I2C_CMD_STOP = (0x01ul << 29),
426
437 VSF_I2C_CMD_RESTART = (0x01ul << 30),
438
447 VSF_I2C_CMD_7_BITS = (0x0ul << 31),
448
457 VSF_I2C_CMD_10_BITS = (0x01ul << 31),
459#endif
460
469enum {
479
490
499#ifndef VSF_I2C_CMD_ALL_BITS_MASK
505#endif
506};
507
538#if VSF_I2C_CFG_REIMPLEMENT_TYPE_IRQ_MASK == DISABLED
539typedef enum vsf_i2c_irq_mask_t {
553
567
579
591
603
615
616
628
629
641
642
654
666
680
694
706
708#endif
709
710enum {
711#ifndef VSF_I2C_IRQ_MASK_MASTER_ERR
715#endif
716
717 // TODO: Add slave error interrupt mask
718#ifndef VSF_I2C_IRQ_MASK_SLAVE_ERR
720#endif
721
722#ifndef VSF_I2C_IRQ_MASK_ERR
725#endif
726
727#ifndef VSF_I2C_IRQ_ALL_BITS_MASK
741#endif
742};
743
744#if VSF_I2C_CFG_REIMPLEMENT_TYPE_STATUS == DISABLED
751typedef struct vsf_i2c_status_t {
752 union {
754 struct {
755 uint32_t is_busy : 1;
756 };
758 };
760#endif
761
762#if VSF_I2C_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
771typedef struct vsf_i2c_capability_t {
772#if VSF_I2C_CFG_INHERIT_HAL_CAPABILITY == ENABLED
774#endif
778
782
786
790
794
799#endif
800
801#if VSF_I2C_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
808typedef struct vsf_i2c_t vsf_i2c_t;
809
843typedef void vsf_i2c_isr_handler_t(void *target_ptr,
844 vsf_i2c_t *i2c_ptr,
846
854typedef struct vsf_i2c_isr_t {
858
862
867
875typedef struct vsf_i2c_cfg_t {
879
883
887
892#endif
893
894#if VSF_I2C_CFG_REIMPLEMENT_TYPE_CTRL == DISABLED
903typedef enum vsf_i2c_ctrl_t {
904 /*
907 VSF_I2C_CTRL_MASTER_ABORT = (0x1ul << 3),
908 #define VSF_I2C_CTRL_MASTER_ABORT VSF_I2C_CTRL_MASTER_ABORT
909 */
910
911 /*
914 VSF_I2C_CTRL_SLAVE_ABORT = (0x1ul << 4),
915 #define VSF_I2C_CTRL_SLAVE_ABORT VSF_I2C_CTRL_SLAVE_ABORT
916 */
917
918 /*
921 VSF_I2C_CTRL_ANALOG_FILTER_ENABLE = (0x0ul << 5),
924 VSF_I2C_CTRL_ANALOG_FILTER_DISABLE = (0x1ul << 5),
925 #define VSF_I2C_CTRL_ANALOG_FILTER_ENABLE VSF_I2C_CTRL_ANALOG_FILTER_ENABLE
926 #define VSF_I2C_CTRL_ANALOG_FILTER_DISABLE VSF_I2C_CTRL_ANALOG_FILTER_DISABLE
927 */
928
929 /*
932 VSF_I2C_CTRL_DIGITAL_FILTER_ENABLE = (0x0ul << 7),
935 VSF_I2C_CTRL_DIGITAL_FILTER_DISABLE = (0x1ul << 7),
936 #define VSF_I2C_CTRL_DIGITAL_FILTER_ENABLE VSF_I2C_CTRL_DIGITAL_FILTER_ENABLE
937 #define VSF_I2C_CTRL_DIGITAL_FILTER_DISABLE VSF_I2C_CTRL_DIGITAL_FILTER_DISABLE
938 */
939
944#endif
945
954typedef struct vsf_i2c_op_t {
956#undef __VSF_HAL_TEMPLATE_API
957#define __VSF_HAL_TEMPLATE_API VSF_HAL_TEMPLATE_API_FP
959
960 VSF_I2C_APIS(vsf_i2c)
962
963#if VSF_I2C_CFG_MULTI_CLASS == ENABLED
970struct vsf_i2c_t {
974};
975#endif
976
977/*============================ GLOBAL VARIABLES ==============================*/
978/*============================ PROTOTYPES ====================================*/
979
999extern vsf_err_t vsf_i2c_init(vsf_i2c_t *i2c_ptr, vsf_i2c_cfg_t *cfg_ptr);
1000
1012extern void vsf_i2c_fini(vsf_i2c_t *i2c_ptr);
1013
1032
1044extern fsm_rt_t vsf_i2c_enable(vsf_i2c_t *i2c_ptr);
1045
1060extern fsm_rt_t vsf_i2c_disable(vsf_i2c_t *i2c_ptr);
1061
1076
1091
1104
1117
1154 uint16_t address,
1155 vsf_i2c_cmd_t cmd,
1156 uint_fast16_t count,
1157 uint8_t *buffer_ptr,
1158 vsf_i2c_cmd_t *cur_cmd_ptr,
1159 uint_fast16_t *offset_ptr);
1160
1181 bool transmit_or_receive,
1182 uint_fast16_t count,
1183 uint8_t *buffer_ptr);
1184
1205 uint16_t address,
1206 vsf_i2c_cmd_t cmd,
1207 uint_fast16_t count,
1208 uint8_t *buffer_ptr);
1209
1228 bool transmit_or_receive,
1229 uint_fast16_t count,
1230 uint8_t *buffer_ptr);
1231
1246
1259
1275extern vsf_err_t vsf_i2c_ctrl(vsf_i2c_t *i2c_ptr, vsf_i2c_ctrl_t ctrl, void * param);
1276
1308
1309/*============================ INCLUDES ======================================*/
1310
1312
1313/*============================ MACROFIED FUNCTIONS ===========================*/
1314
1316#if VSF_I2C_CFG_FUNCTION_RENAME == ENABLED
1317# define __vsf_i2c_t VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_t)
1318# define vsf_i2c_init(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_init) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
1319# define vsf_i2c_fini(__I2C) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_fini) ((__vsf_i2c_t *)(__I2C))
1320# define vsf_i2c_get_configuration(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_get_configuration) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
1321# define vsf_i2c_enable(__I2C) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_enable) ((__vsf_i2c_t *)(__I2C))
1322# define vsf_i2c_disable(__I2C) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_disable) ((__vsf_i2c_t *)(__I2C))
1323# define vsf_i2c_irq_enable(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_irq_enable) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
1324# define vsf_i2c_irq_disable(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_irq_disable) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
1325# define vsf_i2c_irq_clear(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_irq_clear) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
1326# define vsf_i2c_status(__I2C) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_status) ((__vsf_i2c_t *)(__I2C))
1327# define vsf_i2c_capability(__I2C) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_capability) ((__vsf_i2c_t *)(__I2C))
1328# define vsf_i2c_master_fifo_transfer(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_master_fifo_transfer) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
1329# define vsf_i2c_master_request(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_master_request) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
1330# define vsf_i2c_master_get_transferred_count(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_master_get_transferred_count) ((__vsf_i2c_t *)(__I2C))
1331# define vsf_i2c_slave_fifo_transfer(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_slave_fifo_transfer) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
1332# define vsf_i2c_slave_request(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_slave_request) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
1333# define vsf_i2c_slave_get_transferred_count(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_slave_get_transferred_count) ((__vsf_i2c_t *)(__I2C))
1334# define vsf_i2c_ctrl(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_ctrl) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
1335#endif
1337
1338#ifdef __cplusplus
1339}
1340#endif
1341
1342#endif /*__VSF_TEMPLATE_I2C_H__*/
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
vsf_i2c_mode_t
Definition i2c.h:116
vsf_i2c_irq_mask_t
Definition i2c.h:152
void vsf_i2c_isr_handler_t(void *target_ptr, vsf_i2c_t *i2c_ptr, vsf_i2c_irq_mask_t irq_mask)
Definition i2c.h:195
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 uint32_t
Definition stdint.h:9
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:771
uint8_t support_restart
Definition vsf_template_i2c.h:789
uint8_t support_no_stop
Definition vsf_template_i2c.h:785
inherit(vsf_peripheral_capability_t) vsf_i2c_irq_mask_t irq_mask
uint_fast16_t max_transfer_size
Definition vsf_template_i2c.h:793
uint_fast16_t min_transfer_size
Definition vsf_template_i2c.h:797
uint8_t support_no_start
Definition vsf_template_i2c.h:781
I2C configuration.
Definition vsf_template_i2c.h:875
vsf_i2c_mode_t mode
Definition vsf_template_i2c.h:878
uint_fast16_t slave_addr
Definition vsf_template_i2c.h:890
vsf_i2c_isr_t isr
Definition vsf_template_i2c.h:886
uint32_t clock_hz
Definition vsf_template_i2c.h:882
I2C interrupt configuration.
Definition vsf_template_i2c.h:854
vsf_i2c_isr_handler_t * handler_fn
Definition vsf_template_i2c.h:857
void * target_ptr
Definition vsf_template_i2c.h:861
vsf_arch_prio_t prio
Definition vsf_template_i2c.h:865
I2C operation function pointers for multi-class support.
Definition vsf_template_i2c.h:954
Predefined VSF I2C status that can be reimplemented in specific hal drivers.
Definition vsf_template_i2c.h:751
uint32_t value
Definition vsf_template_i2c.h:757
I2C instance structure for multi-class support.
Definition vsf_template_i2c.h:970
const vsf_i2c_op_t * op
Definition vsf_template_i2c.h:973
Definition vsf_template_hal_driver.h:203
Definition vsf_template_hal_driver.h:196
fsm_rt_t
Definition vsf_fsm.h:315
@ VSF_I2C_IRQ_ALL_BITS_MASK
Definition vsf_template_i2c.h:728
@ VSF_I2C_IRQ_MASK_MASTER_ERR
Combined master error interrupt mask.
Definition vsf_template_i2c.h:712
@ VSF_I2C_IRQ_MASK_ERR
Combined error interrupt mask.
Definition vsf_template_i2c.h:723
@ VSF_I2C_IRQ_MASK_SLAVE_ERR
Combined slave error interrupt mask.
Definition vsf_template_i2c.h:719
void vsf_i2c_irq_disable(vsf_i2c_t *i2c_ptr, vsf_i2c_irq_mask_t irq_mask)
I2C instance disables interrupts.
Definition i2c_common.c:92
struct vsf_i2c_cfg_t vsf_i2c_cfg_t
I2C configuration.
struct vsf_i2c_status_t vsf_i2c_status_t
Predefined VSF I2C status that can be reimplemented in specific hal drivers.
fsm_rt_t vsf_i2c_disable(vsf_i2c_t *i2c_ptr)
Disable a I2C instance.
Definition i2c_common.c:74
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
Definition i2c_common.c:187
vsf_i2c_capability_t vsf_i2c_capability(vsf_i2c_t *i2c_ptr)
Get the capabilities of I2C instance.
Definition i2c_common.c:119
vsf_i2c_mode_t
Predefined VSF I2C modes that can be reimplemented in specific HAL drivers.If we want to add optional...
Definition vsf_template_i2c.h:239
@ VSF_I2C_MODE_MASTER
Select master mode for I2C operation. The device initiates and controls the I2C bus communication.
Definition vsf_template_i2c.h:248
@ VSF_I2C_SPEED_HIGH_SPEED_MODE
High speed mode, up to 3.4 Mbit/s. Highest specified I2C speed for performance-critical applications.
Definition vsf_template_i2c.h:298
@ VSF_I2C_MODE_SLAVE
Select slave mode for I2C operation. The device responds to I2C bus commands from master devices.
Definition vsf_template_i2c.h:258
@ VSF_I2C_SPEED_STANDARD_MODE
Standard mode, up to 100 kbit/s. The lowest I2C speed specification, compatible with most devices.
Definition vsf_template_i2c.h:268
@ VSF_I2C_ADDR_7_BITS
7-bit address mode. Standard addressing mode supporting up to 128 unique devices.
Definition vsf_template_i2c.h:308
@ VSF_I2C_SPEED_FAST_MODE_PLUS
Fast mode plus, up to 1 Mbit/s. Enhanced fast mode for higher throughput applications.
Definition vsf_template_i2c.h:288
@ VSF_I2C_SPEED_FAST_MODE
Fast mode, up to 400 kbit/s. Commonly used medium speed I2C mode.
Definition vsf_template_i2c.h:278
@ VSF_I2C_ADDR_10_BITS
10-bit address mode. Extended addressing mode supporting up to 1024 unique devices.
Definition vsf_template_i2c.h:318
vsf_err_t vsf_i2c_ctrl(vsf_i2c_t *i2c_ptr, vsf_i2c_ctrl_t ctrl, void *param)
Calls the specified I2C command.
Definition i2c_common.c:196
struct vsf_i2c_capability_t vsf_i2c_capability_t
Predefined I2C capability structure that can be reimplemented in specific HAL drivers.
struct vsf_i2c_isr_t vsf_i2c_isr_t
I2C interrupt configuration.
vsf_i2c_status_t vsf_i2c_status(vsf_i2c_t *i2c_ptr)
Get the status of I2C instance.
Definition i2c_common.c:110
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
Definition i2c_common.c:178
vsf_err_t vsf_i2c_get_configuration(vsf_i2c_t *i2c_ptr, vsf_i2c_cfg_t *cfg_ptr)
Get current configuration of a I2C instance.
Definition i2c_common.c:55
vsf_i2c_irq_mask_t vsf_i2c_irq_clear(vsf_i2c_t *i2c_ptr, vsf_i2c_irq_mask_t irq_mask)
Clear interrupt flags of I2C instance and return previous state.
Definition i2c_common.c:101
vsf_err_t vsf_i2c_init(vsf_i2c_t *i2c_ptr, vsf_i2c_cfg_t *cfg_ptr)
Initialize a I2C instance.
Definition i2c_common.c:37
@ VSF_I2C_MODE_MASK
Mask for master/slave mode selection. Extracts VSF_I2C_MODE_MASTER and VSF_I2C_MODE_SLAVE bits.
Definition vsf_template_i2c.h:339
@ VSF_I2C_ADDR_MASK
Mask for I2C address mode selection. Extracts VSF_I2C_ADDR_7_BITS and VSF_I2C_ADDR_10_BITS bits.
Definition vsf_template_i2c.h:363
@ VSF_I2C_MODE_ALL_BITS_MASK
Combined mask for all I2C mode configuration bits. Includes mode, speed, and address mode masks.
Definition vsf_template_i2c.h:374
@ VSF_I2C_SPEED_MASK
Mask for I2C speed mode configuration. Extracts all speed mode bits (standard, fast,...
Definition vsf_template_i2c.h:350
vsf_i2c_cmd_t
Predefined VSF I2C commands that can be reimplemented in specific HAL drivers.
Definition vsf_template_i2c.h:386
@ VSF_I2C_CMD_10_BITS
10-bit addressing mode command. Configures the I2C transaction to use 10-bit slave addressing.
Definition vsf_template_i2c.h:457
@ VSF_I2C_CMD_7_BITS
7-bit addressing mode command. Configures the I2C transaction to use 7-bit slave addressing.
Definition vsf_template_i2c.h:447
@ VSF_I2C_CMD_STOP
Stop condition command. Generates a STOP condition on the I2C bus to end the current transaction.
Definition vsf_template_i2c.h:425
@ VSF_I2C_CMD_RESTART
Restart condition command. Generates a repeated START condition without releasing the bus....
Definition vsf_template_i2c.h:437
@ VSF_I2C_CMD_WRITE
Write command for I2C data transfer. Used to write data on the I2C bus.
Definition vsf_template_i2c.h:395
@ VSF_I2C_CMD_READ
Read command for I2C data transfer. Used to read data from the I2C bus.
Definition vsf_template_i2c.h:405
@ VSF_I2C_CMD_START
Start condition command. Generates a START condition on the I2C bus to begin a new transaction.
Definition vsf_template_i2c.h:415
void vsf_i2c_fini(vsf_i2c_t *i2c_ptr)
Finalize a I2C instance.
Definition i2c_common.c:46
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.
Definition i2c_common.c:167
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.
Definition i2c_common.c:155
vsf_i2c_ctrl_t
I2C control commands for hardware-specific operations.
Definition vsf_template_i2c.h:903
@ __VSF_I2C_CTRL_DUMMP
Definition vsf_template_i2c.h:942
fsm_rt_t vsf_i2c_enable(vsf_i2c_t *i2c_ptr)
Enable a I2C instance.
Definition i2c_common.c:65
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.
Definition i2c_common.c:142
void vsf_i2c_irq_enable(vsf_i2c_t *i2c_ptr, vsf_i2c_irq_mask_t irq_mask)
I2C instance enables interrupts.
Definition i2c_common.c:83
vsf_i2c_irq_mask_t
Predefined VSF I2C interrupt masks that can be reimplemented in specific HAL drivers....
Definition vsf_template_i2c.h:539
@ VSF_I2C_IRQ_MASK_MASTER_STOP_DETECT
Master mode: Start condition detection interrupt. Triggered when the master device generates a START ...
Definition vsf_template_i2c.h:640
@ VSF_I2C_IRQ_MASK_SLAVE_TX
Slave mode: Transmit FIFO threshold interrupt. Triggered when transmit FIFO level falls below thresho...
Definition vsf_template_i2c.h:679
@ VSF_I2C_IRQ_MASK_MASTER_TRANSFER_COMPLETE
Master mode: Transfer completion interrupt. Triggered when the current transfer operation is complete...
Definition vsf_template_i2c.h:578
@ VSF_I2C_IRQ_MASK_SLAVE_START_OR_RESTART_DETECT
Slave mode: Repeated START condition detection interrupt. Triggered when repeated START condition is ...
Definition vsf_template_i2c.h:653
@ VSF_I2C_IRQ_MASK_MASTER_TX
Master mode: Transmit FIFO threshold interrupt. Triggered when transmit FIFO level falls below thresh...
Definition vsf_template_i2c.h:552
@ VSF_I2C_IRQ_MASK_MASTER_RX
Master mode: Receive FIFO threshold interrupt. Triggered when receive FIFO level exceeds threshold in...
Definition vsf_template_i2c.h:566
@ VSF_I2C_IRQ_MASK_SLAVE_TRANSFER_COMPLETE
Slave mode: Transfer completion interrupt. Triggered when the current transfer operation is completed...
Definition vsf_template_i2c.h:705
@ VSF_I2C_IRQ_MASK_MASTER_START_OR_RESTART_DETECT
Slave mode: START or RESTART condition detection interrupt. Triggered when START condition is detecte...
Definition vsf_template_i2c.h:627
@ VSF_I2C_IRQ_MASK_MASTER_ADDRESS_NACK
Master mode: Address NACK detection interrupt. Triggered when a NACK is received after sending the ad...
Definition vsf_template_i2c.h:602
@ VSF_I2C_IRQ_MASK_SLAVE_STOP_DETECT
Slave mode: STOP condition detection interrupt. Triggered when STOP condition is detected while in sl...
Definition vsf_template_i2c.h:665
@ VSF_I2C_IRQ_MASK_MASTER_ARBITRATION_LOST
Master mode: Arbitration lost interrupt. Triggered when the master loses arbitration in multi-master ...
Definition vsf_template_i2c.h:590
@ VSF_I2C_IRQ_MASK_MASTER_TX_NACK_DETECT
Master mode: data transmit NACK detection interrupt. Triggered when a NACK is received during master ...
Definition vsf_template_i2c.h:614
@ VSF_I2C_IRQ_MASK_SLAVE_RX
Slave mode: Receive FIFO threshold interrupt. Triggered when receive FIFO level exceeds threshold in ...
Definition vsf_template_i2c.h:693
@ VSF_I2C_CMD_RW_MASK
Mask for read/write command selection. Extracts VSF_I2C_CMD_WRITE and VSF_I2C_CMD_READ bits.
Definition vsf_template_i2c.h:478
@ VSF_I2C_CMD_BITS_MASK
Mask for I2C address bits configuration. Extracts VSF_I2C_CMD_7_BITS and VSF_I2C_CMD_10_BITS bits.
Definition vsf_template_i2c.h:488
@ VSF_I2C_CMD_ALL_BITS_MASK
Combined mask for all I2C command bits. Includes read/write, start/stop/restart, and address bits mas...
Definition vsf_template_i2c.h:500
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:843
fsm_rt_t 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.
Definition i2c_common.c:128
#define VSF_I2C_APIS(__prefix_name)
I2C API template, used to generate I2C type, specific prefix function declarations,...
Definition vsf_template_i2c.h:197
Generated from commit: vsfteam/vsf@3857ca3