diff --git a/CMakeLists.txt b/CMakeLists.txt index 36628a5b..7a9d3bbb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,8 @@ # https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html # The following five lines of boilerplate have to be in your project's # CMakeLists in this exact order for cmake to work correctly -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.8) +set(CMAKE_CXX_STANDARD 17) include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(gay-ipod-fw) diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 7ba80b22..97833c88 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -1,2 +1,2 @@ -idf_component_register(SRCS "gay-ipod-fw.c" +idf_component_register(SRCS "gay-ipod-fw.cpp" INCLUDE_DIRS ".") diff --git a/main/gay-ipod-fw.c b/main/gay-ipod-fw.c deleted file mode 100644 index 7b66f339..00000000 --- a/main/gay-ipod-fw.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -void app_main(void) -{ - -} diff --git a/main/gay-ipod-fw.cpp b/main/gay-ipod-fw.cpp new file mode 100644 index 00000000..1ca65f7a --- /dev/null +++ b/main/gay-ipod-fw.cpp @@ -0,0 +1,33 @@ +#include + +#include "esp_log.h" +#include "driver/i2c.h" + +#define I2C_SDA_IO (0) +#define I2C_SCL_IO (4) +// TODO: check if fast mode i2c (400000) will work. +#define I2C_CLOCK_HZ (100000) + +esp_err_t init_i2c(void) { + int i2c_port = 0; + i2c_config_t config = { + .mode = I2C_MODE_MASTER, + .sda_io_num = I2C_SDA_IO, + .scl_io_num = I2C_SCL_IO, + .sda_pullup_en = GPIO_PULLUP_ENABLE, + .scl_pullup_en = GPIO_PULLUP_ENABLE, + .master = { + .clk_speed = I2C_CLOCK_HZ, + }, + .clk_flags = 0, + }; + // TODO: INT line? + + ESP_ERROR_CHECK(i2c_param_config(i2c_port, &config)); + return i2c_driver_install(i2c_port, config.mode, 0, 0, 0); +} + +extern "C" void app_main(void) +{ + init_i2c(); +}