Skip to content

How to use this driver in c project? e.g. an ESP-IDF hello_world example project written in C language #26

Open
@sonictl

Description

@sonictl

How to use this driver in C project? , e.g. an ESP-IDF hello_world example project written in C language

Hello, I tried to import the i2c and MPU repository as component under my 'hello_world' example project given by ESP-IDF.
if I modify the main.c into main.cpp by modifying some lines in main.c file and CMakeList.txt, the components works.

However, My project with lvgl lib needs to be developed by C language. When I directly using this driver for my MPU6050 on I2C, the error occurs when compiling.

How to use the cpp-written components in C project?

below is the file structure of my project:

% tree -L 3
.
├── CMakeLists.txt
├── Makefile
├── README.md
├── components
│   ├── I2Cbus      *No modification made in this dir
│   │   ├── CMakeLists.txt
│   │   ├── Kconfig
│   │   ├── Kconfig.projbuild
│   │   ├── LICENSE
│   │   ├── Makefile.projbuild
│   │   ├── README.md
│   │   ├── component.mk
│   │   ├── examples
│   │   ├── include
│   │   └── src
│   └── MPUdriver      *No modification made in this dir
│       ├── CMakeLists.txt
│       ├── Kconfig
│       ├── Kconfig.projbuild
│       ├── LICENSE
│       ├── Makefile.projbuild
│       ├── README.md
│       ├── component.mk
│       ├── docs
│       ├── examples
│       ├── include
│       ├── src
│       ├── test
│       └── tools
├── example_test.py
├── main
│   ├── CMakeLists.txt
│   ├── component.mk
│   ├── hello_world_main.c.bak
│   ├── main.c
│   └── main.cpp.ok.bak
├── sdkconfig
└── sdkconfig.old

Some error about namespace, I guess I need to configure something for using C++ component in C proj. but How?

Thank you very much!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions