aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--src/main.cpp26
2 files changed, 28 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index f84d6c8..2dfcd45 100644
--- a/Makefile
+++ b/Makefile
@@ -160,6 +160,11 @@ $(BUILD_PATH)/main.bin: $(BUILD_PATH)/$(PROJECT).out
install: $(BUILD_PATH)/main.bin
openocd -f stm32conf/flash.cfg
+program:
+ dfu-util -a0 -d 0110:1001 -D build/main.bin -R
+programFlash:
+ dfu-util -a1 -d 0110:1001 -D build/main.bin -R
+
run: $(BUILD_PATH)/main.bin
openocd -f stm32conf/run.cfg
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");
+ }
}