From e3b080235a6bf702ef30eb34ffcf5e0734fcf8bd Mon Sep 17 00:00:00 2001 From: Aadi Desai <21363892+supleed2@users.noreply.github.com> Date: Sat, 10 Jun 2023 15:18:42 +0100 Subject: [PATCH] Visualise IRQ via LED --- demo/can.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/demo/can.cpp b/demo/can.cpp index 1d20b24..bf7b50e 100644 --- a/demo/can.cpp +++ b/demo/can.cpp @@ -39,8 +39,10 @@ can_frame can_read(void) { void can_isr(void) { static uint32_t count = 0; - can_ev_pending_frame_write(1); // Should use `can_ev_pending_read()` and check which interrupt, but there is only 1 - leds_out_write(leds_out_read() ^ 0xFF0000); // Toggle Red LED + can_ev_pending_frame_write(1); // Should use `can_ev_pending_read()` and check which interrupt, but there is only 1 + uint32_t o_leds = leds_out_read() >> 8; // Read LED state + uint32_t n_leds = o_leds ? o_leds : 0xFF0000; // Next LED state + leds_out_write(n_leds); // Toggle Red LED count++; can_frame frame = can_read(); printf("\033[F\033[F\33[2K\nCAN frame % 5d received, ID: 0x%03X, data: 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n",