Skip to content

Commit

Permalink
♻️ Refactor main.cpp to fit latest __device__
Browse files Browse the repository at this point in the history
  • Loading branch information
kammce committed Aug 17, 2024
1 parent 54281d1 commit bb8bf53
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions demos/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ resource_list resources{};

[[noreturn]] void terminate_handler() noexcept
{

if (not resources.status_led && not resources.console) {
// spin here until debugger is connected
if (not resources.status_led && not resources.clock) {
// spin here and wait for a debugger to be connected...
while (true) {
continue;
}
}

// Otherwise, blink the led in a pattern

auto& led = *resources.status_led.value();
auto& clock = *resources.clock.value();
// Safe access via ::value() is not necessary here since we have already
// checked the resources above.
auto& led = **resources.status_led;
auto& clock = **resources.clock;

// Otherwise, blink the led in a pattern...
while (true) {
using namespace std::chrono_literals;
led.level(false);
Expand All @@ -51,16 +51,8 @@ resource_list resources{};

int main()
{
try {
resources = initialize_platform();
} catch (...) {
while (true) {
// halt here and wait for a debugger to connect
continue;
}
}

hal::set_terminate(terminate_handler);
resources = initialize_platform();

try {
application(resources);
Expand All @@ -72,5 +64,6 @@ int main()
}
} // Allow any other exceptions to terminate the application

// Terminate if the code reaches this point.
std::terminate();
}

0 comments on commit bb8bf53

Please sign in to comment.