furi-hal.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #include <furi-hal.h>
  2. #include <comp.h>
  3. #include <tim.h>
  4. #include <gpio.h>
  5. #include <stm32wbxx_ll_cortex.h>
  6. #include <fatfs.h>
  7. #define TAG "FuriHal"
  8. void furi_hal_init() {
  9. furi_hal_clock_init();
  10. furi_hal_rtc_init();
  11. furi_hal_console_init();
  12. furi_hal_interrupt_init();
  13. furi_hal_delay_init();
  14. MX_GPIO_Init();
  15. FURI_LOG_I(TAG, "GPIO OK");
  16. furi_hal_bootloader_init();
  17. furi_hal_version_init();
  18. furi_hal_spi_init();
  19. MX_TIM1_Init();
  20. FURI_LOG_I(TAG, "TIM1 OK");
  21. MX_TIM2_Init();
  22. FURI_LOG_I(TAG, "TIM2 OK");
  23. MX_TIM16_Init();
  24. FURI_LOG_I(TAG, "TIM16 OK");
  25. MX_COMP1_Init();
  26. FURI_LOG_I(TAG, "COMP1 OK");
  27. furi_hal_crypto_init();
  28. // VCP + USB
  29. furi_hal_usb_init();
  30. furi_hal_usb_set_config(&usb_cdc_single);
  31. furi_hal_vcp_init();
  32. FURI_LOG_I(TAG, "USB OK");
  33. furi_hal_i2c_init();
  34. // High Level
  35. furi_hal_power_init();
  36. furi_hal_light_init();
  37. furi_hal_vibro_init();
  38. furi_hal_subghz_init();
  39. furi_hal_nfc_init();
  40. furi_hal_rfid_init();
  41. furi_hal_bt_init();
  42. furi_hal_compress_icon_init();
  43. // FreeRTOS glue
  44. furi_hal_os_init();
  45. // FatFS driver initialization
  46. MX_FATFS_Init();
  47. FURI_LOG_I(TAG, "FATFS OK");
  48. // Partial null pointer dereference protection
  49. LL_MPU_Disable();
  50. LL_MPU_ConfigRegion(
  51. LL_MPU_REGION_NUMBER0, 0x00, 0x0,
  52. LL_MPU_REGION_SIZE_1MB
  53. | LL_MPU_REGION_PRIV_RO_URO
  54. | LL_MPU_ACCESS_BUFFERABLE
  55. | LL_MPU_ACCESS_CACHEABLE
  56. | LL_MPU_ACCESS_SHAREABLE
  57. | LL_MPU_TEX_LEVEL1
  58. | LL_MPU_INSTRUCTION_ACCESS_ENABLE
  59. );
  60. LL_MPU_Enable(LL_MPU_CTRL_PRIVILEGED_DEFAULT);
  61. }