aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 46037bd..cf79329 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -7,7 +7,16 @@ void setup();
void loop();
int ledPin = 13;
+uint8_t bytes_in;
+BootVectTable* mapleVect;
+
+void usb_tx_cb(void) {
+}
+
+void usb_rx_cb(void) {
+ bytes_in = usb_serialGetRecvLen();
+}
void setup()
{
@@ -19,8 +28,13 @@ void setup()
pwmWrite(6, 0x8000);
Serial2.println("setup end");
+
+ mapleVect = (BootVectTable*)(BOOTLOADER_VECT_TABLE);
+ mapleVect->serial_tx_cb = usb_tx_cb;
+ mapleVect->serial_rx_cb = usb_rx_cb;
}
+
int toggle = 0;
char* testMsg = "0123456\n";
@@ -28,10 +42,16 @@ void loop() {
toggle ^= 1;
digitalWrite(ledPin, toggle);
delay(1000);
+ usb_serialWriteStr("blink...\n");
- usb_userToPMABufferCopy((u8*)testMsg,USB_SERIAL_ENDP_TXADDR,8);
- _SetEPTxCount(USB_SERIAL_ENDP_TX,8);
- _SetEPTxValid(USB_SERIAL_ENDP_TX);
+ if (bytes_in > 0) {
+ int i;
+ for (i=0;i<bytes_in;i++) {
+ usb_serialWriteStr("b,");
+ }
+ bytes_in = 0;
+ usb_serialWriteStr("\n");
+ }
}