Skip to content
Snippets Groups Projects
Commit e15a1188 authored by moon2's avatar moon2 :speech_balloon:
Browse files

moved i2c into freertos timer

parent daec4e3d
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "esp_log.h" #include "esp_log.h"
#include "driver/i2c.h" #include "driver/i2c.h"
#include "driver/spi_master.h" #include "driver/spi_master.h"
#include <freertos/timers.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
...@@ -54,6 +55,11 @@ static esp_err_t i2c_master_init(void) ...@@ -54,6 +55,11 @@ static esp_err_t i2c_master_init(void)
#define CAPTOUCH_POLLING_PERIOD 15 #define CAPTOUCH_POLLING_PERIOD 15
static uint8_t hw_init_done = 0; static uint8_t hw_init_done = 0;
void i2c_task(TimerHandle_t data){
update_button_state();
captouch_read_cycle();
}
void os_app_main(void) void os_app_main(void)
{ {
ESP_LOGI(TAG, "Starting on %s...", badge23_hw_name); ESP_LOGI(TAG, "Starting on %s...", badge23_hw_name);
...@@ -66,15 +72,10 @@ void os_app_main(void) ...@@ -66,15 +72,10 @@ void os_app_main(void)
init_buttons(); init_buttons();
captouch_init(); captouch_init();
display_init(); display_init();
hw_init_done = 1;
while(1) {
vTaskDelay((CAPTOUCH_POLLING_PERIOD) / portTICK_PERIOD_MS);
update_button_state();
captouch_read_cycle();
}
ESP_ERROR_CHECK(i2c_driver_delete(I2C_MASTER_NUM)); TimerHandle_t i2c = xTimerCreate("I2C task", pdMS_TO_TICKS(CAPTOUCH_POLLING_PERIOD), pdTRUE, (void *) 0, *i2c_task);
ESP_LOGI(TAG, "I2C de-initialized successfully"); if( xTimerStart(i2c, 0 ) != pdPASS) ESP_LOGI(TAG, "I2C task initialization failed");
hw_init_done = 1;
} }
uint8_t hardware_is_initialized(){ uint8_t hardware_is_initialized(){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment