Select one of the symbols to view example projects that use it.
 
Outline
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "esp_compiler.h"
#include "esp_private/log_lock.h"
#define MAX_MUTEX_WAIT_MS
#define MAX_MUTEX_WAIT_TICKS
s_log_mutex
esp_log_impl_lock()
esp_log_impl_lock_timeout()
esp_log_impl_unlock()
Files
loading...
SourceVuESP-IDF Framework and ExamplesESP-IDFcomponents/log/src/os/log_lock.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 *//* ... */ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/semphr.h" #include "esp_compiler.h" #include "esp_private/log_lock.h"5 includes // Maximum time to wait for the mutex in a logging statement. // // We don't expect this to happen in most cases, as contention is low. The most likely case is if a // log function is called from an ISR (technically caller should use the ISR-friendly logging macros but // possible they use the normal one instead and disable the log type by tag). #define MAX_MUTEX_WAIT_MS 10 #define MAX_MUTEX_WAIT_TICKS ((MAX_MUTEX_WAIT_MS + portTICK_PERIOD_MS - 1) / portTICK_PERIOD_MS) static SemaphoreHandle_t s_log_mutex = NULL; void esp_log_impl_lock(void) { if (unlikely(!s_log_mutex)) { s_log_mutex = xSemaphoreCreateMutex(); }{...} if (unlikely(xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED)) { return; }{...} xSemaphoreTake(s_log_mutex, portMAX_DELAY); }{ ... } bool esp_log_impl_lock_timeout(void) { if (unlikely(!s_log_mutex)) { s_log_mutex = xSemaphoreCreateMutex(); }{...} if (unlikely(xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED)) { return true; }{...} return xSemaphoreTake(s_log_mutex, MAX_MUTEX_WAIT_TICKS) == pdTRUE; }{ ... } void esp_log_impl_unlock(void) { if (unlikely(xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED)) { return; }{...} xSemaphoreGive(s_log_mutex); }{ ... }
Details