Просмотр исходного кода

Squashed commit of the following:

commit 7c49f604f986f13790051822c72ae7de1730827c
Author: Zoë Prosvetova <109866245+ZoeMeetAgain@users.noreply.github.com>
Date:   Sat Jul 23 18:33:39 2022 +0200

    Fix toolchain typos (#1435)

commit 253b98c8f014e4fa91a129eaba3a986f91ac5b12
Author: ESurge <s_marcelino@hotmail.com>
Date:   Fri Jul 22 20:35:14 2022 -0700

    Added condition to cli "log" command to end if serial terminal is disconnected. (#1425)

    * Added condition to cli "log" command. If USB is disconnected while "log" command is running, it will end the command.
    * Reverted change on cli_commands.c
      Added condition in cli.c for cli_cmd_interrupt_received function to react appropriately when serial terminal is disconnected.
      Added condition in subghz_cli.c for subghz chat cmd to exit gracefully when serial terminal is disconnected.
    * Formatting

    Co-authored-by: あく <alleteam@gmail.com>

commit 16e598b2c08bf3156370f15fef5b5dd002780f68
Author: Georgii Surkov <37121527+gsurkov@users.noreply.github.com>
Date:   Fri Jul 22 19:00:25 2022 +0300

    [FL-2655, FL-2650] Buffered file streams (#1424)

    * Initial buffered file stream implementation
    * Fix logical errors
    * Fix more logical errors
    * Minimally working implementation
    * Adapt infrared unit tests for buffered streams
    * Increase read buffer size from 512 to 1K
    * Correct naming and formatting
    * More code improvements
    * Allow passing access and open modes for buffered streams
    * Implement tests for buffered streams
    * Better file and method names
    * Add comments and correct formatting
    * Use buffered streams in Infrared
    * Fix compilation error

commit ec57dd310a6ad9657c08d143bd82a66da532dc78
Author: adisbladis <adisbladis@gmail.com>
Date:   Wed Jul 20 20:48:10 2022 +0800

    fbt: Respect SOURCE_DATE_EPOCH when setting build date (#1421)

    * fbt: using SOURCE_DATE_EPOCH from environment for build timestamp (if set)

    Co-authored-by: hedger <hedger@users.noreply.github.com>

commit e3c7201a2065677ad3c96f0bb1f47f7b58cdb819
Author: あく <alleteam@gmail.com>
Date:   Wed Jul 20 13:56:33 2022 +0300

    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>

commit f9c2287ea7dabb0e8275d9a635c4b941516f59bc
Author: Dom <FroggMaster@users.noreply.github.com>
Date:   Sun Jul 17 03:09:47 2022 -0700

    Update ReadMe.md (#1409)

    - Minor correction in grammar for ReadMe.

    Co-authored-by: あく <alleteam@gmail.com>

commit 73711c75e630badf275eb0f11cfc4391ac3d2566
Author: t0m1o1 <94725994+t0m1o1@users.noreply.github.com>
Date:   Sun Jul 17 10:56:47 2022 +0100

    Update bad_usb_script.c to fix incorrect ALT key const #1406

    Co-authored-by: あく <alleteam@gmail.com>

commit e7c3da1da9bbbd454b1a863e336dce3fbd5e6553
Author: Skorpionm <85568270+Skorpionm@users.noreply.github.com>
Date:   Sun Jul 17 13:45:21 2022 +0400

    [FL-2658, FL-2657] SubGhz: add new protocol (IronLogic, Comunello, Sommer(fsk476), Normstahl, KEY, EcoStar, Gibidi, Mutancode) (#1404)

    * Subghz: fix cli  no load keeloq_mfcodes_user
    * SubGhz: add new protocol (IronLogic, Comunello, Sommer(fsk476), Normstahl, KEY, EcoStar, Gibidi, Mutancode)
    * SubGhz: fix syntax
    * SubGhz: fix error build

    Co-authored-by: あく <alleteam@gmail.com>

commit 7741a19244ce3af206c6434fc922f1340a96e547
Author: SG <who.just.the.doctor@gmail.com>
Date:   Sun Jul 17 12:34:13 2022 +0300

    Better crash handling (#1397)

    * Core: correct ISR flag check on crash, dump heap and stack info on crash
    * Core: crash, show task name
    * Core crash: optimization

    Co-authored-by: あく <alleteam@gmail.com>

commit 80629de01ecc6cee5a811ba647479117f17b8374
Author: Georgii Surkov <37121527+gsurkov@users.noreply.github.com>
Date:   Sun Jul 17 12:21:56 2022 +0300

    [FL-2601] Move Infrared unit test data to assets (#1396)

    * Move samsung raw data to assets
    * Add more assets and fix bugs
    * Clean up code
    * Implement all raw data as assets
    * Remove input data from old test files
    * Better signal names
    * Better file opening logic
    * Implement loading parsed data from files
    * Move most of RC5 tests into assets
    * Add more test cases
    * Add more test cases
    * Eliminate RUN_DECODER macro
    * Better code structure
    * Implement run_encoder function
    * More encoder tests
    * Move all encoder tests to assets
    * Move all test data to assets
    * Normalise function names
    * Rename code files
    * Uncomment other tests
    * Swich test order to avoid weird memory leaks
    * UnitTests: cleanup output and redirect it into stdout
    * UnitTests: selectable tests and better reporting

    Co-authored-by: あく <alleteam@gmail.com>

commit 877c5c812236337756bd8dba8694ac0ccf53da66
Author: Nikolay Minaylov <nm29719@gmail.com>
Date:   Sun Jul 17 10:41:16 2022 +0300

    [FL-1962, FL-2464, FL-2465, FL-2466, FL-2560, FL-2637, FL-2595] Ibutton, Infrared, LfRFID GUI fixes (#1392)

    * Ibutton, Infrared, LfRFID GUI fixes
    * Loading screens update

    Co-authored-by: あく <alleteam@gmail.com>

commit edc6ca0c8f3cd66ccfa2a8b0bf102bb1828d388e
Author: Eric Betts <bettse@fastmail.fm>
Date:   Sat Jul 16 23:13:51 2022 -0700

    Log MFC nonces for use with mfkey32v2 (#1390)

    Co-authored-by: あく <alleteam@gmail.com>

commit c29ab50016655d57304e9ffd358a2923cc85faa1
Author: Eric Betts <bettse@fastmail.fm>
Date:   Sat Jul 16 23:01:19 2022 -0700

    Calculate picopass CRC dynamically (#1389)

    Co-authored-by: あく <alleteam@gmail.com>
0xchocolate 3 лет назад
Родитель
Сommit
55ecf32b9e
100 измененных файлов с 480 добавлено и 403 удалено
  1. 1 1
      .github/CODEOWNERS
  2. 2 2
      ReadMe.md
  3. 5 5
      applications/accessor/accessor_view_manager.cpp
  4. 1 1
      applications/accessor/accessor_view_manager.h
  5. 2 2
      applications/archive/helpers/archive_browser.c
  6. 3 10
      applications/archive/views/archive_browser_view.c
  7. 13 13
      applications/bad_usb/bad_usb_script.c
  8. 4 4
      applications/bt/bt_cli.c
  9. 7 7
      applications/bt/bt_debug_app/views/bt_carrier_test.c
  10. 5 5
      applications/bt/bt_debug_app/views/bt_packet_test.c
  11. 32 23
      applications/bt/bt_service/bt.c
  12. 8 5
      applications/bt/bt_service/bt_api.c
  13. 3 3
      applications/bt/bt_service/bt_i.h
  14. 28 26
      applications/cli/cli.c
  15. 2 2
      applications/cli/cli_i.h
  16. 8 8
      applications/cli/cli_vcp.c
  17. 11 11
      applications/debug_tools/blink_test.c
  18. 5 5
      applications/debug_tools/display_test/view_display_test.c
  19. 2 2
      applications/debug_tools/file_browser_test/scenes/file_browser_scene_browser.c
  20. 5 5
      applications/debug_tools/keypad_test.c
  21. 5 5
      applications/debug_tools/text_box_test.c
  22. 2 2
      applications/debug_tools/uart_echo.c
  23. 6 6
      applications/debug_tools/usb_mouse.c
  24. 5 5
      applications/debug_tools/vibro_test.c
  25. 8 8
      applications/desktop/animations/animation_manager.c
  26. 1 1
      applications/desktop/animations/animation_storage.c
  27. 9 11
      applications/desktop/animations/views/bubble_animation_view.c
  28. 5 5
      applications/desktop/desktop.c
  29. 1 1
      applications/desktop/desktop_i.h
  30. 1 1
      applications/desktop/desktop_settings/scenes/desktop_settings_scene_pin_auth.c
  31. 1 1
      applications/desktop/desktop_settings/scenes/desktop_settings_scene_pin_disable.c
  32. 1 1
      applications/desktop/desktop_settings/scenes/desktop_settings_scene_pin_error.c
  33. 1 1
      applications/desktop/desktop_settings/scenes/desktop_settings_scene_pin_setup.c
  34. 2 2
      applications/desktop/helpers/slideshow.c
  35. 1 1
      applications/desktop/scenes/desktop_scene_pin_input.c
  36. 1 1
      applications/desktop/views/desktop_view_locked.c
  37. 1 1
      applications/desktop/views/desktop_view_main.c
  38. 1 1
      applications/desktop/views/desktop_view_pin_input.c
  39. 2 2
      applications/dialogs/dialogs.c
  40. 4 2
      applications/dialogs/dialogs_api.c
  41. 5 5
      applications/dialogs/dialogs_api_lock.h
  42. 1 1
      applications/dialogs/dialogs_i.h
  43. 1 1
      applications/dialogs/view_holder.c
  44. 13 9
      applications/dolphin/dolphin.c
  45. 1 1
      applications/dolphin/dolphin.h
  46. 3 3
      applications/dolphin/dolphin_i.h
  47. 7 8
      applications/dolphin/passport/passport.c
  48. 17 16
      applications/gpio/usb_uart_bridge.c
  49. 7 7
      applications/gui/gui.c
  50. 2 2
      applications/gui/gui_i.h
  51. 5 4
      applications/gui/icon_animation.c
  52. 1 1
      applications/gui/icon_animation_i.h
  53. 6 14
      applications/gui/modules/file_browser.c
  54. 5 4
      applications/gui/modules/file_browser_worker.c
  55. 7 8
      applications/gui/modules/loading.c
  56. 7 6
      applications/gui/modules/popup.c
  57. 6 6
      applications/gui/modules/text_input.c
  58. 4 4
      applications/gui/view.c
  59. 12 8
      applications/gui/view_dispatcher.c
  60. 1 1
      applications/gui/view_dispatcher_i.h
  61. 1 1
      applications/gui/view_i.h
  62. 1 1
      applications/gui/view_stack.c
  63. 14 13
      applications/ibutton/ibutton_cli.c
  64. 3 1
      applications/ibutton/scenes/ibutton_scene_add_type.c
  65. 1 1
      applications/ibutton/scenes/ibutton_scene_emulate.c
  66. 2 2
      applications/ibutton/scenes/ibutton_scene_exit_confirm.c
  67. 4 1
      applications/ibutton/scenes/ibutton_scene_read_crc_error.c
  68. 4 2
      applications/ibutton/scenes/ibutton_scene_read_key_menu.c
  69. 4 1
      applications/ibutton/scenes/ibutton_scene_read_not_key_error.c
  70. 4 1
      applications/ibutton/scenes/ibutton_scene_saved_key_menu.c
  71. 4 1
      applications/ibutton/scenes/ibutton_scene_start.c
  72. 5 4
      applications/infrared/infrared_brute_force.c
  73. 1 1
      applications/infrared/infrared_cli.c
  74. 3 3
      applications/infrared/infrared_remote.c
  75. 1 1
      applications/infrared/infrared_signal.c
  76. 48 0
      applications/infrared/scenes/infrared_scene_ask_retry.c
  77. 1 0
      applications/infrared/scenes/infrared_scene_config.h
  78. 1 2
      applications/infrared/scenes/infrared_scene_learn_success.c
  79. 1 2
      applications/infrared/scenes/infrared_scene_remote_list.c
  80. 1 0
      applications/infrared/scenes/infrared_scene_start.c
  81. 1 1
      applications/infrared/views/infrared_progress_view.c
  82. 7 7
      applications/input/input.c
  83. 5 5
      applications/input/input_cli.c
  84. 1 1
      applications/input/input_i.h
  85. 1 1
      applications/lfrfid/helpers/rfid_key.cpp
  86. 3 3
      applications/lfrfid/helpers/rfid_reader.cpp
  87. 6 6
      applications/lfrfid/helpers/rfid_writer.cpp
  88. 1 1
      applications/lfrfid/lfrfid_app.cpp
  89. 2 2
      applications/lfrfid/lfrfid_cli.cpp
  90. 1 1
      applications/lfrfid/scene/lfrfid_app_scene_emulate.cpp
  91. 1 1
      applications/lfrfid/scene/lfrfid_app_scene_exit_confirm.cpp
  92. 2 2
      applications/lfrfid/scene/lfrfid_app_scene_read.cpp
  93. 1 1
      applications/lfrfid/scene/lfrfid_app_scene_rpc.cpp
  94. 1 1
      applications/loader/loader.c
  95. 1 1
      applications/loader/loader.h
  96. 1 1
      applications/loader/loader_i.h
  97. 17 15
      applications/music_player/music_player.c
  98. 1 1
      applications/music_player/music_player_cli.c
  99. 5 5
      applications/music_player/music_player_worker.c
  100. 2 2
      applications/nfc/helpers/nfc_debug_pcap.c

+ 1 - 1
.github/CODEOWNERS

@@ -40,7 +40,7 @@
 /assets/ @skotopes @DrZlo13 @hedger
 
 # Furi Core
-/core/ @skotopes @DrZlo13 @hedger
+/furi/ @skotopes @DrZlo13 @hedger
 
 # Debug tools and plugins
 /debug/ @skotopes @DrZlo13 @hedger

+ 2 - 2
ReadMe.md

@@ -23,7 +23,7 @@ Flipper Zero's firmware consists of two components:
 - Core2 firmware set - proprietary components by ST: FUS + radio stack. FUS is flashed at factory and you should never update it.
 - Core1 Firmware - HAL + OS + Drivers + Applications.
 
-They both must be flashed in order described.
+They both must be flashed in the order described.
 
 ## With offline update package
 
@@ -155,7 +155,7 @@ Connect your device via ST-Link and run:
 
 - `applications`    - Applications and services used in firmware
 - `assets`          - Assets used by applications and services
-- `core`            - Furi Core: os level primitives and helpers
+- `furi`            - Furi Core: os level primitives and helpers
 - `debug`           - Debug tool: GDB-plugins, SVD-file and etc
 - `docker`          - Docker image sources (used for firmware build automation)
 - `documentation`   - Documentation generation system configs and input files

+ 5 - 5
applications/accessor/accessor_view_manager.cpp

@@ -3,7 +3,7 @@
 #include <callback-connector.h>
 
 AccessorAppViewManager::AccessorAppViewManager() {
-    event_queue = osMessageQueueNew(10, sizeof(AccessorEvent), NULL);
+    event_queue = furi_message_queue_alloc(10, sizeof(AccessorEvent));
 
     view_dispatcher = view_dispatcher_alloc();
     auto callback = cbc::obtain_connector(this, &AccessorAppViewManager::previous_view_callback);
@@ -38,7 +38,7 @@ AccessorAppViewManager::~AccessorAppViewManager() {
     view_dispatcher_free(view_dispatcher);
 
     // free event queue
-    osMessageQueueDelete(event_queue);
+    furi_message_queue_free(event_queue);
 }
 
 void AccessorAppViewManager::switch_to(ViewType type) {
@@ -54,14 +54,14 @@ Popup* AccessorAppViewManager::get_popup() {
 }
 
 void AccessorAppViewManager::receive_event(AccessorEvent* event) {
-    if(osMessageQueueGet(event_queue, event, NULL, 100) != osOK) {
+    if(furi_message_queue_get(event_queue, event, 100) != FuriStatusOk) {
         event->type = AccessorEvent::Type::Tick;
     }
 }
 
 void AccessorAppViewManager::send_event(AccessorEvent* event) {
-    osStatus_t result = osMessageQueuePut(event_queue, event, 0, 0);
-    furi_check(result == osOK);
+    FuriStatus result = furi_message_queue_put(event_queue, event, 0);
+    furi_check(result == FuriStatusOk);
 }
 
 uint32_t AccessorAppViewManager::previous_view_callback(void*) {

+ 1 - 1
applications/accessor/accessor_view_manager.h

@@ -13,7 +13,7 @@ public:
         Tune,
     };
 
-    osMessageQueueId_t event_queue;
+    FuriMessageQueue* event_queue;
 
     AccessorAppViewManager();
     ~AccessorAppViewManager();

+ 2 - 2
applications/archive/helpers/archive_browser.c

@@ -2,8 +2,8 @@
 #include "archive_files.h"
 #include "archive_apps.h"
 #include "archive_browser.h"
-#include "furi/common_defines.h"
-#include "furi/log.h"
+#include <core/common_defines.h>
+#include <core/log.h>
 #include "gui/modules/file_browser_worker.h"
 #include "m-string.h"
 #include <math.h>

+ 3 - 10
applications/archive/views/archive_browser_view.c

@@ -105,17 +105,10 @@ static void archive_draw_frame(Canvas* canvas, uint16_t idx, bool scrollbar, boo
 static void archive_draw_loading(Canvas* canvas, ArchiveBrowserViewModel* model) {
     furi_assert(model);
 
-    uint8_t width = 49;
-    uint8_t height = 47;
-    uint8_t x = 128 / 2 - width / 2;
-    uint8_t y = 64 / 2 - height / 2 + 6;
+    uint8_t x = 128 / 2 - 24 / 2;
+    uint8_t y = 64 / 2 - 24 / 2;
 
-    elements_bold_rounded_frame(canvas, x, y, width, height);
-
-    canvas_set_font(canvas, FontSecondary);
-    elements_multiline_text(canvas, x + 7, y + 13, "Loading...");
-
-    canvas_draw_icon(canvas, x + 13, y + 19, &A_Loading_24);
+    canvas_draw_icon(canvas, x, y, &A_Loading_24);
 }
 
 static void draw_list(Canvas* canvas, ArchiveBrowserViewModel* model) {

+ 13 - 13
applications/bad_usb/bad_usb_script.c

@@ -171,7 +171,7 @@ static bool ducky_altchar(const char* charcode) {
 
     FURI_LOG_I(WORKER_TAG, "char %s", charcode);
 
-    furi_hal_hid_kb_press(HID_KEYBOARD_L_ALT);
+    furi_hal_hid_kb_press(KEY_MOD_LEFT_ALT);
 
     while(!ducky_is_line_end(charcode[i])) {
         state = ducky_numpad_press(charcode[i]);
@@ -179,7 +179,7 @@ static bool ducky_altchar(const char* charcode) {
         i++;
     }
 
-    furi_hal_hid_kb_release(HID_KEYBOARD_L_ALT);
+    furi_hal_hid_kb_release(KEY_MOD_LEFT_ALT);
     return state;
 }
 
@@ -485,8 +485,8 @@ static int32_t bad_usb_worker(void* context) {
 
         } else if(worker_state == BadUsbStateNotConnected) { // State: USB not connected
             uint32_t flags = furi_thread_flags_wait(
-                WorkerEvtEnd | WorkerEvtConnect, osFlagsWaitAny, osWaitForever);
-            furi_check((flags & osFlagsError) == 0);
+                WorkerEvtEnd | WorkerEvtConnect, FuriFlagWaitAny, FuriWaitForever);
+            furi_check((flags & FuriFlagError) == 0);
             if(flags & WorkerEvtEnd) {
                 break;
             } else if(flags & WorkerEvtConnect) {
@@ -497,9 +497,9 @@ static int32_t bad_usb_worker(void* context) {
         } else if(worker_state == BadUsbStateIdle) { // State: ready to start
             uint32_t flags = furi_thread_flags_wait(
                 WorkerEvtEnd | WorkerEvtToggle | WorkerEvtDisconnect,
-                osFlagsWaitAny,
-                osWaitForever);
-            furi_check((flags & osFlagsError) == 0);
+                FuriFlagWaitAny,
+                FuriWaitForever);
+            furi_check((flags & FuriFlagError) == 0);
             if(flags & WorkerEvtEnd) {
                 break;
             } else if(flags & WorkerEvtToggle) { // Start executing script
@@ -520,9 +520,9 @@ static int32_t bad_usb_worker(void* context) {
         } else if(worker_state == BadUsbStateRunning) { // State: running
             uint16_t delay_cur = (delay_val > 1000) ? (1000) : (delay_val);
             uint32_t flags = furi_thread_flags_wait(
-                WorkerEvtEnd | WorkerEvtToggle | WorkerEvtDisconnect, osFlagsWaitAny, delay_cur);
+                WorkerEvtEnd | WorkerEvtToggle | WorkerEvtDisconnect, FuriFlagWaitAny, delay_cur);
             delay_val -= delay_cur;
-            if(!(flags & osFlagsError)) {
+            if(!(flags & FuriFlagError)) {
                 if(flags & WorkerEvtEnd) {
                     break;
                 } else if(flags & WorkerEvtToggle) {
@@ -534,7 +534,7 @@ static int32_t bad_usb_worker(void* context) {
                 }
                 bad_usb->st.state = worker_state;
                 continue;
-            } else if((flags == osFlagsErrorTimeout) || (flags == osFlagsErrorResource)) {
+            } else if((flags == FuriFlagErrorTimeout) || (flags == FuriFlagErrorResource)) {
                 if(delay_val > 0) {
                     bad_usb->st.delay_remain--;
                     continue;
@@ -556,15 +556,15 @@ static int32_t bad_usb_worker(void* context) {
                     bad_usb->st.delay_remain = delay_val / 1000;
                 }
             } else {
-                furi_check((flags & osFlagsError) == 0);
+                furi_check((flags & FuriFlagError) == 0);
             }
 
         } else if(
             (worker_state == BadUsbStateFileError) ||
             (worker_state == BadUsbStateScriptError)) { // State: error
             uint32_t flags = furi_thread_flags_wait(
-                WorkerEvtEnd, osFlagsWaitAny, osWaitForever); // Waiting for exit command
-            furi_check((flags & osFlagsError) == 0);
+                WorkerEvtEnd, FuriFlagWaitAny, FuriWaitForever); // Waiting for exit command
+            furi_check((flags & FuriFlagError) == 0);
             if(flags & WorkerEvtEnd) {
                 break;
             }

+ 4 - 4
applications/bt/bt_cli.c

@@ -41,7 +41,7 @@ static void bt_cli_command_carrier_tx(Cli* cli, string_t args, void* context) {
         furi_hal_bt_start_tone_tx(channel, 0x19 + power);
 
         while(!cli_cmd_interrupt_received(cli)) {
-            osDelay(250);
+            furi_delay_ms(250);
         }
         furi_hal_bt_stop_tone_tx();
 
@@ -69,7 +69,7 @@ static void bt_cli_command_carrier_rx(Cli* cli, string_t args, void* context) {
         furi_hal_bt_start_packet_rx(channel, 1);
 
         while(!cli_cmd_interrupt_received(cli)) {
-            osDelay(250);
+            furi_delay_ms(250);
             printf("RSSI: %6.1f dB\r", (double)furi_hal_bt_get_rssi());
             fflush(stdout);
         }
@@ -119,7 +119,7 @@ static void bt_cli_command_packet_tx(Cli* cli, string_t args, void* context) {
         furi_hal_bt_start_packet_tx(channel, pattern, datarate);
 
         while(!cli_cmd_interrupt_received(cli)) {
-            osDelay(250);
+            furi_delay_ms(250);
         }
         furi_hal_bt_stop_packet_test();
         printf("Transmitted %lu packets", furi_hal_bt_get_transmitted_packets());
@@ -152,7 +152,7 @@ static void bt_cli_command_packet_rx(Cli* cli, string_t args, void* context) {
         furi_hal_bt_start_packet_rx(channel, datarate);
 
         while(!cli_cmd_interrupt_received(cli)) {
-            osDelay(250);
+            furi_delay_ms(250);
             printf("RSSI: %03.1f dB\r", (double)furi_hal_bt_get_rssi());
             fflush(stdout);
         }

+ 7 - 7
applications/bt/bt_debug_app/views/bt_carrier_test.c

@@ -9,7 +9,7 @@ struct BtCarrierTest {
     BtTestMode mode;
     BtTestChannel channel;
     BtTestPower power;
-    osTimerId_t timer;
+    FuriTimer* timer;
 };
 
 static BtTestParamValue bt_param_mode[] = {
@@ -35,10 +35,10 @@ static void bt_carrier_test_start(BtCarrierTest* bt_carrier_test) {
     furi_assert(bt_carrier_test);
     if(bt_carrier_test->mode == BtTestModeRx) {
         furi_hal_bt_start_packet_rx(bt_carrier_test->channel, 1);
-        osTimerStart(bt_carrier_test->timer, osKernelGetTickFreq() / 4);
+        furi_timer_start(bt_carrier_test->timer, furi_kernel_get_tick_frequency() / 4);
     } else if(bt_carrier_test->mode == BtTestModeTxHopping) {
         furi_hal_bt_start_tone_tx(bt_carrier_test->channel, bt_carrier_test->power);
-        osTimerStart(bt_carrier_test->timer, osKernelGetTickFreq() * 2);
+        furi_timer_start(bt_carrier_test->timer, furi_kernel_get_tick_frequency() * 2);
     } else if(bt_carrier_test->mode == BtTestModeTx) {
         furi_hal_bt_start_tone_tx(bt_carrier_test->channel, bt_carrier_test->power);
     }
@@ -68,12 +68,12 @@ static void bt_carrier_test_stop(BtCarrierTest* bt_carrier_test) {
     furi_assert(bt_carrier_test);
     if(bt_carrier_test->mode == BtTestModeTxHopping) {
         furi_hal_bt_stop_tone_tx();
-        osTimerStop(bt_carrier_test->timer);
+        furi_timer_stop(bt_carrier_test->timer);
     } else if(bt_carrier_test->mode == BtTestModeTx) {
         furi_hal_bt_stop_tone_tx();
     } else if(bt_carrier_test->mode == BtTestModeRx) {
         furi_hal_bt_stop_packet_test();
-        osTimerStop(bt_carrier_test->timer);
+        furi_timer_stop(bt_carrier_test->timer);
     }
 }
 
@@ -170,7 +170,7 @@ BtCarrierTest* bt_carrier_test_alloc() {
     bt_carrier_test->power = BtPower0dB;
 
     bt_carrier_test->timer =
-        osTimerNew(bt_test_carrier_timer_callback, osTimerPeriodic, bt_carrier_test, NULL);
+        furi_timer_alloc(bt_test_carrier_timer_callback, FuriTimerTypePeriodic, bt_carrier_test);
 
     return bt_carrier_test;
 }
@@ -178,7 +178,7 @@ BtCarrierTest* bt_carrier_test_alloc() {
 void bt_carrier_test_free(BtCarrierTest* bt_carrier_test) {
     furi_assert(bt_carrier_test);
     bt_test_free(bt_carrier_test->bt_test);
-    osTimerDelete(bt_carrier_test->timer);
+    furi_timer_free(bt_carrier_test->timer);
     free(bt_carrier_test);
 }
 

+ 5 - 5
applications/bt/bt_debug_app/views/bt_packet_test.c

@@ -8,7 +8,7 @@ struct BtPacketTest {
     BtTestMode mode;
     BtTestChannel channel;
     BtTestDataRate data_rate;
-    osTimerId_t timer;
+    FuriTimer* timer;
 };
 
 static BtTestParamValue bt_param_mode[] = {
@@ -31,7 +31,7 @@ static void bt_packet_test_start(BtPacketTest* bt_packet_test) {
     furi_assert(bt_packet_test);
     if(bt_packet_test->mode == BtTestModeRx) {
         furi_hal_bt_start_packet_rx(bt_packet_test->channel, bt_packet_test->data_rate);
-        osTimerStart(bt_packet_test->timer, osKernelGetTickFreq() / 4);
+        furi_timer_start(bt_packet_test->timer, furi_kernel_get_tick_frequency() / 4);
     } else if(bt_packet_test->mode == BtTestModeTx) {
         furi_hal_bt_start_packet_tx(bt_packet_test->channel, 1, bt_packet_test->data_rate);
     }
@@ -44,7 +44,7 @@ static void bt_packet_test_stop(BtPacketTest* bt_packet_test) {
         bt_test_set_packets_tx(bt_packet_test->bt_test, furi_hal_bt_get_transmitted_packets());
     } else if(bt_packet_test->mode == BtTestModeRx) {
         bt_test_set_packets_rx(bt_packet_test->bt_test, furi_hal_bt_stop_packet_test());
-        osTimerStop(bt_packet_test->timer);
+        furi_timer_stop(bt_packet_test->timer);
     }
 }
 
@@ -137,7 +137,7 @@ BtPacketTest* bt_packet_test_alloc() {
     bt_packet_test->data_rate = BtDataRate1M;
 
     bt_packet_test->timer =
-        osTimerNew(bt_test_packet_timer_callback, osTimerPeriodic, bt_packet_test, NULL);
+        furi_timer_alloc(bt_test_packet_timer_callback, FuriTimerTypePeriodic, bt_packet_test);
 
     return bt_packet_test;
 }
@@ -145,7 +145,7 @@ BtPacketTest* bt_packet_test_alloc() {
 void bt_packet_test_free(BtPacketTest* bt_packet_test) {
     furi_assert(bt_packet_test);
     bt_test_free(bt_packet_test->bt_test);
-    osTimerDelete(bt_packet_test->timer);
+    furi_timer_free(bt_packet_test->timer);
     free(bt_packet_test);
 }
 

+ 32 - 23
applications/bt/bt_service/bt.c

@@ -96,12 +96,14 @@ static void bt_battery_level_changed_callback(const void* _event, void* context)
     if(event->type == PowerEventTypeBatteryLevelChanged) {
         message.type = BtMessageTypeUpdateBatteryLevel;
         message.data.battery_level = event->data.battery_level;
-        furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
+        furi_check(
+            furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
     } else if(
         event->type == PowerEventTypeStartCharging || event->type == PowerEventTypeFullyCharged ||
         event->type == PowerEventTypeStopCharging) {
         message.type = BtMessageTypeUpdatePowerState;
-        furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
+        furi_check(
+            furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
     }
 }
 
@@ -115,7 +117,7 @@ Bt* bt_alloc() {
         bt_settings_save(&bt->bt_settings);
     }
     // Alloc queue
-    bt->message_queue = osMessageQueueNew(8, sizeof(BtMessage), NULL);
+    bt->message_queue = furi_message_queue_alloc(8, sizeof(BtMessage));
 
     // Setup statusbar view port
     bt->statusbar_view_port = bt_statusbar_view_port_alloc(bt);
@@ -139,10 +141,10 @@ Bt* bt_alloc() {
 
     // RPC
     bt->rpc = furi_record_open("rpc");
-    bt->rpc_event = osEventFlagsNew(NULL);
+    bt->rpc_event = furi_event_flag_alloc();
 
     // API evnent
-    bt->api_event = osEventFlagsNew(NULL);
+    bt->api_event = furi_event_flag_alloc();
 
     return bt;
 }
@@ -162,7 +164,7 @@ static uint16_t bt_serial_event_callback(SerialServiceEvent event, void* context
         }
         ret = rpc_session_get_available_size(bt->rpc_session);
     } else if(event.event == SerialServiceEventTypeDataSent) {
-        osEventFlagsSet(bt->rpc_event, BT_RPC_EVENT_BUFF_SENT);
+        furi_event_flag_set(bt->rpc_event, BT_RPC_EVENT_BUFF_SENT);
     }
     return ret;
 }
@@ -172,11 +174,11 @@ static void bt_rpc_send_bytes_callback(void* context, uint8_t* bytes, size_t byt
     furi_assert(context);
     Bt* bt = context;
 
-    if(osEventFlagsGet(bt->rpc_event) & BT_RPC_EVENT_DISCONNECTED) {
+    if(furi_event_flag_get(bt->rpc_event) & BT_RPC_EVENT_DISCONNECTED) {
         // Early stop from sending if we're already disconnected
         return;
     }
-    osEventFlagsClear(bt->rpc_event, BT_RPC_EVENT_ALL & (~BT_RPC_EVENT_DISCONNECTED));
+    furi_event_flag_clear(bt->rpc_event, BT_RPC_EVENT_ALL & (~BT_RPC_EVENT_DISCONNECTED));
     size_t bytes_sent = 0;
     while(bytes_sent < bytes_len) {
         size_t bytes_remain = bytes_len - bytes_sent;
@@ -188,13 +190,13 @@ static void bt_rpc_send_bytes_callback(void* context, uint8_t* bytes, size_t byt
             bytes_sent += bytes_remain;
         }
         // We want BT_RPC_EVENT_DISCONNECTED to stick, so don't clear
-        uint32_t event_flag = osEventFlagsWait(
-            bt->rpc_event, BT_RPC_EVENT_ALL, osFlagsWaitAny | osFlagsNoClear, osWaitForever);
+        uint32_t event_flag = furi_event_flag_wait(
+            bt->rpc_event, BT_RPC_EVENT_ALL, FuriFlagWaitAny | FuriFlagNoClear, FuriWaitForever);
         if(event_flag & BT_RPC_EVENT_DISCONNECTED) {
             break;
         } else {
             // If we didn't get BT_RPC_EVENT_DISCONNECTED, then clear everything else
-            osEventFlagsClear(bt->rpc_event, BT_RPC_EVENT_ALL & (~BT_RPC_EVENT_DISCONNECTED));
+            furi_event_flag_clear(bt->rpc_event, BT_RPC_EVENT_ALL & (~BT_RPC_EVENT_DISCONNECTED));
         }
     }
 }
@@ -209,9 +211,10 @@ static bool bt_on_gap_event_callback(GapEvent event, void* context) {
         // Update status bar
         bt->status = BtStatusConnected;
         BtMessage message = {.type = BtMessageTypeUpdateStatus};
-        furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
+        furi_check(
+            furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
         // Clear BT_RPC_EVENT_DISCONNECTED because it might be set from previous session
-        osEventFlagsClear(bt->rpc_event, BT_RPC_EVENT_DISCONNECTED);
+        furi_event_flag_clear(bt->rpc_event, BT_RPC_EVENT_DISCONNECTED);
         if(bt->profile == BtProfileSerial) {
             // Open RPC session
             bt->rpc_session = rpc_session_open(bt->rpc);
@@ -232,12 +235,13 @@ static bool bt_on_gap_event_callback(GapEvent event, void* context) {
         power_get_info(bt->power, &info);
         message.type = BtMessageTypeUpdateBatteryLevel;
         message.data.battery_level = info.charge;
-        furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
+        furi_check(
+            furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
         ret = true;
     } else if(event.type == GapEventTypeDisconnected) {
         if(bt->profile == BtProfileSerial && bt->rpc_session) {
             FURI_LOG_I(TAG, "Close RPC connection");
-            osEventFlagsSet(bt->rpc_event, BT_RPC_EVENT_DISCONNECTED);
+            furi_event_flag_set(bt->rpc_event, BT_RPC_EVENT_DISCONNECTED);
             rpc_session_close(bt->rpc_session);
             furi_hal_bt_serial_set_event_callback(0, NULL, NULL);
             bt->rpc_session = NULL;
@@ -246,17 +250,20 @@ static bool bt_on_gap_event_callback(GapEvent event, void* context) {
     } else if(event.type == GapEventTypeStartAdvertising) {
         bt->status = BtStatusAdvertising;
         BtMessage message = {.type = BtMessageTypeUpdateStatus};
-        furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
+        furi_check(
+            furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
         ret = true;
     } else if(event.type == GapEventTypeStopAdvertising) {
         bt->status = BtStatusOff;
         BtMessage message = {.type = BtMessageTypeUpdateStatus};
-        furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
+        furi_check(
+            furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
         ret = true;
     } else if(event.type == GapEventTypePinCodeShow) {
         BtMessage message = {
             .type = BtMessageTypePinCodeShow, .data.pin_code = event.data.pin_code};
-        furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
+        furi_check(
+            furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
         ret = true;
     } else if(event.type == GapEventTypePinCodeVerify) {
         ret = bt_pin_code_verify_event_handler(bt, event.data.pin_code);
@@ -272,7 +279,8 @@ static void bt_on_key_storage_change_callback(uint8_t* addr, uint16_t size, void
     Bt* bt = context;
     FURI_LOG_I(TAG, "Changed addr start: %08lX, size changed: %d", addr, size);
     BtMessage message = {.type = BtMessageTypeKeysStorageUpdated};
-    furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
+    furi_check(
+        furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
 }
 
 static void bt_statusbar_update(Bt* bt) {
@@ -296,7 +304,7 @@ static void bt_show_warning(Bt* bt, const char* text) {
 static void bt_close_rpc_connection(Bt* bt) {
     if(bt->profile == BtProfileSerial && bt->rpc_session) {
         FURI_LOG_I(TAG, "Close RPC connection");
-        osEventFlagsSet(bt->rpc_event, BT_RPC_EVENT_DISCONNECTED);
+        furi_event_flag_set(bt->rpc_event, BT_RPC_EVENT_DISCONNECTED);
         rpc_session_close(bt->rpc_session);
         furi_hal_bt_serial_set_event_callback(0, NULL, NULL);
         bt->rpc_session = NULL;
@@ -331,12 +339,12 @@ static void bt_change_profile(Bt* bt, BtMessage* message) {
         bt_show_warning(bt, "Radio stack doesn't support this app");
         *message->result = false;
     }
-    osEventFlagsSet(bt->api_event, BT_API_UNLOCK_EVENT);
+    furi_event_flag_set(bt->api_event, BT_API_UNLOCK_EVENT);
 }
 
 static void bt_close_connection(Bt* bt) {
     bt_close_rpc_connection(bt);
-    osEventFlagsSet(bt->api_event, BT_API_UNLOCK_EVENT);
+    furi_event_flag_set(bt->api_event, BT_API_UNLOCK_EVENT);
 }
 
 int32_t bt_srv() {
@@ -377,7 +385,8 @@ int32_t bt_srv() {
 
     BtMessage message;
     while(1) {
-        furi_check(osMessageQueueGet(bt->message_queue, &message, NULL, osWaitForever) == osOK);
+        furi_check(
+            furi_message_queue_get(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
         if(message.type == BtMessageTypeUpdateStatus) {
             // Update view ports
             bt_statusbar_update(bt);

+ 8 - 5
applications/bt/bt_service/bt_api.c

@@ -7,9 +7,10 @@ bool bt_set_profile(Bt* bt, BtProfile profile) {
     bool result = false;
     BtMessage message = {
         .type = BtMessageTypeSetProfile, .data.profile = profile, .result = &result};
-    furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
+    furi_check(
+        furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
     // Wait for unlock
-    osEventFlagsWait(bt->api_event, BT_API_UNLOCK_EVENT, osFlagsWaitAny, osWaitForever);
+    furi_event_flag_wait(bt->api_event, BT_API_UNLOCK_EVENT, FuriFlagWaitAny, FuriWaitForever);
 
     return result;
 }
@@ -19,9 +20,10 @@ void bt_disconnect(Bt* bt) {
 
     // Send message
     BtMessage message = {.type = BtMessageTypeDisconnect};
-    furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
+    furi_check(
+        furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
     // Wait for unlock
-    osEventFlagsWait(bt->api_event, BT_API_UNLOCK_EVENT, osFlagsWaitAny, osWaitForever);
+    furi_event_flag_wait(bt->api_event, BT_API_UNLOCK_EVENT, FuriFlagWaitAny, FuriWaitForever);
 }
 
 void bt_set_status_changed_callback(Bt* bt, BtStatusChangedCallback callback, void* context) {
@@ -34,5 +36,6 @@ void bt_set_status_changed_callback(Bt* bt, BtStatusChangedCallback callback, vo
 void bt_forget_bonded_devices(Bt* bt) {
     furi_assert(bt);
     BtMessage message = {.type = BtMessageTypeForgetBondedDevices};
-    furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
+    furi_check(
+        furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
 }

+ 3 - 3
applications/bt/bt_service/bt_i.h

@@ -48,7 +48,7 @@ struct Bt {
     BtSettings bt_settings;
     BtStatus status;
     BtProfile profile;
-    osMessageQueueId_t message_queue;
+    FuriMessageQueue* message_queue;
     NotificationApp* notification;
     Gui* gui;
     ViewPort* statusbar_view_port;
@@ -59,8 +59,8 @@ struct Bt {
     Power* power;
     Rpc* rpc;
     RpcSession* rpc_session;
-    osEventFlagsId_t rpc_event;
-    osEventFlagsId_t api_event;
+    FuriEventFlag* rpc_event;
+    FuriEventFlag* api_event;
     BtStatusChangedCallback status_changed_cb;
     void* status_changed_ctx;
 };

+ 28 - 26
applications/cli/cli.c

@@ -16,10 +16,10 @@ Cli* cli_alloc() {
 
     cli->session = NULL;
 
-    cli->mutex = osMutexNew(NULL);
+    cli->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
     furi_check(cli->mutex);
 
-    cli->idle_sem = osSemaphoreNew(1, 0, NULL);
+    cli->idle_sem = furi_semaphore_alloc(1, 0);
 
     return cli;
 }
@@ -35,7 +35,7 @@ char cli_getc(Cli* cli) {
     furi_assert(cli);
     char c = 0;
     if(cli->session != NULL) {
-        if(cli->session->rx((uint8_t*)&c, 1, osWaitForever) == 0) {
+        if(cli->session->rx((uint8_t*)&c, 1, FuriWaitForever) == 0) {
             cli_reset(cli);
         }
     } else {
@@ -54,7 +54,7 @@ void cli_write(Cli* cli, const uint8_t* buffer, size_t size) {
 size_t cli_read(Cli* cli, uint8_t* buffer, size_t size) {
     furi_assert(cli);
     if(cli->session != NULL) {
-        return cli->session->rx(buffer, size, osWaitForever);
+        return cli->session->rx(buffer, size, FuriWaitForever);
     } else {
         return 0;
     }
@@ -69,21 +69,23 @@ size_t cli_read_timeout(Cli* cli, uint8_t* buffer, size_t size, uint32_t timeout
     }
 }
 
-bool cli_cmd_interrupt_received(Cli* cli) {
+bool cli_is_connected(Cli* cli) {
     furi_assert(cli);
-    char c = '\0';
     if(cli->session != NULL) {
-        if(cli->session->rx((uint8_t*)&c, 1, 0) == 1) {
-            return c == CliSymbolAsciiETX;
-        }
+        return (cli->session->is_connected());
     }
     return false;
 }
 
-bool cli_is_connected(Cli* cli) {
+bool cli_cmd_interrupt_received(Cli* cli) {
     furi_assert(cli);
-    if(cli->session != NULL) {
-        return (cli->session->is_connected());
+    char c = '\0';
+    if(cli_is_connected(cli)) {
+        if(cli->session->rx((uint8_t*)&c, 1, 0) == 1) {
+            return c == CliSymbolAsciiETX;
+        }
+    } else {
+        return true;
     }
     return false;
 }
@@ -228,17 +230,17 @@ static void cli_handle_enter(Cli* cli) {
     }
 
     // Search for command
-    furi_check(osMutexAcquire(cli->mutex, osWaitForever) == osOK);
+    furi_check(furi_mutex_acquire(cli->mutex, FuriWaitForever) == FuriStatusOk);
     CliCommand* cli_command_ptr = CliCommandTree_get(cli->commands, command);
 
     if(cli_command_ptr) {
         CliCommand cli_command;
         memcpy(&cli_command, cli_command_ptr, sizeof(CliCommand));
-        furi_check(osMutexRelease(cli->mutex) == osOK);
+        furi_check(furi_mutex_release(cli->mutex) == FuriStatusOk);
         cli_nl(cli);
         cli_execute_command(cli, &cli_command, args);
     } else {
-        furi_check(osMutexRelease(cli->mutex) == osOK);
+        furi_check(furi_mutex_release(cli->mutex) == FuriStatusOk);
         cli_nl(cli);
         printf(
             "`%s` command not found, use `help` or `?` to list all available commands",
@@ -339,7 +341,7 @@ void cli_process_input(Cli* cli) {
     if(in_chr == CliSymbolAsciiTab) {
         cli_handle_autocomplete(cli);
     } else if(in_chr == CliSymbolAsciiSOH) {
-        osDelay(33); // We are too fast, Minicom is not ready yet
+        furi_delay_ms(33); // We are too fast, Minicom is not ready yet
         cli_motd();
         cli_prompt(cli);
     } else if(in_chr == CliSymbolAsciiETX) {
@@ -406,9 +408,9 @@ void cli_add_command(
     c.context = context;
     c.flags = flags;
 
-    furi_check(osMutexAcquire(cli->mutex, osWaitForever) == osOK);
+    furi_check(furi_mutex_acquire(cli->mutex, FuriWaitForever) == FuriStatusOk);
     CliCommandTree_set_at(cli->commands, name_str, c);
-    furi_check(osMutexRelease(cli->mutex) == osOK);
+    furi_check(furi_mutex_release(cli->mutex) == FuriStatusOk);
 
     string_clear(name_str);
 }
@@ -423,9 +425,9 @@ void cli_delete_command(Cli* cli, const char* name) {
         name_replace = string_replace_str(name_str, " ", "_");
     } while(name_replace != STRING_FAILURE);
 
-    furi_check(osMutexAcquire(cli->mutex, osWaitForever) == osOK);
+    furi_check(furi_mutex_acquire(cli->mutex, FuriWaitForever) == FuriStatusOk);
     CliCommandTree_erase(cli->commands, name_str);
-    furi_check(osMutexRelease(cli->mutex) == osOK);
+    furi_check(furi_mutex_release(cli->mutex) == FuriStatusOk);
 
     string_clear(name_str);
 }
@@ -433,7 +435,7 @@ void cli_delete_command(Cli* cli, const char* name) {
 void cli_session_open(Cli* cli, void* session) {
     furi_assert(cli);
 
-    furi_check(osMutexAcquire(cli->mutex, osWaitForever) == osOK);
+    furi_check(furi_mutex_acquire(cli->mutex, FuriWaitForever) == FuriStatusOk);
     cli->session = session;
     if(cli->session != NULL) {
         cli->session->init();
@@ -441,20 +443,20 @@ void cli_session_open(Cli* cli, void* session) {
     } else {
         furi_stdglue_set_thread_stdout_callback(NULL);
     }
-    osSemaphoreRelease(cli->idle_sem);
-    furi_check(osMutexRelease(cli->mutex) == osOK);
+    furi_semaphore_release(cli->idle_sem);
+    furi_check(furi_mutex_release(cli->mutex) == FuriStatusOk);
 }
 
 void cli_session_close(Cli* cli) {
     furi_assert(cli);
 
-    furi_check(osMutexAcquire(cli->mutex, osWaitForever) == osOK);
+    furi_check(furi_mutex_acquire(cli->mutex, FuriWaitForever) == FuriStatusOk);
     if(cli->session != NULL) {
         cli->session->deinit();
     }
     cli->session = NULL;
     furi_stdglue_set_thread_stdout_callback(NULL);
-    furi_check(osMutexRelease(cli->mutex) == osOK);
+    furi_check(furi_mutex_release(cli->mutex) == FuriStatusOk);
 }
 
 int32_t cli_srv(void* p) {
@@ -482,7 +484,7 @@ int32_t cli_srv(void* p) {
         if(cli->session != NULL) {
             cli_process_input(cli);
         } else {
-            furi_check(osSemaphoreAcquire(cli->idle_sem, osWaitForever) == osOK);
+            furi_check(furi_semaphore_acquire(cli->idle_sem, FuriWaitForever) == FuriStatusOk);
         }
     }
 

+ 2 - 2
applications/cli/cli_i.h

@@ -41,8 +41,8 @@ BPTREE_DEF2(
 
 struct Cli {
     CliCommandTree_t commands;
-    osMutexId_t mutex;
-    osSemaphoreId_t idle_sem;
+    FuriMutex* mutex;
+    FuriSemaphore* idle_sem;
     string_t last_line;
     string_t line;
     CliSession* session;

+ 8 - 8
applications/cli/cli_vcp.c

@@ -103,8 +103,8 @@ static int32_t vcp_worker(void* context) {
 
     while(1) {
         uint32_t flags =
-            furi_thread_flags_wait(VCP_THREAD_FLAG_ALL, osFlagsWaitAny, osWaitForever);
-        furi_assert((flags & osFlagsError) == 0);
+            furi_thread_flags_wait(VCP_THREAD_FLAG_ALL, FuriFlagWaitAny, FuriWaitForever);
+        furi_assert((flags & FuriFlagError) == 0);
 
         // VCP session opened
         if(flags & VcpEvtConnect) {
@@ -113,7 +113,7 @@ static int32_t vcp_worker(void* context) {
 #endif
             if(vcp->connected == false) {
                 vcp->connected = true;
-                xStreamBufferSend(vcp->rx_stream, &ascii_soh, 1, osWaitForever);
+                xStreamBufferSend(vcp->rx_stream, &ascii_soh, 1, FuriWaitForever);
             }
         }
 
@@ -125,7 +125,7 @@ static int32_t vcp_worker(void* context) {
             if(vcp->connected == true) {
                 vcp->connected = false;
                 xStreamBufferReceive(vcp->tx_stream, vcp->data_buffer, USB_CDC_PKT_LEN, 0);
-                xStreamBufferSend(vcp->rx_stream, &ascii_eot, 1, osWaitForever);
+                xStreamBufferSend(vcp->rx_stream, &ascii_eot, 1, FuriWaitForever);
             }
         }
 
@@ -149,7 +149,7 @@ static int32_t vcp_worker(void* context) {
 #endif
                 if(len > 0) {
                     furi_check(
-                        xStreamBufferSend(vcp->rx_stream, vcp->data_buffer, len, osWaitForever) ==
+                        xStreamBufferSend(vcp->rx_stream, vcp->data_buffer, len, FuriWaitForever) ==
                         (size_t)len);
                 }
             } else {
@@ -203,7 +203,7 @@ static int32_t vcp_worker(void* context) {
                 furi_hal_usb_set_config(vcp->usb_if_prev, NULL);
             }
             xStreamBufferReceive(vcp->tx_stream, vcp->data_buffer, USB_CDC_PKT_LEN, 0);
-            xStreamBufferSend(vcp->rx_stream, &ascii_eot, 1, osWaitForever);
+            xStreamBufferSend(vcp->rx_stream, &ascii_eot, 1, FuriWaitForever);
             break;
         }
     }
@@ -262,7 +262,7 @@ static void cli_vcp_tx(const uint8_t* buffer, size_t size) {
         size_t batch_size = size;
         if(batch_size > USB_CDC_PKT_LEN) batch_size = USB_CDC_PKT_LEN;
 
-        xStreamBufferSend(vcp->tx_stream, buffer, batch_size, osWaitForever);
+        xStreamBufferSend(vcp->tx_stream, buffer, batch_size, FuriWaitForever);
         furi_thread_flags_set(furi_thread_get_id(vcp->thread), VcpEvtStreamTx);
 #ifdef CLI_VCP_DEBUG
         FURI_LOG_D(TAG, "tx %u", batch_size);
@@ -304,7 +304,7 @@ static void vcp_on_cdc_control_line(void* context, uint8_t state) {
 static void vcp_on_cdc_rx(void* context) {
     UNUSED(context);
     uint32_t ret = furi_thread_flags_set(furi_thread_get_id(vcp->thread), VcpEvtRx);
-    furi_check((ret & osFlagsError) == 0);
+    furi_check((ret & FuriFlagError) == 0);
 }
 
 static void vcp_on_cdc_tx_complete(void* context) {

+ 11 - 11
applications/debug_tools/blink_test.c

@@ -1,4 +1,4 @@
-#include "furi/common_defines.h"
+#include <core/common_defines.h>
 #include <furi.h>
 #include <furi_hal.h>
 
@@ -55,10 +55,10 @@ static const NotificationSequence* blink_test_colors[] = {
 
 static void blink_test_update(void* ctx) {
     furi_assert(ctx);
-    osMessageQueueId_t event_queue = ctx;
+    FuriMessageQueue* event_queue = ctx;
     BlinkEvent event = {.type = BlinkEventTypeTick};
     // It's OK to loose this event if system overloaded
-    osMessageQueuePut(event_queue, &event, 0, 0);
+    furi_message_queue_put(event_queue, &event, 0);
 }
 
 static void blink_test_draw_callback(Canvas* canvas, void* ctx) {
@@ -70,22 +70,22 @@ static void blink_test_draw_callback(Canvas* canvas, void* ctx) {
 
 static void blink_test_input_callback(InputEvent* input_event, void* ctx) {
     furi_assert(ctx);
-    osMessageQueueId_t event_queue = ctx;
+    FuriMessageQueue* event_queue = ctx;
 
     BlinkEvent event = {.type = BlinkEventTypeInput, .input = *input_event};
-    osMessageQueuePut(event_queue, &event, 0, osWaitForever);
+    furi_message_queue_put(event_queue, &event, FuriWaitForever);
 }
 
 int32_t blink_test_app(void* p) {
     UNUSED(p);
-    osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(BlinkEvent), NULL);
+    FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(BlinkEvent));
 
     // Configure view port
     ViewPort* view_port = view_port_alloc();
     view_port_draw_callback_set(view_port, blink_test_draw_callback, NULL);
     view_port_input_callback_set(view_port, blink_test_input_callback, event_queue);
-    osTimerId_t timer = osTimerNew(blink_test_update, osTimerPeriodic, event_queue, NULL);
-    osTimerStart(timer, osKernelGetTickFreq());
+    FuriTimer* timer = furi_timer_alloc(blink_test_update, FuriTimerTypePeriodic, event_queue);
+    furi_timer_start(timer, furi_kernel_get_tick_frequency());
 
     // Register view port in GUI
     Gui* gui = furi_record_open("gui");
@@ -97,7 +97,7 @@ int32_t blink_test_app(void* p) {
     BlinkEvent event;
 
     while(1) {
-        furi_check(osMessageQueueGet(event_queue, &event, NULL, osWaitForever) == osOK);
+        furi_check(furi_message_queue_get(event_queue, &event, FuriWaitForever) == FuriStatusOk);
         if(event.type == BlinkEventTypeInput) {
             if((event.input.type == InputTypeShort) && (event.input.key == InputKeyBack)) {
                 break;
@@ -113,11 +113,11 @@ int32_t blink_test_app(void* p) {
 
     notification_message(notifications, &blink_test_sequence_hw_blink_stop);
 
-    osTimerDelete(timer);
+    furi_timer_free(timer);
 
     gui_remove_view_port(gui, view_port);
     view_port_free(view_port);
-    osMessageQueueDelete(event_queue);
+    furi_message_queue_free(event_queue);
 
     furi_record_close("notification");
     furi_record_close("gui");

+ 5 - 5
applications/debug_tools/display_test/view_display_test.c

@@ -9,7 +9,7 @@ typedef struct {
 
 struct ViewDisplayTest {
     View* view;
-    osTimerId_t timer;
+    FuriTimer* timer;
 };
 
 static void view_display_test_draw_callback_intro(Canvas* canvas, void* _model) {
@@ -138,12 +138,12 @@ static bool view_display_test_input_callback(InputEvent* event, void* context) {
 
 static void view_display_test_enter(void* context) {
     ViewDisplayTest* instance = context;
-    osTimerStart(instance->timer, osKernelGetTickFreq() / 32);
+    furi_timer_start(instance->timer, furi_kernel_get_tick_frequency() / 32);
 }
 
 static void view_display_test_exit(void* context) {
     ViewDisplayTest* instance = context;
-    osTimerStop(instance->timer);
+    furi_timer_stop(instance->timer);
 }
 
 static void view_display_test_timer_callback(void* context) {
@@ -167,7 +167,7 @@ ViewDisplayTest* view_display_test_alloc() {
     view_set_exit_callback(instance->view, view_display_test_exit);
 
     instance->timer =
-        osTimerNew(view_display_test_timer_callback, osTimerPeriodic, instance, NULL);
+        furi_timer_alloc(view_display_test_timer_callback, FuriTimerTypePeriodic, instance);
 
     return instance;
 }
@@ -175,7 +175,7 @@ ViewDisplayTest* view_display_test_alloc() {
 void view_display_test_free(ViewDisplayTest* instance) {
     furi_assert(instance);
 
-    osTimerDelete(instance->timer);
+    furi_timer_free(instance->timer);
     view_free(instance->view);
     free(instance);
 }

+ 2 - 2
applications/debug_tools/file_browser_test/scenes/file_browser_scene_browser.c

@@ -1,6 +1,6 @@
 #include "../file_browser_app_i.h"
-#include "furi/check.h"
-#include "furi/log.h"
+#include <core/check.h>
+#include <core/log.h>
 #include "furi_hal.h"
 #include "m-string.h"
 

+ 5 - 5
applications/debug_tools/keypad_test.c

@@ -55,13 +55,13 @@ static void keypad_test_render_callback(Canvas* canvas, void* ctx) {
 }
 
 static void keypad_test_input_callback(InputEvent* input_event, void* ctx) {
-    osMessageQueueId_t event_queue = ctx;
-    osMessageQueuePut(event_queue, input_event, 0, osWaitForever);
+    FuriMessageQueue* event_queue = ctx;
+    furi_message_queue_put(event_queue, input_event, FuriWaitForever);
 }
 
 int32_t keypad_test_app(void* p) {
     UNUSED(p);
-    osMessageQueueId_t event_queue = osMessageQueueNew(32, sizeof(InputEvent), NULL);
+    FuriMessageQueue* event_queue = furi_message_queue_alloc(32, sizeof(InputEvent));
     furi_check(event_queue);
 
     KeypadTestState _state = {{false, false, false, false, false}, 0, 0, 0, 0, 0};
@@ -82,7 +82,7 @@ int32_t keypad_test_app(void* p) {
     gui_add_view_port(gui, view_port, GuiLayerFullscreen);
 
     InputEvent event;
-    while(osMessageQueueGet(event_queue, &event, NULL, osWaitForever) == osOK) {
+    while(furi_message_queue_get(event_queue, &event, FuriWaitForever) == FuriStatusOk) {
         KeypadTestState* state = (KeypadTestState*)acquire_mutex_block(&state_mutex);
         FURI_LOG_I(
             TAG,
@@ -146,7 +146,7 @@ int32_t keypad_test_app(void* p) {
     // remove & free all stuff created by app
     gui_remove_view_port(gui, view_port);
     view_port_free(view_port);
-    osMessageQueueDelete(event_queue);
+    furi_message_queue_free(event_queue);
     delete_mutex(&state_mutex);
 
     furi_record_close("gui");

+ 5 - 5
applications/debug_tools/text_box_test.c

@@ -65,13 +65,13 @@ static void text_box_test_render_callback(Canvas* canvas, void* ctx) {
 }
 
 static void text_box_test_input_callback(InputEvent* input_event, void* ctx) {
-    osMessageQueueId_t event_queue = ctx;
-    osMessageQueuePut(event_queue, input_event, 0, osWaitForever);
+    FuriMessageQueue* event_queue = ctx;
+    furi_message_queue_put(event_queue, input_event, FuriWaitForever);
 }
 
 int32_t text_box_test_app(void* p) {
     UNUSED(p);
-    osMessageQueueId_t event_queue = osMessageQueueNew(32, sizeof(InputEvent), NULL);
+    FuriMessageQueue* event_queue = furi_message_queue_alloc(32, sizeof(InputEvent));
     furi_check(event_queue);
 
     TextBoxTestState _state = {.idx = 0};
@@ -93,7 +93,7 @@ int32_t text_box_test_app(void* p) {
 
     uint32_t test_renders_num = COUNT_OF(text_box_test_render);
     InputEvent event;
-    while(osMessageQueueGet(event_queue, &event, NULL, osWaitForever) == osOK) {
+    while(furi_message_queue_get(event_queue, &event, FuriWaitForever) == FuriStatusOk) {
         TextBoxTestState* state = acquire_mutex_block(&state_mutex);
 
         if(event.type == InputTypeShort) {
@@ -118,7 +118,7 @@ int32_t text_box_test_app(void* p) {
     // remove & free all stuff created by app
     gui_remove_view_port(gui, view_port);
     view_port_free(view_port);
-    osMessageQueueDelete(event_queue);
+    furi_message_queue_free(event_queue);
     delete_mutex(&state_mutex);
 
     furi_record_close("gui");

+ 2 - 2
applications/debug_tools/uart_echo.c

@@ -150,8 +150,8 @@ static int32_t uart_echo_worker(void* context) {
 
     while(1) {
         uint32_t events =
-            furi_thread_flags_wait(WORKER_EVENTS_MASK, osFlagsWaitAny, osWaitForever);
-        furi_check((events & osFlagsError) == 0);
+            furi_thread_flags_wait(WORKER_EVENTS_MASK, FuriFlagWaitAny, FuriWaitForever);
+        furi_check((events & FuriFlagError) == 0);
 
         if(events & WorkerEventStop) break;
         if(events & WorkerEventRx) {

+ 6 - 6
applications/debug_tools/usb_mouse.c

@@ -29,17 +29,17 @@ static void usb_mouse_render_callback(Canvas* canvas, void* ctx) {
 }
 
 static void usb_mouse_input_callback(InputEvent* input_event, void* ctx) {
-    osMessageQueueId_t event_queue = ctx;
+    FuriMessageQueue* event_queue = ctx;
 
     UsbMouseEvent event;
     event.type = EventTypeInput;
     event.input = *input_event;
-    osMessageQueuePut(event_queue, &event, 0, osWaitForever);
+    furi_message_queue_put(event_queue, &event, FuriWaitForever);
 }
 
 int32_t usb_mouse_app(void* p) {
     UNUSED(p);
-    osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(UsbMouseEvent), NULL);
+    FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(UsbMouseEvent));
     furi_check(event_queue);
     ViewPort* view_port = view_port_alloc();
 
@@ -56,9 +56,9 @@ int32_t usb_mouse_app(void* p) {
 
     UsbMouseEvent event;
     while(1) {
-        osStatus_t event_status = osMessageQueueGet(event_queue, &event, NULL, osWaitForever);
+        FuriStatus event_status = furi_message_queue_get(event_queue, &event, FuriWaitForever);
 
-        if(event_status == osOK) {
+        if(event_status == FuriStatusOk) {
             if(event.type == EventTypeInput) {
                 if(event.input.type == InputTypeLong && event.input.key == InputKeyBack) {
                     break;
@@ -118,7 +118,7 @@ int32_t usb_mouse_app(void* p) {
     // remove & free all stuff created by app
     gui_remove_view_port(gui, view_port);
     view_port_free(view_port);
-    osMessageQueueDelete(event_queue);
+    furi_message_queue_free(event_queue);
 
     return 0;
 }

+ 5 - 5
applications/debug_tools/vibro_test.c

@@ -18,13 +18,13 @@ void vibro_test_draw_callback(Canvas* canvas, void* ctx) {
 
 void vibro_test_input_callback(InputEvent* input_event, void* ctx) {
     furi_assert(ctx);
-    osMessageQueueId_t event_queue = ctx;
-    osMessageQueuePut(event_queue, input_event, 0, osWaitForever);
+    FuriMessageQueue* event_queue = ctx;
+    furi_message_queue_put(event_queue, input_event, FuriWaitForever);
 }
 
 int32_t vibro_test_app(void* p) {
     UNUSED(p);
-    osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL);
+    FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
 
     // Configure view port
     ViewPort* view_port = view_port_alloc();
@@ -39,7 +39,7 @@ int32_t vibro_test_app(void* p) {
 
     InputEvent event;
 
-    while(osMessageQueueGet(event_queue, &event, NULL, osWaitForever) == osOK) {
+    while(furi_message_queue_get(event_queue, &event, FuriWaitForever) == FuriStatusOk) {
         if(event.type == InputTypeShort && event.key == InputKeyBack) {
             notification_message(notification, &sequence_reset_vibro);
             notification_message(notification, &sequence_reset_green);
@@ -58,7 +58,7 @@ int32_t vibro_test_app(void* p) {
 
     gui_remove_view_port(gui, view_port);
     view_port_free(view_port);
-    osMessageQueueDelete(event_queue);
+    furi_message_queue_free(event_queue);
 
     furi_record_close("notification");
     furi_record_close("gui");

+ 8 - 8
applications/desktop/animations/animation_manager.c

@@ -44,7 +44,7 @@ struct AnimationManager {
     FuriPubSubSubscription* pubsub_subscription_dolphin;
     BubbleAnimationView* animation_view;
     OneShotView* one_shot_view;
-    osTimerId_t idle_animation_timer;
+    FuriTimer* idle_animation_timer;
     StorageAnimation* current_animation;
     AnimationManagerInteractCallback interact_callback;
     AnimationManagerSetNewIdleAnimationCallback new_idle_callback;
@@ -198,7 +198,7 @@ static void animation_manager_start_new_idle(AnimationManager* animation_manager
     const BubbleAnimation* bubble_animation =
         animation_storage_get_bubble_animation(animation_manager->current_animation);
     animation_manager->state = AnimationManagerStateIdle;
-    osTimerStart(animation_manager->idle_animation_timer, bubble_animation->duration * 1000);
+    furi_timer_start(animation_manager->idle_animation_timer, bubble_animation->duration * 1000);
 }
 
 static bool animation_manager_check_blocking(AnimationManager* animation_manager) {
@@ -246,7 +246,7 @@ static bool animation_manager_check_blocking(AnimationManager* animation_manager
     }
 
     if(blocking_animation) {
-        osTimerStop(animation_manager->idle_animation_timer);
+        furi_timer_stop(animation_manager->idle_animation_timer);
         animation_manager_replace_current_animation(animation_manager, blocking_animation);
         /* no timer starting because this is blocking animation */
         animation_manager->state = AnimationManagerStateBlocked;
@@ -283,7 +283,7 @@ AnimationManager* animation_manager_alloc(void) {
     string_init(animation_manager->freezed_animation_name);
 
     animation_manager->idle_animation_timer =
-        osTimerNew(animation_manager_timer_callback, osTimerOnce, animation_manager, NULL);
+        furi_timer_alloc(animation_manager_timer_callback, FuriTimerTypeOnce, animation_manager);
     bubble_animation_view_set_interact_callback(
         animation_manager->animation_view, animation_manager_interact_callback, animation_manager);
 
@@ -322,7 +322,7 @@ void animation_manager_free(AnimationManager* animation_manager) {
     View* animation_view = bubble_animation_get_view(animation_manager->animation_view);
     view_stack_remove_view(animation_manager->view_stack, animation_view);
     bubble_animation_view_free(animation_manager->animation_view);
-    osTimerDelete(animation_manager->idle_animation_timer);
+    furi_timer_free(animation_manager->idle_animation_timer);
 }
 
 View* animation_manager_get_animation_view(AnimationManager* animation_manager) {
@@ -449,7 +449,7 @@ void animation_manager_unload_and_stall_animation(AnimationManager* animation_ma
         if(animation_manager->freezed_animation_time_left < 0) {
             animation_manager->freezed_animation_time_left = 0;
         }
-        osTimerStop(animation_manager->idle_animation_timer);
+        furi_timer_stop(animation_manager->idle_animation_timer);
     } else {
         furi_assert(0);
     }
@@ -504,13 +504,13 @@ void animation_manager_load_and_continue_animation(AnimationManager* animation_m
                     animation_manager->state = AnimationManagerStateIdle;
 
                     if(animation_manager->freezed_animation_time_left) {
-                        osTimerStart(
+                        furi_timer_start(
                             animation_manager->idle_animation_timer,
                             animation_manager->freezed_animation_time_left);
                     } else {
                         const BubbleAnimation* animation = animation_storage_get_bubble_animation(
                             animation_manager->current_animation);
-                        osTimerStart(
+                        furi_timer_start(
                             animation_manager->idle_animation_timer, animation->duration * 1000);
                     }
                 }

+ 1 - 1
applications/desktop/animations/animation_storage.c

@@ -2,7 +2,7 @@
 #include <stdint.h>
 #include <flipper_format/flipper_format.h>
 #include <furi.h>
-#include <furi/dangerous_defines.h>
+#include <core/dangerous_defines.h>
 #include <storage/storage.h>
 #include <gui/icon_i.h>
 #include <m-string.h>

+ 9 - 11
applications/desktop/animations/views/bubble_animation_view.c

@@ -11,9 +11,7 @@
 #include <gui/icon_i.h>
 #include <input/input.h>
 #include <stdint.h>
-#include <FreeRTOS.h>
-#include <timers.h>
-#include <furi/dangerous_defines.h>
+#include <core/dangerous_defines.h>
 
 #define ACTIVE_SHIFT 2
 
@@ -31,7 +29,7 @@ typedef struct {
 
 struct BubbleAnimationView {
     View* view;
-    osTimerId_t timer;
+    FuriTimer* timer;
     BubbleAnimationInteractCallback interact_callback;
     void* interact_callback_context;
 };
@@ -192,7 +190,7 @@ static void bubble_animation_activate_right_now(BubbleAnimationView* view) {
     view_commit_model(view->view, true);
 
     if(frame_rate) {
-        osTimerStart(view->timer, 1000 / frame_rate);
+        furi_timer_start(view->timer, 1000 / frame_rate);
     }
 }
 
@@ -294,21 +292,21 @@ static void bubble_animation_enter(void* context) {
     view_commit_model(view->view, false);
 
     if(frame_rate) {
-        osTimerStart(view->timer, 1000 / frame_rate);
+        furi_timer_start(view->timer, 1000 / frame_rate);
     }
 }
 
 static void bubble_animation_exit(void* context) {
     furi_assert(context);
     BubbleAnimationView* view = context;
-    osTimerStop(view->timer);
+    furi_timer_stop(view->timer);
 }
 
 BubbleAnimationView* bubble_animation_view_alloc(void) {
     BubbleAnimationView* view = malloc(sizeof(BubbleAnimationView));
     view->view = view_alloc();
     view->interact_callback = NULL;
-    view->timer = osTimerNew(bubble_animation_timer_callback, osTimerPeriodic, view, NULL);
+    view->timer = furi_timer_alloc(bubble_animation_timer_callback, FuriTimerTypePeriodic, view);
 
     view_allocate_model(view->view, ViewModelTypeLocking, sizeof(BubbleAnimationViewModel));
     view_set_context(view->view, view);
@@ -369,7 +367,7 @@ void bubble_animation_view_set_animation(
     model->active_cycle = 0;
     view_commit_model(view->view, true);
 
-    osTimerStart(view->timer, 1000 / new_animation->icon_animation.frame_rate);
+    furi_timer_start(view->timer, 1000 / new_animation->icon_animation.frame_rate);
 }
 
 void bubble_animation_freeze(BubbleAnimationView* view) {
@@ -381,7 +379,7 @@ void bubble_animation_freeze(BubbleAnimationView* view) {
     model->freeze_frame = bubble_animation_clone_first_frame(&model->current->icon_animation);
     model->current = NULL;
     view_commit_model(view->view, false);
-    osTimerStop(view->timer);
+    furi_timer_stop(view->timer);
 }
 
 void bubble_animation_unfreeze(BubbleAnimationView* view) {
@@ -395,7 +393,7 @@ void bubble_animation_unfreeze(BubbleAnimationView* view) {
     frame_rate = model->current->icon_animation.frame_rate;
     view_commit_model(view->view, true);
 
-    osTimerStart(view->timer, 1000 / frame_rate);
+    furi_timer_start(view->timer, 1000 / frame_rate);
     bubble_animation_activate(view, false);
 }
 

+ 5 - 5
applications/desktop/desktop.c

@@ -93,12 +93,12 @@ static void desktop_auto_lock_timer_callback(void* context) {
 }
 
 static void desktop_start_auto_lock_timer(Desktop* desktop) {
-    osTimerStart(
-        desktop->auto_lock_timer, furi_hal_ms_to_ticks(desktop->settings.auto_lock_delay_ms));
+    furi_timer_start(
+        desktop->auto_lock_timer, furi_ms_to_ticks(desktop->settings.auto_lock_delay_ms));
 }
 
 static void desktop_stop_auto_lock_timer(Desktop* desktop) {
-    osTimerStop(desktop->auto_lock_timer);
+    furi_timer_stop(desktop->auto_lock_timer);
 }
 
 static void desktop_auto_lock_arm(Desktop* desktop) {
@@ -232,7 +232,7 @@ Desktop* desktop_alloc() {
     desktop->input_events_subscription = NULL;
 
     desktop->auto_lock_timer =
-        osTimerNew(desktop_auto_lock_timer_callback, osTimerOnce, desktop, NULL);
+        furi_timer_alloc(desktop_auto_lock_timer_callback, FuriTimerTypeOnce, desktop);
 
     return desktop;
 }
@@ -283,7 +283,7 @@ void desktop_free(Desktop* desktop) {
 
     furi_record_close("menu");
 
-    osTimerDelete(desktop->auto_lock_timer);
+    furi_timer_free(desktop->auto_lock_timer);
 
     free(desktop);
 }

+ 1 - 1
applications/desktop/desktop_i.h

@@ -67,7 +67,7 @@ struct Desktop {
     FuriPubSubSubscription* app_start_stop_subscription;
     FuriPubSub* input_events_pubsub;
     FuriPubSubSubscription* input_events_subscription;
-    osTimerId_t auto_lock_timer;
+    FuriTimer* auto_lock_timer;
 };
 
 Desktop* desktop_alloc();

+ 1 - 1
applications/desktop/desktop_settings/scenes/desktop_settings_scene_pin_auth.c

@@ -1,5 +1,5 @@
 #include <stdint.h>
-#include <furi/check.h>
+#include <core/check.h>
 #include <gui/scene_manager.h>
 #include "../../helpers/pin_lock.h"
 #include "../desktop_settings_app.h"

+ 1 - 1
applications/desktop/desktop_settings/scenes/desktop_settings_scene_pin_disable.c

@@ -1,5 +1,5 @@
 #include <stdint.h>
-#include <furi/check.h>
+#include <core/check.h>
 #include <gui/scene_manager.h>
 #include <gui/modules/popup.h>
 

+ 1 - 1
applications/desktop/desktop_settings/scenes/desktop_settings_scene_pin_error.c

@@ -1,5 +1,5 @@
 #include <stdint.h>
-#include <furi/check.h>
+#include <core/check.h>
 #include <gui/scene_manager.h>
 
 #include "desktop/desktop_settings/desktop_settings.h"

+ 1 - 1
applications/desktop/desktop_settings/scenes/desktop_settings_scene_pin_setup.c

@@ -1,5 +1,5 @@
 #include <stdint.h>
-#include <furi/check.h>
+#include <core/check.h>
 #include <gui/scene_manager.h>
 
 #include "../desktop_settings_app.h"

+ 2 - 2
applications/desktop/helpers/slideshow.c

@@ -4,7 +4,7 @@
 #include <storage/storage.h>
 #include <gui/icon.h>
 #include <gui/icon_i.h>
-#include <furi/dangerous_defines.h>
+#include <core/dangerous_defines.h>
 
 #define SLIDESHOW_MAGIC 0x72676468
 #define SLIDESHOW_MAX_SUPPORTED_VERSION 1
@@ -118,4 +118,4 @@ void slideshow_draw(Slideshow* slideshow, Canvas* canvas, uint8_t x, uint8_t y)
         slideshow->icon.width,
         slideshow->icon.height,
         slideshow->icon.frames[slideshow->current_frame]);
-}
+}

+ 1 - 1
applications/desktop/scenes/desktop_scene_pin_input.c

@@ -150,7 +150,7 @@ void desktop_scene_pin_input_on_exit(void* context) {
         desktop->scene_manager, DesktopScenePinInput);
     xTimerStop(state->timer, portMAX_DELAY);
     while(xTimerIsTimerActive(state->timer)) {
-        furi_hal_delay_ms(1);
+        furi_delay_tick(1);
     }
     xTimerDelete(state->timer, portMAX_DELAY);
     free(state);

+ 1 - 1
applications/desktop/views/desktop_view_locked.c

@@ -206,7 +206,7 @@ DesktopViewLocked* desktop_view_locked_alloc() {
 
 void desktop_view_locked_free(DesktopViewLocked* locked_view) {
     furi_assert(locked_view);
-    osTimerDelete(locked_view->timer);
+    furi_timer_free(locked_view->timer);
     view_free(locked_view->view);
     free(locked_view);
 }

+ 1 - 1
applications/desktop/views/desktop_view_main.c

@@ -99,6 +99,6 @@ DesktopMainView* desktop_main_alloc() {
 void desktop_main_free(DesktopMainView* main_view) {
     furi_assert(main_view);
     view_free(main_view->view);
-    osTimerDelete(main_view->poweroff_timer);
+    furi_timer_free(main_view->poweroff_timer);
     free(main_view);
 }

+ 1 - 1
applications/desktop/views/desktop_view_pin_input.c

@@ -214,7 +214,7 @@ void desktop_view_pin_input_free(DesktopViewPinInput* pin_input) {
 
     xTimerStop(pin_input->timer, portMAX_DELAY);
     while(xTimerIsTimerActive(pin_input->timer)) {
-        furi_hal_delay_ms(1);
+        furi_delay_tick(1);
     }
     xTimerDelete(pin_input->timer, portMAX_DELAY);
 

+ 2 - 2
applications/dialogs/dialogs.c

@@ -6,7 +6,7 @@
 
 static DialogsApp* dialogs_app_alloc() {
     DialogsApp* app = malloc(sizeof(DialogsApp));
-    app->message_queue = osMessageQueueNew(8, sizeof(DialogsAppMessage), NULL);
+    app->message_queue = furi_message_queue_alloc(8, sizeof(DialogsAppMessage));
 
     return app;
 }
@@ -33,7 +33,7 @@ int32_t dialogs_srv(void* p) {
 
     DialogsAppMessage message;
     while(1) {
-        if(osMessageQueueGet(app->message_queue, &message, NULL, osWaitForever) == osOK) {
+        if(furi_message_queue_get(app->message_queue, &message, FuriWaitForever) == FuriStatusOk) {
             dialogs_app_process_message(app, &message);
         }
     }

+ 4 - 2
applications/dialogs/dialogs_api.c

@@ -35,7 +35,8 @@ bool dialog_file_browser_show(
         .return_data = &return_data,
     };
 
-    furi_check(osMessageQueuePut(context->message_queue, &message, 0, osWaitForever) == osOK);
+    furi_check(
+        furi_message_queue_put(context->message_queue, &message, FuriWaitForever) == FuriStatusOk);
     API_LOCK_WAIT_UNTIL_UNLOCK_AND_FREE(lock);
 
     return return_data.bool_value;
@@ -60,7 +61,8 @@ DialogMessageButton dialog_message_show(DialogsApp* context, const DialogMessage
         .return_data = &return_data,
     };
 
-    furi_check(osMessageQueuePut(context->message_queue, &message, 0, osWaitForever) == osOK);
+    furi_check(
+        furi_message_queue_put(context->message_queue, &message, FuriWaitForever) == FuriStatusOk);
     API_LOCK_WAIT_UNTIL_UNLOCK_AND_FREE(lock);
 
     return return_data.dialog_value;

+ 5 - 5
applications/dialogs/dialogs_api_lock.h

@@ -1,17 +1,17 @@
 #pragma once
 
-typedef osEventFlagsId_t FuriApiLock;
+typedef FuriEventFlag* FuriApiLock;
 
 #define API_LOCK_EVENT (1U << 0)
 
-#define API_LOCK_INIT_LOCKED() osEventFlagsNew(NULL);
+#define API_LOCK_INIT_LOCKED() furi_event_flag_alloc();
 
 #define API_LOCK_WAIT_UNTIL_UNLOCK(_lock) \
-    osEventFlagsWait(_lock, API_LOCK_EVENT, osFlagsWaitAny, osWaitForever);
+    furi_event_flag_wait(_lock, API_LOCK_EVENT, FuriFlagWaitAny, FuriWaitForever);
 
-#define API_LOCK_FREE(_lock) osEventFlagsDelete(_lock);
+#define API_LOCK_FREE(_lock) furi_event_flag_free(_lock);
 
-#define API_LOCK_UNLOCK(_lock) osEventFlagsSet(_lock, API_LOCK_EVENT);
+#define API_LOCK_UNLOCK(_lock) furi_event_flag_set(_lock, API_LOCK_EVENT);
 
 #define API_LOCK_WAIT_UNTIL_UNLOCK_AND_FREE(_lock) \
     API_LOCK_WAIT_UNTIL_UNLOCK(_lock);             \

+ 1 - 1
applications/dialogs/dialogs_i.h

@@ -7,7 +7,7 @@
 extern "C" {
 #endif
 struct DialogsApp {
-    osMessageQueueId_t message_queue;
+    FuriMessageQueue* message_queue;
 };
 
 #ifdef __cplusplus

+ 1 - 1
applications/dialogs/view_holder.c

@@ -96,7 +96,7 @@ void view_holder_start(ViewHolder* view_holder) {
 }
 
 void view_holder_stop(ViewHolder* view_holder) {
-    while(view_holder->ongoing_input) osDelay(1);
+    while(view_holder->ongoing_input) furi_delay_tick(1);
     view_port_enabled_set(view_holder->view_port, false);
 }
 

+ 13 - 9
applications/dolphin/dolphin.c

@@ -77,7 +77,7 @@ Dolphin* dolphin_alloc() {
     Dolphin* dolphin = malloc(sizeof(Dolphin));
 
     dolphin->state = dolphin_state_alloc();
-    dolphin->event_queue = osMessageQueueNew(8, sizeof(DolphinEvent), NULL);
+    dolphin->event_queue = furi_message_queue_alloc(8, sizeof(DolphinEvent));
     dolphin->pubsub = furi_pubsub_alloc();
     dolphin->butthurt_timer = xTimerCreate(
         NULL, HOURS_IN_TICKS(2 * 24), pdTRUE, dolphin, dolphin_butthurt_timer_callback);
@@ -93,7 +93,7 @@ void dolphin_free(Dolphin* dolphin) {
     furi_assert(dolphin);
 
     dolphin_state_free(dolphin->state);
-    osMessageQueueDelete(dolphin->event_queue);
+    furi_message_queue_free(dolphin->event_queue);
 
     free(dolphin);
 }
@@ -102,25 +102,28 @@ void dolphin_event_send_async(Dolphin* dolphin, DolphinEvent* event) {
     furi_assert(dolphin);
     furi_assert(event);
     event->flag = NULL;
-    furi_check(osMessageQueuePut(dolphin->event_queue, event, 0, osWaitForever) == osOK);
+    furi_check(
+        furi_message_queue_put(dolphin->event_queue, event, FuriWaitForever) == FuriStatusOk);
 }
 
 void dolphin_event_send_wait(Dolphin* dolphin, DolphinEvent* event) {
     furi_assert(dolphin);
     furi_assert(event);
-    event->flag = osEventFlagsNew(NULL);
+    event->flag = furi_event_flag_alloc();
     furi_check(event->flag);
-    furi_check(osMessageQueuePut(dolphin->event_queue, event, 0, osWaitForever) == osOK);
     furi_check(
-        osEventFlagsWait(event->flag, DOLPHIN_LOCK_EVENT_FLAG, osFlagsWaitAny, osWaitForever) ==
+        furi_message_queue_put(dolphin->event_queue, event, FuriWaitForever) == FuriStatusOk);
+    furi_check(
+        furi_event_flag_wait(
+            event->flag, DOLPHIN_LOCK_EVENT_FLAG, FuriFlagWaitAny, FuriWaitForever) ==
         DOLPHIN_LOCK_EVENT_FLAG);
-    furi_check(osEventFlagsDelete(event->flag) == osOK);
+    furi_event_flag_free(event->flag);
 }
 
 void dolphin_event_release(Dolphin* dolphin, DolphinEvent* event) {
     UNUSED(dolphin);
     if(event->flag) {
-        osEventFlagsSet(event->flag, DOLPHIN_LOCK_EVENT_FLAG);
+        furi_event_flag_set(event->flag, DOLPHIN_LOCK_EVENT_FLAG);
     }
 }
 
@@ -161,7 +164,8 @@ int32_t dolphin_srv(void* p) {
 
     DolphinEvent event;
     while(1) {
-        if(osMessageQueueGet(dolphin->event_queue, &event, NULL, HOURS_IN_TICKS(1)) == osOK) {
+        if(furi_message_queue_get(dolphin->event_queue, &event, HOURS_IN_TICKS(1)) ==
+           FuriStatusOk) {
             if(event.type == DolphinEventTypeDeed) {
                 dolphin_state_on_deed(dolphin->state, event.deed);
                 DolphinPubsubEvent event = DolphinPubsubEventUpdate;

+ 1 - 1
applications/dolphin/dolphin.h

@@ -1,6 +1,6 @@
 #pragma once
 
-#include "furi/pubsub.h"
+#include <core/pubsub.h>
 #include "gui/view.h"
 #include "helpers/dolphin_deed.h"
 #include <stdbool.h>

+ 3 - 3
applications/dolphin/dolphin_i.h

@@ -1,6 +1,6 @@
 #pragma once
 
-#include "furi/pubsub.h"
+#include <core/pubsub.h>
 #include <furi.h>
 #include <furi_hal.h>
 
@@ -17,7 +17,7 @@ typedef enum {
 
 typedef struct {
     DolphinEventType type;
-    osEventFlagsId_t flag;
+    FuriEventFlag* flag;
     union {
         DolphinDeed deed;
         DolphinStats* stats;
@@ -28,7 +28,7 @@ struct Dolphin {
     // State
     DolphinState* state;
     // Queue
-    osMessageQueueId_t event_queue;
+    FuriMessageQueue* event_queue;
     FuriPubSub* pubsub;
     TimerHandle_t butthurt_timer;
     TimerHandle_t flush_timer;

+ 7 - 8
applications/dolphin/passport/passport.c

@@ -1,8 +1,7 @@
 #include "assets_icons.h"
-#include "cmsis_os2.h"
 #include "dolphin/helpers/dolphin_state.h"
-#include "furi/check.h"
-#include "furi/record.h"
+#include <core/check.h>
+#include <core/record.h>
 #include <furi.h>
 #include <gui/gui.h>
 #include <furi_hal_version.h>
@@ -28,10 +27,10 @@ static const Icon* const portrait_bad[BUTTHURT_MAX] = {
 static const Icon* const* portraits[MOODS_TOTAL] = {portrait_happy, portrait_ok, portrait_bad};
 
 static void input_callback(InputEvent* input, void* ctx) {
-    osSemaphoreId_t semaphore = ctx;
+    FuriSemaphore* semaphore = ctx;
 
     if((input->type == InputTypeShort) && (input->key == InputKeyBack)) {
-        osSemaphoreRelease(semaphore);
+        furi_semaphore_release(semaphore);
     }
 }
 
@@ -91,7 +90,7 @@ static void render_callback(Canvas* canvas, void* ctx) {
 
 int32_t passport_app(void* p) {
     UNUSED(p);
-    osSemaphoreId_t semaphore = osSemaphoreNew(1, 0, NULL);
+    FuriSemaphore* semaphore = furi_semaphore_alloc(1, 0);
     furi_assert(semaphore);
 
     ViewPort* view_port = view_port_alloc();
@@ -105,12 +104,12 @@ int32_t passport_app(void* p) {
     gui_add_view_port(gui, view_port, GuiLayerFullscreen);
     view_port_update(view_port);
 
-    furi_check(osSemaphoreAcquire(semaphore, osWaitForever) == osOK);
+    furi_check(furi_semaphore_acquire(semaphore, FuriWaitForever) == FuriStatusOk);
 
     gui_remove_view_port(gui, view_port);
     view_port_free(view_port);
     furi_record_close("gui");
-    osSemaphoreDelete(semaphore);
+    furi_semaphore_free(semaphore);
 
     return 0;
 }

+ 17 - 16
applications/gpio/usb_uart_bridge.c

@@ -45,9 +45,9 @@ struct UsbUartBridge {
 
     StreamBufferHandle_t rx_stream;
 
-    osMutexId_t usb_mutex;
+    FuriMutex* usb_mutex;
 
-    osSemaphoreId_t tx_sem;
+    FuriSemaphore* tx_sem;
 
     UsbUartState st;
 
@@ -158,8 +158,8 @@ static int32_t usb_uart_worker(void* context) {
 
     usb_uart->rx_stream = xStreamBufferCreate(USB_UART_RX_BUF_SIZE, 1);
 
-    usb_uart->tx_sem = osSemaphoreNew(1, 1, NULL);
-    usb_uart->usb_mutex = osMutexNew(NULL);
+    usb_uart->tx_sem = furi_semaphore_alloc(1, 1);
+    usb_uart->usb_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
 
     usb_uart->tx_thread = furi_thread_alloc();
     furi_thread_set_name(usb_uart->tx_thread, "UsbUartTxWorker");
@@ -185,18 +185,19 @@ static int32_t usb_uart_worker(void* context) {
 
     while(1) {
         uint32_t events =
-            furi_thread_flags_wait(WORKER_ALL_RX_EVENTS, osFlagsWaitAny, osWaitForever);
-        furi_check((events & osFlagsError) == 0);
+            furi_thread_flags_wait(WORKER_ALL_RX_EVENTS, FuriFlagWaitAny, FuriWaitForever);
+        furi_check((events & FuriFlagError) == 0);
         if(events & WorkerEvtStop) break;
         if(events & WorkerEvtRxDone) {
             size_t len =
                 xStreamBufferReceive(usb_uart->rx_stream, usb_uart->rx_buf, USB_CDC_PKT_LEN, 0);
             if(len > 0) {
-                if(osSemaphoreAcquire(usb_uart->tx_sem, 100) == osOK) {
+                if(furi_semaphore_acquire(usb_uart->tx_sem, 100) == FuriStatusOk) {
                     usb_uart->st.rx_cnt += len;
-                    furi_check(osMutexAcquire(usb_uart->usb_mutex, osWaitForever) == osOK);
+                    furi_check(
+                        furi_mutex_acquire(usb_uart->usb_mutex, FuriWaitForever) == FuriStatusOk);
                     furi_hal_cdc_send(usb_uart->cfg.vcp_ch, usb_uart->rx_buf, len);
-                    furi_check(osMutexRelease(usb_uart->usb_mutex) == osOK);
+                    furi_check(furi_mutex_release(usb_uart->usb_mutex) == FuriStatusOk);
                 } else {
                     xStreamBufferReset(usb_uart->rx_stream);
                 }
@@ -270,8 +271,8 @@ static int32_t usb_uart_worker(void* context) {
     furi_thread_free(usb_uart->tx_thread);
 
     vStreamBufferDelete(usb_uart->rx_stream);
-    osMutexDelete(usb_uart->usb_mutex);
-    osSemaphoreDelete(usb_uart->tx_sem);
+    furi_mutex_free(usb_uart->usb_mutex);
+    furi_semaphore_free(usb_uart->tx_sem);
 
     furi_hal_usb_unlock();
     furi_check(furi_hal_usb_set_config(&usb_cdc_single, NULL) == true);
@@ -288,13 +289,13 @@ static int32_t usb_uart_tx_thread(void* context) {
     uint8_t data[USB_CDC_PKT_LEN];
     while(1) {
         uint32_t events =
-            furi_thread_flags_wait(WORKER_ALL_TX_EVENTS, osFlagsWaitAny, osWaitForever);
-        furi_check((events & osFlagsError) == 0);
+            furi_thread_flags_wait(WORKER_ALL_TX_EVENTS, FuriFlagWaitAny, FuriWaitForever);
+        furi_check((events & FuriFlagError) == 0);
         if(events & WorkerEvtTxStop) break;
         if(events & WorkerEvtCdcRx) {
-            furi_check(osMutexAcquire(usb_uart->usb_mutex, osWaitForever) == osOK);
+            furi_check(furi_mutex_acquire(usb_uart->usb_mutex, FuriWaitForever) == FuriStatusOk);
             size_t len = furi_hal_cdc_receive(usb_uart->cfg.vcp_ch, data, USB_CDC_PKT_LEN);
-            furi_check(osMutexRelease(usb_uart->usb_mutex) == osOK);
+            furi_check(furi_mutex_release(usb_uart->usb_mutex) == FuriStatusOk);
 
             if(len > 0) {
                 usb_uart->st.tx_cnt += len;
@@ -309,7 +310,7 @@ static int32_t usb_uart_tx_thread(void* context) {
 
 static void vcp_on_cdc_tx_complete(void* context) {
     UsbUartBridge* usb_uart = (UsbUartBridge*)context;
-    osSemaphoreRelease(usb_uart->tx_sem);
+    furi_semaphore_release(usb_uart->tx_sem);
 }
 
 static void vcp_on_cdc_rx(void* context) {

+ 7 - 7
applications/gui/gui.c

@@ -28,7 +28,7 @@ void gui_input_events_callback(const void* value, void* ctx) {
 
     Gui* gui = ctx;
 
-    osMessageQueuePut(gui->input_queue, value, 0, osWaitForever);
+    furi_message_queue_put(gui->input_queue, value, FuriWaitForever);
     furi_thread_flags_set(gui->thread_id, GUI_THREAD_FLAG_INPUT);
 }
 
@@ -308,12 +308,12 @@ void gui_input(Gui* gui, InputEvent* input_event) {
 
 void gui_lock(Gui* gui) {
     furi_assert(gui);
-    furi_check(osMutexAcquire(gui->mutex, osWaitForever) == osOK);
+    furi_check(furi_mutex_acquire(gui->mutex, FuriWaitForever) == FuriStatusOk);
 }
 
 void gui_unlock(Gui* gui) {
     furi_assert(gui);
-    furi_check(osMutexRelease(gui->mutex) == osOK);
+    furi_check(furi_mutex_release(gui->mutex) == FuriStatusOk);
 }
 
 void gui_add_view_port(Gui* gui, ViewPort* view_port, GuiLayer layer) {
@@ -473,7 +473,7 @@ Gui* gui_alloc() {
     // Thread ID
     gui->thread_id = furi_thread_get_current_id();
     // Allocate mutex
-    gui->mutex = osMutexNew(NULL);
+    gui->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
     furi_check(gui->mutex);
     // Layers
     for(size_t i = 0; i < GuiLayerMAX; i++) {
@@ -484,7 +484,7 @@ Gui* gui_alloc() {
     CanvasCallbackPairArray_init(gui->canvas_callback_pair);
 
     // Input
-    gui->input_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL);
+    gui->input_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
     gui->input_events = furi_record_open("input_events");
 
     furi_check(gui->input_events);
@@ -501,12 +501,12 @@ int32_t gui_srv(void* p) {
 
     while(1) {
         uint32_t flags =
-            furi_thread_flags_wait(GUI_THREAD_FLAG_ALL, osFlagsWaitAny, osWaitForever);
+            furi_thread_flags_wait(GUI_THREAD_FLAG_ALL, FuriFlagWaitAny, FuriWaitForever);
         // Process and dispatch input
         if(flags & GUI_THREAD_FLAG_INPUT) {
             // Process till queue become empty
             InputEvent input_event;
-            while(osMessageQueueGet(gui->input_queue, &input_event, NULL, 0) == osOK) {
+            while(furi_message_queue_get(gui->input_queue, &input_event, 0) == FuriStatusOk) {
                 gui_input(gui, &input_event);
             }
         }

+ 2 - 2
applications/gui/gui_i.h

@@ -58,7 +58,7 @@ ALGO_DEF(CanvasCallbackPairArray, CanvasCallbackPairArray_t);
 struct Gui {
     // Thread and lock
     FuriThreadId thread_id;
-    osMutexId_t mutex;
+    FuriMutex* mutex;
 
     // Layers and Canvas
     bool lockdown;
@@ -67,7 +67,7 @@ struct Gui {
     CanvasCallbackPairArray_t canvas_callback_pair;
 
     // Input
-    osMessageQueueId_t input_queue;
+    FuriMessageQueue* input_queue;
     FuriPubSub* input_events;
     uint8_t ongoing_input;
     ViewPort* ongoing_input_view_port;

+ 5 - 4
applications/gui/icon_animation.c

@@ -7,15 +7,16 @@ IconAnimation* icon_animation_alloc(const Icon* icon) {
     furi_assert(icon);
     IconAnimation* instance = malloc(sizeof(IconAnimation));
     instance->icon = icon;
-    instance->timer = osTimerNew(icon_animation_timer_callback, osTimerPeriodic, instance, NULL);
+    instance->timer =
+        furi_timer_alloc(icon_animation_timer_callback, FuriTimerTypePeriodic, instance);
     return instance;
 }
 
 void icon_animation_free(IconAnimation* instance) {
     furi_assert(instance);
     icon_animation_stop(instance);
-    while(xTimerIsTimerActive(instance->timer) == pdTRUE) osDelay(1);
-    furi_check(osTimerDelete(instance->timer) == osOK);
+    while(xTimerIsTimerActive(instance->timer) == pdTRUE) furi_delay_tick(1);
+    furi_timer_free(instance->timer);
     free(instance);
 }
 
@@ -68,7 +69,7 @@ void icon_animation_start(IconAnimation* instance) {
         furi_check(
             xTimerChangePeriod(
                 instance->timer,
-                (osKernelGetTickFreq() / instance->icon->frame_rate),
+                (furi_kernel_get_tick_frequency() / instance->icon->frame_rate),
                 portMAX_DELAY) == pdPASS);
     }
 }

+ 1 - 1
applications/gui/icon_animation_i.h

@@ -13,7 +13,7 @@ struct IconAnimation {
     const Icon* icon;
     uint8_t frame;
     bool animating;
-    osTimerId_t timer;
+    FuriTimer* timer;
     IconAnimationCallback callback;
     void* callback_context;
 };

+ 6 - 14
applications/gui/modules/file_browser.c

@@ -1,10 +1,9 @@
 #include "file_browser.h"
 #include "assets_icons.h"
-#include "cmsis_os2.h"
 #include "file_browser_worker.h"
-#include "furi/check.h"
-#include "furi/common_defines.h"
-#include "furi/log.h"
+#include <core/check.h>
+#include <core/common_defines.h>
+#include <core/log.h>
 #include "furi_hal_resources.h"
 #include "m-string.h"
 #include <m-array.h>
@@ -354,19 +353,12 @@ static void browser_draw_frame(Canvas* canvas, uint16_t idx, bool scrollbar) {
 }
 
 static void browser_draw_loading(Canvas* canvas, FileBrowserModel* model) {
-    uint8_t width = 49;
-    uint8_t height = 47;
-    uint8_t x = 128 / 2 - width / 2;
-    uint8_t y = 64 / 2 - height / 2;
-
     UNUSED(model);
 
-    elements_bold_rounded_frame(canvas, x, y, width, height);
-
-    canvas_set_font(canvas, FontSecondary);
-    elements_multiline_text(canvas, x + 7, y + 13, "Loading...");
+    uint8_t x = 128 / 2 - 24 / 2;
+    uint8_t y = 64 / 2 - 24 / 2;
 
-    canvas_draw_icon(canvas, x + 13, y + 19, &A_Loading_24);
+    canvas_draw_icon(canvas, x, y, &A_Loading_24);
 }
 
 static void browser_draw_list(Canvas* canvas, FileBrowserModel* model) {

+ 5 - 4
applications/gui/modules/file_browser_worker.c

@@ -1,6 +1,6 @@
 #include "file_browser_worker.h"
-#include "furi/check.h"
-#include "furi/common_defines.h"
+#include <core/check.h>
+#include <core/common_defines.h>
 #include "m-string.h"
 #include "storage/filesystem_api_defines.h"
 #include <m-array.h>
@@ -262,8 +262,9 @@ static int32_t browser_worker(void* context) {
     furi_thread_flags_set(furi_thread_get_id(browser->thread), WorkerEvtConfigChange);
 
     while(1) {
-        uint32_t flags = furi_thread_flags_wait(WORKER_FLAGS_ALL, osFlagsWaitAny, osWaitForever);
-        furi_assert((flags & osFlagsError) == 0);
+        uint32_t flags =
+            furi_thread_flags_wait(WORKER_FLAGS_ALL, FuriFlagWaitAny, FuriWaitForever);
+        furi_assert((flags & FuriFlagError) == 0);
 
         if(flags & WorkerEvtConfigChange) {
             // If start path is a path to the file - try finding index of this file in a folder

+ 7 - 8
applications/gui/modules/loading.c

@@ -20,17 +20,16 @@ typedef struct {
 static void loading_draw_callback(Canvas* canvas, void* _model) {
     LoadingModel* model = (LoadingModel*)_model;
 
-    uint8_t width = 49;
-    uint8_t height = 47;
-    uint8_t x = (canvas_width(canvas) - width) / 2;
-    uint8_t y = (canvas_height(canvas) - height) / 2;
+    canvas_set_color(canvas, ColorWhite);
+    canvas_draw_box(canvas, 0, 0, canvas_width(canvas), canvas_height(canvas));
+    canvas_set_color(canvas, ColorBlack);
 
-    elements_bold_rounded_frame(canvas, x, y, width, height);
+    uint8_t x = canvas_width(canvas) / 2 - 24 / 2;
+    uint8_t y = canvas_height(canvas) / 2 - 24 / 2;
 
-    canvas_set_font(canvas, FontSecondary);
-    elements_multiline_text(canvas, x + 7, y + 13, "Loading...");
+    canvas_draw_icon(canvas, x, y, &A_Loading_24);
 
-    canvas_draw_icon_animation(canvas, x + 13, y + 19, model->icon);
+    canvas_draw_icon_animation(canvas, x, y, model->icon);
 }
 
 static bool loading_input_callback(InputEvent* event, void* context) {

+ 7 - 6
applications/gui/modules/popup.c

@@ -7,7 +7,7 @@ struct Popup {
     void* context;
     PopupCallback callback;
 
-    osTimerId_t timer;
+    FuriTimer* timer;
     uint32_t timer_period_in_ms;
     bool timer_enabled;
 };
@@ -93,10 +93,11 @@ static bool popup_view_input_callback(InputEvent* event, void* context) {
 void popup_start_timer(void* context) {
     Popup* popup = context;
     if(popup->timer_enabled) {
-        uint32_t timer_period = popup->timer_period_in_ms / (1000.0f / osKernelGetTickFreq());
+        uint32_t timer_period =
+            popup->timer_period_in_ms / (1000.0f / furi_kernel_get_tick_frequency());
         if(timer_period == 0) timer_period = 1;
 
-        if(osTimerStart(popup->timer, timer_period) != osOK) {
+        if(furi_timer_start(popup->timer, timer_period) != FuriStatusOk) {
             furi_assert(0);
         };
     }
@@ -104,13 +105,13 @@ void popup_start_timer(void* context) {
 
 void popup_stop_timer(void* context) {
     Popup* popup = context;
-    osTimerStop(popup->timer);
+    furi_timer_stop(popup->timer);
 }
 
 Popup* popup_alloc() {
     Popup* popup = malloc(sizeof(Popup));
     popup->view = view_alloc();
-    popup->timer = osTimerNew(popup_timer_callback, osTimerOnce, popup, NULL);
+    popup->timer = furi_timer_alloc(popup_timer_callback, FuriTimerTypeOnce, popup);
     furi_assert(popup->timer);
     popup->timer_period_in_ms = 1000;
     popup->timer_enabled = false;
@@ -146,7 +147,7 @@ Popup* popup_alloc() {
 
 void popup_free(Popup* popup) {
     furi_assert(popup);
-    osTimerDelete(popup->timer);
+    furi_timer_free(popup->timer);
     view_free(popup->view);
     free(popup);
 }

+ 6 - 6
applications/gui/modules/text_input.c

@@ -4,7 +4,7 @@
 
 struct TextInput {
     View* view;
-    osTimerId_t timer;
+    FuriTimer* timer;
 };
 
 typedef struct {
@@ -310,7 +310,7 @@ static void text_input_handle_ok(TextInput* text_input, TextInputModel* model, b
            (!model->validator_callback(
                model->text_buffer, model->validator_text, model->validator_callback_context))) {
             model->valadator_message_visible = true;
-            osTimerStart(text_input->timer, osKernelGetTickFreq() * 4);
+            furi_timer_start(text_input->timer, furi_kernel_get_tick_frequency() * 4);
         } else if(model->callback != 0 && text_length > 0) {
             model->callback(model->callback_context);
         }
@@ -438,7 +438,7 @@ TextInput* text_input_alloc() {
     view_set_draw_callback(text_input->view, text_input_view_draw_callback);
     view_set_input_callback(text_input->view, text_input_view_input_callback);
 
-    text_input->timer = osTimerNew(text_input_timer_callback, osTimerOnce, text_input, NULL);
+    text_input->timer = furi_timer_alloc(text_input_timer_callback, FuriTimerTypeOnce, text_input);
 
     with_view_model(
         text_input->view, (TextInputModel * model) {
@@ -460,11 +460,11 @@ void text_input_free(TextInput* text_input) {
         });
 
     // Send stop command
-    osTimerStop(text_input->timer);
+    furi_timer_stop(text_input->timer);
     // Wait till timer stop
-    while(osTimerIsRunning(text_input->timer)) osDelay(1);
+    while(furi_timer_is_running(text_input->timer)) furi_delay_tick(1);
     // Release allocated memory
-    osTimerDelete(text_input->timer);
+    furi_timer_free(text_input->timer);
 
     view_free(text_input->view);
 

+ 4 - 4
applications/gui/view.c

@@ -81,7 +81,7 @@ void view_allocate_model(View* view, ViewModelType type, size_t size) {
         view->model = malloc(size);
     } else if(view->model_type == ViewModelTypeLocking) {
         ViewModelLocking* model = malloc(sizeof(ViewModelLocking));
-        model->mutex = osMutexNew(NULL);
+        model->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
         furi_check(model->mutex);
         model->data = malloc(size);
         view->model = model;
@@ -98,7 +98,7 @@ void view_free_model(View* view) {
         free(view->model);
     } else if(view->model_type == ViewModelTypeLocking) {
         ViewModelLocking* model = view->model;
-        furi_check(osMutexDelete(model->mutex) == osOK);
+        furi_mutex_free(model->mutex);
         free(model->data);
         free(model);
         view->model = NULL;
@@ -111,7 +111,7 @@ void* view_get_model(View* view) {
     furi_assert(view);
     if(view->model_type == ViewModelTypeLocking) {
         ViewModelLocking* model = (ViewModelLocking*)(view->model);
-        furi_check(osMutexAcquire(model->mutex, osWaitForever) == osOK);
+        furi_check(furi_mutex_acquire(model->mutex, FuriWaitForever) == FuriStatusOk);
         return model->data;
     }
     return view->model;
@@ -138,7 +138,7 @@ void view_unlock_model(View* view) {
     furi_assert(view);
     if(view->model_type == ViewModelTypeLocking) {
         ViewModelLocking* model = (ViewModelLocking*)(view->model);
-        furi_check(osMutexRelease(model->mutex) == osOK);
+        furi_check(furi_mutex_release(model->mutex) == FuriStatusOk);
     }
 }
 

+ 12 - 8
applications/gui/view_dispatcher.c

@@ -30,7 +30,7 @@ void view_dispatcher_free(ViewDispatcher* view_dispatcher) {
     view_port_free(view_dispatcher->view_port);
     // Free internal queue
     if(view_dispatcher->queue) {
-        osMessageQueueDelete(view_dispatcher->queue);
+        furi_message_queue_free(view_dispatcher->queue);
     }
     // Free dispatcher
     free(view_dispatcher);
@@ -39,7 +39,7 @@ void view_dispatcher_free(ViewDispatcher* view_dispatcher) {
 void view_dispatcher_enable_queue(ViewDispatcher* view_dispatcher) {
     furi_assert(view_dispatcher);
     furi_assert(view_dispatcher->queue == NULL);
-    view_dispatcher->queue = osMessageQueueNew(16, sizeof(ViewDispatcherMessage), NULL);
+    view_dispatcher->queue = furi_message_queue_alloc(16, sizeof(ViewDispatcherMessage));
 }
 
 void view_dispatcher_set_event_callback_context(ViewDispatcher* view_dispatcher, void* context) {
@@ -77,11 +77,11 @@ void view_dispatcher_run(ViewDispatcher* view_dispatcher) {
     furi_assert(view_dispatcher);
     furi_assert(view_dispatcher->queue);
 
-    uint32_t tick_period = view_dispatcher->tick_period == 0 ? osWaitForever :
+    uint32_t tick_period = view_dispatcher->tick_period == 0 ? FuriWaitForever :
                                                                view_dispatcher->tick_period;
     ViewDispatcherMessage message;
     while(1) {
-        if(osMessageQueueGet(view_dispatcher->queue, &message, NULL, tick_period) != osOK) {
+        if(furi_message_queue_get(view_dispatcher->queue, &message, tick_period) != FuriStatusOk) {
             view_dispatcher_handle_tick_event(view_dispatcher);
             continue;
         }
@@ -96,7 +96,7 @@ void view_dispatcher_run(ViewDispatcher* view_dispatcher) {
 
     // Wait till all input events delivered
     while(view_dispatcher->ongoing_input) {
-        osMessageQueueGet(view_dispatcher->queue, &message, NULL, osWaitForever);
+        furi_message_queue_get(view_dispatcher->queue, &message, FuriWaitForever);
         if(message.type == ViewDispatcherMessageTypeInput) {
             uint8_t key_bit = (1 << message.input.key);
             if(message.input.type == InputTypePress) {
@@ -113,7 +113,8 @@ void view_dispatcher_stop(ViewDispatcher* view_dispatcher) {
     furi_assert(view_dispatcher->queue);
     ViewDispatcherMessage message;
     message.type = ViewDispatcherMessageTypeStop;
-    furi_check(osMessageQueuePut(view_dispatcher->queue, &message, 0, osWaitForever) == osOK);
+    furi_check(
+        furi_message_queue_put(view_dispatcher->queue, &message, FuriWaitForever) == FuriStatusOk);
 }
 
 void view_dispatcher_add_view(ViewDispatcher* view_dispatcher, uint32_t view_id, View* view) {
@@ -224,7 +225,9 @@ void view_dispatcher_input_callback(InputEvent* event, void* context) {
         ViewDispatcherMessage message;
         message.type = ViewDispatcherMessageTypeInput;
         message.input = *event;
-        furi_check(osMessageQueuePut(view_dispatcher->queue, &message, 0, osWaitForever) == osOK);
+        furi_check(
+            furi_message_queue_put(view_dispatcher->queue, &message, FuriWaitForever) ==
+            FuriStatusOk);
     } else {
         view_dispatcher_handle_input(view_dispatcher, event);
     }
@@ -314,7 +317,8 @@ void view_dispatcher_send_custom_event(ViewDispatcher* view_dispatcher, uint32_t
     message.type = ViewDispatcherMessageTypeCustomEvent;
     message.custom_event = event;
 
-    furi_check(osMessageQueuePut(view_dispatcher->queue, &message, 0, osWaitForever) == osOK);
+    furi_check(
+        furi_message_queue_put(view_dispatcher->queue, &message, FuriWaitForever) == FuriStatusOk);
 }
 
 void view_dispatcher_set_current_view(ViewDispatcher* view_dispatcher, View* view) {

+ 1 - 1
applications/gui/view_dispatcher_i.h

@@ -15,7 +15,7 @@
 DICT_DEF2(ViewDict, uint32_t, M_DEFAULT_OPLIST, View*, M_PTR_OPLIST)
 
 struct ViewDispatcher {
-    osMessageQueueId_t queue;
+    FuriMessageQueue* queue;
     Gui* gui;
     ViewPort* view_port;
     ViewDict_t views;

+ 1 - 1
applications/gui/view_i.h

@@ -10,7 +10,7 @@
 
 typedef struct {
     void* data;
-    osMutexId_t mutex;
+    FuriMutex* mutex;
 } ViewModelLocking;
 
 struct View {

+ 1 - 1
applications/gui/view_stack.c

@@ -1,5 +1,5 @@
 #include "gui/view.h"
-#include "furi/memmgr.h"
+#include <core/memmgr.h>
 #include "view_stack.h"
 #include "view_i.h"
 

+ 14 - 13
applications/ibutton/ibutton_cli.c

@@ -67,14 +67,14 @@ void ibutton_cli_print_key_data(iButtonKey* key) {
 
 static void ibutton_cli_worker_read_cb(void* context) {
     furi_assert(context);
-    osEventFlagsId_t event = context;
-    osEventFlagsSet(event, EVENT_FLAG_IBUTTON_COMPLETE);
+    FuriEventFlag* event = context;
+    furi_event_flag_set(event, EVENT_FLAG_IBUTTON_COMPLETE);
 }
 
 void ibutton_cli_read(Cli* cli) {
     iButtonKey* key = ibutton_key_alloc();
     iButtonWorker* worker = ibutton_worker_alloc();
-    osEventFlagsId_t event = osEventFlagsNew(NULL);
+    FuriEventFlag* event = furi_event_flag_alloc();
 
     ibutton_worker_start_thread(worker);
     ibutton_worker_read_set_callback(worker, ibutton_cli_worker_read_cb, event);
@@ -82,7 +82,8 @@ void ibutton_cli_read(Cli* cli) {
     printf("Reading iButton...\r\nPress Ctrl+C to abort\r\n");
     ibutton_worker_read_start(worker, key);
     while(true) {
-        uint32_t flags = osEventFlagsWait(event, EVENT_FLAG_IBUTTON_COMPLETE, osFlagsWaitAny, 100);
+        uint32_t flags =
+            furi_event_flag_wait(event, EVENT_FLAG_IBUTTON_COMPLETE, FuriFlagWaitAny, 100);
 
         if(flags & EVENT_FLAG_IBUTTON_COMPLETE) {
             ibutton_cli_print_key_data(key);
@@ -107,11 +108,11 @@ void ibutton_cli_read(Cli* cli) {
     ibutton_worker_free(worker);
     ibutton_key_free(key);
 
-    osEventFlagsDelete(event);
+    furi_event_flag_free(event);
 };
 
 typedef struct {
-    osEventFlagsId_t event;
+    FuriEventFlag* event;
     iButtonWorkerWriteResult result;
 } iButtonWriteContext;
 
@@ -119,7 +120,7 @@ static void ibutton_cli_worker_write_cb(void* context, iButtonWorkerWriteResult
     furi_assert(context);
     iButtonWriteContext* write_context = (iButtonWriteContext*)context;
     write_context->result = result;
-    osEventFlagsSet(write_context->event, EVENT_FLAG_IBUTTON_COMPLETE);
+    furi_event_flag_set(write_context->event, EVENT_FLAG_IBUTTON_COMPLETE);
 }
 
 void ibutton_cli_write(Cli* cli, string_t args) {
@@ -130,7 +131,7 @@ void ibutton_cli_write(Cli* cli, string_t args) {
     uint8_t key_data[IBUTTON_KEY_DATA_SIZE];
     string_t data;
 
-    write_context.event = osEventFlagsNew(NULL);
+    write_context.event = furi_event_flag_alloc();
 
     string_init(data);
     ibutton_worker_start_thread(worker);
@@ -166,8 +167,8 @@ void ibutton_cli_write(Cli* cli, string_t args) {
 
         ibutton_worker_write_start(worker, key);
         while(true) {
-            uint32_t flags = osEventFlagsWait(
-                write_context.event, EVENT_FLAG_IBUTTON_COMPLETE, osFlagsWaitAny, 100);
+            uint32_t flags = furi_event_flag_wait(
+                write_context.event, EVENT_FLAG_IBUTTON_COMPLETE, FuriFlagWaitAny, 100);
 
             if(flags & EVENT_FLAG_IBUTTON_COMPLETE) {
                 if(write_context.result == iButtonWorkerWriteSameKey ||
@@ -190,7 +191,7 @@ void ibutton_cli_write(Cli* cli, string_t args) {
     ibutton_worker_free(worker);
     ibutton_key_free(key);
 
-    osEventFlagsDelete(write_context.event);
+    furi_event_flag_free(write_context.event);
 };
 
 void ibutton_cli_emulate(Cli* cli, string_t args) {
@@ -228,7 +229,7 @@ void ibutton_cli_emulate(Cli* cli, string_t args) {
 
         ibutton_worker_emulate_start(worker, key);
         while(!cli_cmd_interrupt_received(cli)) {
-            furi_hal_delay_ms(100);
+            furi_delay_ms(100);
         };
         ibutton_worker_stop(worker);
     } while(false);
@@ -291,7 +292,7 @@ static void onewire_cli_search(Cli* cli) {
             }
             printf("\r\n");
         }
-        furi_hal_delay_ms(100);
+        furi_delay_ms(100);
     }
 
     furi_hal_power_disable_otg();

+ 3 - 1
applications/ibutton/scenes/ibutton_scene_add_type.c

@@ -23,7 +23,8 @@ void ibutton_scene_add_type_on_enter(void* context) {
     submenu_add_item(
         submenu, "Metakom", SubmenuIndexMetakom, ibutton_scene_add_type_submenu_callback, ibutton);
 
-    submenu_set_selected_item(submenu, SubmenuIndexCyfral);
+    submenu_set_selected_item(
+        submenu, scene_manager_get_scene_state(ibutton->scene_manager, iButtonSceneAddType));
 
     view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewSubmenu);
 }
@@ -34,6 +35,7 @@ bool ibutton_scene_add_type_on_event(void* context, SceneManagerEvent event) {
     bool consumed = false;
 
     if(event.type == SceneManagerEventTypeCustom) {
+        scene_manager_set_scene_state(ibutton->scene_manager, iButtonSceneAddType, event.event);
         consumed = true;
         if(event.event == SubmenuIndexCyfral) {
             ibutton_key_set_type(key, iButtonKeyCyfral);

+ 1 - 1
applications/ibutton/scenes/ibutton_scene_emulate.c

@@ -1,5 +1,5 @@
 #include "../ibutton_i.h"
-#include "furi/log.h"
+#include <core/log.h>
 #include <dolphin/dolphin.h>
 #include <toolbox/path.h>
 

+ 2 - 2
applications/ibutton/scenes/ibutton_scene_exit_confirm.c

@@ -19,9 +19,9 @@ void ibutton_scene_exit_confirm_on_enter(void* context) {
     widget_add_button_element(
         widget, GuiButtonTypeRight, "Stay", ibutton_scene_exit_confirm_widget_callback, ibutton);
     widget_add_string_element(
-        widget, 64, 19, AlignCenter, AlignBottom, FontPrimary, "Exit to iButton menu");
+        widget, 64, 19, AlignCenter, AlignBottom, FontPrimary, "Exit to iButton menu?");
     widget_add_string_element(
-        widget, 64, 29, AlignCenter, AlignBottom, FontSecondary, "All unsaved data will be lost");
+        widget, 64, 31, AlignCenter, AlignBottom, FontSecondary, "All unsaved data will be lost.");
 
     view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewWidget);
 }

+ 4 - 1
applications/ibutton/scenes/ibutton_scene_read_crc_error.c

@@ -43,7 +43,10 @@ bool ibutton_scene_read_crc_error_on_event(void* context, SceneManagerEvent even
     SceneManager* scene_manager = ibutton->scene_manager;
     bool consumed = false;
 
-    if(event.type == SceneManagerEventTypeCustom) {
+    if(event.type == SceneManagerEventTypeBack) {
+        consumed = true;
+        scene_manager_next_scene(scene_manager, iButtonSceneExitConfirm);
+    } else if(event.type == SceneManagerEventTypeCustom) {
         consumed = true;
         if(event.event == DialogExResultRight) {
             scene_manager_next_scene(scene_manager, iButtonSceneReadKeyMenu);

+ 4 - 2
applications/ibutton/scenes/ibutton_scene_read_key_menu.c

@@ -31,8 +31,8 @@ void ibutton_scene_read_key_menu_on_enter(void* context) {
             ibutton_scene_read_key_menu_submenu_callback,
             ibutton);
     }
-
-    submenu_set_selected_item(submenu, SubmenuIndexSave);
+    submenu_set_selected_item(
+        submenu, scene_manager_get_scene_state(ibutton->scene_manager, iButtonSceneReadKeyMenu));
 
     view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewSubmenu);
 }
@@ -42,6 +42,8 @@ bool ibutton_scene_read_key_menu_on_event(void* context, SceneManagerEvent event
     bool consumed = false;
 
     if(event.type == SceneManagerEventTypeCustom) {
+        scene_manager_set_scene_state(
+            ibutton->scene_manager, iButtonSceneReadKeyMenu, event.event);
         consumed = true;
         if(event.event == SubmenuIndexSave) {
             scene_manager_next_scene(ibutton->scene_manager, iButtonSceneSaveName);

+ 4 - 1
applications/ibutton/scenes/ibutton_scene_read_not_key_error.c

@@ -44,7 +44,10 @@ bool ibutton_scene_read_not_key_error_on_event(void* context, SceneManagerEvent
     SceneManager* scene_manager = ibutton->scene_manager;
     bool consumed = false;
 
-    if(event.type == SceneManagerEventTypeCustom) {
+    if(event.type == SceneManagerEventTypeBack) {
+        consumed = true;
+        scene_manager_next_scene(scene_manager, iButtonSceneExitConfirm);
+    } else if(event.type == SceneManagerEventTypeCustom) {
         consumed = true;
         if(event.event == DialogExResultRight) {
             scene_manager_next_scene(scene_manager, iButtonSceneReadKeyMenu);

+ 4 - 1
applications/ibutton/scenes/ibutton_scene_saved_key_menu.c

@@ -42,7 +42,8 @@ void ibutton_scene_saved_key_menu_on_enter(void* context) {
     submenu_add_item(
         submenu, "Info", SubmenuIndexInfo, ibutton_scene_saved_key_menu_submenu_callback, ibutton);
 
-    submenu_set_selected_item(submenu, SubmenuIndexEmulate);
+    submenu_set_selected_item(
+        submenu, scene_manager_get_scene_state(ibutton->scene_manager, iButtonSceneSavedKeyMenu));
 
     view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewSubmenu);
 }
@@ -52,6 +53,8 @@ bool ibutton_scene_saved_key_menu_on_event(void* context, SceneManagerEvent even
     bool consumed = false;
 
     if(event.type == SceneManagerEventTypeCustom) {
+        scene_manager_set_scene_state(
+            ibutton->scene_manager, iButtonSceneSavedKeyMenu, event.event);
         consumed = true;
         if(event.event == SubmenuIndexEmulate) {
             scene_manager_next_scene(ibutton->scene_manager, iButtonSceneEmulate);

+ 4 - 1
applications/ibutton/scenes/ibutton_scene_start.c

@@ -1,4 +1,5 @@
 #include "../ibutton_i.h"
+#include "ibutton/scenes/ibutton_scene.h"
 
 enum SubmenuIndex {
     SubmenuIndexRead,
@@ -22,7 +23,8 @@ void ibutton_scene_start_on_enter(void* context) {
     submenu_add_item(
         submenu, "Add Manually", SubmenuIndexAdd, ibutton_scene_start_submenu_callback, ibutton);
 
-    submenu_set_selected_item(submenu, SubmenuIndexRead);
+    submenu_set_selected_item(
+        submenu, scene_manager_get_scene_state(ibutton->scene_manager, iButtonSceneStart));
 
     view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewSubmenu);
 }
@@ -32,6 +34,7 @@ bool ibutton_scene_start_on_event(void* context, SceneManagerEvent event) {
     bool consumed = false;
 
     if(event.type == SceneManagerEventTypeCustom) {
+        scene_manager_set_scene_state(ibutton->scene_manager, iButtonSceneStart, event.event);
         consumed = true;
         if(event.event == SubmenuIndexRead) {
             scene_manager_next_scene(ibutton->scene_manager, iButtonSceneRead);

+ 5 - 4
applications/infrared/infrared_brute_force.c

@@ -51,9 +51,9 @@ bool infrared_brute_force_calculate_messages(InfraredBruteForce* brute_force) {
     bool success = false;
 
     Storage* storage = furi_record_open("storage");
-    FlipperFormat* ff = flipper_format_file_alloc(storage);
+    FlipperFormat* ff = flipper_format_buffered_file_alloc(storage);
 
-    success = flipper_format_file_open_existing(ff, brute_force->db_filename);
+    success = flipper_format_buffered_file_open_existing(ff, brute_force->db_filename);
     if(success) {
         string_t signal_name;
         string_init(signal_name);
@@ -95,8 +95,9 @@ bool infrared_brute_force_start(
 
     if(*record_count) {
         Storage* storage = furi_record_open("storage");
-        brute_force->ff = flipper_format_file_alloc(storage);
-        success = flipper_format_file_open_existing(brute_force->ff, brute_force->db_filename);
+        brute_force->ff = flipper_format_buffered_file_alloc(storage);
+        success =
+            flipper_format_buffered_file_open_existing(brute_force->ff, brute_force->db_filename);
         if(!success) {
             flipper_format_free(brute_force->ff);
             brute_force->ff = NULL;

+ 1 - 1
applications/infrared/infrared_cli.c

@@ -63,7 +63,7 @@ static void infrared_cli_start_ir_rx(Cli* cli, string_t args) {
 
     printf("Receiving INFRARED...\r\nPress Ctrl+C to abort\r\n");
     while(!cli_cmd_interrupt_received(cli)) {
-        furi_hal_delay_ms(50);
+        furi_delay_ms(50);
     }
 
     infrared_worker_rx_stop(worker);

+ 3 - 3
applications/infrared/infrared_remote.c

@@ -7,7 +7,7 @@
 #include <m-array.h>
 #include <toolbox/path.h>
 #include <storage/storage.h>
-#include <furi/common_defines.h>
+#include <core/common_defines.h>
 
 #define TAG "InfraredRemote"
 
@@ -140,13 +140,13 @@ bool infrared_remote_store(InfraredRemote* remote) {
 
 bool infrared_remote_load(InfraredRemote* remote, string_t path) {
     Storage* storage = furi_record_open("storage");
-    FlipperFormat* ff = flipper_format_file_alloc(storage);
+    FlipperFormat* ff = flipper_format_buffered_file_alloc(storage);
 
     string_t buf;
     string_init(buf);
 
     FURI_LOG_I(TAG, "load file: \'%s\'", string_get_cstr(path));
-    bool success = flipper_format_file_open_existing(ff, string_get_cstr(path));
+    bool success = flipper_format_buffered_file_open_existing(ff, string_get_cstr(path));
 
     if(success) {
         uint32_t version;

+ 1 - 1
applications/infrared/infrared_signal.c

@@ -2,7 +2,7 @@
 
 #include <stdlib.h>
 #include <string.h>
-#include <furi/check.h>
+#include <core/check.h>
 #include <infrared_worker.h>
 #include <infrared_transmit.h>
 

+ 48 - 0
applications/infrared/scenes/infrared_scene_ask_retry.c

@@ -0,0 +1,48 @@
+#include "../infrared_i.h"
+
+static void infrared_scene_dialog_result_callback(DialogExResult result, void* context) {
+    Infrared* infrared = context;
+    view_dispatcher_send_custom_event(infrared->view_dispatcher, result);
+}
+
+void infrared_scene_ask_retry_on_enter(void* context) {
+    Infrared* infrared = context;
+    DialogEx* dialog_ex = infrared->dialog_ex;
+
+    dialog_ex_set_header(dialog_ex, "Return to reading?", 64, 0, AlignCenter, AlignTop);
+    dialog_ex_set_text(
+        dialog_ex, "All unsaved data\nwill be lost", 64, 31, AlignCenter, AlignCenter);
+    dialog_ex_set_icon(dialog_ex, 0, 0, NULL);
+    dialog_ex_set_left_button_text(dialog_ex, "Exit");
+    dialog_ex_set_center_button_text(dialog_ex, NULL);
+    dialog_ex_set_right_button_text(dialog_ex, "Stay");
+    dialog_ex_set_result_callback(dialog_ex, infrared_scene_dialog_result_callback);
+    dialog_ex_set_context(dialog_ex, context);
+
+    view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewDialogEx);
+}
+
+bool infrared_scene_ask_retry_on_event(void* context, SceneManagerEvent event) {
+    Infrared* infrared = context;
+    SceneManager* scene_manager = infrared->scene_manager;
+    bool consumed = false;
+
+    if(event.type == SceneManagerEventTypeBack) {
+        consumed = true;
+    } else if(event.type == SceneManagerEventTypeCustom) {
+        if(event.event == DialogExResultLeft) {
+            scene_manager_search_and_switch_to_previous_scene(scene_manager, InfraredSceneLearn);
+            consumed = true;
+        } else if(event.event == DialogExResultRight) {
+            scene_manager_previous_scene(scene_manager);
+            consumed = true;
+        }
+    }
+
+    return consumed;
+}
+
+void infrared_scene_ask_retry_on_exit(void* context) {
+    Infrared* infrared = context;
+    dialog_ex_reset(infrared->dialog_ex);
+}

+ 1 - 0
applications/infrared/scenes/infrared_scene_config.h

@@ -1,5 +1,6 @@
 ADD_SCENE(infrared, start, Start)
 ADD_SCENE(infrared, ask_back, AskBack)
+ADD_SCENE(infrared, ask_retry, AskRetry)
 ADD_SCENE(infrared, edit, Edit)
 ADD_SCENE(infrared, edit_delete, EditDelete)
 ADD_SCENE(infrared, edit_delete_done, EditDeleteDone)

+ 1 - 2
applications/infrared/scenes/infrared_scene_learn_success.c

@@ -89,8 +89,7 @@ bool infrared_scene_learn_success_on_event(void* context, SceneManagerEvent even
     } else if(event.type == SceneManagerEventTypeCustom) {
         if(event.event == DialogExResultLeft) {
             if(scene_state == InfraredSceneLearnSuccessStateIdle) {
-                scene_manager_search_and_switch_to_previous_scene(
-                    scene_manager, InfraredSceneLearn);
+                scene_manager_next_scene(scene_manager, InfraredSceneAskRetry);
             }
             consumed = true;
         } else if(event.event == DialogExResultRight) {

+ 1 - 2
applications/infrared/scenes/infrared_scene_remote_list.c

@@ -5,7 +5,6 @@ void infrared_scene_remote_list_on_enter(void* context) {
     SceneManager* scene_manager = infrared->scene_manager;
     ViewDispatcher* view_dispatcher = infrared->view_dispatcher;
 
-    string_set_str(infrared->file_path, INFRARED_APP_FOLDER);
     bool success = dialog_file_browser_show(
         infrared->dialogs,
         infrared->file_path,
@@ -16,7 +15,7 @@ void infrared_scene_remote_list_on_enter(void* context) {
         true);
 
     if(success) {
-        view_set_orientation(view_stack_get_view(infrared->view_stack), ViewOrientationHorizontal);
+        view_set_orientation(view_stack_get_view(infrared->view_stack), ViewOrientationVertical);
         view_dispatcher_switch_to_view(view_dispatcher, InfraredViewStack);
 
         infrared_show_loading_popup(infrared, true);

+ 1 - 0
applications/infrared/scenes/infrared_scene_start.c

@@ -66,6 +66,7 @@ bool infrared_scene_start_on_event(void* context, SceneManagerEvent event) {
             scene_manager_next_scene(scene_manager, InfraredSceneLearn);
             consumed = true;
         } else if(submenu_index == SubmenuIndexSavedRemotes) {
+            string_set_str(infrared->file_path, INFRARED_APP_FOLDER);
             scene_manager_next_scene(scene_manager, InfraredSceneRemoteList);
             consumed = true;
         } else if(submenu_index == SubmenuIndexDebug) {

+ 1 - 1
applications/infrared/views/infrared_progress_view.c

@@ -1,4 +1,4 @@
-#include "furi/check.h"
+#include <core/check.h>
 #include "furi_hal_resources.h"
 #include "assets_icons.h"
 #include "gui/canvas.h"

+ 7 - 7
applications/input/input.c

@@ -4,18 +4,18 @@
 
 static Input* input = NULL;
 
-inline static void input_timer_start(osTimerId_t timer_id, uint32_t ticks) {
+inline static void input_timer_start(FuriTimer* timer_id, uint32_t ticks) {
     TimerHandle_t hTimer = (TimerHandle_t)timer_id;
     furi_check(xTimerChangePeriod(hTimer, ticks, portMAX_DELAY) == pdPASS);
 }
 
-inline static void input_timer_stop(osTimerId_t timer_id) {
+inline static void input_timer_stop(FuriTimer* timer_id) {
     TimerHandle_t hTimer = (TimerHandle_t)timer_id;
     furi_check(xTimerStop(hTimer, portMAX_DELAY) == pdPASS);
     // xTimerStop is not actually stopping timer,
     // Instead it places stop event into timer queue
     // This code ensures that timer is stopped
-    while(xTimerIsTimerActive(hTimer) == pdTRUE) osDelay(1);
+    while(xTimerIsTimerActive(hTimer) == pdTRUE) furi_delay_tick(1);
 }
 
 void input_press_timer_callback(void* arg) {
@@ -84,8 +84,8 @@ int32_t input_srv() {
         input->pin_states[i].pin = &input_pins[i];
         input->pin_states[i].state = GPIO_Read(input->pin_states[i]);
         input->pin_states[i].debounce = INPUT_DEBOUNCE_TICKS_HALF;
-        input->pin_states[i].press_timer =
-            osTimerNew(input_press_timer_callback, osTimerPeriodic, &input->pin_states[i], NULL);
+        input->pin_states[i].press_timer = furi_timer_alloc(
+            input_press_timer_callback, FuriTimerTypePeriodic, &input->pin_states[i]);
         input->pin_states[i].press_counter = 0;
     }
 
@@ -127,9 +127,9 @@ int32_t input_srv() {
         }
 
         if(is_changing) {
-            osDelay(1);
+            furi_delay_tick(1);
         } else {
-            furi_thread_flags_wait(INPUT_THREAD_FLAG_ISR, osFlagsWaitAny, osWaitForever);
+            furi_thread_flags_wait(INPUT_THREAD_FLAG_ISR, FuriFlagWaitAny, FuriWaitForever);
         }
     }
 

+ 5 - 5
applications/input/input_cli.c

@@ -15,20 +15,20 @@ static void input_cli_usage() {
 static void input_cli_dump_events_callback(const void* value, void* ctx) {
     furi_assert(value);
     furi_assert(ctx);
-    osMessageQueueId_t input_queue = ctx;
-    osMessageQueuePut(input_queue, value, 0, osWaitForever);
+    FuriMessageQueue* input_queue = ctx;
+    furi_message_queue_put(input_queue, value, FuriWaitForever);
 }
 
 static void input_cli_dump(Cli* cli, string_t args, Input* input) {
     UNUSED(args);
-    osMessageQueueId_t input_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL);
+    FuriMessageQueue* input_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
     FuriPubSubSubscription* input_subscription =
         furi_pubsub_subscribe(input->event_pubsub, input_cli_dump_events_callback, input_queue);
 
     InputEvent input_event;
     printf("Press CTRL+C to stop\r\n");
     while(!cli_cmd_interrupt_received(cli)) {
-        if(osMessageQueueGet(input_queue, &input_event, NULL, 100) == osOK) {
+        if(furi_message_queue_get(input_queue, &input_event, 100) == FuriStatusOk) {
             printf(
                 "key: %s type: %s\r\n",
                 input_get_key_name(input_event.key),
@@ -37,7 +37,7 @@ static void input_cli_dump(Cli* cli, string_t args, Input* input) {
     }
 
     furi_pubsub_unsubscribe(input->event_pubsub, input_subscription);
-    osMessageQueueDelete(input_queue);
+    furi_message_queue_free(input_queue);
 }
 
 static void input_cli_send_print_usage() {

+ 1 - 1
applications/input/input_i.h

@@ -25,7 +25,7 @@ typedef struct {
     // State
     volatile bool state;
     volatile uint8_t debounce;
-    volatile osTimerId_t press_timer;
+    FuriTimer* press_timer;
     volatile uint8_t press_counter;
     volatile uint32_t counter;
 } InputPinState;

+ 1 - 1
applications/lfrfid/helpers/rfid_key.cpp

@@ -1,5 +1,5 @@
 #include "rfid_key.h"
-#include <furi/check.h>
+#include <core/check.h>
 #include <string.h>
 
 RfidKey::RfidKey() {

+ 3 - 3
applications/lfrfid/helpers/rfid_reader.cpp

@@ -39,12 +39,12 @@ void RfidReader::decode(bool polarity) {
 }
 
 bool RfidReader::switch_timer_elapsed() {
-    const uint32_t seconds_to_switch = osKernelGetTickFreq() * 2.0f;
-    return (osKernelGetTickCount() - switch_os_tick_last) > seconds_to_switch;
+    const uint32_t seconds_to_switch = furi_kernel_get_tick_frequency() * 2.0f;
+    return (furi_get_tick() - switch_os_tick_last) > seconds_to_switch;
 }
 
 void RfidReader::switch_timer_reset() {
-    switch_os_tick_last = osKernelGetTickCount();
+    switch_os_tick_last = furi_get_tick();
 }
 
 void RfidReader::switch_mode() {

+ 6 - 6
applications/lfrfid/helpers/rfid_writer.cpp

@@ -49,15 +49,15 @@ void RfidWriter::stop() {
 
 void RfidWriter::write_gap(uint32_t gap_time) {
     furi_hal_rfid_tim_read_stop();
-    furi_hal_delay_us(gap_time * 8);
+    furi_delay_us(gap_time * 8);
     furi_hal_rfid_tim_read_start();
 }
 
 void RfidWriter::write_bit(bool value) {
     if(value) {
-        furi_hal_delay_us(T55xxTiming::data_1 * 8);
+        furi_delay_us(T55xxTiming::data_1 * 8);
     } else {
-        furi_hal_delay_us(T55xxTiming::data_0 * 8);
+        furi_delay_us(T55xxTiming::data_0 * 8);
     }
     write_gap(T55xxTiming::write_gap);
 }
@@ -69,7 +69,7 @@ void RfidWriter::write_byte(uint8_t value) {
 }
 
 void RfidWriter::write_block(uint8_t page, uint8_t block, bool lock_bit, uint32_t data) {
-    furi_hal_delay_us(T55xxTiming::wait_time * 8);
+    furi_delay_us(T55xxTiming::wait_time * 8);
 
     // start gap
     write_gap(T55xxTiming::start_gap);
@@ -102,9 +102,9 @@ void RfidWriter::write_block(uint8_t page, uint8_t block, bool lock_bit, uint32_
     write_bit((block >> 1) & 1);
     write_bit((block >> 0) & 1);
 
-    furi_hal_delay_us(T55xxTiming::program * 8);
+    furi_delay_us(T55xxTiming::program * 8);
 
-    furi_hal_delay_us(T55xxTiming::wait_time * 8);
+    furi_delay_us(T55xxTiming::wait_time * 8);
     write_reset();
 }
 

+ 1 - 1
applications/lfrfid/lfrfid_app.cpp

@@ -1,6 +1,6 @@
 #include "lfrfid_app.h"
 #include "assets_icons.h"
-#include "furi/common_defines.h"
+#include <core/common_defines.h>
 #include "m-string.h"
 #include "scene/lfrfid_app_scene_start.h"
 #include "scene/lfrfid_app_scene_read.h"

+ 2 - 2
applications/lfrfid/lfrfid_cli.cpp

@@ -94,7 +94,7 @@ static void lfrfid_cli_read(Cli* cli, string_t args) {
             printf("\r\n");
             break;
         }
-        furi_hal_delay_ms(100);
+        furi_delay_ms(100);
     }
 
     printf("Reading stopped\r\n");
@@ -144,7 +144,7 @@ static void lfrfid_cli_emulate(Cli* cli, string_t args) {
 
     printf("Emulating RFID...\r\nPress Ctrl+C to abort\r\n");
     while(!cli_cmd_interrupt_received(cli)) {
-        furi_hal_delay_ms(100);
+        furi_delay_ms(100);
     }
     printf("Emulation stopped\r\n");
     emulator.stop();

+ 1 - 1
applications/lfrfid/scene/lfrfid_app_scene_emulate.cpp

@@ -1,5 +1,5 @@
 #include "lfrfid_app_scene_emulate.h"
-#include "furi/common_defines.h"
+#include <core/common_defines.h>
 #include <dolphin/dolphin.h>
 
 static const NotificationSequence sequence_blink_start_magenta = {

+ 1 - 1
applications/lfrfid/scene/lfrfid_app_scene_exit_confirm.cpp

@@ -19,7 +19,7 @@ void LfRfidAppSceneExitConfirm::on_enter(LfRfidApp* app, bool /* need_restore */
 
     line_1->set_text("Exit to RFID menu?", 64, 19, 128 - 2, AlignCenter, AlignBottom, FontPrimary);
     line_2->set_text(
-        "All unsaved data will be lost", 64, 29, 0, AlignCenter, AlignBottom, FontSecondary);
+        "All unsaved data will be lost.", 64, 31, 0, AlignCenter, AlignBottom, FontSecondary);
 
     app->view_controller.switch_to<ContainerVM>();
 }

+ 2 - 2
applications/lfrfid/scene/lfrfid_app_scene_read.cpp

@@ -22,9 +22,9 @@ bool LfRfidAppSceneRead::on_event(LfRfidApp* app, LfRfidApp::Event* event) {
             app->scene_controller.switch_to_next_scene(LfRfidApp::SceneType::ReadSuccess);
         } else {
             if(app->worker.any_read()) {
-                notification_message(app->notification, &sequence_blink_green_10);
+                notification_message(app->notification, &sequence_blink_yellow_10);
             } else if(app->worker.detect()) {
-                notification_message(app->notification, &sequence_blink_cyan_10);
+                notification_message(app->notification, &sequence_blink_yellow_10);
             } else {
                 notification_message(app->notification, &sequence_blink_cyan_10);
             }

+ 1 - 1
applications/lfrfid/scene/lfrfid_app_scene_rpc.cpp

@@ -1,5 +1,5 @@
 #include "lfrfid_app_scene_rpc.h"
-#include "furi/common_defines.h"
+#include <core/common_defines.h>
 #include <dolphin/dolphin.h>
 
 void LfRfidAppSceneRpc::on_enter(LfRfidApp* app, bool /* need_restore */) {

+ 1 - 1
applications/loader/loader.c

@@ -471,7 +471,7 @@ int32_t loader_srv(void* p) {
 
     while(1) {
         uint32_t flags =
-            furi_thread_flags_wait(LOADER_THREAD_FLAG_ALL, osFlagsWaitAny, osWaitForever);
+            furi_thread_flags_wait(LOADER_THREAD_FLAG_ALL, FuriFlagWaitAny, FuriWaitForever);
         if(flags & LOADER_THREAD_FLAG_SHOW_MENU) {
             menu_set_selected_item(loader_instance->primary_menu, 0);
             view_dispatcher_switch_to_view(

+ 1 - 1
applications/loader/loader.h

@@ -1,6 +1,6 @@
 #pragma once
 
-#include <furi/pubsub.h>
+#include <core/pubsub.h>
 #include <stdbool.h>
 
 typedef struct Loader Loader;

+ 1 - 1
applications/loader/loader_i.h

@@ -2,7 +2,7 @@
 
 #include <furi.h>
 #include <furi_hal.h>
-#include <furi/pubsub.h>
+#include <core/pubsub.h>
 #include <cli/cli.h>
 #include <lib/toolbox/args.h>
 

+ 17 - 15
applications/music_player/music_player.c

@@ -27,9 +27,9 @@ typedef struct {
 
 typedef struct {
     MusicPlayerModel* model;
-    osMutexId_t* model_mutex;
+    FuriMutex** model_mutex;
 
-    osMessageQueueId_t input_queue;
+    FuriMessageQueue* input_queue;
 
     ViewPort* view_port;
     Gui* gui;
@@ -126,7 +126,7 @@ static bool is_black_note(uint8_t semitone, uint8_t id) {
 
 static void render_callback(Canvas* canvas, void* ctx) {
     MusicPlayer* music_player = ctx;
-    furi_check(osMutexAcquire(music_player->model_mutex, osWaitForever) == osOK);
+    furi_check(furi_mutex_acquire(music_player->model_mutex, FuriWaitForever) == FuriStatusOk);
 
     canvas_clear(canvas);
     canvas_set_color(canvas, ColorBlack);
@@ -208,13 +208,13 @@ static void render_callback(Canvas* canvas, void* ctx) {
         canvas_draw_line(canvas, x_pos, 64 - 16 * i, x_pos + 48, 64 - 16 * i);
     }
 
-    osMutexRelease(music_player->model_mutex);
+    furi_mutex_release(music_player->model_mutex);
 }
 
 static void input_callback(InputEvent* input_event, void* ctx) {
     MusicPlayer* music_player = ctx;
     if(input_event->type == InputTypeShort) {
-        osMessageQueuePut(music_player->input_queue, input_event, 0, 0);
+        furi_message_queue_put(music_player->input_queue, input_event, 0);
     }
 }
 
@@ -225,7 +225,7 @@ static void music_player_worker_callback(
     float position,
     void* context) {
     MusicPlayer* music_player = context;
-    furi_check(osMutexAcquire(music_player->model_mutex, osWaitForever) == osOK);
+    furi_check(furi_mutex_acquire(music_player->model_mutex, FuriWaitForever) == FuriStatusOk);
 
     for(size_t i = 0; i < MUSIC_PLAYER_SEMITONE_HISTORY_SIZE - 1; i++) {
         size_t r = MUSIC_PLAYER_SEMITONE_HISTORY_SIZE - 1 - i;
@@ -243,7 +243,7 @@ static void music_player_worker_callback(
     music_player->model->semitone_history[0] = semitone;
     music_player->model->duration_history[0] = duration;
 
-    osMutexRelease(music_player->model_mutex);
+    furi_mutex_release(music_player->model_mutex);
     view_port_update(music_player->view_port);
 }
 
@@ -255,9 +255,9 @@ MusicPlayer* music_player_alloc() {
     memset(instance->model->semitone_history, 0xff, MUSIC_PLAYER_SEMITONE_HISTORY_SIZE);
     instance->model->volume = 3;
 
-    instance->model_mutex = osMutexNew(NULL);
+    instance->model_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
 
-    instance->input_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL);
+    instance->input_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
 
     instance->worker = music_player_worker_alloc();
     music_player_worker_set_volume(
@@ -282,9 +282,9 @@ void music_player_free(MusicPlayer* instance) {
 
     music_player_worker_free(instance->worker);
 
-    osMessageQueueDelete(instance->input_queue);
+    furi_message_queue_free(instance->input_queue);
 
-    osMutexDelete(instance->model_mutex);
+    furi_mutex_free(instance->model_mutex);
 
     free(instance->model);
     free(instance);
@@ -327,11 +327,13 @@ int32_t music_player_app(void* p) {
         music_player_worker_start(music_player->worker);
 
         InputEvent input;
-        while(osMessageQueueGet(music_player->input_queue, &input, NULL, osWaitForever) == osOK) {
-            furi_check(osMutexAcquire(music_player->model_mutex, osWaitForever) == osOK);
+        while(furi_message_queue_get(music_player->input_queue, &input, FuriWaitForever) ==
+              FuriStatusOk) {
+            furi_check(
+                furi_mutex_acquire(music_player->model_mutex, FuriWaitForever) == FuriStatusOk);
 
             if(input.key == InputKeyBack) {
-                osMutexRelease(music_player->model_mutex);
+                furi_mutex_release(music_player->model_mutex);
                 break;
             } else if(input.key == InputKeyUp) {
                 if(music_player->model->volume < COUNT_OF(MUSIC_PLAYER_VOLUMES) - 1)
@@ -344,7 +346,7 @@ int32_t music_player_app(void* p) {
                     music_player->worker, MUSIC_PLAYER_VOLUMES[music_player->model->volume]);
             }
 
-            osMutexRelease(music_player->model_mutex);
+            furi_mutex_release(music_player->model_mutex);
             view_port_update(music_player->view_port);
         }
 

+ 1 - 1
applications/music_player/music_player_cli.c

@@ -26,7 +26,7 @@ static void music_player_cli(Cli* cli, string_t args, void* context) {
         music_player_worker_set_volume(music_player_worker, 1.0f);
         music_player_worker_start(music_player_worker);
         while(!cli_cmd_interrupt_received(cli)) {
-            osDelay(50);
+            furi_delay_ms(50);
         }
         music_player_worker_stop(music_player_worker);
     } while(0);

+ 5 - 5
applications/music_player/music_player_worker.c

@@ -51,20 +51,20 @@ static int32_t music_player_worker_thread_callback(void* context) {
     while(instance->should_work) {
         if(NoteBlockArray_end_p(it)) {
             NoteBlockArray_it(it, instance->notes);
-            osDelay(10);
+            furi_delay_ms(10);
         } else {
             NoteBlock* note_block = NoteBlockArray_ref(it);
 
             float note_from_a4 = (float)note_block->semitone - NOTE_C4_SEMITONE;
             float frequency = NOTE_C4 * powf(TWO_POW_TWELTH_ROOT, note_from_a4);
             float duration =
-                60.0 * osKernelGetTickFreq() * 4 / instance->bpm / note_block->duration;
+                60.0 * furi_kernel_get_tick_frequency() * 4 / instance->bpm / note_block->duration;
             uint32_t dots = note_block->dots;
             while(dots > 0) {
                 duration += duration / 2;
                 dots--;
             }
-            uint32_t next_tick = furi_hal_get_tick() + duration;
+            uint32_t next_tick = furi_get_tick() + duration;
             float volume = instance->volume;
 
             if(instance->callback) {
@@ -78,10 +78,10 @@ static int32_t music_player_worker_thread_callback(void* context) {
 
             furi_hal_speaker_stop();
             furi_hal_speaker_start(frequency, volume);
-            while(instance->should_work && furi_hal_get_tick() < next_tick) {
+            while(instance->should_work && furi_get_tick() < next_tick) {
                 volume *= 0.9945679;
                 furi_hal_speaker_set_volume(volume);
-                furi_hal_delay_ms(2);
+                furi_delay_ms(2);
             }
             NoteBlockArray_next(it);
         }

+ 2 - 2
applications/nfc/helpers/nfc_debug_pcap.c

@@ -77,8 +77,8 @@ static void
         .event = event,
         .len = len << 8 | len >> 8,
     };
-    xStreamBufferSend(instance->stream, &pkt_hdr, sizeof(pkt_hdr), osWaitForever);
-    xStreamBufferSend(instance->stream, data, len, osWaitForever);
+    xStreamBufferSend(instance->stream, &pkt_hdr, sizeof(pkt_hdr), FuriWaitForever);
+    xStreamBufferSend(instance->stream, data, len, FuriWaitForever);
 }
 
 static void

Некоторые файлы не были показаны из-за большого количества измененных файлов