flipperzero-firmware/firmware/targets/f7/Src/main.c
あく e3c7201a20
Furi: core refactoring and CMSIS removal part 2 (#1410)
* Furi: rename and move core
* Furi: drop CMSIS_OS header and unused api, partially refactor and cleanup the rest
* Furi: CMSIS_OS drop and refactoring.
* Furi: refactoring, remove cmsis legacy
* Furi: fix incorrect assert on queue deallocation, cleanup timer
* Furi: improve delay api, get rid of floats
* hal: dropped furi_hal_crc
* Furi: move DWT based delay to cortex HAL
* Furi: update core documentation

Co-authored-by: hedger <hedger@nanode.su>
2022-07-20 13:56:33 +03:00

74 lines
1.7 KiB
C

#include <furi.h>
#include <furi_hal.h>
#include <flipper.h>
#include <alt_boot.h>
#include <semphr.h>
#include <update_util/update_operation.h>
#define TAG "Main"
int32_t init_task(void* context) {
UNUSED(context);
// Flipper FURI HAL
furi_hal_init();
// Init flipper
flipper_init();
return 0;
}
int main() {
// Initialize FURI layer
furi_init();
// Flipper critical FURI HAL
furi_hal_init_early();
FuriThread* main_thread = furi_thread_alloc();
furi_thread_set_name(main_thread, "Init");
furi_thread_set_stack_size(main_thread, 4096);
furi_thread_set_callback(main_thread, init_task);
#ifdef FURI_RAM_EXEC
furi_thread_start(main_thread);
#else
furi_hal_light_sequence("RGB");
// Delay is for button sampling
furi_delay_ms(100);
FuriHalRtcBootMode boot_mode = furi_hal_rtc_get_boot_mode();
if(boot_mode == FuriHalRtcBootModeDfu || !furi_hal_gpio_read(&gpio_button_left)) {
furi_hal_light_sequence("rgb WB");
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeNormal);
flipper_boot_dfu_exec();
furi_hal_power_reset();
} else if(boot_mode == FuriHalRtcBootModeUpdate) {
furi_hal_light_sequence("rgb BR");
flipper_boot_update_exec();
// if things go nice, we shouldn't reach this point.
// But if we do, abandon to avoid bootloops
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeNormal);
furi_hal_power_reset();
} else {
furi_hal_light_sequence("rgb G");
furi_thread_start(main_thread);
}
#endif
// Run Kernel
furi_run();
furi_crash("Kernel is Dead");
}
void Error_Handler(void) {
furi_crash("ErrorHandler");
}
void abort() {
furi_crash("AbortHandler");
}