moved i2c driver init+gpio
This commit is contained in:
parent
f860dc7c19
commit
2acd83103f
@ -1 +1 @@
|
|||||||
Subproject commit 30a1c5637313ff0a93a2e06e5043c918e5a0c61d
|
Subproject commit c810cb4680c1d384120b3f0b1ee0362dc9d1aa70
|
@ -1,8 +1,10 @@
|
|||||||
#include "CO2_Sense.h"
|
#include "CO2_Sense.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/portmacro.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "hal/gpio_types.h"
|
||||||
#include "nvs_flash.h"
|
#include "nvs_flash.h"
|
||||||
|
|
||||||
#include "lwip/err.h"
|
#include "lwip/err.h"
|
||||||
@ -10,6 +12,8 @@
|
|||||||
|
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "esp_sleep.h"
|
#include "esp_sleep.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
#include "driver/i2c.h"
|
||||||
|
|
||||||
#include "ledController.h"
|
#include "ledController.h"
|
||||||
#include "scd4x_i2c.h"
|
#include "scd4x_i2c.h"
|
||||||
@ -23,6 +27,16 @@ void app_main(void){
|
|||||||
nvs_handle_t nvs_handle;
|
nvs_handle_t nvs_handle;
|
||||||
ESP_ERROR_CHECK(nvs_open("main", NVS_READWRITE, &nvs_handle));
|
ESP_ERROR_CHECK(nvs_open("main", NVS_READWRITE, &nvs_handle));
|
||||||
|
|
||||||
|
// setup GPIOs
|
||||||
|
gpio_config_t VBAT_OK_c = {
|
||||||
|
GPIO_NUM_3,
|
||||||
|
GPIO_MODE_INPUT,
|
||||||
|
GPIO_PULLUP_DISABLE,
|
||||||
|
GPIO_PULLDOWN_DISABLE,
|
||||||
|
GPIO_INTR_DISABLE,
|
||||||
|
};
|
||||||
|
ESP_ERROR_CHECK(gpio_config(&VBAT_OK_c));
|
||||||
|
|
||||||
configuration_data_t* conf = malloc(sizeof(configuration_data_t));
|
configuration_data_t* conf = malloc(sizeof(configuration_data_t));
|
||||||
init_conf_from_nvs(conf, nvs_handle);
|
init_conf_from_nvs(conf, nvs_handle);
|
||||||
|
|
||||||
@ -84,10 +98,22 @@ void init_nvs(void){
|
|||||||
ESP_ERROR_CHECK(ret);
|
ESP_ERROR_CHECK(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void init_i2c(){
|
||||||
|
int i2c_master_port = I2C_NUM_0;
|
||||||
|
i2c_config_t conf = {
|
||||||
|
.mode = I2C_MODE_MASTER,
|
||||||
|
.sda_io_num = CONFIG_SDA_PIN,
|
||||||
|
.sda_pullup_en = GPIO_PULLUP_DISABLE,
|
||||||
|
.scl_io_num = CONFIG_SCL_PIN,
|
||||||
|
.scl_pullup_en = GPIO_PULLUP_DISABLE,
|
||||||
|
.master.clk_speed = 10000,
|
||||||
|
// .clk_flags = 0, /*!< Optional, you can use I2C_SCLK_SRC_FLAG_* flags to choose i2c source clock here. */
|
||||||
|
};
|
||||||
|
i2c_param_config(i2c_master_port, &conf);
|
||||||
|
i2c_driver_install(i2c_master_port, I2C_MODE_MASTER, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void init_scd4x(){
|
void init_scd4x(){
|
||||||
sensirion_i2c_hal_init(CONFIG_SDA_PIN, CONFIG_SCL_PIN);
|
|
||||||
|
|
||||||
scd4x_wake_up();
|
scd4x_wake_up();
|
||||||
scd4x_stop_periodic_measurement();
|
scd4x_stop_periodic_measurement();
|
||||||
scd4x_reinit();
|
scd4x_reinit();
|
||||||
|
@ -6,5 +6,6 @@ void fetch_sensor_task(void* pvParameters);
|
|||||||
void init_nvs(void);
|
void init_nvs(void);
|
||||||
void init_avahi(char* hostname);
|
void init_avahi(char* hostname);
|
||||||
void init_http_server(configuration_data_t* main_conf);
|
void init_http_server(configuration_data_t* main_conf);
|
||||||
|
void init_i2c();
|
||||||
void init_scd4x();
|
void init_scd4x();
|
||||||
led_disp_config_t* generate_led_conf(nvs_handle_t nvs, unsigned int nb);
|
led_disp_config_t* generate_led_conf(nvs_handle_t nvs, unsigned int nb);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user