furi_hal.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #include <furi_hal.h>
  2. #include <furi_hal_mpu.h>
  3. #include <stm32wbxx_ll_cortex.h>
  4. #define TAG "FuriHal"
  5. void furi_hal_init_early() {
  6. furi_hal_cortex_init_early();
  7. furi_hal_clock_init_early();
  8. furi_hal_resources_init_early();
  9. furi_hal_os_init();
  10. furi_hal_spi_config_init_early();
  11. furi_hal_i2c_init_early();
  12. furi_hal_light_init();
  13. furi_hal_rtc_init_early();
  14. }
  15. void furi_hal_deinit_early() {
  16. furi_hal_rtc_deinit_early();
  17. furi_hal_i2c_deinit_early();
  18. furi_hal_spi_config_deinit_early();
  19. furi_hal_resources_deinit_early();
  20. furi_hal_clock_deinit_early();
  21. }
  22. void furi_hal_init() {
  23. furi_hal_mpu_init();
  24. furi_hal_clock_init();
  25. furi_hal_console_init();
  26. furi_hal_rtc_init();
  27. furi_hal_interrupt_init();
  28. furi_hal_flash_init();
  29. furi_hal_resources_init();
  30. FURI_LOG_I(TAG, "GPIO OK");
  31. furi_hal_version_init();
  32. furi_hal_spi_config_init();
  33. furi_hal_spi_dma_init();
  34. furi_hal_speaker_init();
  35. FURI_LOG_I(TAG, "Speaker OK");
  36. furi_hal_crypto_init();
  37. // USB
  38. #ifndef FURI_RAM_EXEC
  39. furi_hal_usb_init();
  40. FURI_LOG_I(TAG, "USB OK");
  41. #endif
  42. furi_hal_i2c_init();
  43. // High Level
  44. furi_hal_power_init();
  45. furi_hal_light_init();
  46. #ifndef FURI_RAM_EXEC
  47. furi_hal_vibro_init();
  48. #endif
  49. furi_hal_bt_init();
  50. furi_hal_compress_icon_init();
  51. }
  52. void furi_hal_switch(void* address) {
  53. __set_BASEPRI(0);
  54. asm volatile("ldr r3, [%0] \n"
  55. "msr msp, r3 \n"
  56. "ldr r3, [%1] \n"
  57. "mov pc, r3 \n"
  58. :
  59. : "r"(address), "r"(address + 0x4)
  60. : "r3");
  61. }