diff --git a/right/build/kds/.cproject b/right/build/kds/.cproject
index e15dc10..68d4c88 100644
--- a/right/build/kds/.cproject
+++ b/right/build/kds/.cproject
@@ -112,7 +112,7 @@
-
+
diff --git a/right/src/main.c b/right/src/main.c
index 934cef3..5a52314 100644
--- a/right/src/main.c
+++ b/right/src/main.c
@@ -13,6 +13,7 @@
#include "bootloader_config.h"
#include "command.h"
#include "test_states.h"
+#include "wormhole.h"
key_matrix_t KeyMatrix = {
.colNum = KEYBOARD_MATRIX_COLS_NUM,
@@ -90,44 +91,25 @@ void UpdateUsbReports()
IsUsbBasicKeyboardReportSent = false;
}
-typedef struct {
- uint32_t magicNumber;
- uint8_t enumerationMode;
-} wormhole_t;
-
-wormhole_t *message_ptr __attribute__ ((__section__ (".noinit")));
-
-void* getSP(void)
-{
- void *sp;
- __asm__ __volatile__ ("mov %0, sp" : "=r"(sp));
- return sp;
-}
-
-void __attribute__ ((__section__ (".init3"), __naked__)) move_sp(void) {
- void* SP = getSP();
- SP -= sizeof(wormhole_t);
- message_ptr = (wormhole_t*)(SP + 1);
-}
-
void main() {
InitPeripherials();
InitClock();
-#ifdef ENABLE_BUSPAL
- init_hardware();
- handleUsbBusPalCommand();
-#else
- LedDriver_InitAllLeds(1);
- InitBridgeProtocolScheduler();
- KeyMatrix_Init(&KeyMatrix);
- UpdateUsbReports();
- InitUsb();
-
- // deserialize_Layer(testData, 0);
-
- while (1) {
+ if (false/* || Wormhole->magicNumber == WORMHOLE_MAGIC_NUMBER*/) {
+ Wormhole->magicNumber = 0;
+ init_hardware();
+ handleUsbBusPalCommand();
+ } else {
+ LedDriver_InitAllLeds(1);
+ InitBridgeProtocolScheduler();
+ KeyMatrix_Init(&KeyMatrix);
UpdateUsbReports();
- asm("wfi");
+ InitUsb();
+
+ // deserialize_Layer(testData, 0);
+
+ while (1) {
+ UpdateUsbReports();
+ asm("wfi");
+ }
}
-#endif
}
diff --git a/right/src/usb_protocol_handler.c b/right/src/usb_protocol_handler.c
index c36aaa7..10a7e86 100644
--- a/right/src/usb_protocol_handler.c
+++ b/right/src/usb_protocol_handler.c
@@ -9,6 +9,7 @@
#include "led_pwm.h"
#include "bridge_protocol_scheduler.h"
#include "bridge_slaves/bridge_slave_uhk_module.h"
+#include "wormhole.h"
void setError(uint8_t error);
void setGenericError();
@@ -109,6 +110,7 @@ void getSystemProperty() {
}
void jumpToBootloader() {
+// Wormhole->magicNumber = WORMHOLE_MAGIC_NUMBER;
SCB->AIRCR = 0x5FA<
+
+// Macros:
+
+ #define WORMHOLE_MAGIC_NUMBER 0x3b04cd9e94521f9a
+ #define NO_INIT_GCC __attribute__ ((section (".noinit")))
+
+// Typedefs:
+
+ typedef struct {
+ uint64_t magicNumber;
+ uint8_t enumerationMode;
+ } wormhole_t;
+
+// Variables:
+
+ extern wormhole_t *Wormhole NO_INIT_GCC;
+
+#endif