WFI with interrupt-driven wakeup for USB and W6300

This commit is contained in:
Ian Gulliver
2026-04-10 12:55:04 +09:00
parent 3d20bf4c33
commit 0c11cbb1d1
4 changed files with 27 additions and 4 deletions

View File

@@ -8,6 +8,7 @@
#include "timer_queue.h"
#include "net.h"
#include "debug_log.h"
#include "hardware/sync.h"
static timer_queue timers;
@@ -39,6 +40,8 @@ void dispatch_schedule_ms(uint32_t ms, std::function<void()> fn) {
});
while (true) {
uint32_t save = save_and_disable_interrupts();
dlog_if_slow("tud_task", 1000, [&]{ tud_task(); });
dlog_if_slow("drain", 1000, [&]{ usb.drain(); });
dlog_if_slow("timers", 1000, [&]{ timers.run(); });
@@ -76,6 +79,7 @@ void dispatch_schedule_ms(uint32_t ms, std::function<void()> fn) {
}
}
// __wfi();
__wfi();
restore_interrupts(save);
}
}

View File

@@ -283,6 +283,10 @@ bool net_init() {
w6300::open_socket(raw_socket, w6300::protocol::macraw, w6300::port_num{0}, w6300::sock_flag::none);
w6300::set_socket_io_mode(raw_socket, w6300::sock_io_mode::nonblock);
// CHECK START
w6300::set_socket_interrupt_mask(raw_socket, 0x04);
w6300::set_interrupt_mask(w6300::ik_sock_0);
// CHECK END
return true;
}
@@ -296,6 +300,7 @@ void net_set_handler(net_handler handler) {
}
void net_poll() {
w6300::clear_interrupt(w6300::ik_int_all);
if (w6300::get_socket_recv_buf(raw_socket) == 0) return;
static uint8_t rx_buf[1518];
w6300::ip_address dummy_addr = {};