From 796148a4c59f543bcf1c30bd4a12d8071a3bd892 Mon Sep 17 00:00:00 2001 From: XiaochaoGONG Date: Wed, 3 Apr 2019 11:41:33 +0800 Subject: [PATCH] Add choice for selecting affinited core --- Kconfig | 15 +++++++++++++++ driver/camera.c | 11 +++++++++-- sensors/ov3660.c | 4 +--- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Kconfig b/Kconfig index 56934a0..8d3af00 100755 --- a/Kconfig +++ b/Kconfig @@ -27,5 +27,20 @@ config SCCB_HARDWARE_I2C help Enable this option if you want to use hardware I2C to control the camera. Disable this option to use software I2C. + +choice CAMERA_TASK_PINNED_TO_CORE + bool "Camera task pinned to core" + default CAMERA_CORE0 + help + Pin the camera handle task to a certain core(0/1). It can also be done automatically choosing NO_AFFINITY. + + config CAMERA_CORE0 + bool "CORE0" + config CAMERA_CORE1 + bool "CORE1" + config CAMERA_NO_AFFINITY + bool "NO_AFFINITY" + +endchoice endmenu diff --git a/driver/camera.c b/driver/camera.c index 3d00939..6058b1c 100755 --- a/driver/camera.c +++ b/driver/camera.c @@ -968,7 +968,7 @@ esp_err_t camera_probe(const camera_config_t* config, camera_model_t* out_camera vTaskDelay(10 / portTICK_PERIOD_MS); gpio_set_level(config->pin_reset, 1); vTaskDelay(10 / portTICK_PERIOD_MS); -#if CONFIG_OV2640_SUPPORT +#if (CONFIG_OV2640_SUPPORT && !CONFIG_OV3660_SUPPORT) } else { //reset OV2640 SCCB_Write(0x30, 0xFF, 0x01);//bank sensor @@ -1176,7 +1176,14 @@ esp_err_t camera_init(const camera_config_t* config) } //ToDo: core affinity? - if (!xTaskCreatePinnedToCore(&dma_filter_task, "dma_filter", 4096, NULL, 10, &s_state->dma_filter_task, 0)) { +#if CONFIG_CAMERA_CORE0 + if (!xTaskCreatePinnedToCore(&dma_filter_task, "dma_filter", 4096, NULL, 10, &s_state->dma_filter_task, 0)) +#elif CONFIG_CAMERA_CORE1 + if (!xTaskCreatePinnedToCore(&dma_filter_task, "dma_filter", 4096, NULL, 10, &s_state->dma_filter_task, 1)) +#else + if (!xTaskCreate(&dma_filter_task, "dma_filter", 4096, NULL, 10, &s_state->dma_filter_task)) +#endif + { ESP_LOGE(TAG, "Failed to create DMA filter task"); err = ESP_ERR_NO_MEM; goto fail; diff --git a/sensors/ov3660.c b/sensors/ov3660.c index c23314f..f59011d 100755 --- a/sensors/ov3660.c +++ b/sensors/ov3660.c @@ -17,11 +17,9 @@ #include "freertos/task.h" #if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) -#include "Arduino.h" #include "esp32-hal-log.h" #else #include "esp_log.h" -#define delay(x) static const char *TAG = "ov3660"; #endif @@ -99,7 +97,7 @@ static int write_regs(uint8_t slv_addr, const uint16_t (*regs)[2]) int i = 0, ret = 0; while (!ret && regs[i][0] != REGLIST_TAIL) { if (regs[i][0] == REG_DLY) { - delay(regs[i][1]); + vTaskDelay(regs[i][1] / portTICK_PERIOD_MS); } else { ret = write_reg(slv_addr, regs[i][0], regs[i][1]); }