aboutsummaryrefslogtreecommitdiff
path: root/bootloaders/nuevo_diskloader/src
diff options
context:
space:
mode:
Diffstat (limited to 'bootloaders/nuevo_diskloader/src')
-rw-r--r--bootloaders/nuevo_diskloader/src/CDC.cpp8
-rw-r--r--bootloaders/nuevo_diskloader/src/DiskLoader.cpp19
-rw-r--r--bootloaders/nuevo_diskloader/src/USBCore.cpp2
3 files changed, 18 insertions, 11 deletions
diff --git a/bootloaders/nuevo_diskloader/src/CDC.cpp b/bootloaders/nuevo_diskloader/src/CDC.cpp
index 8bc4b51..cc798b4 100644
--- a/bootloaders/nuevo_diskloader/src/CDC.cpp
+++ b/bootloaders/nuevo_diskloader/src/CDC.cpp
@@ -101,7 +101,7 @@ bool WEAK CDC_Setup(Setup& setup)
return false;
}
-
+/*
int _serialPeek = -1;
void Serial_::begin(uint16_t baud_count)
{
@@ -149,11 +149,6 @@ void Serial_::flush(void)
size_t Serial_::write(uint8_t c)
{
- /* only try to send bytes if the high-level CDC connection itself
- is open (not just the pipe) - the OS should set lineState when the port
- is opened and clear lineState when the port is closed.
- bytes sent before the user opens the connection or after
- the connection is closed are lost - just like with a UART. */
// TODO - ZE - check behavior on different OSes and test what happens if an
// open connection isn't broken cleanly (cable is yanked out, host dies
@@ -172,6 +167,7 @@ size_t Serial_::write(uint8_t c)
}
Serial_ Serial;
+*/
#endif
#endif /* if defined(USBCON) */ \ No newline at end of file
diff --git a/bootloaders/nuevo_diskloader/src/DiskLoader.cpp b/bootloaders/nuevo_diskloader/src/DiskLoader.cpp
index 724a130..cbb709b 100644
--- a/bootloaders/nuevo_diskloader/src/DiskLoader.cpp
+++ b/bootloaders/nuevo_diskloader/src/DiskLoader.cpp
@@ -3,6 +3,7 @@
*/
#include "Platform.h"
+#include "USBCore.h"
//extern "C"
void entrypoint(void) __attribute__ ((naked)) __attribute__ ((section (".vectors")));
@@ -123,9 +124,12 @@ int main()
u16 address = 0;
for (;;)
{
- while (Serial.available() < 1)
- ;
- u8 cmd = Serial.read();
+// while (Serial.available() < 1)
+// ;
+// u8 cmd = Serial.read();
+ while (!USB_Available(CDC_RX))
+ ;
+ u8 cmd = USB_Recv(CDC_RX);
// Read packet contents
u8 len;
@@ -180,8 +184,15 @@ int main()
}
// Check sync
- if (Serial.available() > 0 && Serial.read() != ' ')
+// if (Serial.available() > 0 && Serial.read() != ' ')
+// break;
+// if (USB_Available(CDC_RX) && USB_Recv(CDC_RX) != ' ')
+ u16 countdown = 5000;
+ while (!USB_Available(CDC_RX) && countdown-- > 10)
+ ;
+ if (USB_Recv(CDC_RX) != ' ')
break;
+
USB_Send(CDC_TX, &_inSync, 1);
if (send)
diff --git a/bootloaders/nuevo_diskloader/src/USBCore.cpp b/bootloaders/nuevo_diskloader/src/USBCore.cpp
index abb529a..cfcef73 100644
--- a/bootloaders/nuevo_diskloader/src/USBCore.cpp
+++ b/bootloaders/nuevo_diskloader/src/USBCore.cpp
@@ -273,7 +273,7 @@ int USB_Send(u8 ep, const void* d, int len)
// if (!(--timeout))
// return -1;
// delay(1);
- _delay_ms(3);
+ _delay_ms(1);
continue;
}