summaryrefslogtreecommitdiff
path: root/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/config/rt7/i2c_hard_config.h
blob: d48f6221f16c13f236e593022f7ae86a582ebf47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
 * Copyright (c) 2006-2026, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author         Notes
 * 2026-06-07     dirtwillfly    first version for NS800
 */
#ifndef __I2C_HARD_CONFIG_H__
#define __I2C_HARD_CONFIG_H__

#include <rtthread.h>

#ifdef __cplusplus
extern "C" {
#endif

/* I2C1 default GPIO configuration */
/* GPIO_0 (SDA) -> GPIOA, GPIO_PIN_0 */
/* GPIO_1 (SCL) -> GPIOA, GPIO_PIN_1 */
#ifndef BSP_I2C1_SCL_PIN_NUM
#define BSP_I2C1_SCL_PIN_NUM     1U
#endif
#ifndef BSP_I2C1_SDA_PIN_NUM
#define BSP_I2C1_SDA_PIN_NUM     0U
#endif
#ifndef BSP_I2C1_SCL_PORT
#define BSP_I2C1_SCL_PORT        GPIOA
#endif
#ifndef BSP_I2C1_SDA_PORT
#define BSP_I2C1_SDA_PORT        GPIOA
#endif
#ifndef BSP_I2C1_SCL_PIN
#define BSP_I2C1_SCL_PIN         GPIO_PIN_1
#endif
#ifndef BSP_I2C1_SDA_PIN
#define BSP_I2C1_SDA_PIN         GPIO_PIN_0
#endif
#ifndef BSP_I2C1_SCL_ALT_FUNC
#define BSP_I2C1_SCL_ALT_FUNC    ALT6_FUNCTION
#endif
#ifndef BSP_I2C1_SDA_ALT_FUNC
#define BSP_I2C1_SDA_ALT_FUNC    ALT6_FUNCTION
#endif

/* I2C2 default GPIO configuration */
/* GPIO_34 (SDA) -> GPIOB, GPIO_PIN_2 */
/* GPIO_35 (SCL) -> GPIOB, GPIO_PIN_3 */
#ifndef BSP_I2C2_SCL_PIN_NUM
#define BSP_I2C2_SCL_PIN_NUM     35U
#endif
#ifndef BSP_I2C2_SDA_PIN_NUM
#define BSP_I2C2_SDA_PIN_NUM     34U
#endif
#ifndef BSP_I2C2_SCL_PORT
#define BSP_I2C2_SCL_PORT        GPIOB
#endif
#ifndef BSP_I2C2_SDA_PORT
#define BSP_I2C2_SDA_PORT        GPIOB
#endif
#ifndef BSP_I2C2_SCL_PIN
#define BSP_I2C2_SCL_PIN         GPIO_PIN_3
#endif
#ifndef BSP_I2C2_SDA_PIN
#define BSP_I2C2_SDA_PIN         GPIO_PIN_2
#endif
#ifndef BSP_I2C2_SCL_ALT_FUNC
#define BSP_I2C2_SCL_ALT_FUNC    ALT6_FUNCTION
#endif
#ifndef BSP_I2C2_SDA_ALT_FUNC
#define BSP_I2C2_SDA_ALT_FUNC    ALT6_FUNCTION
#endif

#ifdef BSP_USING_HARD_I2C1
#ifndef BSP_I2C1_BAUDRATE
#define BSP_I2C1_BAUDRATE    100000
#endif

#ifndef I2C1_BUS_CONFIG
#define I2C1_BUS_CONFIG                                 \
    {                                                   \
        .name = "hwi2c1",                               \
        .Instance = I2C1,                               \
        .baudrate = BSP_I2C1_BAUDRATE,                  \
        .timeout = 1000,                                \
        .irq_type = I2C1_MST_IRQn,                      \
        .scl_pin_num = BSP_I2C1_SCL_PIN_NUM,            \
        .sda_pin_num = BSP_I2C1_SDA_PIN_NUM,            \
        .scl_port = BSP_I2C1_SCL_PORT,                  \
        .sda_port = BSP_I2C1_SDA_PORT,                  \
        .scl_pin = BSP_I2C1_SCL_PIN,                    \
        .sda_pin = BSP_I2C1_SDA_PIN,                    \
        .scl_alt_func = BSP_I2C1_SCL_ALT_FUNC,          \
        .sda_alt_func = BSP_I2C1_SDA_ALT_FUNC,          \
    }
#endif /* I2C1_BUS_CONFIG */
#endif /* BSP_USING_HARD_I2C1 */

#ifdef BSP_USING_HARD_I2C2
#ifndef BSP_I2C2_BAUDRATE
#define BSP_I2C2_BAUDRATE    100000
#endif

#ifndef I2C2_BUS_CONFIG
#define I2C2_BUS_CONFIG                                 \
    {                                                   \
        .name = "hwi2c2",                               \
        .Instance = I2C2,                               \
        .baudrate = BSP_I2C2_BAUDRATE,                  \
        .timeout = 1000,                                \
        .irq_type = I2C2_MST_IRQn,                      \
        .scl_pin_num = BSP_I2C2_SCL_PIN_NUM,            \
        .sda_pin_num = BSP_I2C2_SDA_PIN_NUM,            \
        .scl_port = BSP_I2C2_SCL_PORT,                  \
        .sda_port = BSP_I2C2_SDA_PORT,                  \
        .scl_pin = BSP_I2C2_SCL_PIN,                    \
        .sda_pin = BSP_I2C2_SDA_PIN,                    \
        .scl_alt_func = BSP_I2C2_SCL_ALT_FUNC,          \
        .sda_alt_func = BSP_I2C2_SDA_ALT_FUNC,          \
    }
#endif /* I2C2_BUS_CONFIG */
#endif /* BSP_USING_HARD_I2C2 */

#ifdef __cplusplus
}
#endif

#endif /* __I2C_HARD_CONFIG_H__ */