void cpld_update(void) { #define WAIT_LOOP_DELAY (6000000) #define ALL_LEDS (PIN_LED1|PIN_LED2|PIN_LED3) int i; int error; usb_queue_flush_endpoint(&usb_endpoint_bulk_in); usb_queue_flush_endpoint(&usb_endpoint_bulk_out); refill_cpld_buffer(); error = cpld_jtag_program(sizeof(cpld_xsvf_buffer), cpld_xsvf_buffer, refill_cpld_buffer); if(error == 0) { /* blink LED1, LED2, and LED3 on success */ while (1) { gpio_set(PORT_LED1_3, ALL_LEDS); /* LEDs on */ for (i = 0; i < WAIT_LOOP_DELAY; i++) /* Wait a bit. */ __asm__("nop"); gpio_clear(PORT_LED1_3, ALL_LEDS); /* LEDs off */ for (i = 0; i < WAIT_LOOP_DELAY; i++) /* Wait a bit. */ __asm__("nop"); } }else { /* LED3 (Red) steady on error */ gpio_set(PORT_LED1_3, PIN_LED3); /* LEDs on */ while (1); } }
void usb_endpoint_flush( const usb_endpoint_t* const endpoint ) { const uint_fast8_t endpoint_number = usb_endpoint_number(endpoint->address); usb_queue_flush_endpoint(endpoint); if( usb_endpoint_is_in(endpoint->address) ) { usb_flush_primed_endpoints(USB0_ENDPTFLUSH_FETB(1 << endpoint_number)); } else { usb_flush_primed_endpoints(USB0_ENDPTFLUSH_FERB(1 << endpoint_number)); } }
void usb_endpoint_disable( const usb_endpoint_t* const endpoint ) { const uint_fast8_t endpoint_number = usb_endpoint_number(endpoint->address); if( usb_endpoint_is_in(endpoint->address) ) { USB0_ENDPTCTRL(endpoint_number) &= ~(USB0_ENDPTCTRL_TXE); } else { USB0_ENDPTCTRL(endpoint_number) &= ~(USB0_ENDPTCTRL_RXE); } usb_queue_flush_endpoint(endpoint); usb_endpoint_clear_pending_interrupts(endpoint); usb_endpoint_flush(endpoint); }