VSF Documented
vsf_i2c_util.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_I2C_UTIL_H__
19#define __HAL_I2C_UTIL_H__
20
21/* Utilities for i2c: reg access utility, etc */
22
23/*============================ INCLUDES ======================================*/
24
25#if VSF_HAL_USE_I2C == ENABLED
26
27#if defined(__VSF_I2C_UTIL_CLASS_IMPLEMENT)
28# undef __VSF_I2C_UTIL_CLASS_IMPLEMENT
29# define __VSF_CLASS_IMPLEMENT__
30#elif defined(__VSF_I2C_UTIL_CLASS_INHERIT__)
31# undef __VSF_I2C_UTIL_CLASS_INHERIT__
32# define __VSF_CLASS_INHERIT__
33#endif
34
35#include "utilities/ooc_class.h"
36
37/*============================ MACROS ========================================*/
38/*============================ MACROFIED FUNCTIONS ===========================*/
39/*============================ INCLUDES ======================================*/
40/*============================ TYPES =========================================*/
41
43 public_member(
44 vsf_i2c_t *i2c_ptr;
45 uint8_t i2c_addr;
46 // register address size in bytes: 1 or 2(sent big-endian, for
47 // devices with a 16-bit register map). device drivers state this
48 // explicitly in their init; the instance zero default reads as 1
49 // only to keep pre-existing callers source-compatible
50 uint8_t reg_addr_len;
51 )
52 protected_member(
54 uint16_t datalen;
55 void *data;
56 )
57 private_member(
58 // register address staging bytes(big-endian), implementation
59 // scratch only - no consumer touches it across completion
60 uint8_t reg_buf[2];
61 uint8_t is_busy : 1;
62 uint8_t is_read : 1;
63 uint8_t is_regaddr : 1;
64 )
65};
66
67/*============================ GLOBAL VARIABLES ==============================*/
68/*============================ LOCAL VARIABLES ===============================*/
69/*============================ PROTOTYPES ====================================*/
70/*============================ IMPLEMENTATION ================================*/
71
75 bool is_read, uint8_t *data, uint_fast16_t datalen);
76
77#endif // VSF_HAL_USE_I2C
78#endif // __HAL_I2C_UTIL_H__
vsf_err_t
Definition __type.h:42
Definition vsf_i2c_util.h:42
vsf_i2c_irq_mask_t
Definition i2c.h:103
struct ieee80211_ext_chansw_ie data
Definition ieee80211.h:80
#define vsf_class(__name)
Definition ooc_class.h:52
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 short uint_fast16_t
Definition stdint.h:25
unsigned char uint8_t
Definition stdint.h:5
I2C instance structure for multi-class support.
Definition vsf_template_i2c.h:1056
class vsf_$ * reg
vsf_err_t vsf_i2c_regacc(vsf_i2c_regacc_t *i2c_regacc, uint_fast16_t reg, bool is_read, uint8_t *data, uint_fast16_t datalen)
Definition vsf_i2c_util.c:60
vsf_err_t vsf_i2c_regacc_irqhandler(vsf_i2c_regacc_t *i2c_regacc, vsf_i2c_irq_mask_t irq_mask)
Definition vsf_i2c_util.c:33
Generated from commit: vsfteam/vsf@37e3cbb