From fe9885ff7bd10dd19292bbe42879004b86b9ba08 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sat, 25 Apr 2009 13:25:15 +0200 Subject: * digital/dev2: - added real ISP. --- digital/dev2/src/usb_serial_isp/main.c | 44 ++-------------------------------- 1 file changed, 2 insertions(+), 42 deletions(-) (limited to 'digital/dev2/src/usb_serial_isp/main.c') diff --git a/digital/dev2/src/usb_serial_isp/main.c b/digital/dev2/src/usb_serial_isp/main.c index 849b9942..9639fd83 100644 --- a/digital/dev2/src/usb_serial_isp/main.c +++ b/digital/dev2/src/usb_serial_isp/main.c @@ -32,6 +32,7 @@ #include "descriptors.h" #include "common/serial.h" +#include "common/usb_isp.h" #include "common/select.h" HANDLES_EVENT (USB_Connect); @@ -41,47 +42,6 @@ HANDLES_EVENT (USB_UnhandledControlPacket); volatile uint8_t usb_connected, usb_configured; -uint8_t isp_sent; - -void -isp_send_char (uint8_t c) -{ - Endpoint_SelectEndpoint (ISP_TX_EPNUM); - /* Wait endpoint to become ready. */ - while (!Endpoint_ReadWriteAllowed ()) - ; - Endpoint_Write_Byte (c); - /* If at end of endpoint buffer, send. */ - if (!Endpoint_ReadWriteAllowed ()) - Endpoint_ClearCurrentBank (); - /* Select back RX endpoint. */ - Endpoint_SelectEndpoint (ISP_RX_EPNUM); - /* Will need extra clear at end of all transfers. */ - isp_sent = 1; -} - -static void -isp_task (void) -{ - Endpoint_SelectEndpoint (ISP_RX_EPNUM); - /* If data is available from USB: */ - if (Endpoint_ReadWriteAllowed ()) - { - /* Read as much as possible, and clear endpoint. */ - do { - isp_frame_accept_char (Endpoint_Read_Byte ()); - } while (Endpoint_ReadWriteAllowed ()); - Endpoint_ClearCurrentBank (); - } - /* If data has been sent, sent a ZLP or finalise last packet. */ - if (isp_sent) - { - Endpoint_SelectEndpoint (ISP_TX_EPNUM); - Endpoint_ClearCurrentBank (); - isp_sent = 0; - } -} - int main (void) { @@ -102,7 +62,7 @@ main (void) if (usb_configured) { serial_task (); - isp_task (); + usb_isp_task (); } } } -- cgit v1.2.3