esp_wifi/wifi/os_adapter.rs
1#[cfg_attr(esp32c3, path = "os_adapter_esp32c3.rs")]
2#[cfg_attr(esp32c2, path = "os_adapter_esp32c2.rs")]
3#[cfg_attr(esp32c6, path = "os_adapter_esp32c6.rs")]
4#[cfg_attr(esp32h2, path = "os_adapter_esp32h2.rs")]
5#[cfg_attr(esp32, path = "os_adapter_esp32.rs")]
6#[cfg_attr(esp32s3, path = "os_adapter_esp32s3.rs")]
7#[cfg_attr(esp32s2, path = "os_adapter_esp32s2.rs")]
8pub(crate) mod os_adapter_chip_specific;
9
10use core::{cell::RefCell, ptr::addr_of_mut};
11
12use enumset::EnumSet;
13
14use super::WifiEvent;
15use crate::{
16 compat::{
17 common::{
18 create_queue,
19 create_recursive_mutex,
20 delete_queue,
21 lock_mutex,
22 number_of_messages_in_queue,
23 receive_queued,
24 send_queued,
25 str_from_c,
26 thread_sem_get,
27 unlock_mutex,
28 ConcurrentQueue,
29 },
30 malloc::calloc,
31 },
32 hal::{
33 clock::RadioClockController,
34 peripherals::RADIO_CLK,
35 sync::{Locked, RawMutex},
36 },
37 memory_fence::memory_fence,
38 preempt::yield_task,
39};
40
41static WIFI_LOCK: RawMutex = RawMutex::new();
42
43static mut QUEUE_HANDLE: *mut ConcurrentQueue = core::ptr::null_mut();
44
45// useful for waiting for events - clear and wait for the event bit to be set
46// again
47pub(crate) static WIFI_EVENTS: Locked<RefCell<EnumSet<WifiEvent>>> =
48 Locked::new(RefCell::new(enumset::enum_set!()));
49
50/// **************************************************************************
51/// Name: wifi_env_is_chip
52///
53/// Description:
54/// Config chip environment
55///
56/// Returned Value:
57/// True if on chip or false if on FPGA.
58///
59/// *************************************************************************
60pub unsafe extern "C" fn env_is_chip() -> bool {
61 true
62}
63
64/// **************************************************************************
65/// Name: wifi_set_intr
66///
67/// Description:
68/// Do nothing
69///
70/// Input Parameters:
71/// cpu_no - The CPU which the interrupt number belongs.
72/// intr_source - The interrupt hardware source number.
73/// intr_num - The interrupt number CPU.
74/// intr_prio - The interrupt priority.
75///
76/// Returned Value:
77/// None
78///
79/// *************************************************************************
80pub unsafe extern "C" fn set_intr(cpu_no: i32, intr_source: u32, intr_num: u32, intr_prio: i32) {
81 trace!(
82 "set_intr {} {} {} {}",
83 cpu_no,
84 intr_source,
85 intr_num,
86 intr_prio
87 );
88 crate::wifi::os_adapter::os_adapter_chip_specific::set_intr(
89 cpu_no,
90 intr_source,
91 intr_num,
92 intr_prio,
93 );
94}
95
96/// **************************************************************************
97/// Name: wifi_clear_intr
98///
99/// Description:
100/// Don't support
101///
102/// *************************************************************************
103pub unsafe extern "C" fn clear_intr(intr_source: u32, intr_num: u32) {
104 // original code does nothing here
105 trace!("clear_intr called {} {}", intr_source, intr_num);
106}
107
108pub static mut ISR_INTERRUPT_1: (
109 *mut crate::binary::c_types::c_void,
110 *mut crate::binary::c_types::c_void,
111) = (core::ptr::null_mut(), core::ptr::null_mut());
112
113/// **************************************************************************
114/// Name: esp32c3_ints_on
115///
116/// Description:
117/// Enable Wi-Fi interrupt
118///
119/// Input Parameters:
120/// mask - No mean
121///
122/// Returned Value:
123/// None
124///
125/// *************************************************************************
126pub unsafe extern "C" fn ints_on(mask: u32) {
127 trace!("chip_ints_on {:x}", mask);
128
129 crate::wifi::os_adapter::os_adapter_chip_specific::chip_ints_on(mask);
130}
131
132/// **************************************************************************
133/// Name: esp32c3_ints_off
134///
135/// Description:
136/// Disable Wi-Fi interrupt
137///
138/// Input Parameters:
139/// mask - No mean
140///
141/// Returned Value:
142/// None
143///
144/// *************************************************************************
145pub unsafe extern "C" fn ints_off(mask: u32) {
146 trace!("chip_ints_off {:x}", mask);
147
148 crate::wifi::os_adapter::os_adapter_chip_specific::chip_ints_off(mask);
149}
150
151/// **************************************************************************
152/// Name: wifi_is_from_isr
153///
154/// Description:
155/// Check current is in interrupt
156///
157/// Input Parameters:
158/// None
159///
160/// Returned Value:
161/// true if in interrupt or false if not
162///
163/// *************************************************************************
164pub unsafe extern "C" fn is_from_isr() -> bool {
165 true
166}
167
168/// **************************************************************************
169/// Name: esp_spin_lock_create
170///
171/// Description:
172/// Create spin lock in SMP mode
173///
174/// Input Parameters:
175/// None
176///
177/// Returned Value:
178/// Spin lock data pointer
179///
180/// *************************************************************************
181static mut FAKE_SPIN_LOCK: u8 = 1;
182pub unsafe extern "C" fn spin_lock_create() -> *mut crate::binary::c_types::c_void {
183 // original: return (void *)1;
184 let ptr = addr_of_mut!(FAKE_SPIN_LOCK);
185 trace!("spin_lock_create {:?}", ptr);
186 ptr as *mut crate::binary::c_types::c_void
187}
188
189/// **************************************************************************
190/// Name: esp_spin_lock_delete
191///
192/// Description:
193/// Delete spin lock
194///
195/// Input Parameters:
196/// lock - Spin lock data pointer
197///
198/// Returned Value:
199/// None
200///
201/// *************************************************************************
202pub unsafe extern "C" fn spin_lock_delete(lock: *mut crate::binary::c_types::c_void) {
203 // original: DEBUGASSERT((int)lock == 1);
204 trace!("spin_lock_delete {:?}", lock);
205}
206
207/// **************************************************************************
208/// Name: esp_wifi_int_disable
209///
210/// Description:
211/// Enter critical section by disabling interrupts and taking the spin lock
212/// if in SMP mode.
213///
214/// Input Parameters:
215/// wifi_int_mux - Spin lock data pointer
216///
217/// Returned Value:
218/// CPU PS value.
219///
220/// *************************************************************************
221pub unsafe extern "C" fn wifi_int_disable(
222 _wifi_int_mux: *mut crate::binary::c_types::c_void,
223) -> u32 {
224 trace!("wifi_int_disable");
225 // TODO: can we use wifi_int_mux?
226 unsafe { WIFI_LOCK.acquire() as _ }
227}
228
229/// **************************************************************************
230/// Name: esp_wifi_int_restore
231///
232/// Description:
233/// Exit from critical section by enabling interrupts and releasing the spin
234/// lock if in SMP mode.
235///
236/// Input Parameters:
237/// wifi_int_mux - Spin lock data pointer
238/// tmp - CPU PS value.
239///
240/// Returned Value:
241/// None
242///
243/// *************************************************************************
244pub unsafe extern "C" fn wifi_int_restore(
245 _wifi_int_mux: *mut crate::binary::c_types::c_void,
246 tmp: u32,
247) {
248 trace!("wifi_int_restore");
249 let token = tmp as critical_section::RawRestoreState;
250 unsafe { WIFI_LOCK.release(token) }
251}
252
253/// **************************************************************************
254/// Name: esp_task_yield_from_isr
255///
256/// Description:
257/// Do nothing in NuttX
258///
259/// Input Parameters:
260/// None
261///
262/// Returned Value:
263/// None
264///
265/// *************************************************************************
266pub unsafe extern "C" fn task_yield_from_isr() {
267 // original: /* Do nothing */
268 trace!("task_yield_from_isr");
269 yield_task();
270}
271
272/// **************************************************************************
273/// Name: esp_thread_semphr_get
274///
275/// Description:
276/// Get thread self's semaphore
277///
278/// Input Parameters:
279/// None
280///
281/// Returned Value:
282/// Semaphore data pointer
283///
284/// *************************************************************************
285pub unsafe extern "C" fn wifi_thread_semphr_get() -> *mut crate::binary::c_types::c_void {
286 thread_sem_get()
287}
288
289/// **************************************************************************
290/// Name: esp_mutex_create
291///
292/// Description:
293/// Create mutex
294///
295/// Input Parameters:
296/// None
297///
298/// Returned Value:
299/// Mutex data pointer
300///
301/// *************************************************************************
302pub unsafe extern "C" fn mutex_create() -> *mut crate::binary::c_types::c_void {
303 todo!("mutex_create")
304}
305
306/// **************************************************************************
307/// Name: esp_recursive_mutex_create
308///
309/// Description:
310/// Create recursive mutex
311///
312/// Input Parameters:
313/// None
314///
315/// Returned Value:
316/// Recursive mutex data pointer
317///
318/// *************************************************************************
319pub unsafe extern "C" fn recursive_mutex_create() -> *mut crate::binary::c_types::c_void {
320 create_recursive_mutex()
321}
322
323/// **************************************************************************
324/// Name: esp_mutex_delete
325///
326/// Description:
327/// Delete mutex
328///
329/// Input Parameters:
330/// mutex_data - mutex data pointer
331///
332/// Returned Value:
333/// None
334///
335/// *************************************************************************
336pub unsafe extern "C" fn mutex_delete(mutex: *mut crate::binary::c_types::c_void) {
337 crate::compat::common::mutex_delete(mutex);
338}
339
340/// **************************************************************************
341/// Name: esp_mutex_lock
342///
343/// Description:
344/// Lock mutex
345///
346/// Input Parameters:
347/// mutex_data - mutex data pointer
348///
349/// Returned Value:
350/// True if success or false if fail
351///
352/// *************************************************************************
353pub unsafe extern "C" fn mutex_lock(mutex: *mut crate::binary::c_types::c_void) -> i32 {
354 lock_mutex(mutex)
355}
356
357/// **************************************************************************
358/// Name: esp_mutex_unlock
359///
360/// Description:
361/// Unlock mutex
362///
363/// Input Parameters:
364/// mutex_data - mutex data pointer
365///
366/// Returned Value:
367/// True if success or false if fail
368///
369/// *************************************************************************
370pub unsafe extern "C" fn mutex_unlock(mutex: *mut crate::binary::c_types::c_void) -> i32 {
371 unlock_mutex(mutex)
372}
373
374/// **************************************************************************
375/// Name: esp_queue_create
376///
377/// Description:
378/// Create message queue
379///
380/// Input Parameters:
381/// queue_len - queue message number
382/// item_size - message size
383///
384/// Returned Value:
385/// Message queue data pointer
386///
387/// *************************************************************************
388pub unsafe extern "C" fn queue_create(
389 queue_len: u32,
390 item_size: u32,
391) -> *mut crate::binary::c_types::c_void {
392 // TODO remove this once fixed in esp_supplicant AND we updated to the fixed
393 // version - JIRA: WIFI-6676
394 let (queue_len, item_size) = if queue_len != 3 && item_size != 4 {
395 (queue_len, item_size)
396 } else {
397 warn!("Fixing queue item_size");
398 (3, 8)
399 };
400
401 create_queue(queue_len as i32, item_size as i32).cast()
402}
403
404/// **************************************************************************
405/// Name: esp_queue_delete
406///
407/// Description:
408/// Delete message queue
409///
410/// Input Parameters:
411/// queue - Message queue data pointer
412///
413/// Returned Value:
414/// None
415///
416/// *************************************************************************
417pub unsafe extern "C" fn queue_delete(queue: *mut crate::binary::c_types::c_void) {
418 delete_queue(queue.cast());
419}
420
421/// **************************************************************************
422/// Name: esp_queue_send
423///
424/// Description:
425/// Send message of low priority to queue within a certain period of time
426///
427/// Input Parameters:
428/// queue - Message queue data pointer
429/// item - Message data pointer
430/// ticks - Wait ticks
431///
432/// Returned Value:
433/// True if success or false if fail
434///
435/// *************************************************************************
436pub unsafe extern "C" fn queue_send(
437 queue: *mut crate::binary::c_types::c_void,
438 item: *mut crate::binary::c_types::c_void,
439 block_time_tick: u32,
440) -> i32 {
441 send_queued(queue.cast(), item, block_time_tick)
442}
443
444/// **************************************************************************
445/// Name: esp_queue_send_from_isr
446///
447/// Description:
448/// Send message of low priority to queue in ISR within
449/// a certain period of time
450///
451/// Input Parameters:
452/// queue - Message queue data pointer
453/// item - Message data pointer
454/// hptw - No mean
455///
456/// Returned Value:
457/// True if success or false if fail
458///
459/// *************************************************************************
460pub unsafe extern "C" fn queue_send_from_isr(
461 queue: *mut crate::binary::c_types::c_void,
462 item: *mut crate::binary::c_types::c_void,
463 _hptw: *mut crate::binary::c_types::c_void,
464) -> i32 {
465 trace!("queue_send_from_isr");
466 *(_hptw as *mut u32) = 1;
467 queue_send(queue, item, 1000)
468}
469
470/// **************************************************************************
471/// Name: esp_queue_send_to_back
472///
473/// Description:
474/// Send message of low priority to queue within a certain period of time
475///
476/// Input Parameters:
477/// queue - Message queue data pointer
478/// item - Message data pointer
479/// ticks - Wait ticks
480///
481/// Returned Value:
482/// True if success or false if fail
483///
484/// *************************************************************************
485pub unsafe extern "C" fn queue_send_to_back(
486 _queue: *mut crate::binary::c_types::c_void,
487 _item: *mut crate::binary::c_types::c_void,
488 _block_time_tick: u32,
489) -> i32 {
490 todo!("queue_send_to_back")
491}
492
493/// **************************************************************************
494/// Name: esp_queue_send_from_to_front
495///
496/// Description:
497/// Send message of high priority to queue within a certain period of time
498///
499/// Input Parameters:
500/// queue - Message queue data pointer
501/// item - Message data pointer
502/// ticks - Wait ticks
503///
504/// Returned Value:
505/// True if success or false if fail
506///
507/// *************************************************************************
508pub unsafe extern "C" fn queue_send_to_front(
509 _queue: *mut crate::binary::c_types::c_void,
510 _item: *mut crate::binary::c_types::c_void,
511 _block_time_tick: u32,
512) -> i32 {
513 todo!("queue_send_to_front")
514}
515
516/// **************************************************************************
517/// Name: esp_queue_recv
518///
519/// Description:
520/// Receive message from queue within a certain period of time
521///
522/// Input Parameters:
523/// queue - Message queue data pointer
524/// item - Message data pointer
525/// ticks - Wait ticks
526///
527/// Returned Value:
528/// True if success or false if fail
529///
530/// *************************************************************************
531pub unsafe extern "C" fn queue_recv(
532 queue: *mut crate::binary::c_types::c_void,
533 item: *mut crate::binary::c_types::c_void,
534 block_time_tick: u32,
535) -> i32 {
536 receive_queued(queue.cast(), item, block_time_tick)
537}
538
539/// **************************************************************************
540/// Name: esp_queue_msg_waiting
541///
542/// Description:
543/// Get message number in the message queue
544///
545/// Input Parameters:
546/// queue - Message queue data pointer
547///
548/// Returned Value:
549/// Message number
550///
551/// *************************************************************************
552pub unsafe extern "C" fn queue_msg_waiting(queue: *mut crate::binary::c_types::c_void) -> u32 {
553 number_of_messages_in_queue(queue.cast())
554}
555
556/// **************************************************************************
557/// Name: esp_event_group_create
558///
559/// Description:
560/// Don't support
561///
562/// *************************************************************************
563pub unsafe extern "C" fn event_group_create() -> *mut crate::binary::c_types::c_void {
564 todo!("event_group_create")
565}
566
567/// **************************************************************************
568/// Name: esp_event_group_delete
569///
570/// Description:
571/// Don't support
572///
573/// *************************************************************************
574pub unsafe extern "C" fn event_group_delete(_event: *mut crate::binary::c_types::c_void) {
575 todo!("event_group_delete")
576}
577
578/// **************************************************************************
579/// Name: esp_event_group_set_bits
580///
581/// Description:
582/// Don't support
583///
584/// *************************************************************************
585pub unsafe extern "C" fn event_group_set_bits(
586 _event: *mut crate::binary::c_types::c_void,
587 _bits: u32,
588) -> u32 {
589 todo!("event_group_set_bits")
590}
591
592/// **************************************************************************
593/// Name: esp_event_group_clear_bits
594///
595/// Description:
596/// Don't support
597///
598/// *************************************************************************
599pub unsafe extern "C" fn event_group_clear_bits(
600 _event: *mut crate::binary::c_types::c_void,
601 _bits: u32,
602) -> u32 {
603 todo!("event_group_clear_bits")
604}
605
606/// **************************************************************************
607/// Name: esp_event_group_wait_bits
608///
609/// Description:
610/// Don't support
611///
612/// *************************************************************************
613pub unsafe extern "C" fn event_group_wait_bits(
614 _event: *mut crate::binary::c_types::c_void,
615 _bits_to_wait_for: u32,
616 _clear_on_exit: crate::binary::c_types::c_int,
617 _wait_for_all_bits: crate::binary::c_types::c_int,
618 _block_time_tick: u32,
619) -> u32 {
620 todo!("event_group_wait_bits")
621}
622
623/// **************************************************************************
624/// Name: esp_task_create_pinned_to_core
625///
626/// Description:
627/// Create task and bind it to target CPU, the task will run when it
628/// is created
629///
630/// Input Parameters:
631/// entry - Task entry
632/// name - Task name
633/// stack_depth - Task stack size
634/// param - Task private data
635/// prio - Task priority
636/// task_handle - Task handle pointer which is used to pause, resume
637/// and delete the task
638/// core_id - CPU which the task runs in
639///
640/// Returned Value:
641/// True if success or false if fail
642///
643/// *************************************************************************
644pub unsafe extern "C" fn task_create_pinned_to_core(
645 task_func: *mut crate::binary::c_types::c_void,
646 name: *const crate::binary::c_types::c_char,
647 stack_depth: u32,
648 param: *mut crate::binary::c_types::c_void,
649 prio: u32,
650 task_handle: *mut crate::binary::c_types::c_void,
651 core_id: u32,
652) -> i32 {
653 trace!("task_create_pinned_to_core task_func {:?} name {} stack_depth {} param {:?} prio {}, task_handle {:?} core_id {}",
654 task_func,
655 str_from_c(name as _),
656 stack_depth,
657 param,
658 prio,
659 task_handle,
660 core_id
661 );
662
663 let task_func = core::mem::transmute::<
664 *mut crate::binary::c_types::c_void,
665 extern "C" fn(*mut esp_wifi_sys::c_types::c_void),
666 >(task_func);
667
668 let task = crate::preempt::task_create(task_func, param, stack_depth as usize);
669 *(task_handle as *mut usize) = task as usize;
670
671 1
672}
673
674/// **************************************************************************
675/// Name: esp_task_create
676///
677/// Description:
678/// Create task and the task will run when it is created
679///
680/// Input Parameters:
681/// entry - Task entry
682/// name - Task name
683/// stack_depth - Task stack size
684/// param - Task private data
685/// prio - Task priority
686/// task_handle - Task handle pointer which is used to pause, resume
687/// and delete the task
688///
689/// Returned Value:
690/// True if success or false if fail
691///
692/// *************************************************************************
693pub unsafe extern "C" fn task_create(
694 task_func: *mut crate::binary::c_types::c_void,
695 name: *const crate::binary::c_types::c_char,
696 stack_depth: u32,
697 param: *mut crate::binary::c_types::c_void,
698 prio: u32,
699 task_handle: *mut crate::binary::c_types::c_void,
700) -> i32 {
701 task_create_pinned_to_core(task_func, name, stack_depth, param, prio, task_handle, 0)
702}
703
704/// **************************************************************************
705/// Name: esp_task_delete
706///
707/// Description:
708/// Delete the target task
709///
710/// Input Parameters:
711/// task_handle - Task handle pointer which is used to pause, resume
712/// and delete the task
713///
714/// Returned Value:
715/// None
716///
717/// *************************************************************************
718pub unsafe extern "C" fn task_delete(task_handle: *mut crate::binary::c_types::c_void) {
719 trace!("task delete called for {:?}", task_handle);
720
721 let task = if task_handle.is_null() {
722 crate::preempt::current_task()
723 } else {
724 task_handle as *mut _
725 };
726 crate::preempt::schedule_task_deletion(task);
727}
728
729/// **************************************************************************
730/// Name: esp_task_delay
731///
732/// Description:
733/// Current task wait for some ticks
734///
735/// Input Parameters:
736/// tick - Waiting ticks
737///
738/// Returned Value:
739/// None
740///
741/// *************************************************************************
742pub unsafe extern "C" fn task_delay(tick: u32) {
743 trace!("task_delay tick {}", tick);
744 let start_time = crate::time::systimer_count();
745 while crate::time::elapsed_time_since(start_time) < tick as u64 {
746 yield_task();
747 }
748}
749
750/// **************************************************************************
751/// Name: esp_task_ms_to_tick
752///
753/// Description:
754/// Transform from millim seconds to system ticks
755///
756/// Input Parameters:
757/// ms - Millim seconds
758///
759/// Returned Value:
760/// System ticks
761///
762/// *************************************************************************
763pub unsafe extern "C" fn task_ms_to_tick(ms: u32) -> i32 {
764 trace!("task_ms_to_tick ms {}", ms);
765 crate::time::millis_to_ticks(ms as u64) as i32
766}
767
768/// **************************************************************************
769/// Name: esp_task_get_current_task
770///
771/// Description:
772/// Transform from millim seconds to system ticks
773///
774/// Input Parameters:
775/// ms - Millim seconds
776///
777/// Returned Value:
778/// System ticks
779///
780/// *************************************************************************
781pub unsafe extern "C" fn task_get_current_task() -> *mut crate::binary::c_types::c_void {
782 let res = crate::preempt::current_task() as *mut crate::binary::c_types::c_void;
783 trace!("task get current task - return {:?}", res);
784
785 res
786}
787
788/// **************************************************************************
789/// Name: esp_task_get_max_priority
790///
791/// Description:
792/// Get OS task maximum priority
793///
794/// Input Parameters:
795/// None
796///
797/// Returned Value:
798/// Task maximum priority
799///
800/// *************************************************************************
801pub unsafe extern "C" fn task_get_max_priority() -> i32 {
802 trace!("task_get_max_priority");
803 255
804}
805
806/// **************************************************************************
807/// Name: esp_malloc
808///
809/// Description:
810/// Allocate a block of memory
811///
812/// Input Parameters:
813/// size - memory size
814///
815/// Returned Value:
816/// Memory pointer
817///
818/// *************************************************************************
819pub unsafe extern "C" fn malloc(size: usize) -> *mut crate::binary::c_types::c_void {
820 crate::compat::malloc::malloc(size).cast()
821}
822
823/// **************************************************************************
824/// Name: esp_free
825///
826/// Description:
827/// Free a block of memory
828///
829/// Input Parameters:
830/// ptr - memory block
831///
832/// Returned Value:
833/// No
834///
835/// *************************************************************************
836pub unsafe extern "C" fn free(p: *mut crate::binary::c_types::c_void) {
837 crate::compat::malloc::free(p.cast());
838}
839
840/// **************************************************************************
841/// Name: esp_event_post
842///
843/// Description:
844/// Active work queue and let the work to process the cached event
845///
846/// Input Parameters:
847/// event_base - Event set name
848/// event_id - Event ID
849/// event_data - Event private data
850/// event_data_size - Event data size
851/// ticks - Waiting system ticks
852///
853/// Returned Value:
854/// 0 if success or -1 if fail
855///
856/// *************************************************************************
857pub unsafe extern "C" fn event_post(
858 event_base: *const crate::binary::c_types::c_char,
859 event_id: i32,
860 event_data: *mut crate::binary::c_types::c_void,
861 event_data_size: usize,
862 ticks_to_wait: u32,
863) -> i32 {
864 trace!(
865 "event_post {:?} {} {:?} {} {:?}",
866 event_base,
867 event_id,
868 event_data,
869 event_data_size,
870 ticks_to_wait
871 );
872 use num_traits::FromPrimitive;
873
874 let event = unwrap!(WifiEvent::from_i32(event_id));
875 trace!("EVENT: {:?}", event);
876
877 WIFI_EVENTS.with(|events| events.borrow_mut().insert(event));
878 let handled = super::event::dispatch_event_handler(event, event_data, event_data_size);
879
880 super::state::update_state(event, handled);
881
882 event.waker().wake();
883
884 match event {
885 WifiEvent::StaConnected | WifiEvent::StaDisconnected => {
886 crate::wifi::embassy::STA_LINK_STATE_WAKER.wake();
887 }
888
889 WifiEvent::ApStart | WifiEvent::ApStop => {
890 crate::wifi::embassy::AP_LINK_STATE_WAKER.wake();
891 }
892
893 _ => {}
894 }
895
896 memory_fence();
897
898 0
899}
900
901/// **************************************************************************
902/// Name: esp_get_free_heap_size
903///
904/// Description:
905/// Get free heap size by byte
906///
907/// Input Parameters:
908/// None
909///
910/// Returned Value:
911/// Free heap size
912///
913/// *************************************************************************
914pub unsafe extern "C" fn get_free_heap_size() -> u32 {
915 extern "C" {
916 fn esp_wifi_free_internal_heap() -> usize;
917 }
918
919 esp_wifi_free_internal_heap() as u32
920}
921
922/// **************************************************************************
923/// Name: esp_rand
924///
925/// Description:
926/// Get random data of type uint32_t
927///
928/// Input Parameters:
929/// None
930///
931/// Returned Value:
932/// Random data
933///
934/// *************************************************************************
935pub unsafe extern "C" fn rand() -> u32 {
936 crate::common_adapter::random()
937}
938
939/// **************************************************************************
940/// Name: esp_dport_access_stall_other_cpu_start
941///
942/// Description:
943/// Don't support
944///
945/// *************************************************************************
946pub unsafe extern "C" fn dport_access_stall_other_cpu_start_wrap() {
947 trace!("dport_access_stall_other_cpu_start_wrap")
948}
949
950/// **************************************************************************
951/// Name: esp_dport_access_stall_other_cpu_end
952///
953/// Description:
954/// Don't support
955///
956/// *************************************************************************
957pub unsafe extern "C" fn dport_access_stall_other_cpu_end_wrap() {
958 trace!("dport_access_stall_other_cpu_end_wrap")
959}
960/// **************************************************************************
961/// Name: wifi_apb80m_request
962///
963/// Description:
964/// Take Wi-Fi lock in auto-sleep
965///
966/// *************************************************************************
967pub unsafe extern "C" fn wifi_apb80m_request() {
968 trace!("wifi_apb80m_request - no-op")
969}
970/// **************************************************************************
971/// Name: wifi_apb80m_release
972///
973/// Description:
974/// Release Wi-Fi lock in auto-sleep
975///
976/// *************************************************************************
977pub unsafe extern "C" fn wifi_apb80m_release() {
978 trace!("wifi_apb80m_release - no-op")
979}
980
981/// **************************************************************************
982/// Name: esp32c3_phy_disable
983///
984/// Description:
985/// Deinitialize PHY hardware
986///
987/// Input Parameters:
988/// None
989///
990/// Returned Value:
991/// None
992///
993/// *************************************************************************
994pub unsafe extern "C" fn phy_disable() {
995 trace!("phy_disable");
996
997 crate::common_adapter::chip_specific::phy_disable();
998}
999
1000/// **************************************************************************
1001/// Name: esp32c3_phy_enable
1002///
1003/// Description:
1004/// Initialize PHY hardware
1005///
1006/// Input Parameters:
1007/// None
1008///
1009/// Returned Value:
1010/// None
1011///
1012/// *************************************************************************
1013pub unsafe extern "C" fn phy_enable() {
1014 // quite some code needed here
1015 trace!("phy_enable");
1016
1017 crate::common_adapter::chip_specific::phy_enable();
1018}
1019
1020/// **************************************************************************
1021/// Name: wifi_phy_update_country_info
1022///
1023/// Description:
1024/// Don't support
1025///
1026/// *************************************************************************
1027#[allow(clippy::unnecessary_cast)]
1028pub unsafe extern "C" fn phy_update_country_info(
1029 country: *const crate::binary::c_types::c_char,
1030) -> crate::binary::c_types::c_int {
1031 // not implemented in original code
1032 trace!("phy_update_country_info {}", str_from_c(country.cast()));
1033 -1
1034}
1035
1036/// **************************************************************************
1037/// Name: wifi_reset_mac
1038///
1039/// Description:
1040/// Reset Wi-Fi hardware MAC
1041///
1042/// Input Parameters:
1043/// None
1044///
1045/// Returned Value:
1046/// None
1047///
1048/// *************************************************************************
1049pub unsafe extern "C" fn wifi_reset_mac() {
1050 trace!("wifi_reset_mac");
1051 // stealing RADIO_CLK is safe since it is passed (as mutable reference or by
1052 // value) into `init`
1053 let radio_clocks = unsafe { RADIO_CLK::steal() };
1054 RadioClockController::new(radio_clocks).reset_mac();
1055}
1056
1057/// **************************************************************************
1058/// Name: wifi_clock_enable
1059///
1060/// Description:
1061/// Enable Wi-Fi clock
1062///
1063/// Input Parameters:
1064/// None
1065///
1066/// Returned Value:
1067/// None
1068///
1069/// *************************************************************************
1070pub unsafe extern "C" fn wifi_clock_enable() {
1071 trace!("wifi_clock_enable");
1072 // stealing RADIO_CLK is safe since it is passed (as mutable reference or by
1073 // value) into `init`
1074 let radio_clocks = unsafe { RADIO_CLK::steal() };
1075 RadioClockController::new(radio_clocks).enable_wifi(true);
1076}
1077
1078/// **************************************************************************
1079/// Name: wifi_clock_disable
1080///
1081/// Description:
1082/// Disable Wi-Fi clock
1083///
1084/// Input Parameters:
1085/// None
1086///
1087/// Returned Value:
1088/// None
1089///
1090/// *************************************************************************
1091pub unsafe extern "C" fn wifi_clock_disable() {
1092 trace!("wifi_clock_disable");
1093 // stealing RADIO_CLK is safe since it is passed (as mutable reference or by
1094 // value) into `init`
1095 let radio_clocks = unsafe { RADIO_CLK::steal() };
1096 RadioClockController::new(radio_clocks).enable_wifi(false);
1097}
1098
1099/// **************************************************************************
1100/// Name: wifi_rtc_enable_iso
1101///
1102/// Description:
1103/// Don't support
1104///
1105/// *************************************************************************
1106pub unsafe extern "C" fn wifi_rtc_enable_iso() {
1107 todo!("wifi_rtc_enable_iso")
1108}
1109
1110/// **************************************************************************
1111/// Name: wifi_rtc_disable_iso
1112///
1113/// Description:
1114/// Don't support
1115///
1116/// *************************************************************************
1117pub unsafe extern "C" fn wifi_rtc_disable_iso() {
1118 todo!("wifi_rtc_disable_iso")
1119}
1120
1121/// **************************************************************************
1122/// Name: esp_timer_get_time
1123///
1124/// Description:
1125/// Get time in microseconds since boot.
1126///
1127/// Returned Value:
1128/// System time in micros
1129///
1130/// *************************************************************************
1131#[no_mangle]
1132pub unsafe extern "C" fn esp_timer_get_time() -> i64 {
1133 trace!("esp_timer_get_time");
1134 crate::time::ticks_to_micros(crate::time::systimer_count()) as i64
1135}
1136
1137/// **************************************************************************
1138/// Name: esp_nvs_set_i8
1139///
1140/// Description:
1141/// Save data of type int8_t into file system
1142///
1143/// Input Parameters:
1144/// handle - NVS handle
1145/// key - Data index
1146/// value - Stored data
1147///
1148/// Returned Value:
1149/// 0 if success or -1 if fail
1150///
1151/// *************************************************************************
1152pub unsafe extern "C" fn nvs_set_i8(
1153 _handle: u32,
1154 _key: *const crate::binary::c_types::c_char,
1155 _value: i8,
1156) -> crate::binary::c_types::c_int {
1157 debug!("nvs_set_i8");
1158 -1
1159}
1160
1161/// **************************************************************************
1162/// Name: esp_nvs_get_i8
1163///
1164/// Description:
1165/// Read data of type int8_t from file system
1166///
1167/// Input Parameters:
1168/// handle - NVS handle
1169/// key - Data index
1170/// out_value - Read buffer pointer
1171///
1172/// Returned Value:
1173/// 0 if success or -1 if fail
1174///
1175/// *************************************************************************
1176pub unsafe extern "C" fn nvs_get_i8(
1177 _handle: u32,
1178 _key: *const crate::binary::c_types::c_char,
1179 _out_value: *mut i8,
1180) -> crate::binary::c_types::c_int {
1181 todo!("nvs_get_i8")
1182}
1183
1184/// **************************************************************************
1185/// Name: esp_nvs_set_u8
1186///
1187/// Description:
1188/// Save data of type uint8_t into file system
1189///
1190/// Input Parameters:
1191/// handle - NVS handle
1192/// key - Data index
1193/// value - Stored data
1194///
1195/// Returned Value:
1196/// 0 if success or -1 if fail
1197///
1198/// *************************************************************************
1199pub unsafe extern "C" fn nvs_set_u8(
1200 _handle: u32,
1201 _key: *const crate::binary::c_types::c_char,
1202 _value: u8,
1203) -> crate::binary::c_types::c_int {
1204 todo!("nvs_set_u8")
1205}
1206
1207/// **************************************************************************
1208/// Name: esp_nvs_get_u8
1209///
1210/// Description:
1211/// Read data of type uint8_t from file system
1212///
1213/// Input Parameters:
1214/// handle - NVS handle
1215/// key - Data index
1216/// out_value - Read buffer pointer
1217///
1218/// Returned Value:
1219/// 0 if success or -1 if fail
1220///
1221/// *************************************************************************
1222pub unsafe extern "C" fn nvs_get_u8(
1223 _handle: u32,
1224 _key: *const crate::binary::c_types::c_char,
1225 _out_value: *mut u8,
1226) -> crate::binary::c_types::c_int {
1227 todo!("nvs_get_u8")
1228}
1229
1230/// **************************************************************************
1231/// Name: esp_nvs_set_u16
1232///
1233/// Description:
1234/// Save data of type uint16_t into file system
1235///
1236/// Input Parameters:
1237/// handle - NVS handle
1238/// key - Data index
1239/// value - Stored data
1240///
1241/// Returned Value:
1242/// 0 if success or -1 if fail
1243///
1244/// *************************************************************************
1245pub unsafe extern "C" fn nvs_set_u16(
1246 _handle: u32,
1247 _key: *const crate::binary::c_types::c_char,
1248 _value: u16,
1249) -> crate::binary::c_types::c_int {
1250 todo!("nvs_set_u16")
1251}
1252
1253/// **************************************************************************
1254/// Name: esp_nvs_get_u16
1255///
1256/// Description:
1257/// Read data of type uint16_t from file system
1258///
1259/// Input Parameters:
1260/// handle - NVS handle
1261/// key - Data index
1262/// out_value - Read buffer pointer
1263///
1264/// Returned Value:
1265/// 0 if success or -1 if fail
1266///
1267/// *************************************************************************
1268pub unsafe extern "C" fn nvs_get_u16(
1269 _handle: u32,
1270 _key: *const crate::binary::c_types::c_char,
1271 _out_value: *mut u16,
1272) -> crate::binary::c_types::c_int {
1273 todo!("nvs_get_u16")
1274}
1275
1276/// **************************************************************************
1277/// Name: esp_nvs_open
1278///
1279/// Description:
1280/// Create a file system storage data object
1281///
1282/// Input Parameters:
1283/// name - Storage index
1284/// open_mode - Storage mode
1285/// out_handle - Storage handle
1286///
1287/// Returned Value:
1288/// 0 if success or -1 if fail
1289///
1290/// *************************************************************************
1291pub unsafe extern "C" fn nvs_open(
1292 _name: *const crate::binary::c_types::c_char,
1293 _open_mode: u32,
1294 _out_handle: *mut u32,
1295) -> crate::binary::c_types::c_int {
1296 todo!("nvs_open")
1297}
1298
1299/// **************************************************************************
1300/// Name: esp_nvs_close
1301///
1302/// Description:
1303/// Close storage data object and free resource
1304///
1305/// Input Parameters:
1306/// handle - NVS handle
1307///
1308/// Returned Value:
1309/// 0 if success or -1 if fail
1310///
1311/// *************************************************************************
1312pub unsafe extern "C" fn nvs_close(_handle: u32) {
1313 todo!("nvs_close")
1314}
1315
1316/// **************************************************************************
1317/// Name: esp_nvs_commit
1318///
1319/// Description:
1320/// This function has no practical effect
1321///
1322/// *************************************************************************
1323pub unsafe extern "C" fn nvs_commit(_handle: u32) -> crate::binary::c_types::c_int {
1324 todo!("nvs_commit")
1325}
1326
1327/// **************************************************************************
1328/// Name: esp_nvs_set_blob
1329///
1330/// Description:
1331/// Save a block of data into file system
1332///
1333/// Input Parameters:
1334/// handle - NVS handle
1335/// key - Data index
1336/// value - Stored buffer pointer
1337/// length - Buffer length
1338///
1339/// Returned Value:
1340/// 0 if success or -1 if fail
1341///
1342/// *************************************************************************
1343pub unsafe extern "C" fn nvs_set_blob(
1344 _handle: u32,
1345 _key: *const crate::binary::c_types::c_char,
1346 _value: *const crate::binary::c_types::c_void,
1347 _length: usize,
1348) -> crate::binary::c_types::c_int {
1349 todo!("nvs_set_blob")
1350}
1351
1352/// **************************************************************************
1353/// Name: esp_nvs_get_blob
1354///
1355/// Description:
1356/// Read a block of data from file system
1357///
1358/// Input Parameters:
1359/// handle - NVS handle
1360/// key - Data index
1361/// out_value - Read buffer pointer
1362/// length - Buffer length
1363///
1364/// Returned Value:
1365/// 0 if success or -1 if fail
1366///
1367/// *************************************************************************
1368pub unsafe extern "C" fn nvs_get_blob(
1369 _handle: u32,
1370 _key: *const crate::binary::c_types::c_char,
1371 _out_value: *mut crate::binary::c_types::c_void,
1372 _length: *mut usize,
1373) -> crate::binary::c_types::c_int {
1374 todo!("nvs_get_blob")
1375}
1376
1377/// **************************************************************************
1378/// Name: esp_nvs_erase_key
1379///
1380/// Description:
1381/// Read a block of data from file system
1382///
1383/// Input Parameters:
1384/// handle - NVS handle
1385/// key - Data index
1386///
1387/// Returned Value:
1388/// 0 if success or -1 if fail
1389///
1390/// *************************************************************************
1391pub unsafe extern "C" fn nvs_erase_key(
1392 _handle: u32,
1393 _key: *const crate::binary::c_types::c_char,
1394) -> crate::binary::c_types::c_int {
1395 todo!("nvs_erase_key")
1396}
1397
1398/// **************************************************************************
1399/// Name: esp_get_random
1400///
1401/// Description:
1402/// Fill random data int given buffer of given length
1403///
1404/// Input Parameters:
1405/// buf - buffer pointer
1406/// len - buffer length
1407///
1408/// Returned Value:
1409/// 0 if success or -1 if fail
1410///
1411/// *************************************************************************
1412pub unsafe extern "C" fn get_random(buf: *mut u8, len: usize) -> crate::binary::c_types::c_int {
1413 trace!("get_random");
1414 crate::common_adapter::esp_fill_random(buf, len as u32);
1415 0
1416}
1417
1418/// **************************************************************************
1419/// Name: esp_get_time
1420///
1421/// Description:
1422/// Get std C time
1423///
1424/// Input Parameters:
1425/// t - buffer to store time of type timeval
1426///
1427/// Returned Value:
1428/// 0 if success or -1 if fail
1429///
1430/// *************************************************************************
1431pub unsafe extern "C" fn get_time(
1432 _t: *mut crate::binary::c_types::c_void,
1433) -> crate::binary::c_types::c_int {
1434 todo!("get_time")
1435}
1436
1437/// **************************************************************************
1438/// Name: esp_log_write
1439///
1440/// Description:
1441/// Output log with by format string and its arguments
1442///
1443/// Input Parameters:
1444/// level - log level, no mean here
1445/// tag - log TAG, no mean here
1446/// format - format string
1447///
1448/// Returned Value:
1449/// None
1450///
1451/// *************************************************************************
1452#[cfg(feature = "sys-logs")]
1453pub unsafe extern "C" fn log_write(
1454 level: u32,
1455 _tag: *const crate::binary::c_types::c_char,
1456 format: *const crate::binary::c_types::c_char,
1457 args: ...
1458) {
1459 crate::binary::log::syslog(level, format as _, args);
1460}
1461
1462/// **************************************************************************
1463/// Name: esp_log_writev
1464///
1465/// Description:
1466/// Output log with by format string and its arguments
1467///
1468/// Input Parameters:
1469/// level - log level, no mean here
1470/// tag - log TAG, no mean here
1471/// format - format string
1472/// args - arguments list
1473///
1474/// Returned Value:
1475/// None
1476///
1477/// *************************************************************************
1478#[cfg(feature = "sys-logs")]
1479#[allow(improper_ctypes_definitions)]
1480pub unsafe extern "C" fn log_writev(
1481 level: u32,
1482 _tag: *const crate::binary::c_types::c_char,
1483 format: *const crate::binary::c_types::c_char,
1484 args: crate::binary::include::va_list,
1485) {
1486 crate::binary::log::syslog(
1487 level,
1488 format as _,
1489 core::mem::transmute::<crate::binary::include::va_list, core::ffi::VaListImpl<'_>>(args),
1490 );
1491}
1492
1493/// **************************************************************************
1494/// Name: esp_log_timestamp
1495///
1496/// Description:
1497/// Get system time by millim second
1498///
1499/// Input Parameters:
1500/// None
1501///
1502/// Returned Value:
1503/// System time
1504///
1505/// *************************************************************************
1506pub unsafe extern "C" fn log_timestamp() -> u32 {
1507 esp_hal::time::Instant::now()
1508 .duration_since_epoch()
1509 .as_millis() as u32
1510}
1511
1512/// **************************************************************************
1513/// Name: esp_malloc_internal
1514///
1515/// Description:
1516/// Drivers allocate a block of memory
1517///
1518/// Input Parameters:
1519/// size - memory size
1520///
1521/// Returned Value:
1522/// Memory pointer
1523///
1524/// *************************************************************************
1525pub unsafe extern "C" fn malloc_internal(size: usize) -> *mut crate::binary::c_types::c_void {
1526 crate::compat::malloc::malloc(size).cast()
1527}
1528
1529/// **************************************************************************
1530/// Name: esp_realloc_internal
1531///
1532/// Description:
1533/// Drivers allocate a block of memory by old memory block
1534///
1535/// Input Parameters:
1536/// ptr - old memory pointer
1537/// size - memory size
1538///
1539/// Returned Value:
1540/// New memory pointer
1541///
1542/// *************************************************************************
1543pub unsafe extern "C" fn realloc_internal(
1544 _ptr: *mut crate::binary::c_types::c_void,
1545 _size: usize,
1546) -> *mut crate::binary::c_types::c_void {
1547 todo!("realloc_internal")
1548}
1549
1550/// **************************************************************************
1551/// Name: esp_calloc_internal
1552///
1553/// Description:
1554/// Drivers allocate some continuous blocks of memory
1555///
1556/// Input Parameters:
1557/// n - memory block number
1558/// size - memory block size
1559///
1560/// Returned Value:
1561/// New memory pointer
1562///
1563/// *************************************************************************
1564pub unsafe extern "C" fn calloc_internal(
1565 n: usize,
1566 size: usize,
1567) -> *mut crate::binary::c_types::c_void {
1568 calloc(n as u32, size) as *mut crate::binary::c_types::c_void
1569}
1570
1571/// **************************************************************************
1572/// Name: esp_zalloc_internal
1573///
1574/// Description:
1575/// Drivers allocate a block of memory and clear it with 0
1576///
1577/// Input Parameters:
1578/// size - memory size
1579///
1580/// Returned Value:
1581/// New memory pointer
1582///
1583/// *************************************************************************
1584pub unsafe extern "C" fn zalloc_internal(size: usize) -> *mut crate::binary::c_types::c_void {
1585 calloc(size as u32, 1usize) as *mut crate::binary::c_types::c_void
1586}
1587
1588/// **************************************************************************
1589/// Name: esp_wifi_malloc
1590///
1591/// Description:
1592/// Applications allocate a block of memory
1593///
1594/// Input Parameters:
1595/// size - memory size
1596///
1597/// Returned Value:
1598/// Memory pointer
1599///
1600/// *************************************************************************
1601pub unsafe extern "C" fn wifi_malloc(size: usize) -> *mut crate::binary::c_types::c_void {
1602 malloc(size)
1603}
1604
1605/// **************************************************************************
1606/// Name: esp_wifi_realloc
1607///
1608/// Description:
1609/// Applications allocate a block of memory by old memory block
1610///
1611/// Input Parameters:
1612/// ptr - old memory pointer
1613/// size - memory size
1614///
1615/// Returned Value:
1616/// New memory pointer
1617///
1618/// *************************************************************************
1619pub unsafe extern "C" fn wifi_realloc(
1620 _ptr: *mut crate::binary::c_types::c_void,
1621 _size: usize,
1622) -> *mut crate::binary::c_types::c_void {
1623 todo!("wifi_realloc")
1624}
1625
1626/// **************************************************************************
1627/// Name: esp_wifi_calloc
1628///
1629/// Description:
1630/// Applications allocate some continuous blocks of memory
1631///
1632/// Input Parameters:
1633/// n - memory block number
1634/// size - memory block size
1635///
1636/// Returned Value:
1637/// New memory pointer
1638///
1639/// *************************************************************************
1640pub unsafe extern "C" fn wifi_calloc(n: usize, size: usize) -> *mut crate::binary::c_types::c_void {
1641 trace!("wifi_calloc {} {}", n, size);
1642 calloc(n as u32, size) as *mut crate::binary::c_types::c_void
1643}
1644
1645/// **************************************************************************
1646/// Name: esp_wifi_zalloc
1647///
1648/// Description:
1649/// Applications allocate a block of memory and clear it with 0
1650///
1651/// Input Parameters:
1652/// size - memory size
1653///
1654/// Returned Value:
1655/// New memory pointer
1656///
1657/// *************************************************************************
1658pub unsafe extern "C" fn wifi_zalloc(size: usize) -> *mut crate::binary::c_types::c_void {
1659 wifi_calloc(size, 1)
1660}
1661
1662/// **************************************************************************
1663/// Name: esp_wifi_create_queue
1664///
1665/// Description:
1666/// Create Wi-Fi static message queue
1667///
1668/// Input Parameters:
1669/// queue_len - queue message number
1670/// item_size - message size
1671///
1672/// Returned Value:
1673/// Wi-Fi static message queue data pointer
1674///
1675/// *************************************************************************
1676pub unsafe extern "C" fn wifi_create_queue(
1677 queue_len: crate::binary::c_types::c_int,
1678 item_size: crate::binary::c_types::c_int,
1679) -> *mut crate::binary::c_types::c_void {
1680 let queue = create_queue(queue_len, item_size);
1681 QUEUE_HANDLE = queue;
1682
1683 addr_of_mut!(QUEUE_HANDLE).cast()
1684}
1685
1686/// **************************************************************************
1687/// Name: esp_wifi_delete_queue
1688///
1689/// Description:
1690/// Delete Wi-Fi static message queue
1691///
1692/// Input Parameters:
1693/// queue - Wi-Fi static message queue data pointer
1694///
1695/// Returned Value:
1696/// None
1697///
1698/// *************************************************************************
1699pub unsafe extern "C" fn wifi_delete_queue(queue: *mut crate::binary::c_types::c_void) {
1700 trace!("wifi_delete_queue {:?}", queue);
1701 if queue == addr_of_mut!(QUEUE_HANDLE).cast() {
1702 delete_queue(QUEUE_HANDLE);
1703 } else {
1704 warn!("unknown queue when trying to delete WIFI queue");
1705 }
1706}
1707
1708/// **************************************************************************
1709/// Name: wifi_coex_deinit
1710///
1711/// Description:
1712/// Don't support
1713///
1714/// *************************************************************************
1715pub unsafe extern "C" fn coex_deinit() {
1716 trace!("coex_deinit");
1717
1718 #[cfg(coex)]
1719 crate::binary::include::coex_deinit();
1720}
1721
1722/// **************************************************************************
1723/// Name: wifi_coex_enable
1724///
1725/// Description:
1726/// Don't support
1727///
1728/// *************************************************************************
1729pub unsafe extern "C" fn coex_enable() -> crate::binary::c_types::c_int {
1730 trace!("coex_enable");
1731
1732 #[cfg(coex)]
1733 return crate::binary::include::coex_enable();
1734
1735 #[cfg(not(coex))]
1736 0
1737}
1738
1739/// **************************************************************************
1740/// Name: wifi_coex_disable
1741///
1742/// Description:
1743/// Don't support
1744///
1745/// *************************************************************************
1746pub unsafe extern "C" fn coex_disable() {
1747 trace!("coex_disable");
1748
1749 #[cfg(coex)]
1750 crate::binary::include::coex_disable();
1751}
1752
1753/// **************************************************************************
1754/// Name: esp_coex_status_get
1755///
1756/// Description:
1757/// Don't support
1758///
1759/// *************************************************************************
1760pub unsafe extern "C" fn coex_status_get() -> u32 {
1761 trace!("coex_status_get");
1762
1763 #[cfg(coex)]
1764 return crate::binary::include::coex_status_get();
1765
1766 #[cfg(not(coex))]
1767 0
1768}
1769
1770/// **************************************************************************
1771/// Name: esp_coex_wifi_request
1772///
1773/// Description:
1774/// Don't support
1775///
1776/// *************************************************************************
1777#[cfg_attr(not(coex), allow(unused_variables))]
1778pub unsafe extern "C" fn coex_wifi_request(
1779 event: u32,
1780 latency: u32,
1781 duration: u32,
1782) -> crate::binary::c_types::c_int {
1783 trace!("coex_wifi_request");
1784
1785 #[cfg(coex)]
1786 return crate::binary::include::coex_wifi_request(event, latency, duration);
1787
1788 #[cfg(not(coex))]
1789 0
1790}
1791
1792/// **************************************************************************
1793/// Name: esp_coex_wifi_release
1794///
1795/// Description:
1796/// Don't support
1797///
1798/// *************************************************************************
1799#[cfg_attr(not(coex), allow(unused_variables))]
1800pub unsafe extern "C" fn coex_wifi_release(event: u32) -> crate::binary::c_types::c_int {
1801 trace!("coex_wifi_release");
1802
1803 #[cfg(coex)]
1804 return crate::binary::include::coex_wifi_release(event);
1805
1806 #[cfg(not(coex))]
1807 0
1808}
1809
1810/// **************************************************************************
1811/// Name: wifi_coex_wifi_set_channel
1812///
1813/// Description:
1814/// Don't support
1815///
1816/// *************************************************************************
1817#[cfg_attr(not(coex), allow(unused_variables))]
1818pub unsafe extern "C" fn coex_wifi_channel_set(
1819 primary: u8,
1820 secondary: u8,
1821) -> crate::binary::c_types::c_int {
1822 trace!("coex_wifi_channel_set");
1823
1824 #[cfg(coex)]
1825 return crate::binary::include::coex_wifi_channel_set(primary, secondary);
1826
1827 #[cfg(not(coex))]
1828 0
1829}
1830
1831/// **************************************************************************
1832/// Name: wifi_coex_get_event_duration
1833///
1834/// Description:
1835/// Don't support
1836///
1837/// *************************************************************************
1838#[cfg_attr(not(coex), allow(unused_variables))]
1839pub unsafe extern "C" fn coex_event_duration_get(
1840 event: u32,
1841 duration: *mut u32,
1842) -> crate::binary::c_types::c_int {
1843 trace!("coex_event_duration_get");
1844
1845 #[cfg(coex)]
1846 return crate::binary::include::coex_event_duration_get(event, duration);
1847
1848 #[cfg(not(coex))]
1849 0
1850}
1851
1852/// **************************************************************************
1853/// Name: wifi_coex_get_pti
1854///
1855/// Description:
1856/// Don't support
1857///
1858/// *************************************************************************
1859#[cfg(any(esp32c3, esp32c2, esp32c6, esp32s3))]
1860#[cfg_attr(not(coex), allow(unused_variables))]
1861pub unsafe extern "C" fn coex_pti_get(event: u32, pti: *mut u8) -> crate::binary::c_types::c_int {
1862 trace!("coex_pti_get");
1863
1864 #[cfg(coex)]
1865 return crate::binary::include::coex_pti_get(event, pti);
1866
1867 #[cfg(not(coex))]
1868 0
1869}
1870
1871#[cfg(any(esp32, esp32s2))]
1872pub unsafe extern "C" fn coex_pti_get(event: u32, pti: *mut u8) -> crate::binary::c_types::c_int {
1873 trace!("coex_pti_get {} {:?}", event, pti);
1874 0
1875}
1876
1877/// **************************************************************************
1878/// Name: wifi_coex_clear_schm_status_bit
1879///
1880/// Description:
1881/// Don't support
1882///
1883/// *************************************************************************
1884#[allow(unused_variables)]
1885pub unsafe extern "C" fn coex_schm_status_bit_clear(type_: u32, status: u32) {
1886 trace!("coex_schm_status_bit_clear");
1887
1888 #[cfg(coex)]
1889 crate::binary::include::coex_schm_status_bit_clear(type_, status);
1890}
1891
1892/// **************************************************************************
1893/// Name: wifi_coex_set_schm_status_bit
1894///
1895/// Description:
1896/// Don't support
1897///
1898/// *************************************************************************
1899#[allow(unused_variables)]
1900pub unsafe extern "C" fn coex_schm_status_bit_set(type_: u32, status: u32) {
1901 trace!("coex_schm_status_bit_set");
1902
1903 #[cfg(coex)]
1904 crate::binary::include::coex_schm_status_bit_set(type_, status);
1905}
1906
1907/// **************************************************************************
1908/// Name: wifi_coex_set_schm_interval
1909///
1910/// Description:
1911/// Don't support
1912///
1913/// *************************************************************************
1914#[allow(unused_variables)]
1915pub unsafe extern "C" fn coex_schm_interval_set(interval: u32) -> crate::binary::c_types::c_int {
1916 trace!("coex_schm_interval_set");
1917
1918 #[cfg(coex)]
1919 return crate::binary::include::coex_schm_interval_set(interval);
1920
1921 #[cfg(not(coex))]
1922 0
1923}
1924
1925/// **************************************************************************
1926/// Name: wifi_coex_get_schm_interval
1927///
1928/// Description:
1929/// Don't support
1930///
1931/// *************************************************************************
1932#[allow(unused_variables)]
1933pub unsafe extern "C" fn coex_schm_interval_get() -> u32 {
1934 trace!("coex_schm_interval_get");
1935
1936 #[cfg(coex)]
1937 return crate::binary::include::coex_schm_interval_get();
1938
1939 #[cfg(not(coex))]
1940 0
1941}
1942
1943/// **************************************************************************
1944/// Name: wifi_coex_get_schm_curr_period
1945///
1946/// Description:
1947/// Don't support
1948///
1949/// *************************************************************************
1950#[allow(unused_variables)]
1951pub unsafe extern "C" fn coex_schm_curr_period_get() -> u8 {
1952 trace!("coex_schm_curr_period_get");
1953
1954 #[cfg(coex)]
1955 return crate::binary::include::coex_schm_curr_period_get();
1956
1957 #[cfg(not(coex))]
1958 0
1959}
1960
1961/// **************************************************************************
1962/// Name: wifi_coex_get_schm_curr_phase
1963///
1964/// Description:
1965/// Don't support
1966///
1967/// *************************************************************************
1968#[allow(unused_variables)]
1969pub unsafe extern "C" fn coex_schm_curr_phase_get() -> *mut crate::binary::c_types::c_void {
1970 trace!("coex_schm_curr_phase_get");
1971
1972 #[cfg(coex)]
1973 return crate::binary::include::coex_schm_curr_phase_get();
1974
1975 #[cfg(not(coex))]
1976 return core::ptr::null_mut();
1977}
1978
1979pub unsafe extern "C" fn coex_schm_process_restart_wrapper() -> esp_wifi_sys::c_types::c_int {
1980 trace!("coex_schm_process_restart_wrapper");
1981
1982 #[cfg(not(coex))]
1983 return 0;
1984
1985 #[cfg(coex)]
1986 crate::binary::include::coex_schm_process_restart()
1987}
1988
1989#[allow(unused_variables)]
1990pub unsafe extern "C" fn coex_schm_register_cb_wrapper(
1991 arg1: esp_wifi_sys::c_types::c_int,
1992 cb: ::core::option::Option<
1993 unsafe extern "C" fn(arg1: esp_wifi_sys::c_types::c_int) -> esp_wifi_sys::c_types::c_int,
1994 >,
1995) -> esp_wifi_sys::c_types::c_int {
1996 trace!("coex_schm_register_cb_wrapper {} {:?}", arg1, cb);
1997
1998 #[cfg(not(coex))]
1999 return 0;
2000
2001 #[cfg(coex)]
2002 crate::binary::include::coex_schm_register_callback(
2003 arg1 as u32,
2004 unwrap!(cb) as *const esp_wifi_sys::c_types::c_void as *mut esp_wifi_sys::c_types::c_void,
2005 )
2006}
2007
2008pub unsafe extern "C" fn coex_schm_flexible_period_set(period: u8) -> i32 {
2009 trace!("coex_schm_flexible_period_set {}", period);
2010
2011 #[cfg(coex)]
2012 unsafe {
2013 extern "C" {
2014 fn coex_schm_flexible_period_set(period: u8) -> i32;
2015 }
2016
2017 coex_schm_flexible_period_set(period)
2018 }
2019
2020 #[cfg(not(coex))]
2021 0
2022}
2023
2024pub unsafe extern "C" fn coex_schm_flexible_period_get() -> u8 {
2025 trace!("coex_schm_flexible_period_get");
2026
2027 #[cfg(coex)]
2028 unsafe {
2029 extern "C" {
2030 fn coex_schm_flexible_period_get() -> u8;
2031 }
2032
2033 coex_schm_flexible_period_get()
2034 }
2035
2036 #[cfg(not(coex))]
2037 0
2038}
2039
2040pub unsafe extern "C" fn coex_register_start_cb(
2041 _cb: Option<unsafe extern "C" fn() -> esp_wifi_sys::c_types::c_int>,
2042) -> esp_wifi_sys::c_types::c_int {
2043 #[cfg(coex)]
2044 return esp_wifi_sys::include::coex_register_start_cb(_cb);
2045
2046 #[cfg(not(coex))]
2047 0
2048}
2049
2050/// **************************************************************************
2051/// Name: esp_clk_slowclk_cal_get_wrapper
2052///
2053/// Description:
2054/// Get the calibration value of RTC slow clock
2055///
2056/// Input Parameters:
2057/// None
2058///
2059/// Returned Value:
2060/// The calibration value obtained using rtc_clk_cal
2061///
2062/// *************************************************************************
2063#[allow(unused)]
2064pub unsafe extern "C" fn slowclk_cal_get() -> u32 {
2065 trace!("slowclk_cal_get");
2066
2067 // TODO not hardcode this
2068
2069 #[cfg(esp32s2)]
2070 return 44462;
2071
2072 #[cfg(esp32s3)]
2073 return 44462;
2074
2075 #[cfg(esp32c3)]
2076 return 28639;
2077
2078 #[cfg(esp32c2)]
2079 return 28639;
2080
2081 #[cfg(any(esp32c6, esp32h2))]
2082 return 0;
2083
2084 #[cfg(esp32)]
2085 return 28639;
2086}