summaryrefslogtreecommitdiff
path: root/bsp/raspberry-pico/Drivers/drv_soft_i2c.h
blob: b5e663b673e7855f32d4dcab6ee0cf93e6a81cc8 (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
/*
 * Copyright (c) 2006-2023, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2023/06/01     chushicheng  first version
 */

#ifndef __DRV_SOFT_I2C__
#define __DRV_SOFT_I2C__

#include <rtdevice.h>
#include "drv_gpio.h"
#include "board.h"

#ifdef BSP_USING_SOFT_I2C
/* pico i2c dirver class */
struct pico_i2c
{
    struct rt_i2c_bit_ops ops;
    struct rt_i2c_bus_device i2c_bus;
};

/* pico config class */
struct pico_soft_i2c_config
{
    rt_uint8_t scl;
    rt_uint8_t sda;
    const char *bus_name;
};

#ifdef BSP_USING_SOFT_I2C1
#define I2C1_BUS_CONFIG                                  \
    {                                                    \
        .scl = BSP_SOFT_I2C1_SCL_PIN,                    \
        .sda = BSP_SOFT_I2C1_SDA_PIN,                    \
        .bus_name = "i2c1",                              \
    }
#endif

int rt_soft_i2c_init(void);

#endif /* BSP_USING_SOFT_I2C */
#endif