furi_hal.c 1.9 KB

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