summaryrefslogtreecommitdiffhomepage
path: root/digital/dev2/src/usb_serial_isp/main.c
diff options
context:
space:
mode:
authorNicolas Schodet2009-04-25 13:25:15 +0200
committerNicolas Schodet2009-04-25 13:25:15 +0200
commitfe9885ff7bd10dd19292bbe42879004b86b9ba08 (patch)
treea765bd67c12b2a40c831350c6a10963573cbcd14 /digital/dev2/src/usb_serial_isp/main.c
parent00ba3a7f13e2d6c5688d96c73d9012859e8a6350 (diff)
* digital/dev2:
- added real ISP.
Diffstat (limited to 'digital/dev2/src/usb_serial_isp/main.c')
-rw-r--r--digital/dev2/src/usb_serial_isp/main.c44
1 files changed, 2 insertions, 42 deletions
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 ();
}
}
}