aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2021-10-30 16:49:20 -0400
committerClyne Sullivan <clyne@bitgloo.com>2021-10-30 16:49:20 -0400
commitff2054f2cb8a780936d95741e1daa7df789fa246 (patch)
tree1980e1f75df9555421b3206d153adaeff9c86036
parent6f1c5203f14f82b6a10c9756ef1dc39bc8631ec0 (diff)
fix fault handling; fix LEDs for rev2
-rw-r--r--source/board/board_l4.c7
-rw-r--r--source/board/l4/board.h6
-rw-r--r--source/conversion.cpp6
-rw-r--r--source/conversion.hpp2
-rw-r--r--source/handlers.cpp2
-rw-r--r--source/monitor.cpp25
6 files changed, 26 insertions, 22 deletions
diff --git a/source/board/board_l4.c b/source/board/board_l4.c
index 31d1d51..55af697 100644
--- a/source/board/board_l4.c
+++ b/source/board/board_l4.c
@@ -277,9 +277,12 @@ bool mmc_lld_is_write_protected(MMCDriver *mmcp) {
* @note You can add your board-specific code here.
*/
void boardInit(void) {
- palSetLineMode(LINE_LED_GREEN, PAL_MODE_OUTPUT_PUSHPULL);
- palSetLineMode(LINE_LED_YELLOW, PAL_MODE_OUTPUT_PUSHPULL);
palSetLineMode(LINE_LED_RED, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetLineMode(LINE_LED_GREEN, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetLineMode(LINE_LED_BLUE, PAL_MODE_OUTPUT_PUSHPULL);
+ palClearLine(LINE_LED_RED);
+ palClearLine(LINE_LED_GREEN);
+ palClearLine(LINE_LED_BLUE);
SCB->CPACR |= 0xF << 20; // Enable FPU
diff --git a/source/board/l4/board.h b/source/board/l4/board.h
index e4dcf03..4b2642a 100644
--- a/source/board/l4/board.h
+++ b/source/board/l4/board.h
@@ -1502,8 +1502,8 @@ extern "C" {
#endif
#endif /* _FROM_ASM_ */
-#define LINE_LED_GREEN PAL_LINE(GPIOC_BASE, 10U)
-#define LINE_LED_YELLOW PAL_LINE(GPIOC_BASE, 11U)
-#define LINE_LED_RED PAL_LINE(GPIOC_BASE, 12U)
+#define LINE_LED_RED PAL_LINE(GPIOC_BASE, 10U)
+#define LINE_LED_GREEN PAL_LINE(GPIOC_BASE, 11U)
+#define LINE_LED_BLUE PAL_LINE(GPIOC_BASE, 12U)
#endif /* BOARD_H */
diff --git a/source/conversion.cpp b/source/conversion.cpp
index c9dc0c9..6fdea07 100644
--- a/source/conversion.cpp
+++ b/source/conversion.cpp
@@ -83,11 +83,11 @@ thread_t *ConversionManager::getMonitorHandle()
return m_thread_monitor;
}
-void ConversionManager::abort()
+void ConversionManager::abort(bool fpu_stacked)
{
ELFManager::unload();
EM.add(Error::ConversionAborted);
- run_status = RunStatus::Recovering;
+ //run_status = RunStatus::Recovering;
// Confirm that the exception return thread is the algorithm...
uint32_t *psp;
@@ -104,7 +104,7 @@ void ConversionManager::abort()
// We do this by rebuilding the thread's stacked exception return.
auto newpsp = reinterpret_cast<uint32_t *>(m_thread_runner_stack.data() +
m_thread_runner_stack.size() -
- 8 * sizeof(uint32_t));
+ (fpu_stacked ? 26 : 8) * sizeof(uint32_t));
// Set the LR register to the thread's entry point.
newpsp[5] = reinterpret_cast<uint32_t>(threadRunner);
// Overwrite the instruction we'll return to with "bx lr" (jump to address in LR).
diff --git a/source/conversion.hpp b/source/conversion.hpp
index 6af4972..a26dd19 100644
--- a/source/conversion.hpp
+++ b/source/conversion.hpp
@@ -39,7 +39,7 @@ public:
static thread_t *getMonitorHandle();
// Internal only: Aborts a running conversion.
- static void abort();
+ static void abort(bool fpu_stacked = true);
private:
static void threadMonitor(void *);
diff --git a/source/handlers.cpp b/source/handlers.cpp
index 2ff948d..43e65c3 100644
--- a/source/handlers.cpp
+++ b/source/handlers.cpp
@@ -108,7 +108,7 @@ void MemManage_Handler()
asm("mov %0, lr" : "=r" (lr));
// 2. Recover from the fault.
- ConversionManager::abort();
+ ConversionManager::abort((lr & (1 << 4)) ? false : true);
// 3. Return.
asm("mov lr, %0; bx lr" :: "r" (lr));
diff --git a/source/monitor.cpp b/source/monitor.cpp
index 08a62d5..6ef97e9 100644
--- a/source/monitor.cpp
+++ b/source/monitor.cpp
@@ -39,30 +39,31 @@ void Monitor::threadMonitor(void *)
#endif
};
- palClearLine(LINE_LED_RED);
- palClearLine(LINE_LED_YELLOW);
+ palSetLine(LINE_LED_RED);
+ palSetLine(LINE_LED_GREEN);
+ palSetLine(LINE_LED_BLUE);
while (1) {
bool isidle = run_status == RunStatus::Idle;
- auto led = isidle ? LINE_LED_GREEN : LINE_LED_YELLOW;
+ auto led = isidle ? LINE_LED_GREEN : LINE_LED_BLUE;
auto delay = isidle ? 500 : 250;
- palSetLine(led);
+ palToggleLine(led);
chThdSleepMilliseconds(delay);
- palClearLine(led);
+ palToggleLine(led);
chThdSleepMilliseconds(delay);
- if (run_status == RunStatus::Idle && readButton()) {
- palSetLine(LINE_LED_RED);
- palSetLine(LINE_LED_YELLOW);
+ if (isidle && readButton()) {
+ palClearLine(LINE_LED_GREEN);
+ palClearLine(LINE_LED_BLUE);
chSysLock();
while (readButton())
asm("nop");
while (!readButton())
asm("nop");
chSysUnlock();
- palClearLine(LINE_LED_RED);
- palClearLine(LINE_LED_YELLOW);
+ palSetLine(LINE_LED_GREEN);
+ palSetLine(LINE_LED_BLUE);
chThdSleepMilliseconds(500);
}
@@ -70,9 +71,9 @@ void Monitor::threadMonitor(void *)
if (auto err = EM.hasError(); err ^ erroron) {
erroron = err;
if (err)
- palSetLine(LINE_LED_RED);
- else
palClearLine(LINE_LED_RED);
+ else
+ palSetLine(LINE_LED_RED);
}
}
}