esp32_nimble/utilities/
nimble_npl_os.rs

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
use esp_idf_svc::sys::*;

#[inline]
#[allow(unused)]
pub fn ble_npl_hw_enter_critical() {
  #[cfg(all(esp32c3, esp_idf_version_major = "4"))]
  unsafe {
    vPortEnterCritical();
  }

  #[cfg(all(not(esp32c3), esp_idf_version_major = "4"))]
  unsafe {
    xPortEnterCriticalTimeout(&mut ble_port_mutex, portMUX_NO_TIMEOUT);
  };

  #[cfg(not(esp_idf_version_major = "4"))]
  unsafe {
    npl_freertos_hw_enter_critical();
  }
}

#[inline]
#[allow(unused)]
pub fn ble_npl_hw_exit_critical() {
  #[cfg(all(esp32c3, esp_idf_version_major = "4"))]
  unsafe {
    vPortExitCritical();
  }

  #[cfg(all(not(esp32c3), esp_idf_version_major = "4"))]
  unsafe {
    vPortExitCritical(&mut ble_port_mutex);
  };

  #[cfg(not(esp_idf_version_major = "4"))]
  unsafe {
    npl_freertos_hw_exit_critical(0);
  }
}