Enter a critical section from normal task or ISR. This macro will check if the current CPU is processing an ISR or not and enter the critical section accordingly. On multi-core systems, this will disable interrupts and take the spinlock \c lock. On single core systems, a spinlock is unncessary, hence \c lock is ignored and interrupts are disabled only. Example usage with static locks:
{c}
...
#include "os/critical_section.h"
...
DEFINE_CRIT_SECTION_LOCK_STATIC(my_lock); // will have internal linking (static)
...
esp_os_enter_critical(&my_lock);
// code inside critical section
esp_os_exit_critical(&my_lock);