esp_wifi/wifi/
os_adapter_esp32c2.rs

1use crate::hal::{interrupt, peripherals};
2
3pub(crate) fn chip_ints_on(mask: u32) {
4    unsafe {
5        peripherals::INTERRUPT_CORE0::regs()
6            .cpu_int_enable()
7            .modify(|r, w| w.bits(r.bits() | mask));
8    }
9}
10
11pub(crate) fn chip_ints_off(mask: u32) {
12    unsafe {
13        peripherals::INTERRUPT_CORE0::regs()
14            .cpu_int_enable()
15            .modify(|r, w| w.bits(r.bits() & !mask));
16    }
17}
18
19pub(crate) unsafe extern "C" fn set_intr(
20    _cpu_no: i32,
21    _intr_source: u32,
22    _intr_num: u32,
23    _intr_prio: i32,
24) {
25    // this gets called with
26    // INFO - set_intr 0 2 1 1 (WIFI_PWR)
27    // INFO - set_intr 0 0 1 1 (WIFI_MAC)
28
29    // we do nothing here since all the interrupts are already
30    // configured in `setup_timer_isr` and messing with the interrupts will
31    // get us into trouble
32}
33
34/// **************************************************************************
35/// Name: esp_set_isr
36///
37/// Description:
38///   Register interrupt function
39///
40/// Input Parameters:
41///   n   - Interrupt ID
42///   f   - Interrupt function
43///   arg - Function private data
44///
45/// Returned Value:
46///   None
47///
48/// *************************************************************************
49pub unsafe extern "C" fn set_isr(
50    n: i32,
51    f: *mut crate::binary::c_types::c_void,
52    arg: *mut crate::binary::c_types::c_void,
53) {
54    trace!("set_isr - interrupt {} function {:?} arg {:?}", n, f, arg);
55    match n {
56        0 => unsafe {
57            crate::wifi::ISR_INTERRUPT_1 = (f, arg);
58        },
59        1 => unsafe {
60            crate::wifi::ISR_INTERRUPT_1 = (f, arg);
61        },
62        _ => panic!("set_isr - unsupported interrupt number {}", n),
63    }
64    #[cfg(feature = "wifi")]
65    {
66        unwrap!(interrupt::enable(
67            peripherals::Interrupt::WIFI_MAC,
68            interrupt::Priority::Priority1
69        ));
70        unwrap!(interrupt::enable(
71            peripherals::Interrupt::WIFI_PWR,
72            interrupt::Priority::Priority1
73        ));
74    }
75}