Level-triggered w6300 interrupt, drain until empty, rearm after drain
This commit is contained in:
@@ -137,13 +137,11 @@ void net_poll(std::span<uint8_t> tx) {
|
|||||||
w6300::irq_pending = false;
|
w6300::irq_pending = false;
|
||||||
w6300::clear_interrupt(w6300::ik_int_all);
|
w6300::clear_interrupt(w6300::ik_int_all);
|
||||||
static uint8_t rx_buf[1518];
|
static uint8_t rx_buf[1518];
|
||||||
uint16_t available = w6300::get_socket_recv_buf(raw_socket);
|
while (w6300::get_socket_recv_buf(raw_socket) > 0) {
|
||||||
uint16_t consumed = 0;
|
|
||||||
while (consumed < available) {
|
|
||||||
auto result = w6300::recv(raw_socket, std::span{rx_buf});
|
auto result = w6300::recv(raw_socket, std::span{rx_buf});
|
||||||
if (!result) break;
|
if (!result) break;
|
||||||
consumed += *result + 2;
|
|
||||||
span_writer tx_writer(tx);
|
span_writer tx_writer(tx);
|
||||||
process_frame({rx_buf, *result}, tx_writer);
|
process_frame({rx_buf, *result}, tx_writer);
|
||||||
}
|
}
|
||||||
|
w6300::rearm_gpio_irq();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,8 +77,11 @@ void pio_init() {
|
|||||||
gpio_init(PIN_INT);
|
gpio_init(PIN_INT);
|
||||||
gpio_set_dir(PIN_INT, GPIO_IN);
|
gpio_set_dir(PIN_INT, GPIO_IN);
|
||||||
gpio_pull_up(PIN_INT);
|
gpio_pull_up(PIN_INT);
|
||||||
gpio_set_irq_enabled_with_callback(PIN_INT, GPIO_IRQ_EDGE_FALL, true,
|
gpio_set_irq_enabled_with_callback(PIN_INT, GPIO_IRQ_LEVEL_LOW, true,
|
||||||
[](uint, uint32_t){ irq_pending = true; });
|
[](uint gpio, uint32_t){
|
||||||
|
irq_pending = true;
|
||||||
|
gpio_set_irq_enabled(gpio, GPIO_IRQ_LEVEL_LOW, false);
|
||||||
|
});
|
||||||
|
|
||||||
pio_hw_t *pios[2] = {pio0, pio1};
|
pio_hw_t *pios[2] = {pio0, pio1};
|
||||||
uint pio_index = 1;
|
uint pio_index = 1;
|
||||||
@@ -500,6 +503,10 @@ void clear_interrupt(intr_kind intr) {
|
|||||||
set_slirclr((uint8_t)((uint32_t)intr >> 16));
|
set_slirclr((uint8_t)((uint32_t)intr >> 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rearm_gpio_irq() {
|
||||||
|
gpio_set_irq_enabled(PIN_INT, GPIO_IRQ_LEVEL_LOW, true);
|
||||||
|
}
|
||||||
|
|
||||||
void set_interrupt_mask(intr_kind intr) {
|
void set_interrupt_mask(intr_kind intr) {
|
||||||
set_imr((uint8_t)intr);
|
set_imr((uint8_t)intr);
|
||||||
set_simr((uint8_t)((uint16_t)intr >> 8));
|
set_simr((uint8_t)((uint16_t)intr >> 8));
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ extern volatile bool irq_pending;
|
|||||||
|
|
||||||
void clear_interrupt(intr_kind intr);
|
void clear_interrupt(intr_kind intr);
|
||||||
void set_interrupt_mask(intr_kind intr);
|
void set_interrupt_mask(intr_kind intr);
|
||||||
|
void rearm_gpio_irq();
|
||||||
|
|
||||||
std::expected<socket_id, sock_error> open_socket(socket_id sn, protocol proto, sock_flag flag);
|
std::expected<socket_id, sock_error> open_socket(socket_id sn, protocol proto, sock_flag flag);
|
||||||
std::expected<uint16_t, sock_error> send(socket_id sn, std::span<const uint8_t> buf);
|
std::expected<uint16_t, sock_error> send(socket_id sn, std::span<const uint8_t> buf);
|
||||||
|
|||||||
Reference in New Issue
Block a user