src/main.cpp

changeset 64
897330ee6e9d
parent 63
f71f6c0af3cd
child 65
d9c5eaf85fab
--- a/src/main.cpp	Thu Sep 09 21:59:53 2021 +0200
+++ b/src/main.cpp	Sun Oct 03 22:58:49 2021 +0200
@@ -18,11 +18,7 @@
 #endif
 
 #include "platform/CircularBuffer.h"
-
-// cannot make it work...
-// #include <USBSerial.h>
-// USBSerial usbcdc(false);
-
+#include <USBSerial.h>
 
 Display *dsp;
 volatile bool splashscreen;
@@ -154,23 +150,25 @@
 FileHandle *mbed::mbed_override_console(int fd)
 {
 	return static_cast<FileHandle*> (&pc);
+	//return &pc;
 }
 #endif
 
 
 void setup() {
+#if defined(HAVE_PC)
+	pc.connect();
+	ThisThread::sleep_for(100ms);
+	//pc.printf("SERIAL CONNECTION\r\n");
+#endif
+
   printf("\n\nSETUP\n");
   printf("  System Core Clock = %ld MHZ\r\n", SystemCoreClock/1000000);
 
+  printf("Create USBSerial\n");
   hp = NULL;
-#if defined(TARGET_NUCLEO_F446RE)
-  printf("Serial communication pins\r\n");
-  printf("     USBRX=%d\r\n", USBRX);
-  printf("     USBTX=%d\r\n", USBTX);
-#endif
-#if defined(TARGET_HP34970_FP_F303RD)
+
   printf("Serial communication via UART4\r\n");
-#endif
 
   printf("Setup HP communication pins\r\n");
   //printf("     HP_RX=%d\r\n", HP_RX);
@@ -229,8 +227,10 @@
   splashscreen = true;
   splashscreen_timer.attach(callback(&end_splashscreen), 5s);
   rst.fall(&reset_irq);
+  printf("SETUP DONE\r\n");
 
-  printf("SETUP DONE\r\n");
+  if (rst.read() == 0)
+    reset();
 }
 
 void end_splashscreen(void)
@@ -251,6 +251,7 @@
 {
 	must_reset = true;
 	//rst_delay.attach(callback(&reset_irq_tmr), 50ms);
+    NVIC_SystemReset();
 }
 
 void reset(void)
@@ -297,6 +298,7 @@
 
 void shutdown(void)
 {
+  // TODO: implement low-power-mode stuff
   must_shutdown = true;
 }
 

mercurial