VSF Documented
mrequest_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/*
19 Use this template only if the STOP condition can not be controlled, ie hw will
20 automatically generate STOP condition by force. This template will merge all
21 requests before STOP and issue once as a workaround.
22*/
23
24#ifndef __HAL_DRIVER_COMMON_I2C_MERGER_REQUEST_H__
25#define __HAL_DRIVER_COMMON_I2C_MERGER_REQUEST_H__
26
27/*============================ INCLUDES ======================================*/
28
29#include "hal/vsf_hal_cfg.h"
30
31#if (VSF_HAL_USE_I2C == ENABLED) && (VSF_HAL_USE_MERGER_REQUEST_I2C == ENABLED)
32
33#if defined(__VSF_I2C_MERGER_REQUEST_CLASS_IMPLEMENT)
34# undef __VSF_I2C_MERGER_REQUEST_CLASS_IMPLEMENT
35# define __VSF_CLASS_IMPLEMENT__
36#endif
37
38#include "utilities/ooc_class.h"
39
40/*============================ MACROS ========================================*/
41
42#ifndef VSF_MREQUEST_I2C_CFG_REQEUST_BUFFER_SIZE
43# define VSF_MREQUEST_I2C_CFG_REQEUST_BUFFER_SIZE 3
44#endif
45
46#ifndef VSF_MREQUEST_I2C_CFG_MULTI_CLASS
47# define VSF_MREQUEST_I2C_CFG_MULTI_CLASS VSF_I2C_CFG_MULTI_CLASS
48#endif
49
50
51/*============================ MACROFIED FUNCTIONS ===========================*/
52
53#if VSF_MREQUEST_I2C_CFG_MULTI_CLASS == ENABLED
54# define __describe_mrequest_i2c_op() .op = &vsf_mrequest_i2c_op,
55#else
56# define __describe_mrequest_i2c_op()
57#endif
58
59#define __describe_mrequest_i2c(__name, __real_i2c) \
60 vsf_mrequest_i2c_t __name = { \
61 __describe_mrequest_i2c_op() \
62 .i2c_ptr = __real_i2c, \
63 };
64
65#define describe_mrequest_i2c(__name, __real_i2c) \
66 __describe_mrequest_i2c(__name, __real_i2c)
67
68/*============================ INCLUDES ======================================*/
69/*============================ TYPES =========================================*/
70
72 public_member(
74 implement(vsf_i2c_t)
75#endif
76 vsf_i2c_t *i2c_ptr;
77 )
78
79 private_member(
80 vsf_i2c_cfg_t cfg;
83
84 struct {
85 vsf_i2c_cmd_t cmd;
86 uint8_t *buffer_ptr;
87 uint16_t address;
88 uint16_t count;
89 } request;
90 )
91};
92
93/*============================ GLOBAL VARIABLES ==============================*/
94
95#define VSF_I2C_CFG_DEC_PREFIX vsf_mrequest
96#define VSF_I2C_CFG_DEC_UPCASE_PREFIX VSF_MREQUEST
97#define VSF_I2C_CFG_DEC_EXTERN_OP ENABLED
99
100/*============================ LOCAL VARIABLES ===============================*/
101/*============================ PROTOTYPES ====================================*/
102/*============================ IMPLEMENTATION ================================*/
103
104
105#endif // VSF_HAL_I2C_IMP_REQUEST_BY_CMD
106#endif
#define ENABLED
Definition __type.h:28
Definition mrequest_i2c.h:71
vsf_i2c_cmd_t
Definition i2c.h:32
#define VSF_MREQUEST_I2C_CFG_REQEUST_BUFFER_SIZE
Definition mrequest_i2c.h:43
#define VSF_MREQUEST_I2C_CFG_MULTI_CLASS
Definition mrequest_i2c.h:47
#define vsf_class(__name)
Definition ooc_class.h:48
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 char uint8_t
Definition stdint.h:5
i2c configuration
Definition vsf_template_i2c.h:314
Definition vsf_template_i2c.h:334
vsf_i2c_irq_mask_t
Definition vsf_template_i2c.h:194