Bläddra i källkod

src/cyw43_ll: Ignore wrong-payload-type error when using SPI interface.

Also change some CYW43_DEBUG into CYW43_VDEBUG, to tune the debugging
output.

Fixes issue #36.
Peter Harper 2 år sedan
förälder
incheckning
fe548dc69b
1 ändrade filer med 12 tillägg och 4 borttagningar
  1. 12 4
      src/cyw43_ll.c

+ 12 - 4
src/cyw43_ll.c

@@ -258,6 +258,9 @@ static void cyw43_xxd(size_t len, const uint8_t *buf) {
 
 #define CYW_EAPOL_KEY_TIMEOUT (5000)
 
+// Errors generated by sdpcm_process_rx_packet.
+#define CYW43_ERROR_WRONG_PAYLOAD_TYPE (-9)
+
 static int cyw43_ll_sdpcm_poll_device(cyw43_int_t *self, size_t *len, uint8_t **buf);
 static void cyw43_write_iovar_n(cyw43_int_t *self, const char *var, size_t len, const void *buf, uint32_t iface);
 
@@ -658,14 +661,14 @@ static int cyw43_sdpcm_send_common(cyw43_int_t *self, uint32_t kind, size_t len,
     // Wait until we are allowed to send
     // Credits are 8-bit unsigned integers that roll over, so we are stalled while they are equal
     if (self->wlan_flow_control || self->wwd_sdpcm_last_bus_data_credit == self->wwd_sdpcm_packet_transmit_sequence_number) {
-        CYW43_DEBUG("[CYW43;%u] STALL(%u;%u-%u)\n", (int)cyw43_hal_ticks_ms(), self->wlan_flow_control, self->wwd_sdpcm_packet_transmit_sequence_number, self->wwd_sdpcm_last_bus_data_credit);
+        CYW43_VDEBUG("[CYW43;%u] STALL(%u;%u-%u)\n", (int)cyw43_hal_ticks_ms(), self->wlan_flow_control, self->wwd_sdpcm_packet_transmit_sequence_number, self->wwd_sdpcm_last_bus_data_credit);
 
         uint32_t start_us = cyw43_hal_ticks_us();
         uint32_t last_poke = start_us - 100000;
         for (;;) {
             uint32_t cur_us = cyw43_hal_ticks_us();
             if (cur_us - last_poke >= 100000) {
-                CYW43_DEBUG("STALL(%u;%u-%u): do poke at %u us\n", self->wlan_flow_control, self->wwd_sdpcm_packet_transmit_sequence_number, self->wwd_sdpcm_last_bus_data_credit, (unsigned int)(cur_us - start_us));
+                CYW43_VDEBUG("STALL(%u;%u-%u): do poke at %u us\n", self->wlan_flow_control, self->wwd_sdpcm_packet_transmit_sequence_number, self->wwd_sdpcm_last_bus_data_credit, (unsigned int)(cur_us - start_us));
                 last_poke = cur_us;
                 #if !CYW43_USE_SPI
                 cyw43_write_backplane(self, SDIO_TO_SB_MAILBOX, 4, 1 << 3);
@@ -936,7 +939,7 @@ static int sdpcm_process_rx_packet(cyw43_int_t *self, uint8_t *buf, size_t *out_
                 // ethernet packet doesn't have the correct type
                 // Note - this happens during startup but appears to be expected
                 CYW43_VDEBUG("wrong payload type 0x%02x 0x%02x\n", payload[12], payload[13]);
-                return -9;
+                return CYW43_ERROR_WRONG_PAYLOAD_TYPE;
             }
 
             // check the Broadcom OUI
@@ -1182,8 +1185,13 @@ void cyw43_ll_process_packets(cyw43_ll_t *self_in) {
             cyw43_cb_process_async_event(self, cyw43_ll_parse_async_event(len, buf));
         } else if (ret == DATA_HEADER) {
             cyw43_cb_process_ethernet(self->cb_data, len >> 31, len & 0x7fffffff, buf);
+        } else if (CYW43_USE_SPI && ret == CYW43_ERROR_WRONG_PAYLOAD_TYPE) {
+            // Ignore this error when using the SPI interface.  It can occur when there
+            // is a lot of traffic over the SPI (eg sending UDP packets continuously)
+            // and seems to be harmless.
+            CYW43_VDEBUG("got wrong payload type for packet\n");
         } else {
-            CYW43_WARN("got unexpected packet %d\n", ret);
+            CYW43_DEBUG("got unexpected packet %d\n", ret);
         }
     }
 }