summaryrefslogtreecommitdiff
path: root/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/drv_i2c.h
blob: b173b58653181d512b87d24919389927c0b46d0f (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
/*
 * 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 __DRV_I2C_H__
#define __DRV_I2C_H__

#include "drv_config.h"
#include "board.h"
#include "rtdevice.h"

#ifdef __cplusplus
extern "C"
{
#endif

#define BSP_I2C_CTRL_SET_TIMING 0x40

struct ns800_i2c_config
{
    const char      *name;
    I2C_TypeDef     *Instance;
    uint32_t        baudrate;
    uint32_t        timeout;
    IRQn_Type       irq_type;
    uint32_t        scl_pin_num;     /* SCL pin number for get_pin_info */
    uint32_t        sda_pin_num;     /* SDA pin number for get_pin_info */
    GPIO_TypeDef    *scl_port;       /* SCL GPIO port */
    GPIO_TypeDef    *sda_port;       /* SDA GPIO port */
    GPIO_PinNum     scl_pin;         /* SCL pin in the port */
    GPIO_PinNum     sda_pin;         /* SDA pin in the port */
    GPIO_AltFunc    scl_alt_func;    /* SCL alternate function */
    GPIO_AltFunc    sda_alt_func;    /* SDA alternate function */
};

struct ns800_i2c
{
    struct ns800_i2c_config    *config;
    struct rt_i2c_bus_device    i2c_bus;
};

#ifdef __cplusplus
}
#endif

#endif /* __DRV_I2C_H__ */