VSF Documented
vsf_gpio_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 __HAL_DRIVER_GPIO_I2C_H__
19#define __HAL_DRIVER_GPIO_I2C_H__
20
21/*============================ INCLUDES ======================================*/
22
23#include "hal/vsf_hal_cfg.h"
24
25#if (VSF_HAL_USE_I2C == ENABLED) && (VSF_HAL_USE_GPIO_I2C == ENABLED)
26
27#if defined(__VSF_HAL_GPIO_I2C_CLASS_IMPLEMENT)
28# define __VSF_CLASS_IMPLEMENT__
29#endif
30
31#include "utilities/ooc_class.h"
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37/*============================ MACROS ========================================*/
38
39#ifndef VSF_GPIO_I2C_CFG_MULTI_CLASS
40# define VSF_GPIO_I2C_CFG_MULTI_CLASS VSF_I2C_CFG_MULTI_CLASS
41#endif
42
43/*============================ MACROFIED FUNCTIONS ===========================*/
44
45#if VSF_GPIO_I2C_CFG_MULTI_CLASS == ENABLED
46# define __describe_gpio_i2c_op() .op = &vsf_gpio_i2c_op,
47#else
48# define __describe_gpio_i2c_op()
49#endif
50
51#define __describe_gpio_i2c(__name, __gpio_port, __fn_delay, __scl_pin, __sda_pin)\
52 vsf_gpio_i2c_t __name = { \
53 __describe_gpio_i2c_op() \
54 .port = (__gpio_port), \
55 .fn_delay = (__fn_delay), \
56 .scl_pin = (__scl_pin), \
57 .sda_pin = (__sda_pin), \
58 };
59
60#define describe_gpio_i2c(__name, __gpio_port, __fn_delay, __scl_pin, __sda_pin)\
61 __describe_gpio_i2c(__name, (__gpio_port), (__fn_delay), (__scl_pin), (__sda_pin))
62
63/*============================ TYPES =========================================*/
64
66
67typedef void (*vsf_gpio_i2c_delay)(vsf_gpio_i2c_t *gpio_i2c_ptr);
68
70#if VSF_GPIO_I2C_CFG_MULTI_CLASS == ENABLED
71 public_member(
72 implement(vsf_i2c_t)
73 )
74#endif
75 private_member(
76 vsf_i2c_cfg_t cfg;
78 vsf_i2c_irq_mask_t enabled_irq_mask;
79 uint16_t transferred_count;
80
81 bool is_busy;
82 bool is_enabled;
83 )
84
85 public_member(
86 vsf_gpio_t *port;
87 vsf_gpio_i2c_delay fn_delay;
88 uint8_t scl_pin;
89 uint8_t sda_pin;
90 )
91};
92
93
94/*============================ INCLUDES ======================================*/
95
96#define VSF_I2C_CFG_DEC_PREFIX vsf_gpio
97#define VSF_I2C_CFG_DEC_UPCASE_PREFIX VSF_GPIO
98#define VSF_I2C_CFG_DEC_EXTERN_OP ENABLED
100
101#ifdef __cplusplus
102}
103#endif
104
105#endif /* (VSF_HAL_USE_I2C == ENABLED) && (__HAL_DRIVER_GPIO_I2C_H__ == ENABLED) */
106#endif /* EOF */
Definition vsf_gpio_i2c.h:69
#define vsf_dcl_class
Definition ooc_class.h:46
#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
Definition vsf_template_gpio.h:471
i2c configuration
Definition vsf_template_i2c.h:314
Definition vsf_template_i2c.h:334
void(* vsf_gpio_i2c_delay)(vsf_gpio_i2c_t *gpio_i2c_ptr)
Definition vsf_gpio_i2c.h:67
vsf_i2c_irq_mask_t
Definition vsf_template_i2c.h:194