|
|
|
@ -61,24 +61,29 @@ esp_err_t periph_init() { |
|
|
|
|
return rv; |
|
|
|
|
} |
|
|
|
|
#else |
|
|
|
|
int i2c_co2_port = I2C_NUM_1; |
|
|
|
|
|
|
|
|
|
const uart_config_t uart_config = { |
|
|
|
|
.baud_rate = 9600, |
|
|
|
|
.data_bits = UART_DATA_8_BITS, |
|
|
|
|
.parity = UART_PARITY_DISABLE, |
|
|
|
|
.stop_bits = UART_STOP_BITS_1, |
|
|
|
|
.use_ref_tick = true |
|
|
|
|
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE, |
|
|
|
|
.source_clk = UART_SCLK_APB, |
|
|
|
|
//.use_ref_tick = true
|
|
|
|
|
}; |
|
|
|
|
ESP_ERROR_CHECK( uart_param_config(UART_NUM_1, &uart_config) ); |
|
|
|
|
|
|
|
|
|
// Set UART pins(TX: IO17 (UART2 default), RX: IO16 (UART2 default), RTS: IO18, CTS: IO19)
|
|
|
|
|
ESP_ERROR_CHECK(uart_set_pin(UART_NUM_2,
|
|
|
|
|
ESP_ERROR_CHECK(uart_driver_install(i2c_co2_port, |
|
|
|
|
/* rxbuf */ 256, /* txbuf */ 256, /* que */ 0, /* uart que */ NULL, /* alloc flags */ 0)); |
|
|
|
|
|
|
|
|
|
ESP_ERROR_CHECK( uart_param_config(i2c_co2_port, &uart_config) ); |
|
|
|
|
|
|
|
|
|
// Set UART pins(TX, RX, RTS, CTS)
|
|
|
|
|
ESP_ERROR_CHECK(uart_set_pin(i2c_co2_port,
|
|
|
|
|
CONFIG_PIN_I2C_SCL1, |
|
|
|
|
CONFIG_PIN_I2C_SDA1,
|
|
|
|
|
UART_PIN_NO_CHANGE,
|
|
|
|
|
UART_PIN_NO_CHANGE)); |
|
|
|
|
|
|
|
|
|
ESP_ERROR_CHECK(uart_driver_install(UART_NUM_1, |
|
|
|
|
/* rxbuf */ 256, /* txbuf */ 0, /* que */ 0, /* uart que */ NULL, /* alloc flags */ 0)); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -95,7 +100,7 @@ esp_err_t periph_init() { |
|
|
|
|
return rv; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
gpio_set_level(CONFIG_PIN_CO2_COMSEL, 0); // low=I2C
|
|
|
|
|
gpio_set_level(CONFIG_PIN_CO2_COMSEL, 1); // low=I2C
|
|
|
|
|
gpio_set_level(CONFIG_PIN_CO2_EN, 1); // active high
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|