Skip to content

Commit

Permalink
Merge pull request #451 from adafruit/deinit-check
Browse files Browse the repository at this point in the history
don't reset LEDC channel if it wasn't used by camera
  • Loading branch information
me-no-dev authored Sep 23, 2022
2 parents 5611989 + 846554e commit de025b8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions target/xclk.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
static const char* TAG = "camera_xclk";
#endif

static ledc_channel_t g_ledc_channel = 0;
#define NO_CAMERA_LEDC_CHANNEL 0xFF
static ledc_channel_t g_ledc_channel = NO_CAMERA_LEDC_CHANNEL;

esp_err_t xclk_timer_conf(int ledc_timer, int xclk_freq_hz)
{
Expand Down Expand Up @@ -60,5 +61,8 @@ esp_err_t camera_enable_out_clock(camera_config_t* config)

void camera_disable_out_clock()
{
ledc_stop(LEDC_LOW_SPEED_MODE, g_ledc_channel, 0);
if (g_ledc_channel != NO_CAMERA_LEDC_CHANNEL) {
ledc_stop(LEDC_LOW_SPEED_MODE, g_ledc_channel, 0);
g_ledc_channel = NO_CAMERA_LEDC_CHANNEL;
}
}

0 comments on commit de025b8

Please sign in to comment.