/*@only@*//*@null@*/wwd_result_t wwd_bus_read_frame( wiced_buffer_t* buffer ) { uint32_t intstatus; void *p0 = NULL; uint16_t *hwtag; intstatus = read_intstatus(); /* Handle DMA interrupts */ if (intstatus & I_XI) { dma_tx_reclaim(); } if ( rxactive_dma( ) == 0 ) { refill_dma( ); if ( rxactive_dma( ) != 0 ) { int_enab(); } } /* Handle DMA errors */ if (intstatus & I_ERRORS) { refill_dma( ); WPRINT_WWD_DEBUG(("RX errors: intstatus: 0x%x\n", (unsigned int)intstatus)); } /* Handle DMA receive interrupt */ p0 = read_dma_packet( &hwtag ); if ( p0 == NULL) { if ( rxactive_dma( ) != 0 ) { int_enab(); } return WWD_NO_PACKET_TO_RECEIVE; } *buffer = p0; host_buffer_add_remove_at_front( buffer, - (int)sizeof(wwd_buffer_header_t) ); wwd_sdpcm_update_credit((uint8_t*)hwtag); refill_dma( ); /* where are buffers from dma_rx and dma_getnextrxp created? */ return WWD_SUCCESS; }
/* user API: requests us to start transmitting data via USB IN EP */ void fastsource_start(void) { if(USBD_GetState() != USBD_STATE_CONFIGURED) return; if (!usb_state.active) refill_dma(); }
/* completion callback: USBD_Write() has completed an IN transfer */ static void wr_compl_cb(void *arg, unsigned char status, unsigned int transferred, unsigned int remain) { struct req_ctx *rctx = arg; usb_state.active = 0; req_ctx_set_state(rctx, RCTX_STATE_FREE); if (status == 0 && remain == 0) { refill_dma(); } else { TRACE_WARNING("Err: EP%u wr_compl, status 0x%02u, xfr %u, remain %u\r\n", EP_NR, status, transferred, remain); } }