moved to configurable components, added SSD1306 support

This commit is contained in:
Lurkars
2020-07-15 22:22:54 +02:00
parent 1eedea1b9a
commit eaf1c74faa
35 changed files with 1577 additions and 621 deletions
+7
View File
@@ -0,0 +1,7 @@
idf_component_register(
SRCS
"i2c-main.c"
INCLUDE_DIRS "."
PRIV_REQUIRES
driver
)
+39
View File
@@ -0,0 +1,39 @@
// Copyright 2020 Lukas Haubaum
//
// Licensed under the GNU Affero General Public License, Version 3;
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// https://www.gnu.org/licenses/agpl-3.0.html
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <stdio.h>
#include "driver/i2c.h"
#include "i2c-main.h"
static bool i2c_initialized = false;
void i2c_main_init()
{
i2c_config_t i2c_config = {
.mode = I2C_MODE_MASTER,
.sda_io_num = I2C_SDA_PIN,
.scl_io_num = I2C_SCL_PIN,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = I2C_CLK_SPEED};
ESP_ERROR_CHECK(i2c_param_config(I2C_NUM_0, &i2c_config));
ESP_ERROR_CHECK(i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 0));
}
bool i2c_is_initialized()
{
return i2c_initialized;
}
+35
View File
@@ -0,0 +1,35 @@
// Copyright 2020 Lukas Haubaum
//
// Licensed under the GNU Affero General Public License, Version 3;
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// https://www.gnu.org/licenses/agpl-3.0.html
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _i2c_main_H_
#define _i2c_main_H_
#define I2C_SDA_PIN (21)
#define I2C_SCL_PIN (22)
#define I2C_CLK_SPEED (1000000)
/**
* @brief initialize main I2C interface
*/
void i2c_main_init();
/**
* @brief check if I2C interface already initialized
*
* @return
* - false I2C not initialized
* - true I2C initialized
*/
bool i2c_is_initialized();
#endif