-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from esp-cpp/refactor/peripheral-api
Refactor/peripheral api
- Loading branch information
Showing
23 changed files
with
504 additions
and
998 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
idf_component_register( | ||
INCLUDE_DIRS "include" | ||
SRC_DIRS "src" | ||
REQUIRES "driver" "heap" "fatfs" "esp_lcd" "esp_psram" "spi_flash" "nvs_flash" "codec" "display" "display_drivers" "controller" "mcp23x17" "ads1x15" "qwiicnes" "input_drivers" "ft5x06" "tt21100" "drv2605" "event_manager" | ||
REQUIRES "driver" "heap" "fatfs" "esp_lcd" "esp_psram" "spi_flash" "nvs_flash" "codec" "display" "display_drivers" "mcp23x17" "input_drivers" "tt21100" "drv2605" "event_manager" "i2c" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
|
||
#include "i2c.hpp" | ||
|
||
extern std::shared_ptr<espp::I2c> internal_i2c; | ||
extern std::shared_ptr<espp::I2c> external_i2c; | ||
|
||
void i2c_init(); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "hal_i2c.hpp" | ||
|
||
// Only used for the touchpad and the imu | ||
static constexpr i2c_port_t I2C_INTERNAL = I2C_NUM_0; | ||
// used for our peripherals (external to the ESP S3 BOX) | ||
static constexpr i2c_port_t I2C_EXTERNAL = I2C_NUM_1; | ||
static constexpr int I2C_FREQ_HZ = (400*1000); | ||
static constexpr int I2C_TIMEOUT_MS = 10; | ||
|
||
std::shared_ptr<espp::I2c> internal_i2c = nullptr; | ||
std::shared_ptr<espp::I2c> external_i2c = nullptr; | ||
|
||
static bool initialized = false; | ||
|
||
void i2c_init() { | ||
if (initialized) return; | ||
internal_i2c = std::make_shared<espp::I2c>(espp::I2c::Config{ | ||
.port = I2C_INTERNAL, | ||
.sda_io_num = GPIO_NUM_8, | ||
.scl_io_num = GPIO_NUM_18, | ||
.sda_pullup_en = GPIO_PULLUP_ENABLE, | ||
.scl_pullup_en = GPIO_PULLUP_ENABLE}); | ||
external_i2c = std::make_shared<espp::I2c>(espp::I2c::Config{ | ||
.port = I2C_EXTERNAL, | ||
.sda_io_num = GPIO_NUM_41, | ||
.scl_io_num = GPIO_NUM_40, | ||
.sda_pullup_en = GPIO_PULLUP_ENABLE, | ||
.scl_pullup_en = GPIO_PULLUP_ENABLE}); | ||
initialized = true; | ||
} |
Oops, something went wrong.