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
219/*============================ TYPES =========================================*/
220
237#if VSF_I2C_CFG_REIMPLEMENT_TYPE_MODE == DISABLED
238typedef enum vsf_i2c_mode_t {
247 VSF_I2C_MODE_MASTER = (0x1ul << 28),
248
257 VSF_I2C_MODE_SLAVE = (0x0ul << 28),
258
268
277 VSF_I2C_SPEED_FAST_MODE = (0x1ul << 29),
278
288
298
307 VSF_I2C_ADDR_7_BITS = (0x0ul << 31),
308
317 VSF_I2C_ADDR_10_BITS = (0x1ul << 31),
319#endif
320
329enum {
340
353
364
376};
377
384#if VSF_I2C_CFG_REIMPLEMENT_TYPE_CMD == DISABLED
385typedef enum vsf_i2c_cmd_t {
394 VSF_I2C_CMD_WRITE = (0x00ul << 0),
395
404 VSF_I2C_CMD_READ = (0x01ul << 0),
405
414 VSF_I2C_CMD_START = (0x01ul << 28),
415
424 VSF_I2C_CMD_STOP = (0x01ul << 29),
425
436 VSF_I2C_CMD_RESTART = (0x01ul << 30),
437
446 VSF_I2C_CMD_7_BITS = (0x0ul << 31),
447
456 VSF_I2C_CMD_10_BITS = (0x01ul << 31),
458#endif
459
468enum {
478
489
498#ifndef VSF_I2C_CMD_ALL_BITS_MASK
504#endif
505};
506
537#if VSF_I2C_CFG_REIMPLEMENT_TYPE_IRQ_MASK == DISABLED
538typedef enum vsf_i2c_irq_mask_t {
552
566
578
590
602
614
626
638
639
651
652
664
676
690
704
716
729#endif
730
731enum {
732#ifndef VSF_I2C_IRQ_ALL_BITS_MASK
748#endif
749};
750
751#if VSF_I2C_CFG_REIMPLEMENT_TYPE_STATUS == DISABLED
758typedef struct vsf_i2c_status_t {
759 union {
761 struct {
762 uint32_t is_busy : 1;
763 };
765 };
767#endif
768
769#if VSF_I2C_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
778typedef struct vsf_i2c_capability_t {
779#if VSF_I2C_CFG_INHERIT_HAL_CAPABILITY == ENABLED
781#endif
785
789
793
797
801
806#endif
807
808#if VSF_I2C_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
815typedef struct vsf_i2c_t vsf_i2c_t;
816
850typedef void vsf_i2c_isr_handler_t(void *target_ptr,
851 vsf_i2c_t *i2c_ptr,
853
861typedef struct vsf_i2c_isr_t {
865
869
874
882typedef struct vsf_i2c_cfg_t {
886
890
894
899#endif
900
901#if VSF_I2C_CFG_REIMPLEMENT_TYPE_CTRL == DISABLED
910typedef enum vsf_i2c_ctrl_t {
911 /*
914 VSF_I2C_CTRL_MASTER_ABORT = (0x1ul << 3),
915 #define VSF_I2C_CTRL_MASTER_ABORT VSF_I2C_CTRL_MASTER_ABORT
916 */
917
918 /*
921 VSF_I2C_CTRL_SLAVE_ABORT = (0x1ul << 4),
922 #define VSF_I2C_CTRL_SLAVE_ABORT VSF_I2C_CTRL_SLAVE_ABORT
923 */
924
925 /*
928 VSF_I2C_CTRL_ANALOG_FILTER_ENABLE = (0x0ul << 5),
931 VSF_I2C_CTRL_ANALOG_FILTER_DISABLE = (0x1ul << 5),
932 #define VSF_I2C_CTRL_ANALOG_FILTER_ENABLE VSF_I2C_CTRL_ANALOG_FILTER_ENABLE
933 #define VSF_I2C_CTRL_ANALOG_FILTER_DISABLE VSF_I2C_CTRL_ANALOG_FILTER_DISABLE
934 */
935
936 /*
939 VSF_I2C_CTRL_DIGITAL_FILTER_ENABLE = (0x0ul << 7),
942 VSF_I2C_CTRL_DIGITAL_FILTER_DISABLE = (0x1ul << 7),
943 #define VSF_I2C_CTRL_DIGITAL_FILTER_ENABLE VSF_I2C_CTRL_DIGITAL_FILTER_ENABLE
944 #define VSF_I2C_CTRL_DIGITAL_FILTER_DISABLE VSF_I2C_CTRL_DIGITAL_FILTER_DISABLE
945 */
946
951#endif
952
961typedef struct vsf_i2c_op_t {
963#undef __VSF_HAL_TEMPLATE_API
964#define __VSF_HAL_TEMPLATE_API VSF_HAL_TEMPLATE_API_FP
966
967 VSF_I2C_APIS(vsf_i2c)
969
970#if VSF_I2C_CFG_MULTI_CLASS == ENABLED
977struct vsf_i2c_t {
981};
982#endif
983
984/*============================ GLOBAL VARIABLES ==============================*/
985/*============================ PROTOTYPES ====================================*/
986
1006extern vsf_err_t vsf_i2c_init(vsf_i2c_t *i2c_ptr, vsf_i2c_cfg_t *cfg_ptr);
1007
1019extern void vsf_i2c_fini(vsf_i2c_t *i2c_ptr);
1020
1039
1051extern fsm_rt_t vsf_i2c_enable(vsf_i2c_t *i2c_ptr);
1052
1067extern fsm_rt_t vsf_i2c_disable(vsf_i2c_t *i2c_ptr);
1068
1083
1098
1111
1124
1161 uint16_t address,
1162 vsf_i2c_cmd_t cmd,
1163 uint_fast16_t count,
1164 uint8_t *buffer_ptr,
1165 vsf_i2c_cmd_t *cur_cmd_ptr,
1166 uint_fast16_t *offset_ptr);
1167
1188 bool transmit_or_receive,
1189 uint_fast16_t count,
1190 uint8_t *buffer_ptr);
1191
1212 uint16_t address,
1213 vsf_i2c_cmd_t cmd,
1214 uint_fast16_t count,
1215 uint8_t *buffer_ptr);
1216
1235 bool transmit_or_receive,
1236 uint_fast16_t count,
1237 uint8_t *buffer_ptr);
1238
1253
1266
1282extern vsf_err_t vsf_i2c_ctrl(vsf_i2c_t *i2c_ptr, vsf_i2c_ctrl_t ctrl, void * param);
1283
1284/*============================ INCLUDES ======================================*/
1285
1287
1288/*============================ MACROFIED FUNCTIONS ===========================*/
1289
1291#if VSF_I2C_CFG_FUNCTION_RENAME == ENABLED
1292# define __vsf_i2c_t VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_t)
1293# define vsf_i2c_init(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_init) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
1294# define vsf_i2c_fini(__I2C) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_fini) ((__vsf_i2c_t *)(__I2C))
1295# define vsf_i2c_get_configuration(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_get_configuration) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
1296# define vsf_i2c_enable(__I2C) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_enable) ((__vsf_i2c_t *)(__I2C))
1297# define vsf_i2c_disable(__I2C) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_disable) ((__vsf_i2c_t *)(__I2C))
1298# define vsf_i2c_irq_enable(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_irq_enable) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
1299# define vsf_i2c_irq_disable(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_irq_disable) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
1300# define vsf_i2c_status(__I2C) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_status) ((__vsf_i2c_t *)(__I2C))
1301# define vsf_i2c_capability(__I2C) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_capability) ((__vsf_i2c_t *)(__I2C))
1302# define vsf_i2c_master_fifo_transfer(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_master_fifo_transfer) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
1303# define vsf_i2c_master_request(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_master_request) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
1304# define vsf_i2c_master_get_transferred_count(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_master_get_transferred_count) ((__vsf_i2c_t *)(__I2C))
1305# define vsf_i2c_slave_fifo_transfer(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_slave_fifo_transfer) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
1306# define vsf_i2c_slave_request(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_slave_request) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
1307# define vsf_i2c_slave_get_transferred_count(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_slave_get_transferred_count) ((__vsf_i2c_t *)(__I2C))
1308# define vsf_i2c_ctrl(__I2C, ...) VSF_MCONNECT(VSF_I2C_CFG_PREFIX, _i2c_ctrl) ((__vsf_i2c_t *)(__I2C), ##__VA_ARGS__)
1309#endif
1311
1312#ifdef __cplusplus
1313}
1314#endif
1315
1316#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:197
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:778
uint8_t support_restart
Definition vsf_template_i2c.h:796
uint8_t support_no_stop
Definition vsf_template_i2c.h:792
inherit(vsf_peripheral_capability_t) vsf_i2c_irq_mask_t irq_mask
uint_fast16_t max_transfer_size
Definition vsf_template_i2c.h:800
uint_fast16_t min_transfer_size
Definition vsf_template_i2c.h:804
uint8_t support_no_start
Definition vsf_template_i2c.h:788
I2C configuration.
Definition vsf_template_i2c.h:882
vsf_i2c_mode_t mode
Definition vsf_template_i2c.h:885
uint_fast16_t slave_addr
Definition vsf_template_i2c.h:897
vsf_i2c_isr_t isr
Definition vsf_template_i2c.h:893
uint32_t clock_hz
Definition vsf_template_i2c.h:889
I2C interrupt configuration.
Definition vsf_template_i2c.h:861
vsf_i2c_isr_handler_t * handler_fn
Definition vsf_template_i2c.h:864
void * target_ptr
Definition vsf_template_i2c.h:868
vsf_arch_prio_t prio
Definition vsf_template_i2c.h:872
I2C operation function pointers for multi-class support.
Definition vsf_template_i2c.h:961
Predefined VSF I2C status that can be reimplemented in specific hal drivers.
Definition vsf_template_i2c.h:758
uint32_t value
Definition vsf_template_i2c.h:764
I2C instance structure for multi-class support.
Definition vsf_template_i2c.h:977
const vsf_i2c_op_t * op
Definition vsf_template_i2c.h:980
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:733
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:178
vsf_i2c_capability_t vsf_i2c_capability(vsf_i2c_t *i2c_ptr)
Get the capabilities of I2C instance.
Definition i2c_common.c:110
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:238
@ VSF_I2C_MODE_MASTER
Select master mode for I2C operation. The device initiates and controls the I2C bus communication.
Definition vsf_template_i2c.h:247
@ 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:297
@ 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:257
@ 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:267
@ VSF_I2C_ADDR_7_BITS
7-bit address mode. Standard addressing mode supporting up to 128 unique devices.
Definition vsf_template_i2c.h:307
@ 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:287
@ VSF_I2C_SPEED_FAST_MODE
Fast mode, up to 400 kbit/s. Commonly used medium speed I2C mode.
Definition vsf_template_i2c.h:277
@ VSF_I2C_ADDR_10_BITS
10-bit address mode. Extended addressing mode supporting up to 1024 unique devices.
Definition vsf_template_i2c.h:317
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:187
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:101
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:169
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_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:338
@ 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:362
@ 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:373
@ VSF_I2C_SPEED_MASK
Mask for I2C speed mode configuration. Extracts all speed mode bits (standard, fast,...
Definition vsf_template_i2c.h:349
vsf_i2c_cmd_t
Predefined VSF I2C commands that can be reimplemented in specific HAL drivers.
Definition vsf_template_i2c.h:385
@ 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:456
@ 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:446
@ 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:424
@ VSF_I2C_CMD_RESTART
Restart condition command. Generates a repeated START condition without releasing the bus....
Definition vsf_template_i2c.h:436
@ VSF_I2C_CMD_WRITE
Write command for I2C data transfer. Used to write data on the I2C bus.
Definition vsf_template_i2c.h:394
@ VSF_I2C_CMD_READ
Read command for I2C data transfer. Used to read data from the I2C bus.
Definition vsf_template_i2c.h:404
@ 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:414
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:158
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:146
vsf_i2c_ctrl_t
I2C control commands for hardware-specific operations.
Definition vsf_template_i2c.h:910
@ __VSF_I2C_CTRL_DUMMP
Definition vsf_template_i2c.h:949
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:133
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:538
@ 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:650
@ 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:689
@ 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:577
@ 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:663
@ 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:551
@ VSF_I2C_IRQ_MASK_MASTER_ERR
Master mode: Error interrupt. Triggered on any error condition in master mode. Only valid in master m...
Definition vsf_template_i2c.h:625
@ 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:565
@ 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:715
@ 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:637
@ 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:601
@ VSF_I2C_IRQ_MASK_SLAVE_ERR
Slave mode: Error interrupt. Triggered on any error condition in slave mode. Only valid in slave mode...
Definition vsf_template_i2c.h:727
@ 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:675
@ 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:589
@ 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:613
@ 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:703
@ 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:477
@ 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:487
@ 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:499
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:850
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:119
#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@74aa6ce