int main(void) { Error check_error = success; uint8 narrow; uint8 wide; os_sleep(100); CheckCleanup(os_boot(boot_module_table, LENGTH(boot_module_table)), boot_failure); CheckCleanup(record_command(0, null), record_failure); record_failure: narrow = 2; wide = 1; goto failure; boot_failure: narrow = 1; wide = os_boot_index(); goto failure; failure: while (!uart_character_ready()) led_signal(narrow, wide); error_stack_print(); write(PSTR("\r\n\r\nWavelogger v4.0\r\n")); write(PSTR("Reset reason: 0x%hx\r\n"), os_reset_reason()); shell_run(shell_command_table, LENGTH(shell_command_table)); return 0; }
__attribute__((section(".boot"))) int main(void) { // exit critical section __asm volatile("cpsie i"); // ensure exception will work as planned os_boot(); BEGIN_TRY { TRY { io_seproxyhal_init(); G_io_seproxyhal_spi_buffer[0] = SEPROXYHAL_TAG_SET_TICKER_INTERVAL; G_io_seproxyhal_spi_buffer[1] = 0; G_io_seproxyhal_spi_buffer[2] = 2; G_io_seproxyhal_spi_buffer[3] = 0; G_io_seproxyhal_spi_buffer[4] = const_anti_align_0x1000[sizeof(const_anti_align_0x1000) - 1]; io_seproxyhal_spi_send(G_io_seproxyhal_spi_buffer, 5); G_io_seproxyhal_spi_buffer[0] = SEPROXYHAL_TAG_SET_TICKER_INTERVAL; G_io_seproxyhal_spi_buffer[1] = 0; G_io_seproxyhal_spi_buffer[2] = 2; G_io_seproxyhal_spi_buffer[3] = 0; G_io_seproxyhal_spi_buffer[4] = 50; io_seproxyhal_spi_send(G_io_seproxyhal_spi_buffer, 5); // initialize the game panel, targets and player { unsigned int i; os_memset(&G_player, 0, sizeof(G_player)); os_memset(G_shots, 0, sizeof(G_shots)); os_memset(G_targets, 0, sizeof(G_targets)); // consume events G_events = 0; // draw buttons only once ! to avoid flickering G_draw_buttons = 1; G_state_index = 0; G_player.x = 100; G_player.y = 200; G_player.velocity = PLAYER_VELOCITY; G_player.last_direction = 0; for (i = 0; i < TARGET_COUNT; i++) { G_targets[i].x = 300 - (cx_rng_u8() % 100); G_targets[i].y = 20 + (cx_rng_u8() * 10 + G_player.y) % (SCREEN_HEIGHT - 20); G_targets[i].alive = 1; } } // erase loader screen (once only) G_state = ERASE_SCREEN; io_seproxyhal_display(&erase_screen[0]); sample_main(); } CATCH_OTHER(e) { } FINALLY { } } END_TRY; }