• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
3  *
4  * This file is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef _I2C_BES_H__
10 #define _I2C_BES_H__
11 
12 #include "hal_i2c.h"
13 #include "hal_iomux.h"
14 #ifdef CHIP_BEST2003
15 #include "hal_iomux_best2003.h"
16 #endif
17 #include "device_resource_if.h"
18 #include "osal_mutex.h"
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 struct I2cResource {
24     uint32_t port;
25     uint32_t mode;
26     uint32_t sclPin;
27     uint32_t sdaPin;
28     uint32_t useSync;
29     uint32_t useDma;
30     uint32_t asMaster;
31     uint32_t speed;
32     uint32_t addrAsSlave;
33     uint32_t addressWidth;
34 };
35 
36 struct I2cDevice {
37     uint16_t devAddr;      /**< device addr */
38     uint32_t addressWidth; /**< Addressing mode: 7 bit or 10 bit */
39     struct OsalMutex mutex;
40     uint32_t port;
41     struct HAL_I2C_CONFIG_T i2cCfg;
42     struct I2cResource resource;
43 };
44 
45 #ifdef __cplusplus
46 }
47 #endif
48 
49 #endif
50