From 0a97d6913c1a48156e3e2d8f339e027a003f948f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=81=8F?= Date: Sun, 8 Aug 2021 21:03:25 +0300 Subject: [PATCH] Rename api-hal to furi-hal (#629) --- ReadMe.md | 64 +++++ applications/accessor/accessor-app.cpp | 10 +- applications/accessor/helpers/wiegand.cpp | 2 +- applications/bt/bt.c | 38 +-- applications/bt/bt_cli.c | 26 +- applications/bt/bt_i.h | 2 +- applications/cli/cli.c | 24 +- applications/cli/cli_commands.c | 34 +-- applications/cli/cli_i.h | 2 +- applications/debug_tools/blink_test.c | 2 +- applications/debug_tools/vibro_test.c | 2 +- applications/dolphin/dolphin.c | 2 +- applications/dolphin/dolphin_i.h | 2 +- applications/dolphin/dolphin_views.c | 22 +- applications/dolphin/passport/passport.c | 4 +- applications/dolphin/scenes/scene.c | 6 +- applications/gpio-tester/gpio-tester.c | 2 +- applications/gui/canvas.c | 6 +- applications/gui/modules/button_panel.c | 2 +- applications/gui/u8g2_periphery.c | 10 +- applications/ibutton/helpers/key-reader.cpp | 4 +- applications/ibutton/helpers/key-writer.cpp | 4 +- .../ibutton/helpers/pulse-sequencer.cpp | 2 +- applications/ibutton/ibutton-app.cpp | 4 +- applications/ibutton/ibutton-cli.cpp | 2 +- applications/input/input.h | 2 +- applications/input/input_i.h | 2 +- applications/irda/cli/irda-cli.cpp | 8 +- applications/irda/scene/irda-app-scene.hpp | 2 +- applications/irda/view/irda-app-brut-view.c | 2 +- applications/irda_monitor/irda_monitor.c | 4 +- applications/lfrfid-debug/lfrfid-debug-app.h | 2 +- .../scene/lfrfid-debug-app-scene-tune.cpp | 16 +- .../lfrfid/helpers/decoder-analyzer.cpp | 2 +- .../lfrfid/helpers/decoder-emmarine.cpp | 2 +- .../lfrfid/helpers/decoder-gpio-out.cpp | 2 +- applications/lfrfid/helpers/decoder-hid26.cpp | 2 +- .../lfrfid/helpers/decoder-indala.cpp | 2 +- applications/lfrfid/helpers/rfid-reader.cpp | 24 +- .../lfrfid/helpers/rfid-timer-emulator.cpp | 18 +- .../lfrfid/helpers/rfid-timer-emulator.h | 2 +- applications/lfrfid/helpers/rfid-writer.cpp | 18 +- applications/lfrfid/lfrfid-app.cpp | 4 +- applications/lfrfid/lfrfid-app.h | 2 +- applications/lfrfid/lfrfid-cli.cpp | 2 +- applications/loader/loader.c | 6 +- applications/loader/loader_i.h | 2 +- applications/music-player/music-player.c | 2 +- applications/nfc/nfc.c | 2 +- applications/nfc/nfc_cli.c | 20 +- applications/nfc/nfc_worker.c | 106 +++---- .../notification/notification-app-api.c | 2 +- applications/notification/notification-app.c | 12 +- applications/notification/notification-app.h | 2 +- applications/power-observer/power-observer.c | 4 +- applications/power/power.c | 42 +-- applications/power/power_cli.c | 14 +- applications/scened-app-example/scened-app.h | 2 +- .../storage-settings-scene-internal-info.c | 4 +- applications/storage/storage-cli.c | 4 +- applications/storage/storage-glue.c | 6 +- applications/storage/storage-test-app.c | 2 +- applications/storage/storages/storage-ext.c | 4 +- applications/storage/storages/storage-int.c | 26 +- applications/subghz/subghz_cli.c | 64 ++--- applications/subghz/subghz_i.h | 2 +- applications/subghz/views/subghz_capture.c | 28 +- applications/subghz/views/subghz_static.c | 18 +- applications/subghz/views/subghz_test_basic.c | 38 +-- .../subghz/views/subghz_test_packet.c | 50 ++-- applications/tests/furi_valuemutex_test.c | 2 +- applications/tests/test_index.c | 2 +- bootloader/Makefile | 2 +- bootloader/targets/f6/api-hal/api-hal.c | 6 - bootloader/targets/f6/api-hal/api-hal.h | 6 - .../api-hal-i2c.c => furi-hal/furi-hal-i2c.c} | 14 +- .../api-hal-i2c.h => furi-hal/furi-hal-i2c.h} | 12 +- .../furi-hal-light.c} | 6 +- .../furi-hal-light.h} | 6 +- .../furi-hal-resources.h} | 0 bootloader/targets/f6/furi-hal/furi-hal.c | 6 + bootloader/targets/f6/furi-hal/furi-hal.h | 6 + bootloader/targets/f6/target.c | 34 +-- bootloader/targets/f6/target.mk | 4 +- .../target.h | 0 core/core.mk | 2 +- core/flipper.c | 6 +- .../{api-hal => furi-hal}/api-interrupt-mgr.c | 0 .../{api-hal => furi-hal}/api-interrupt-mgr.h | 0 core/{api-hal => furi-hal}/api-spi.h | 0 core/furi.h | 4 +- core/furi/check.c | 2 +- core/furi/stdglue.c | 4 +- firmware/Makefile | 2 +- firmware/ReadMe.md | 4 +- .../targets/api-hal-include/api-hal-boot.h | 34 --- .../targets/api-hal-include/api-hal-ibutton.h | 20 -- .../targets/api-hal-include/api-hal-nfc.h | 66 ----- .../targets/api-hal-include/api-hal-version.h | 90 ------ firmware/targets/api-hal-include/api-hal.h | 32 --- firmware/targets/f6/Src/fatfs/spi_sd_hal.c | 10 +- .../targets/f6/Src/fatfs/stm32_adafruit_sd.c | 20 +- firmware/targets/f6/Src/fatfs/user_diskio.c | 28 +- firmware/targets/f6/Src/main.c | 6 +- firmware/targets/f6/Src/usbd_cdc_if.c | 20 +- firmware/targets/f6/Src/usbd_desc.c | 8 +- firmware/targets/f6/api-hal/api-hal-clock.h | 10 - firmware/targets/f6/api-hal/api-hal-flash.c | 88 ------ .../targets/f6/api-hal/api-hal-os-timer.h | 64 ----- .../targets/f6/api-hal/api-hal-spi-config.h | 67 ----- firmware/targets/f6/api-hal/api-hal-vcp.c | 106 ------- firmware/targets/f6/api-hal/api-hal-version.c | 242 ---------------- firmware/targets/f6/ble-glue/app_ble.c | 10 +- firmware/targets/f6/ble-glue/app_debug.c | 4 +- firmware/targets/f6/ble-glue/app_entry.c | 6 +- firmware/targets/f6/ble-glue/dis_app.c | 4 +- firmware/targets/f6/ble-glue/tl_dbg_conf.h | 8 +- .../furi-hal-boot.c} | 14 +- .../api-hal-bt.c => furi-hal/furi-hal-bt.c} | 36 +-- .../furi-hal-clock.c} | 8 +- firmware/targets/f6/furi-hal/furi-hal-clock.h | 10 + .../furi-hal-console.c} | 12 +- .../furi-hal-console.h} | 4 +- .../furi-hal-delay.c} | 4 +- firmware/targets/f6/furi-hal/furi-hal-flash.c | 88 ++++++ .../furi-hal-flash.h} | 24 +- .../furi-hal-gpio.c} | 6 +- .../furi-hal-gpio.h} | 0 .../api-hal-i2c.c => furi-hal/furi-hal-i2c.c} | 32 +-- .../furi-hal-ibutton.c} | 18 +- .../furi-hal-interrupt.c} | 76 ++--- .../furi-hal-interrupt.h} | 8 +- .../furi-hal-irda.c} | 222 +++++++-------- .../furi-hal-light.c} | 6 +- .../api-hal-nfc.c => furi-hal/furi-hal-nfc.c} | 28 +- .../targets/f6/furi-hal/furi-hal-os-timer.h | 64 +++++ .../api-hal-os.c => furi-hal/furi-hal-os.c} | 76 ++--- .../api-hal-os.h => furi-hal/furi-hal-os.h} | 2 +- .../furi-hal-power.c} | 98 +++---- .../api-hal-pwm.c => furi-hal/furi-hal-pwm.c} | 2 +- .../api-hal-pwm.h => furi-hal/furi-hal-pwm.h} | 0 .../furi-hal-resources.c} | 2 +- .../furi-hal-resources.h} | 0 .../furi-hal-rfid.c} | 52 ++-- .../api-hal-sd.c => furi-hal/furi-hal-sd.c} | 2 +- .../furi-hal-spi-config.c} | 30 +- .../targets/f6/furi-hal/furi-hal-spi-config.h | 67 +++++ .../api-hal-spi.c => furi-hal/furi-hal-spi.c} | 48 ++-- .../api-hal-spi.h => furi-hal/furi-hal-spi.h} | 34 +-- .../furi-hal-subghz.c} | 268 +++++++++--------- .../furi-hal-task.c} | 2 +- .../furi-hal-task.h} | 0 firmware/targets/f6/furi-hal/furi-hal-vcp.c | 106 +++++++ .../targets/f6/furi-hal/furi-hal-version.c | 242 ++++++++++++++++ .../furi-hal-vibro.c} | 8 +- .../api-hal.c => furi-hal/furi-hal.c} | 34 +-- firmware/targets/f6/target.mk | 18 +- .../targets/furi-hal-include/furi-hal-boot.h | 34 +++ .../furi-hal-bt.h} | 30 +- .../furi-hal-delay.h} | 2 +- .../furi-hal-i2c.h} | 20 +- .../furi-hal-include/furi-hal-ibutton.h | 20 ++ .../furi-hal-irda.h} | 54 ++-- .../furi-hal-light.h} | 6 +- .../targets/furi-hal-include/furi-hal-nfc.h | 66 +++++ .../furi-hal-power.h} | 58 ++-- .../furi-hal-rfid.h} | 32 +-- .../furi-hal-sd.h} | 0 .../furi-hal-subghz.h} | 70 ++--- .../furi-hal-vcp.h} | 8 +- .../furi-hal-include/furi-hal-version.h | 90 ++++++ .../furi-hal-vibro.h} | 6 +- firmware/targets/furi-hal-include/furi-hal.h | 32 +++ lib/ST25RFAL002/platform.c | 14 +- lib/ST25RFAL002/platform.h | 6 +- lib/app-template/app-template.h | 2 +- lib/cyfral/cyfral_emulator.h | 2 +- lib/drivers/bq25896.c | 10 +- lib/drivers/bq27220.c | 20 +- lib/drivers/cc1101.c | 56 ++-- lib/drivers/cc1101.h | 86 +++--- lib/drivers/lp5562.c | 6 +- lib/irda/encoder_decoder/irda.c | 2 +- lib/irda/worker/irda_transmit.c | 40 +-- lib/irda/worker/irda_transmit.h | 2 +- lib/irda/worker/irda_worker.c | 16 +- lib/irda/worker/irda_worker.h | 6 +- lib/onewire/blanks_writer.cpp | 2 +- lib/onewire/one_wire_master.h | 2 +- lib/onewire/one_wire_slave.h | 2 +- lib/subghz/protocols/subghz_protocol_common.h | 2 +- lib/subghz/subghz_worker.h | 2 +- 192 files changed, 2276 insertions(+), 2212 deletions(-) delete mode 100644 bootloader/targets/f6/api-hal/api-hal.c delete mode 100644 bootloader/targets/f6/api-hal/api-hal.h rename bootloader/targets/f6/{api-hal/api-hal-i2c.c => furi-hal/furi-hal-i2c.c} (92%) rename bootloader/targets/f6/{api-hal/api-hal-i2c.h => furi-hal/furi-hal-i2c.h} (78%) rename bootloader/targets/f6/{api-hal/api-hal-light.c => furi-hal/furi-hal-light.c} (91%) rename bootloader/targets/f6/{api-hal/api-hal-light.h => furi-hal/furi-hal-light.h} (52%) rename bootloader/targets/f6/{api-hal/api-hal-resources.h => furi-hal/furi-hal-resources.h} (100%) create mode 100644 bootloader/targets/f6/furi-hal/furi-hal.c create mode 100644 bootloader/targets/f6/furi-hal/furi-hal.h rename bootloader/targets/{api-hal-include => furi-hal-include}/target.h (100%) rename core/{api-hal => furi-hal}/api-interrupt-mgr.c (100%) rename core/{api-hal => furi-hal}/api-interrupt-mgr.h (100%) rename core/{api-hal => furi-hal}/api-spi.h (100%) delete mode 100644 firmware/targets/api-hal-include/api-hal-boot.h delete mode 100644 firmware/targets/api-hal-include/api-hal-ibutton.h delete mode 100644 firmware/targets/api-hal-include/api-hal-nfc.h delete mode 100644 firmware/targets/api-hal-include/api-hal-version.h delete mode 100644 firmware/targets/api-hal-include/api-hal.h delete mode 100644 firmware/targets/f6/api-hal/api-hal-clock.h delete mode 100644 firmware/targets/f6/api-hal/api-hal-flash.c delete mode 100644 firmware/targets/f6/api-hal/api-hal-os-timer.h delete mode 100644 firmware/targets/f6/api-hal/api-hal-spi-config.h delete mode 100644 firmware/targets/f6/api-hal/api-hal-vcp.c delete mode 100644 firmware/targets/f6/api-hal/api-hal-version.c rename firmware/targets/f6/{api-hal/api-hal-boot.c => furi-hal/furi-hal-boot.c} (66%) rename firmware/targets/f6/{api-hal/api-hal-bt.c => furi-hal/furi-hal-bt.c} (80%) rename firmware/targets/f6/{api-hal/api-hal-clock.c => furi-hal/furi-hal-clock.c} (97%) create mode 100644 firmware/targets/f6/furi-hal/furi-hal-clock.h rename firmware/targets/f6/{api-hal/api-hal-console.c => furi-hal/furi-hal-console.c} (86%) rename firmware/targets/f6/{api-hal/api-hal-console.h => furi-hal/furi-hal-console.h} (55%) rename firmware/targets/f6/{api-hal/api-hal-delay.c => furi-hal/furi-hal-delay.c} (92%) create mode 100644 firmware/targets/f6/furi-hal/furi-hal-flash.c rename firmware/targets/f6/{api-hal/api-hal-flash.h => furi-hal/furi-hal-flash.h} (67%) rename firmware/targets/f6/{api-hal/api-hal-gpio.c => furi-hal/furi-hal-gpio.c} (98%) rename firmware/targets/f6/{api-hal/api-hal-gpio.h => furi-hal/furi-hal-gpio.h} (100%) rename firmware/targets/f6/{api-hal/api-hal-i2c.c => furi-hal/furi-hal-i2c.c} (83%) rename firmware/targets/f6/{api-hal/api-hal-ibutton.c => furi-hal/furi-hal-ibutton.c} (50%) rename firmware/targets/f6/{api-hal/api-hal-interrupt.c => furi-hal/furi-hal-interrupt.c} (57%) rename firmware/targets/f6/{api-hal/api-hal-interrupt.h => furi-hal/furi-hal-interrupt.h} (71%) rename firmware/targets/f6/{api-hal/api-hal-irda.c => furi-hal/furi-hal-irda.c} (71%) rename firmware/targets/f6/{api-hal/api-hal-light.c => furi-hal/furi-hal-light.c} (91%) rename firmware/targets/f6/{api-hal/api-hal-nfc.c => furi-hal/furi-hal-nfc.c} (86%) create mode 100644 firmware/targets/f6/furi-hal/furi-hal-os-timer.h rename firmware/targets/f6/{api-hal/api-hal-os.c => furi-hal/furi-hal-os.c} (55%) rename firmware/targets/f6/{api-hal/api-hal-os.h => furi-hal/furi-hal-os.h} (83%) rename firmware/targets/f6/{api-hal/api-hal-power.c => furi-hal/furi-hal-power.c} (73%) rename firmware/targets/f6/{api-hal/api-hal-pwm.c => furi-hal/furi-hal-pwm.c} (98%) rename firmware/targets/f6/{api-hal/api-hal-pwm.h => furi-hal/furi-hal-pwm.h} (100%) rename firmware/targets/f6/{api-hal/api-hal-resources.c => furi-hal/furi-hal-resources.c} (98%) rename firmware/targets/f6/{api-hal/api-hal-resources.h => furi-hal/furi-hal-resources.h} (100%) rename firmware/targets/f6/{api-hal/api-hal-rfid.c => furi-hal/furi-hal-rfid.c} (88%) rename firmware/targets/f6/{api-hal/api-hal-sd.c => furi-hal/furi-hal-sd.c} (96%) rename firmware/targets/f6/{api-hal/api-hal-spi-config.c => furi-hal/furi-hal-spi-config.c} (75%) create mode 100644 firmware/targets/f6/furi-hal/furi-hal-spi-config.h rename firmware/targets/f6/{api-hal/api-hal-spi.c => furi-hal/furi-hal-spi.c} (64%) rename firmware/targets/f6/{api-hal/api-hal-spi.h => furi-hal/furi-hal-spi.h} (60%) rename firmware/targets/f6/{api-hal/api-hal-subghz.c => furi-hal/furi-hal-subghz.c} (60%) rename firmware/targets/f6/{api-hal/api-hal-task.c => furi-hal/furi-hal-task.c} (98%) rename firmware/targets/f6/{api-hal/api-hal-task.h => furi-hal/furi-hal-task.h} (100%) create mode 100644 firmware/targets/f6/furi-hal/furi-hal-vcp.c create mode 100644 firmware/targets/f6/furi-hal/furi-hal-version.c rename firmware/targets/f6/{api-hal/api-hal-vibro.c => furi-hal/furi-hal-vibro.c} (63%) rename firmware/targets/f6/{api-hal/api-hal.c => furi-hal/furi-hal.c} (71%) create mode 100644 firmware/targets/furi-hal-include/furi-hal-boot.h rename firmware/targets/{api-hal-include/api-hal-bt.h => furi-hal-include/furi-hal-bt.h} (54%) rename firmware/targets/{api-hal-include/api-hal-delay.h => furi-hal-include/furi-hal-delay.h} (89%) rename firmware/targets/{api-hal-include/api-hal-i2c.h => furi-hal-include/furi-hal-i2c.h} (83%) create mode 100644 firmware/targets/furi-hal-include/furi-hal-ibutton.h rename firmware/targets/{api-hal-include/api-hal-irda.h => furi-hal-include/furi-hal-irda.h} (54%) rename firmware/targets/{api-hal-include/api-hal-light.h => furi-hal-include/furi-hal-light.h} (68%) create mode 100644 firmware/targets/furi-hal-include/furi-hal-nfc.h rename firmware/targets/{api-hal-include/api-hal-power.h => furi-hal-include/furi-hal-power.h} (51%) rename firmware/targets/{api-hal-include/api-hal-rfid.h => furi-hal-include/furi-hal-rfid.h} (64%) rename firmware/targets/{api-hal-include/api-hal-sd.h => furi-hal-include/furi-hal-sd.h} (100%) rename firmware/targets/{api-hal-include/api-hal-subghz.h => furi-hal-include/furi-hal-subghz.h} (59%) rename firmware/targets/{api-hal-include/api-hal-vcp.h => furi-hal-include/furi-hal-vcp.h} (77%) create mode 100644 firmware/targets/furi-hal-include/furi-hal-version.h rename firmware/targets/{api-hal-include/api-hal-vibro.h => furi-hal-include/furi-hal-vibro.h} (64%) create mode 100644 firmware/targets/furi-hal-include/furi-hal.h diff --git a/ReadMe.md b/ReadMe.md index 5b26bd81..07e13689 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -66,3 +66,67 @@ One liner: `./flash_core1_main.sh` * Project website: [flipperzero.one](https://flipperzero.one) * Kickstarter page: [kickstarter.com](https://www.kickstarter.com/projects/flipper-devices/flipper-zero-tamagochi-for-hackers) * Forum: [forum.flipperzero.one](https://forum.flipperzero.one/) + +# Folders structure + +- applications - application and services + * accessor - Wiegand server + * archive - Archive and file manager + * bt - BLE service and application + * cli - Console service + * debug_tools - different tools that we use on factory and for debug + * dialogs - service for showing GUI dialogs + * dolphin - dolphin service and supplientary apps + * gpio-tester - GPIO control application + * gui - GUI service + * ibutton - ibutton application, onewire keys and more + * input - input service + * irda - irda application, controls your IR devices + * irda_monitor - irda debug tool + * lfrfid - LF RFID application + * lfrfid-debug - LF RFID debug tool + * loader - application loader service + * menu - main menu service + * music-player - music player app (demo) + * nfc - NFC application, HF rfid, EMV and etc + * notification - notification service + * power - power service + * power-observer - power debug tool + * scened-app-example - c++ application example + * storage - storage service, internal + sdcard + * storage-settings - storage settings app + * subghz - subghz application, 433 fobs and etc + * tests - unit tests and etc +- assets - assets used by applications and services + * compiled - compilation results + * icons - source icons images +- bootloader - bootloader for flipper + * src - bootloader sources + * targets - targets' hal and implementation +- core - core libraries: home for furi +- debug - debug helpers, plugins and tools +- docker - docker image sources (used for automated firmware build) +- firmware - firmware for flipper + * targets - targets' hal and implementation +- lib - different libraries and drivers that apps and firmware uses + * ST25RFAL002 - ST253916 driver and NFC hal + * STM32CubeWB - STM32WB hal + * app-scened-template - scened template app library + * app-template - template app library + * callback-connector - callback connector library + * common-api - common api delaration library + * cyfral - cyfral library + * drivers - drivers that we wrote + * fatfs - external storage file system + * fnv1a-hash - fnv1a hash library + * irda - irda library + * littlefs - internal storage file system + * mlib - algorithms and containers + * nfc_protocols - nfc protocols library + * onewire - one wire library + * qrcode - qr code generator library + * subghz - subghz library + * toolbox - toolbox of things that we are using but don't place in core + * u8g2 - graphics library that we use to draw GUI +- make - make helpers +- scripts - supplimentary scripts diff --git a/applications/accessor/accessor-app.cpp b/applications/accessor/accessor-app.cpp index eb430bc3..f7446b55 100644 --- a/applications/accessor/accessor-app.cpp +++ b/applications/accessor/accessor-app.cpp @@ -1,6 +1,6 @@ #include "accessor-app.h" #include -#include +#include #include void AccessorApp::run(void) { @@ -33,16 +33,16 @@ void AccessorApp::run(void) { AccessorApp::AccessorApp() : onewire_master{&ibutton_gpio} { - api_hal_power_insomnia_enter(); + furi_hal_power_insomnia_enter(); notification = static_cast(furi_record_open("notification")); notify_init(); - api_hal_power_enable_otg(); + furi_hal_power_enable_otg(); } AccessorApp::~AccessorApp() { - api_hal_power_disable_otg(); + furi_hal_power_disable_otg(); furi_record_close("notification"); - api_hal_power_insomnia_exit(); + furi_hal_power_insomnia_exit(); } AccessorAppViewManager* AccessorApp::get_view_manager() { diff --git a/applications/accessor/helpers/wiegand.cpp b/applications/accessor/helpers/wiegand.cpp index bc618489..9e92a15d 100644 --- a/applications/accessor/helpers/wiegand.cpp +++ b/applications/accessor/helpers/wiegand.cpp @@ -1,6 +1,6 @@ #include "wiegand.h" #include -#include +#include volatile unsigned long WIEGAND::_cardTempHigh = 0; volatile unsigned long WIEGAND::_cardTemp = 0; diff --git a/applications/bt/bt.c b/applications/bt/bt.c index 7b8bbdc6..41974f65 100644 --- a/applications/bt/bt.c +++ b/applications/bt/bt.c @@ -153,24 +153,24 @@ int32_t bt_srv() { furi_record_create("bt", bt); - api_hal_bt_init(); + furi_hal_bt_init(); BtMessage message; while(1) { furi_check(osMessageQueueGet(bt->message_queue, &message, NULL, osWaitForever) == osOK); if(message.type == BtMessageTypeStartTestCarrier) { // Start carrier test - api_hal_bt_stop_tone_tx(); + furi_hal_bt_stop_tone_tx(); if(bt->state.type == BtStateCarrierTx) { - api_hal_bt_start_tone_tx(message.param.channel, message.param.power); + furi_hal_bt_start_tone_tx(message.param.channel, message.param.power); } else if(bt->state.type == BtStateHoppingTx) { bt->state.param.channel = bt_switch_channel(InputKeyRight, bt->state.param.channel); - api_hal_bt_start_tone_tx(bt->state.param.channel, bt->state.param.power); + furi_hal_bt_start_tone_tx(bt->state.param.channel, bt->state.param.power); } else if(bt->state.type == BtStateCarrierRxStart) { - api_hal_bt_start_packet_rx(bt->state.param.channel, bt->state.param.datarate); + furi_hal_bt_start_packet_rx(bt->state.param.channel, bt->state.param.datarate); bt->state.type = BtStateCarrierRxRunning; } else if(bt->state.type == BtStateCarrierRxRunning) { - bt->state.param.rssi = api_hal_bt_get_rssi(); + bt->state.param.rssi = furi_hal_bt_get_rssi(); } with_view_model( bt->view_test_carrier, (BtViewTestCarrierModel * model) { @@ -183,14 +183,14 @@ int32_t bt_srv() { view_dispatcher_switch_to_view(bt->view_dispatcher, BtViewTestCarrier); } else if(message.type == BtMessageTypeStopTestCarrier) { if(bt->state.type == BtStateCarrierRxRunning) { - api_hal_bt_stop_packet_test(); + furi_hal_bt_stop_packet_test(); } else { - api_hal_bt_stop_tone_tx(); + furi_hal_bt_stop_tone_tx(); } bt->state.type = BtStateReady; } else if(message.type == BtMessageTypeSetupTestPacketTx) { // Update packet test setup - api_hal_bt_stop_packet_test(); + furi_hal_bt_stop_packet_test(); with_view_model( bt->view_test_packet_tx, (BtViewTestPacketTxModel * model) { model->type = bt->state.type; @@ -202,10 +202,10 @@ int32_t bt_srv() { } else if(message.type == BtMessageTypeStartTestPacketTx) { // Start sending packets if(bt->state.type == BtStatePacketStart) { - api_hal_bt_start_packet_tx(message.param.channel, 1, message.param.datarate); + furi_hal_bt_start_packet_tx(message.param.channel, 1, message.param.datarate); } else if(bt->state.type == BtStatePacketSetup) { - api_hal_bt_stop_packet_test(); - bt->state.param.packets_sent = api_hal_bt_get_transmitted_packets(); + furi_hal_bt_stop_packet_test(); + bt->state.param.packets_sent = furi_hal_bt_get_transmitted_packets(); } with_view_model( bt->view_test_packet_tx, (BtViewTestPacketTxModel * model) { @@ -218,7 +218,7 @@ int32_t bt_srv() { view_dispatcher_switch_to_view(bt->view_dispatcher, BtViewTestPacketTx); } else if(message.type == BtMessageTypeSetupTestPacketRx) { // Update packet test setup - api_hal_bt_stop_packet_test(); + furi_hal_bt_stop_packet_test(); with_view_model( bt->view_test_packet_rx, (BtViewTestPacketRxModel * model) { model->type = bt->state.type; @@ -230,12 +230,12 @@ int32_t bt_srv() { } else if(message.type == BtMessageTypeStartTestPacketRx) { // Start test rx if(bt->state.type == BtStatePacketStart) { - api_hal_bt_start_packet_rx(message.param.channel, message.param.datarate); + furi_hal_bt_start_packet_rx(message.param.channel, message.param.datarate); bt->state.type = BtStatePacketRunning; } else if(bt->state.type == BtStatePacketRunning) { - bt->state.param.rssi = api_hal_bt_get_rssi(); + bt->state.param.rssi = furi_hal_bt_get_rssi(); } else if(bt->state.type == BtStatePacketSetup) { - bt->state.param.packets_received = api_hal_bt_stop_packet_test(); + bt->state.param.packets_received = furi_hal_bt_stop_packet_test(); } with_view_model( bt->view_test_packet_rx, (BtViewTestPacketRxModel * model) { @@ -249,17 +249,17 @@ int32_t bt_srv() { view_dispatcher_switch_to_view(bt->view_dispatcher, BtViewTestPacketRx); } else if(message.type == BtMessageTypeStopTestPacket) { // Stop test packet tx - api_hal_bt_stop_packet_test(); + furi_hal_bt_stop_packet_test(); bt->state.type = BtStateReady; } else if(message.type == BtMessageTypeStartApp) { // Start app view_dispatcher_switch_to_view(bt->view_dispatcher, BtViewStartApp); - if(api_hal_bt_start_app()) { + if(furi_hal_bt_start_app()) { bt->state.type = BtStateStartedApp; } } else if(message.type == BtMessageTypeUpdateStatusbar) { // Update statusbar - view_port_enabled_set(bt->statusbar_view_port, api_hal_bt_is_alive()); + view_port_enabled_set(bt->statusbar_view_port, furi_hal_bt_is_alive()); } } return 0; diff --git a/applications/bt/bt_cli.c b/applications/bt/bt_cli.c index 3c325003..47a05d06 100644 --- a/applications/bt/bt_cli.c +++ b/applications/bt/bt_cli.c @@ -1,6 +1,6 @@ #include "bt_cli.h" #include -#include +#include void bt_cli_init() { Cli* cli = furi_record_open("cli"); @@ -17,7 +17,7 @@ void bt_cli_init() { void bt_cli_command_info(Cli* cli, string_t args, void* context) { string_t buffer; string_init(buffer); - api_hal_bt_dump_state(buffer); + furi_hal_bt_dump_state(buffer); printf(string_get_cstr(buffer)); string_clear(buffer); } @@ -41,12 +41,12 @@ void bt_cli_command_carrier_tx(Cli* cli, string_t args, void* context) { } printf("Transmitting carrier at %hu channel at %hu dB power\r\n", channel, power); printf("Press CTRL+C to stop\r\n"); - api_hal_bt_start_tone_tx(channel, 0x19 + power); + furi_hal_bt_start_tone_tx(channel, 0x19 + power); while(!cli_cmd_interrupt_received(cli)) { osDelay(250); } - api_hal_bt_stop_tone_tx(); + furi_hal_bt_stop_tone_tx(); } void bt_cli_command_carrier_rx(Cli* cli, string_t args, void* context) { @@ -64,15 +64,15 @@ void bt_cli_command_carrier_rx(Cli* cli, string_t args, void* context) { printf("Receiving carrier at %hu channel\r\n", channel); printf("Press CTRL+C to stop\r\n"); - api_hal_bt_start_packet_rx(channel, 1); + furi_hal_bt_start_packet_rx(channel, 1); while(!cli_cmd_interrupt_received(cli)) { osDelay(1024 / 4); - printf("RSSI: %6.1f dB\r", api_hal_bt_get_rssi()); + printf("RSSI: %6.1f dB\r", furi_hal_bt_get_rssi()); fflush(stdout); } - api_hal_bt_stop_packet_test(); + furi_hal_bt_stop_packet_test(); } void bt_cli_command_packet_tx(Cli* cli, string_t args, void* context) { @@ -111,13 +111,13 @@ void bt_cli_command_packet_tx(Cli* cli, string_t args, void* context) { channel, datarate); printf("Press CTRL+C to stop\r\n"); - api_hal_bt_start_packet_tx(channel, pattern, datarate); + furi_hal_bt_start_packet_tx(channel, pattern, datarate); while(!cli_cmd_interrupt_received(cli)) { osDelay(250); } - api_hal_bt_stop_packet_test(); - printf("Transmitted %lu packets", api_hal_bt_get_transmitted_packets()); + furi_hal_bt_stop_packet_test(); + printf("Transmitted %lu packets", furi_hal_bt_get_transmitted_packets()); } void bt_cli_command_packet_rx(Cli* cli, string_t args, void* context) { @@ -139,15 +139,15 @@ void bt_cli_command_packet_rx(Cli* cli, string_t args, void* context) { } printf("Receiving packets at %hu channel at %hu M datarate\r\n", channel, datarate); printf("Press CTRL+C to stop\r\n"); - api_hal_bt_start_packet_rx(channel, datarate); + furi_hal_bt_start_packet_rx(channel, datarate); float rssi_raw = 0; while(!cli_cmd_interrupt_received(cli)) { osDelay(250); - rssi_raw = api_hal_bt_get_rssi(); + rssi_raw = furi_hal_bt_get_rssi(); printf("RSSI: %03.1f dB\r", rssi_raw); fflush(stdout); } - uint16_t packets_received = api_hal_bt_stop_packet_test(); + uint16_t packets_received = furi_hal_bt_stop_packet_test(); printf("Received %hu packets", packets_received); } diff --git a/applications/bt/bt_i.h b/applications/bt/bt_i.h index 8d45836b..6a5fe383 100644 --- a/applications/bt/bt_i.h +++ b/applications/bt/bt_i.h @@ -5,7 +5,7 @@ #include "bt_types.h" #include -#include +#include #include diff --git a/applications/cli/cli.c b/applications/cli/cli.c index e8567087..ab5451dc 100644 --- a/applications/cli/cli.c +++ b/applications/cli/cli.c @@ -1,7 +1,7 @@ #include "cli_i.h" #include "cli_commands.h" -#include +#include #include Cli* cli_alloc() { @@ -30,33 +30,33 @@ void cli_free(Cli* cli) { } void cli_putc(char c) { - api_hal_vcp_tx((uint8_t*)&c, 1); + furi_hal_vcp_tx((uint8_t*)&c, 1); } char cli_getc(Cli* cli) { furi_assert(cli); char c; - if(api_hal_vcp_rx((uint8_t*)&c, 1) == 0) { + if(furi_hal_vcp_rx((uint8_t*)&c, 1) == 0) { cli_reset(cli); } return c; } void cli_stdout_callback(void* _cookie, const char* data, size_t size) { - api_hal_vcp_tx((const uint8_t*)data, size); + furi_hal_vcp_tx((const uint8_t*)data, size); } void cli_write(Cli* cli, uint8_t* buffer, size_t size) { - return api_hal_vcp_tx(buffer, size); + return furi_hal_vcp_tx(buffer, size); } size_t cli_read(Cli* cli, uint8_t* buffer, size_t size) { - return api_hal_vcp_rx(buffer, size); + return furi_hal_vcp_rx(buffer, size); } bool cli_cmd_interrupt_received(Cli* cli) { char c = '\0'; - if(api_hal_vcp_rx_with_timeout((uint8_t*)&c, 1, 0) == 1) { + if(furi_hal_vcp_rx_with_timeout((uint8_t*)&c, 1, 0) == 1) { return c == CliSymbolAsciiETX; } else { return false; @@ -92,7 +92,7 @@ void cli_motd() { "Read Manual https://docs.flipperzero.one\r\n" "\r\n"); - const Version* firmware_version = api_hal_version_get_firmware_version(); + const Version* firmware_version = furi_hal_version_get_firmware_version(); if(firmware_version) { printf( "Firmware version: %s %s (%s built on %s)\r\n", @@ -143,7 +143,7 @@ static void cli_normalize_line(Cli* cli) { static void cli_execute_command(Cli* cli, CliCommand* command, string_t args) { if(!(command->flags & CliCommandFlagInsomniaSafe)) { - api_hal_power_insomnia_enter(); + furi_hal_power_insomnia_enter(); } // Ensure that we running alone @@ -164,7 +164,7 @@ static void cli_execute_command(Cli* cli, CliCommand* command, string_t args) { } if(!(command->flags & CliCommandFlagInsomniaSafe)) { - api_hal_power_insomnia_exit(); + furi_hal_power_insomnia_exit(); } } @@ -305,9 +305,9 @@ void cli_process_input(Cli* cli) { } else if(c == CliSymbolAsciiEOT) { cli_reset(cli); } else if(c == CliSymbolAsciiEsc) { - r = api_hal_vcp_rx((uint8_t*)&c, 1); + r = furi_hal_vcp_rx((uint8_t*)&c, 1); if(r && c == '[') { - api_hal_vcp_rx((uint8_t*)&c, 1); + furi_hal_vcp_rx((uint8_t*)&c, 1); cli_handle_escape(cli, c); } else { cli_putc(CliSymbolAsciiBell); diff --git a/applications/cli/cli_commands.c b/applications/cli/cli_commands.c index d23a8c59..5d1afc12 100644 --- a/applications/cli/cli_commands.c +++ b/applications/cli/cli_commands.c @@ -1,6 +1,6 @@ #include "cli_commands.h" -#include -#include +#include +#include #include #include #include @@ -14,33 +14,33 @@ */ void cli_command_device_info(Cli* cli, string_t args, void* context) { // Model name - printf("hardware_model : %s\r\n", api_hal_version_get_model_name()); - const char* name = api_hal_version_get_name_ptr(); + printf("hardware_model : %s\r\n", furi_hal_version_get_model_name()); + const char* name = furi_hal_version_get_name_ptr(); if(name) { printf("hardware_name : %s\r\n", name); } // Unique ID printf("hardware_uid : "); - const uint8_t* uid = api_hal_version_uid(); - for(size_t i = 0; i < api_hal_version_uid_size(); i++) { + const uint8_t* uid = furi_hal_version_uid(); + for(size_t i = 0; i < furi_hal_version_uid_size(); i++) { printf("%02X", uid[i]); } printf("\r\n"); // Board Revision - printf("hardware_ver : %d\r\n", api_hal_version_get_hw_version()); - printf("hardware_target : %d\r\n", api_hal_version_get_hw_target()); - printf("hardware_body : %d\r\n", api_hal_version_get_hw_body()); - printf("hardware_connect : %d\r\n", api_hal_version_get_hw_connect()); - printf("hardware_timestamp : %lu\r\n", api_hal_version_get_hw_timestamp()); + printf("hardware_ver : %d\r\n", furi_hal_version_get_hw_version()); + printf("hardware_target : %d\r\n", furi_hal_version_get_hw_target()); + printf("hardware_body : %d\r\n", furi_hal_version_get_hw_body()); + printf("hardware_connect : %d\r\n", furi_hal_version_get_hw_connect()); + printf("hardware_timestamp : %lu\r\n", furi_hal_version_get_hw_timestamp()); // Color and Region - printf("hardware_color : %d\r\n", api_hal_version_get_hw_color()); - printf("hardware_region : %d\r\n", api_hal_version_get_hw_region()); + printf("hardware_color : %d\r\n", furi_hal_version_get_hw_color()); + printf("hardware_region : %d\r\n", furi_hal_version_get_hw_region()); // Bootloader Version - const Version* boot_version = api_hal_version_get_boot_version(); + const Version* boot_version = furi_hal_version_get_boot_version(); if(boot_version) { printf("boot_version : %s\r\n", version_get_version(boot_version)); printf("boot_commit : %s\r\n", version_get_githash(boot_version)); @@ -49,7 +49,7 @@ void cli_command_device_info(Cli* cli, string_t args, void* context) { } // Firmware version - const Version* firmware_version = api_hal_version_get_firmware_version(); + const Version* firmware_version = furi_hal_version_get_firmware_version(); if(firmware_version) { printf("firmware_version : %s\r\n", version_get_version(firmware_version)); printf("firmware_commit : %s\r\n", version_get_githash(firmware_version)); @@ -58,7 +58,7 @@ void cli_command_device_info(Cli* cli, string_t args, void* context) { } WirelessFwInfo_t pWirelessInfo; - if(api_hal_bt_is_alive() && SHCI_GetWirelessFwInfo(&pWirelessInfo) == SHCI_Success) { + if(furi_hal_bt_is_alive() && SHCI_GetWirelessFwInfo(&pWirelessInfo) == SHCI_Success) { printf("radio_alive : true\r\n"); // FUS Info printf("radio_fus_major : %d\r\n", pWirelessInfo.FusVersionMajor); @@ -80,7 +80,7 @@ void cli_command_device_info(Cli* cli, string_t args, void* context) { printf("radio_stack_flash : %dK\r\n", pWirelessInfo.MemorySizeFlash * 4); // Mac address printf("radio_ble_mac : "); - const uint8_t* ble_mac = api_hal_version_get_ble_mac(); + const uint8_t* ble_mac = furi_hal_version_get_ble_mac(); for(size_t i = 0; i < 6; i++) { printf("%02X", ble_mac[i]); } diff --git a/applications/cli/cli_i.h b/applications/cli/cli_i.h index e60fa450..b0ab6384 100755 --- a/applications/cli/cli_i.h +++ b/applications/cli/cli_i.h @@ -3,7 +3,7 @@ #include "cli.h" #include -#include +#include #include #include diff --git a/applications/debug_tools/blink_test.c b/applications/debug_tools/blink_test.c index 26f4c6d4..cc41c188 100644 --- a/applications/debug_tools/blink_test.c +++ b/applications/debug_tools/blink_test.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/applications/debug_tools/vibro_test.c b/applications/debug_tools/vibro_test.c index e756be24..b5e9be63 100644 --- a/applications/debug_tools/vibro_test.c +++ b/applications/debug_tools/vibro_test.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/applications/dolphin/dolphin.c b/applications/dolphin/dolphin.c index 2dcd13ef..705ed808 100644 --- a/applications/dolphin/dolphin.c +++ b/applications/dolphin/dolphin.c @@ -411,7 +411,7 @@ int32_t dolphin_srv() { furi_record_create("dolphin", dolphin); - if(!api_hal_version_do_i_belong_here()) { + if(!furi_hal_version_do_i_belong_here()) { view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewHwMismatch); } diff --git a/applications/dolphin/dolphin_i.h b/applications/dolphin/dolphin_i.h index ccddf802..3f47e2c3 100644 --- a/applications/dolphin/dolphin_i.h +++ b/applications/dolphin/dolphin_i.h @@ -5,7 +5,7 @@ #include "dolphin_views.h" #include -#include +#include #include #include #include diff --git a/applications/dolphin/dolphin_views.c b/applications/dolphin/dolphin_views.c index 30c15ead..8953fe3a 100644 --- a/applications/dolphin/dolphin_views.c +++ b/applications/dolphin/dolphin_views.c @@ -2,8 +2,8 @@ #include #include #include -#include -#include +#include +#include static char* Lockmenu_Items[3] = {"Lock", "Set PIN", "DUMB mode"}; @@ -14,7 +14,7 @@ void dolphin_view_first_start_draw(Canvas* canvas, void* model) { canvas_set_font(canvas, FontSecondary); uint8_t width = canvas_width(canvas); uint8_t height = canvas_height(canvas); - const char* my_name = api_hal_version_get_name_ptr(); + const char* my_name = furi_hal_version_get_name_ptr(); if(m->page == 0) { canvas_draw_icon(canvas, 0, height - 48, &I_DolphinFirstStart0_70x53); elements_multiline_text_framed(canvas, 75, 20, "Hey m8,\npress > to\ncontinue"); @@ -119,20 +119,20 @@ void dolphin_view_idle_down_draw(Canvas* canvas, void* model) { if(m->screen != DolphinViewStatsMeta) { // Hardware version - const char* my_name = api_hal_version_get_name_ptr(); + const char* my_name = furi_hal_version_get_name_ptr(); snprintf( buffer, sizeof(buffer), "HW: %d.F%dB%dC%d %s", - api_hal_version_get_hw_version(), - api_hal_version_get_hw_target(), - api_hal_version_get_hw_body(), - api_hal_version_get_hw_connect(), + furi_hal_version_get_hw_version(), + furi_hal_version_get_hw_target(), + furi_hal_version_get_hw_body(), + furi_hal_version_get_hw_connect(), my_name ? my_name : "Unknown"); canvas_draw_str(canvas, 5, 23, buffer); - ver = m->screen == DolphinViewStatsBoot ? api_hal_version_get_boot_version() : - api_hal_version_get_firmware_version(); + ver = m->screen == DolphinViewStatsBoot ? furi_hal_version_get_boot_version() : + furi_hal_version_get_firmware_version(); if(!ver) { canvas_draw_str(canvas, 5, 33, "No info"); @@ -178,7 +178,7 @@ void dolphin_view_hw_mismatch_draw(Canvas* canvas, void* model) { char buffer[64]; canvas_set_font(canvas, FontSecondary); - snprintf(buffer, 64, "HW target: F%d", api_hal_version_get_hw_target()); + snprintf(buffer, 64, "HW target: F%d", furi_hal_version_get_hw_target()); canvas_draw_str(canvas, 5, 27, buffer); canvas_draw_str(canvas, 5, 38, "FW target: " TARGET); } diff --git a/applications/dolphin/passport/passport.c b/applications/dolphin/passport/passport.c index 9b1cae04..de4b1966 100644 --- a/applications/dolphin/passport/passport.c +++ b/applications/dolphin/passport/passport.c @@ -1,6 +1,6 @@ #include #include -#include +#include #include "dolphin/dolphin.h" #include "dolphin/dolphin_state.h" #include "math.h" @@ -80,7 +80,7 @@ static void render_callback(Canvas* canvas, void* ctx) { canvas_draw_line(canvas, 59, 31, 124, 31); canvas_draw_line(canvas, 59, 44, 124, 44); - const char* my_name = api_hal_version_get_name_ptr(); + const char* my_name = furi_hal_version_get_name_ptr(); canvas_draw_str(canvas, 59, 15, my_name ? my_name : "Unknown"); snprintf(level, 20, "Level: %ld", current_level); diff --git a/applications/dolphin/scenes/scene.c b/applications/dolphin/scenes/scene.c index ed15592a..13c0cff0 100644 --- a/applications/dolphin/scenes/scene.c +++ b/applications/dolphin/scenes/scene.c @@ -1,5 +1,5 @@ #include -#include +#include #include "scene.h" static SceneAppGui* scene_app_gui = NULL; @@ -109,7 +109,7 @@ void scene_free() { } int32_t scene_app(void* p) { - api_hal_power_insomnia_enter(); + furi_hal_power_insomnia_enter(); scene_alloc(); osTimerStart(scene_app_gui->timer, 40); @@ -146,6 +146,6 @@ int32_t scene_app(void* p) { osDelay(15); scene_free(); - api_hal_power_insomnia_exit(); + furi_hal_power_insomnia_exit(); return 0; } \ No newline at end of file diff --git a/applications/gpio-tester/gpio-tester.c b/applications/gpio-tester/gpio-tester.c index 2ac741cc..4d079632 100644 --- a/applications/gpio-tester/gpio-tester.c +++ b/applications/gpio-tester/gpio-tester.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/applications/gui/canvas.c b/applications/gui/canvas.c index 3e4d0d85..49907732 100644 --- a/applications/gui/canvas.c +++ b/applications/gui/canvas.c @@ -3,7 +3,7 @@ #include "icon_animation_i.h" #include -#include +#include uint8_t u8g2_gpio_and_delay_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr); uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr); @@ -11,7 +11,7 @@ uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ Canvas* canvas_init() { Canvas* canvas = furi_alloc(sizeof(Canvas)); - api_hal_power_insomnia_enter(); + furi_hal_power_insomnia_enter(); canvas->orientation = CanvasOrientationHorizontal; u8g2_Setup_st7565_erc12864_alt_f( @@ -24,7 +24,7 @@ Canvas* canvas_init() { u8g2_SetPowerSave(&canvas->fb, 0); u8g2_SendBuffer(&canvas->fb); - api_hal_power_insomnia_exit(); + furi_hal_power_insomnia_exit(); return canvas; } diff --git a/applications/gui/modules/button_panel.c b/applications/gui/modules/button_panel.c index 7bb5cf05..b4cffe05 100644 --- a/applications/gui/modules/button_panel.c +++ b/applications/gui/modules/button_panel.c @@ -1,5 +1,5 @@ #include "button_panel.h" -#include "api-hal-resources.h" +#include "furi-hal-resources.h" #include "gui/canvas.h" #include #include diff --git a/applications/gui/u8g2_periphery.c b/applications/gui/u8g2_periphery.c index e738ec18..6740b82b 100644 --- a/applications/gui/u8g2_periphery.c +++ b/applications/gui/u8g2_periphery.c @@ -1,8 +1,8 @@ #include "u8g2/u8g2.h" -#include +#include #include -static ApiHalSpiDevice* u8g2_periphery_display = NULL; +static FuriHalSpiDevice* u8g2_periphery_display = NULL; uint8_t u8g2_gpio_and_delay_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr) { switch(msg) { @@ -36,7 +36,7 @@ uint8_t u8g2_gpio_and_delay_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, vo uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr) { switch(msg) { case U8X8_MSG_BYTE_SEND: - api_hal_spi_bus_tx(u8g2_periphery_display->bus, (uint8_t*)arg_ptr, arg_int, 10000); + furi_hal_spi_bus_tx(u8g2_periphery_display->bus, (uint8_t*)arg_ptr, arg_int, 10000); break; case U8X8_MSG_BYTE_SET_DC: @@ -49,14 +49,14 @@ uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ case U8X8_MSG_BYTE_START_TRANSFER: furi_assert(u8g2_periphery_display == NULL); u8g2_periphery_display = - (ApiHalSpiDevice*)api_hal_spi_device_get(ApiHalSpiDeviceIdDisplay); + (FuriHalSpiDevice*)furi_hal_spi_device_get(FuriHalSpiDeviceIdDisplay); hal_gpio_write(u8g2_periphery_display->chip_select, false); break; case U8X8_MSG_BYTE_END_TRANSFER: furi_assert(u8g2_periphery_display); hal_gpio_write(u8g2_periphery_display->chip_select, true); - api_hal_spi_device_return(u8g2_periphery_display); + furi_hal_spi_device_return(u8g2_periphery_display); u8g2_periphery_display = NULL; break; diff --git a/applications/ibutton/helpers/key-reader.cpp b/applications/ibutton/helpers/key-reader.cpp index f5885870..91ada058 100644 --- a/applications/ibutton/helpers/key-reader.cpp +++ b/applications/ibutton/helpers/key-reader.cpp @@ -183,12 +183,12 @@ void KeyReader::switch_mode_if_needed() { } void KeyReader::start() { - api_hal_power_enable_otg(); + furi_hal_power_enable_otg(); switch_to(ReadMode::CYFRAL_METAKOM); } void KeyReader::stop() { - api_hal_power_disable_otg(); + furi_hal_power_disable_otg(); onewire_master->stop(); stop_comaparator(); } diff --git a/applications/ibutton/helpers/key-writer.cpp b/applications/ibutton/helpers/key-writer.cpp index a39a7f7c..428be8f1 100644 --- a/applications/ibutton/helpers/key-writer.cpp +++ b/applications/ibutton/helpers/key-writer.cpp @@ -14,12 +14,12 @@ KeyWriter::Error KeyWriter::write(iButtonKey* key) { } void KeyWriter::start() { - api_hal_power_enable_otg(); + furi_hal_power_enable_otg(); onewire_master->start(); } void KeyWriter::stop() { - api_hal_power_disable_otg(); + furi_hal_power_disable_otg(); onewire_master->stop(); } diff --git a/applications/ibutton/helpers/pulse-sequencer.cpp b/applications/ibutton/helpers/pulse-sequencer.cpp index c7637b4d..21818a3b 100644 --- a/applications/ibutton/helpers/pulse-sequencer.cpp +++ b/applications/ibutton/helpers/pulse-sequencer.cpp @@ -1,7 +1,7 @@ #include "pulse-sequencer.h" #include #include -#include +#include void PulseSequencer::set_periods( uint32_t* _periods, diff --git a/applications/ibutton/ibutton-app.cpp b/applications/ibutton/ibutton-app.cpp index 082c2673..651d754d 100644 --- a/applications/ibutton/ibutton-app.cpp +++ b/applications/ibutton/ibutton-app.cpp @@ -38,7 +38,7 @@ void iButtonApp::run(void* args) { iButtonApp::iButtonApp() : notification{"notification"} { - api_hal_power_insomnia_enter(); + furi_hal_power_insomnia_enter(); key_worker = new KeyWorker(&ibutton_gpio); } @@ -49,7 +49,7 @@ iButtonApp::~iButtonApp() { } delete key_worker; - api_hal_power_insomnia_exit(); + furi_hal_power_insomnia_exit(); } iButtonAppViewManager* iButtonApp::get_view_manager() { diff --git a/applications/ibutton/ibutton-cli.cpp b/applications/ibutton/ibutton-cli.cpp index 7602d46d..f865a26e 100644 --- a/applications/ibutton/ibutton-cli.cpp +++ b/applications/ibutton/ibutton-cli.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/applications/input/input.h b/applications/input/input.h index 3e855eec..1ad82555 100644 --- a/applications/input/input.h +++ b/applications/input/input.h @@ -1,6 +1,6 @@ #pragma once -#include +#include /* Input Types * Some of them are physical events and some logical diff --git a/applications/input/input_i.h b/applications/input/input_i.h index a3262fc4..a0f6cfc3 100644 --- a/applications/input/input_i.h +++ b/applications/input/input_i.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include #define INPUT_DEBOUNCE_TICKS_HALF (INPUT_DEBOUNCE_TICKS / 2) #define INPUT_PRESS_TICKS 150 diff --git a/applications/irda/cli/irda-cli.cpp b/applications/irda/cli/irda-cli.cpp index 07aef327..0a28dd9a 100644 --- a/applications/irda/cli/irda-cli.cpp +++ b/applications/irda/cli/irda-cli.cpp @@ -1,11 +1,11 @@ -#include +#include #include #include #include #include #include #include -#include +#include #include #include #include @@ -48,7 +48,7 @@ static void signal_received_callback(void* context, IrdaWorkerSignal* received_s } static void irda_cli_start_ir_rx(Cli* cli, string_t args, void* context) { - if(api_hal_irda_is_busy()) { + if(furi_hal_irda_is_busy()) { printf("IRDA is busy. Exit."); return; } @@ -142,7 +142,7 @@ static bool parse_signal_raw( } static void irda_cli_start_ir_tx(Cli* cli, string_t args, void* context) { - if(api_hal_irda_is_busy()) { + if(furi_hal_irda_is_busy()) { printf("IRDA is busy. Exit."); return; } diff --git a/applications/irda/scene/irda-app-scene.hpp b/applications/irda/scene/irda-app-scene.hpp index 3b110901..da80acfa 100644 --- a/applications/irda/scene/irda-app-scene.hpp +++ b/applications/irda/scene/irda-app-scene.hpp @@ -1,6 +1,6 @@ #pragma once #include "../irda-app-event.hpp" -#include +#include #include "irda.h" #include #include diff --git a/applications/irda/view/irda-app-brut-view.c b/applications/irda/view/irda-app-brut-view.c index 8d53f90e..56936383 100644 --- a/applications/irda/view/irda-app-brut-view.c +++ b/applications/irda/view/irda-app-brut-view.c @@ -1,4 +1,4 @@ -#include "api-hal-resources.h" +#include "furi-hal-resources.h" #include "assets_icons.h" #include "gui/canvas.h" #include "gui/view.h" diff --git a/applications/irda_monitor/irda_monitor.c b/applications/irda_monitor/irda_monitor.c index 56a81a3f..8e3098cd 100644 --- a/applications/irda_monitor/irda_monitor.c +++ b/applications/irda_monitor/irda_monitor.c @@ -4,8 +4,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/applications/lfrfid-debug/lfrfid-debug-app.h b/applications/lfrfid-debug/lfrfid-debug-app.h index fab9fa9a..e9494719 100644 --- a/applications/lfrfid-debug/lfrfid-debug-app.h +++ b/applications/lfrfid-debug/lfrfid-debug-app.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include #include diff --git a/applications/lfrfid-debug/scene/lfrfid-debug-app-scene-tune.cpp b/applications/lfrfid-debug/scene/lfrfid-debug-app-scene-tune.cpp index 1d5c885d..fea0e586 100644 --- a/applications/lfrfid-debug/scene/lfrfid-debug-app-scene-tune.cpp +++ b/applications/lfrfid-debug/scene/lfrfid-debug-app-scene-tune.cpp @@ -3,9 +3,9 @@ void LfRfidDebugAppSceneTune::on_enter(LfRfidDebugApp* app, bool need_restore) { app->view_controller.switch_to(); - api_hal_rfid_pins_read(); - api_hal_rfid_tim_read(125000, 0.5); - api_hal_rfid_tim_read_start(); + furi_hal_rfid_pins_read(); + furi_hal_rfid_tim_read(125000, 0.5); + furi_hal_rfid_tim_read_start(); } bool LfRfidDebugAppSceneTune::on_event(LfRfidDebugApp* app, LfRfidDebugApp::Event* event) { @@ -14,15 +14,15 @@ bool LfRfidDebugAppSceneTune::on_event(LfRfidDebugApp* app, LfRfidDebugApp::Even LfRfidViewTuneVM* tune = app->view_controller; if(tune->is_dirty()) { - api_hal_rfid_set_read_period(tune->get_ARR()); - api_hal_rfid_set_read_pulse(tune->get_CCR()); + furi_hal_rfid_set_read_period(tune->get_ARR()); + furi_hal_rfid_set_read_pulse(tune->get_CCR()); } return consumed; } void LfRfidDebugAppSceneTune::on_exit(LfRfidDebugApp* app) { - api_hal_rfid_tim_read_stop(); - api_hal_rfid_tim_reset(); - api_hal_rfid_pins_reset(); + furi_hal_rfid_tim_read_stop(); + furi_hal_rfid_tim_reset(); + furi_hal_rfid_pins_reset(); } \ No newline at end of file diff --git a/applications/lfrfid/helpers/decoder-analyzer.cpp b/applications/lfrfid/helpers/decoder-analyzer.cpp index d3ee90ba..501f3f8d 100644 --- a/applications/lfrfid/helpers/decoder-analyzer.cpp +++ b/applications/lfrfid/helpers/decoder-analyzer.cpp @@ -1,6 +1,6 @@ #include "decoder-analyzer.h" #include -#include +#include bool DecoderAnalyzer::read(uint8_t* _data, uint8_t _data_size) { bool result = false; diff --git a/applications/lfrfid/helpers/decoder-emmarine.cpp b/applications/lfrfid/helpers/decoder-emmarine.cpp index 74648980..5ca57e27 100644 --- a/applications/lfrfid/helpers/decoder-emmarine.cpp +++ b/applications/lfrfid/helpers/decoder-emmarine.cpp @@ -1,7 +1,7 @@ #include "emmarine.h" #include "decoder-emmarine.h" #include -#include +#include constexpr uint32_t clocks_in_us = 64; constexpr uint32_t short_time = 255 * clocks_in_us; diff --git a/applications/lfrfid/helpers/decoder-gpio-out.cpp b/applications/lfrfid/helpers/decoder-gpio-out.cpp index 50cec34d..fc6815fc 100644 --- a/applications/lfrfid/helpers/decoder-gpio-out.cpp +++ b/applications/lfrfid/helpers/decoder-gpio-out.cpp @@ -1,6 +1,6 @@ #include "decoder-gpio-out.h" #include -#include +#include void DecoderGpioOut::process_front(bool polarity, uint32_t time) { hal_gpio_write(&gpio_ext_pa7, polarity); diff --git a/applications/lfrfid/helpers/decoder-hid26.cpp b/applications/lfrfid/helpers/decoder-hid26.cpp index 94f52493..d6245e29 100644 --- a/applications/lfrfid/helpers/decoder-hid26.cpp +++ b/applications/lfrfid/helpers/decoder-hid26.cpp @@ -1,5 +1,5 @@ #include "decoder-hid26.h" -#include +#include constexpr uint32_t clocks_in_us = 64; diff --git a/applications/lfrfid/helpers/decoder-indala.cpp b/applications/lfrfid/helpers/decoder-indala.cpp index 2103a180..01bff329 100644 --- a/applications/lfrfid/helpers/decoder-indala.cpp +++ b/applications/lfrfid/helpers/decoder-indala.cpp @@ -1,5 +1,5 @@ #include "decoder-indala.h" -#include +#include constexpr uint32_t clocks_in_us = 64; constexpr uint32_t us_per_bit = 255; diff --git a/applications/lfrfid/helpers/rfid-reader.cpp b/applications/lfrfid/helpers/rfid-reader.cpp index dae887d0..62f75ed3 100644 --- a/applications/lfrfid/helpers/rfid-reader.cpp +++ b/applications/lfrfid/helpers/rfid-reader.cpp @@ -1,6 +1,6 @@ #include "rfid-reader.h" #include -#include +#include #include #include @@ -49,11 +49,11 @@ void RfidReader::switch_mode() { switch(type) { case Type::Normal: type = Type::Indala; - api_hal_rfid_change_read_config(62500.0f, 0.25f); + furi_hal_rfid_change_read_config(62500.0f, 0.25f); break; case Type::Indala: type = Type::Normal; - api_hal_rfid_change_read_config(125000.0f, 0.5f); + furi_hal_rfid_change_read_config(125000.0f, 0.5f); break; } @@ -76,9 +76,9 @@ RfidReader::RfidReader() { void RfidReader::start() { type = Type::Normal; - api_hal_rfid_pins_read(); - api_hal_rfid_tim_read(125000, 0.5); - api_hal_rfid_tim_read_start(); + furi_hal_rfid_pins_read(); + furi_hal_rfid_tim_read(125000, 0.5); + furi_hal_rfid_tim_read_start(); start_comparator(); switch_timer_reset(); @@ -92,9 +92,9 @@ void RfidReader::start_forced(RfidReader::Type _type) { start(); break; case Type::Indala: - api_hal_rfid_pins_read(); - api_hal_rfid_tim_read(62500.0f, 0.25f); - api_hal_rfid_tim_read_start(); + furi_hal_rfid_pins_read(); + furi_hal_rfid_tim_read(62500.0f, 0.25f); + furi_hal_rfid_tim_read_start(); start_comparator(); switch_timer_reset(); @@ -104,9 +104,9 @@ void RfidReader::start_forced(RfidReader::Type _type) { } void RfidReader::stop() { - api_hal_rfid_pins_reset(); - api_hal_rfid_tim_read_stop(); - api_hal_rfid_tim_reset(); + furi_hal_rfid_pins_reset(); + furi_hal_rfid_tim_read_stop(); + furi_hal_rfid_tim_reset(); stop_comparator(); } diff --git a/applications/lfrfid/helpers/rfid-timer-emulator.cpp b/applications/lfrfid/helpers/rfid-timer-emulator.cpp index b8747672..05afb146 100644 --- a/applications/lfrfid/helpers/rfid-timer-emulator.cpp +++ b/applications/lfrfid/helpers/rfid-timer-emulator.cpp @@ -21,12 +21,12 @@ void RfidTimerEmulator::start(LfrfidKeyType type, const uint8_t* data, uint8_t d if(data_size >= lfrfid_key_get_type_data_count(type)) { current_encoder->init(data, data_size); - api_hal_rfid_tim_emulate(125000); - api_hal_rfid_pins_emulate(); + furi_hal_rfid_tim_emulate(125000); + furi_hal_rfid_pins_emulate(); api_interrupt_add(timer_update_callback, InterruptTypeTimerUpdate, this); - api_hal_rfid_tim_emulate_start(); + furi_hal_rfid_tim_emulate_start(); } } else { // not found @@ -34,18 +34,18 @@ void RfidTimerEmulator::start(LfrfidKeyType type, const uint8_t* data, uint8_t d } void RfidTimerEmulator::stop() { - api_hal_rfid_tim_emulate_stop(); + furi_hal_rfid_tim_emulate_stop(); api_interrupt_remove(timer_update_callback, InterruptTypeTimerUpdate); - api_hal_rfid_tim_reset(); - api_hal_rfid_pins_reset(); + furi_hal_rfid_tim_reset(); + furi_hal_rfid_pins_reset(); } void RfidTimerEmulator::timer_update_callback(void* _hw, void* ctx) { RfidTimerEmulator* _this = static_cast(ctx); TIM_HandleTypeDef* hw = static_cast(_hw); - if(api_hal_rfid_is_tim_emulate(hw)) { + if(furi_hal_rfid_is_tim_emulate(hw)) { bool result; bool polarity; uint16_t period; @@ -58,7 +58,7 @@ void RfidTimerEmulator::timer_update_callback(void* _hw, void* ctx) { _this->pulse_joiner.pop_pulse(&period, &pulse); - api_hal_rfid_set_emulate_period(period - 1); - api_hal_rfid_set_emulate_pulse(pulse); + furi_hal_rfid_set_emulate_period(period - 1); + furi_hal_rfid_set_emulate_pulse(pulse); } } diff --git a/applications/lfrfid/helpers/rfid-timer-emulator.h b/applications/lfrfid/helpers/rfid-timer-emulator.h index 2a4365b5..d99ce982 100644 --- a/applications/lfrfid/helpers/rfid-timer-emulator.h +++ b/applications/lfrfid/helpers/rfid-timer-emulator.h @@ -1,5 +1,5 @@ #pragma once -#include +#include #include "key-info.h" #include "encoder-generic.h" #include "encoder-emmarine.h" diff --git a/applications/lfrfid/helpers/rfid-writer.cpp b/applications/lfrfid/helpers/rfid-writer.cpp index 9df81d53..d849e9eb 100644 --- a/applications/lfrfid/helpers/rfid-writer.cpp +++ b/applications/lfrfid/helpers/rfid-writer.cpp @@ -1,5 +1,5 @@ #include "rfid-writer.h" -#include +#include #include "protocols/protocol-emmarin.h" #include "protocols/protocol-hid-h10301.h" #include "protocols/protocol-indala-40134.h" @@ -34,21 +34,21 @@ RfidWriter::~RfidWriter() { } void RfidWriter::start() { - api_hal_rfid_tim_read(125000, 0.5); - api_hal_rfid_pins_read(); - api_hal_rfid_tim_read_start(); + furi_hal_rfid_tim_read(125000, 0.5); + furi_hal_rfid_pins_read(); + furi_hal_rfid_tim_read_start(); } void RfidWriter::stop() { - api_hal_rfid_tim_read_stop(); - api_hal_rfid_tim_reset(); - api_hal_rfid_pins_reset(); + furi_hal_rfid_tim_read_stop(); + furi_hal_rfid_tim_reset(); + furi_hal_rfid_pins_reset(); } void RfidWriter::write_gap(uint32_t gap_time) { - api_hal_rfid_tim_read_stop(); + furi_hal_rfid_tim_read_stop(); delay_us(gap_time * 8); - api_hal_rfid_tim_read_start(); + furi_hal_rfid_tim_read_start(); } void RfidWriter::write_bit(bool value) { diff --git a/applications/lfrfid/lfrfid-app.cpp b/applications/lfrfid/lfrfid-app.cpp index 1cd59b61..41cba8d7 100644 --- a/applications/lfrfid/lfrfid-app.cpp +++ b/applications/lfrfid/lfrfid-app.cpp @@ -26,11 +26,11 @@ LfRfidApp::LfRfidApp() : scene_controller{this} , notification{"notification"} , text_store(40) { - api_hal_power_insomnia_enter(); + furi_hal_power_insomnia_enter(); } LfRfidApp::~LfRfidApp() { - api_hal_power_insomnia_exit(); + furi_hal_power_insomnia_exit(); } void LfRfidApp::run(void* _args) { diff --git a/applications/lfrfid/lfrfid-app.h b/applications/lfrfid/lfrfid-app.h index cc126410..b60d6994 100644 --- a/applications/lfrfid/lfrfid-app.h +++ b/applications/lfrfid/lfrfid-app.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include #include diff --git a/applications/lfrfid/lfrfid-cli.cpp b/applications/lfrfid/lfrfid-cli.cpp index d0ae56da..a039ccc8 100644 --- a/applications/lfrfid/lfrfid-cli.cpp +++ b/applications/lfrfid/lfrfid-cli.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/applications/loader/loader.c b/applications/loader/loader.c index 97079bf5..50630ac6 100644 --- a/applications/loader/loader.c +++ b/applications/loader/loader.c @@ -15,7 +15,7 @@ static void loader_menu_callback(void* _ctx) { LOADER_LOG_TAG, "Can't start app. %s is running", loader_instance->current_app->name); return; } - api_hal_power_insomnia_enter(); + furi_hal_power_insomnia_enter(); loader_instance->current_app = flipper_app; FURI_LOG_I( @@ -39,7 +39,7 @@ static void loader_cli_callback(Cli* cli, string_t args, void* _ctx) { } loader_instance->lock_semaphore++; - api_hal_power_insomnia_enter(); + furi_hal_power_insomnia_enter(); loader_instance->current_app = flipper_app; printf("Starting furi application %s", loader_instance->current_app->name); furi_thread_set_name(loader_instance->thread, flipper_app->name); @@ -133,7 +133,7 @@ static void loader_thread_state_callback(FuriThreadState thread_state, void* con "Application thread stopped. Heap allocation balance: %d. Thread allocation balance: %d.", heap_diff, furi_thread_get_heap_size(instance->thread)); - api_hal_power_insomnia_exit(); + furi_hal_power_insomnia_exit(); loader_unlock(instance); } } diff --git a/applications/loader/loader_i.h b/applications/loader/loader_i.h index 9a02794e..f5340434 100644 --- a/applications/loader/loader_i.h +++ b/applications/loader/loader_i.h @@ -1,7 +1,7 @@ #include "loader.h" #include -#include +#include #include #include #include diff --git a/applications/music-player/music-player.c b/applications/music-player/music-player.c index 57713ada..9fa7708d 100644 --- a/applications/music-player/music-player.c +++ b/applications/music-player/music-player.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/applications/nfc/nfc.c b/applications/nfc/nfc.c index 2e37a566..a1f4a19e 100755 --- a/applications/nfc/nfc.c +++ b/applications/nfc/nfc.c @@ -1,5 +1,5 @@ #include "nfc_i.h" -#include "api-hal-nfc.h" +#include "furi-hal-nfc.h" bool nfc_custom_event_callback(void* context, uint32_t event) { furi_assert(context); diff --git a/applications/nfc/nfc_cli.c b/applications/nfc/nfc_cli.c index 6349cde4..8adf5761 100755 --- a/applications/nfc/nfc_cli.c +++ b/applications/nfc/nfc_cli.c @@ -1,7 +1,7 @@ #include "nfc_cli.h" #include "nfc_types.h" #include -#include +#include void nfc_cli_init() { Cli* cli = furi_record_open("cli"); @@ -12,18 +12,18 @@ void nfc_cli_init() { void nfc_cli_detect(Cli* cli, string_t args, void* context) { // Check if nfc worker is not busy - if(api_hal_nfc_is_busy()) { + if(furi_hal_nfc_is_busy()) { printf("Nfc is busy"); return; } rfalNfcDevice* dev_list; uint8_t dev_cnt = 0; bool cmd_exit = false; - api_hal_nfc_exit_sleep(); + furi_hal_nfc_exit_sleep(); printf("Detecting nfc...\r\nPress Ctrl+C to abort\r\n"); while(!cmd_exit) { cmd_exit |= cli_cmd_interrupt_received(cli); - cmd_exit |= api_hal_nfc_detect(&dev_list, &dev_cnt, 400, true); + cmd_exit |= furi_hal_nfc_detect(&dev_list, &dev_cnt, 400, true); if(dev_cnt > 0) { printf("Found %d devices\r\n", dev_cnt); for(uint8_t i = 0; i < dev_cnt; i++) { @@ -40,17 +40,17 @@ void nfc_cli_detect(Cli* cli, string_t args, void* context) { } osDelay(50); } - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); } void nfc_cli_emulate(Cli* cli, string_t args, void* context) { // Check if nfc worker is not busy - if(api_hal_nfc_is_busy()) { + if(furi_hal_nfc_is_busy()) { printf("Nfc is busy"); return; } - api_hal_nfc_exit_sleep(); + furi_hal_nfc_exit_sleep(); printf("Emulating NFC-A Type: T2T UID: CF72D440 SAK: 20 ATQA: 00/04\r\n"); printf("Press Ctrl+C to abort\r\n"); @@ -64,11 +64,11 @@ void nfc_cli_emulate(Cli* cli, string_t args, void* context) { }; while(!cli_cmd_interrupt_received(cli)) { - if(api_hal_nfc_listen(params.uid, params.uid_len, params.atqa, params.sak, 100)) { + if(furi_hal_nfc_listen(params.uid, params.uid_len, params.atqa, params.sak, 100)) { printf("Reader detected\r\n"); - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); } osDelay(50); } - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); } diff --git a/applications/nfc/nfc_worker.c b/applications/nfc/nfc_worker.c index 30aecbfd..334e6d7b 100755 --- a/applications/nfc/nfc_worker.c +++ b/applications/nfc/nfc_worker.c @@ -1,5 +1,5 @@ #include "nfc_worker_i.h" -#include +#include #include "nfc_protocols/emv_decoder.h" #include "nfc_protocols/mifare_ultralight.h" @@ -15,7 +15,7 @@ NfcWorker* nfc_worker_alloc() { nfc_worker->callback = NULL; nfc_worker->context = NULL; // Initialize rfal - if(!api_hal_nfc_is_busy()) { + if(!furi_hal_nfc_is_busy()) { nfc_worker_change_state(nfc_worker, NfcWorkerStateReady); } else { nfc_worker_change_state(nfc_worker, NfcWorkerStateBroken); @@ -70,8 +70,8 @@ void nfc_worker_change_state(NfcWorker* nfc_worker, NfcWorkerState state) { void nfc_worker_task(void* context) { NfcWorker* nfc_worker = context; - api_hal_power_insomnia_enter(); - api_hal_nfc_exit_sleep(); + furi_hal_power_insomnia_enter(); + furi_hal_nfc_exit_sleep(); if(nfc_worker->state == NfcWorkerStateDetect) { nfc_worker_detect(nfc_worker); @@ -90,9 +90,9 @@ void nfc_worker_task(void* context) { } else if(nfc_worker->state == NfcWorkerStateField) { nfc_worker_field(nfc_worker); } - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); nfc_worker_change_state(nfc_worker, NfcWorkerStateReady); - api_hal_power_insomnia_exit(); + furi_hal_power_insomnia_exit(); osThreadExit(); } @@ -103,7 +103,7 @@ void nfc_worker_detect(NfcWorker* nfc_worker) { NfcDeviceCommomData* result = &nfc_worker->dev_data->nfc_data; while(nfc_worker->state == NfcWorkerStateDetect) { - if(api_hal_nfc_detect(&dev_list, &dev_cnt, 1000, true)) { + if(furi_hal_nfc_detect(&dev_list, &dev_cnt, 1000, true)) { // Process first found device dev = &dev_list[0]; result->uid_len = dev->nfcidLen; @@ -143,7 +143,7 @@ void nfc_worker_detect(NfcWorker* nfc_worker) { void nfc_worker_emulate(NfcWorker* nfc_worker) { NfcDeviceCommomData* data = &nfc_worker->dev_data->nfc_data; while(nfc_worker->state == NfcWorkerStateEmulate) { - if(api_hal_nfc_listen(data->uid, data->uid_len, data->atqa, data->sak, 100)) { + if(furi_hal_nfc_listen(data->uid, data->uid_len, data->atqa, data->sak, 100)) { FURI_LOG_I(NFC_WORKER_TAG, "Reader detected"); } osDelay(10); @@ -163,7 +163,7 @@ void nfc_worker_read_emv_app(NfcWorker* nfc_worker) { while(nfc_worker->state == NfcWorkerStateReadEMVApp) { memset(&emv_app, 0, sizeof(emv_app)); - if(api_hal_nfc_detect(&dev_list, &dev_cnt, 1000, false)) { + if(furi_hal_nfc_detect(&dev_list, &dev_cnt, 1000, false)) { // Card was found. Check that it supports EMV if(dev_list[0].rfInterface == RFAL_NFC_INTERFACE_ISODEP) { result->nfc_data.uid_len = dev_list[0].dev.nfca.nfcId1Len; @@ -176,10 +176,10 @@ void nfc_worker_read_emv_app(NfcWorker* nfc_worker) { FURI_LOG_I(NFC_WORKER_TAG, "Send select PPSE command"); tx_len = emv_prepare_select_ppse(tx_buff); - err = api_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); + err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); if(err != ERR_NONE) { FURI_LOG_E(NFC_WORKER_TAG, "Error during selection PPSE request: %d", err); - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); continue; } FURI_LOG_I( @@ -195,18 +195,18 @@ void nfc_worker_read_emv_app(NfcWorker* nfc_worker) { break; } else { FURI_LOG_E(NFC_WORKER_TAG, "Can't find pay application"); - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); continue; } } else { // Can't find EMV card FURI_LOG_W(NFC_WORKER_TAG, "Card doesn't support EMV"); - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); } } else { // Can't find EMV card FURI_LOG_W(NFC_WORKER_TAG, "Can't find any cards"); - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); } osDelay(20); } @@ -225,7 +225,7 @@ void nfc_worker_read_emv(NfcWorker* nfc_worker) { while(nfc_worker->state == NfcWorkerStateReadEMV) { memset(&emv_app, 0, sizeof(emv_app)); - if(api_hal_nfc_detect(&dev_list, &dev_cnt, 1000, false)) { + if(furi_hal_nfc_detect(&dev_list, &dev_cnt, 1000, false)) { // Card was found. Check that it supports EMV if(dev_list[0].rfInterface == RFAL_NFC_INTERFACE_ISODEP) { result->nfc_data.uid_len = dev_list[0].dev.nfca.nfcId1Len; @@ -238,10 +238,10 @@ void nfc_worker_read_emv(NfcWorker* nfc_worker) { FURI_LOG_I(NFC_WORKER_TAG, "Send select PPSE command"); tx_len = emv_prepare_select_ppse(tx_buff); - err = api_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); + err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); if(err != ERR_NONE) { FURI_LOG_E(NFC_WORKER_TAG, "Error during selection PPSE request: %d", err); - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); continue; } FURI_LOG_I( @@ -250,16 +250,16 @@ void nfc_worker_read_emv(NfcWorker* nfc_worker) { FURI_LOG_I(NFC_WORKER_TAG, "Select PPSE responce parced"); } else { FURI_LOG_E(NFC_WORKER_TAG, "Can't find pay application"); - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); continue; } FURI_LOG_I(NFC_WORKER_TAG, "Starting application ..."); tx_len = emv_prepare_select_app(tx_buff, &emv_app); - err = api_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); + err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); if(err != ERR_NONE) { FURI_LOG_E( NFC_WORKER_TAG, "Error during application selection request: %d", err); - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); continue; } FURI_LOG_I( @@ -270,16 +270,16 @@ void nfc_worker_read_emv(NfcWorker* nfc_worker) { memcpy(result->emv_data.name, emv_app.name, sizeof(emv_app.name)); } else { FURI_LOG_E(NFC_WORKER_TAG, "Can't read card name"); - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); continue; } FURI_LOG_I(NFC_WORKER_TAG, "Starting Get Processing Options command ..."); tx_len = emv_prepare_get_proc_opt(tx_buff, &emv_app); - err = api_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); + err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); if(err != ERR_NONE) { FURI_LOG_E( NFC_WORKER_TAG, "Error during Get Processing Options command: %d", err); - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); continue; } if(emv_decode_get_proc_opt(rx_buff, *rx_len, &emv_app)) { @@ -303,7 +303,7 @@ void nfc_worker_read_emv(NfcWorker* nfc_worker) { // Iterate over all records in file for(uint8_t record = record_start; record <= record_end; ++record) { tx_len = emv_prepare_read_sfi_record(tx_buff, sfi, record); - err = api_hal_nfc_data_exchange( + err = furi_hal_nfc_data_exchange( tx_buff, tx_len, &rx_buff, &rx_len, false); if(err != ERR_NONE) { FURI_LOG_E( @@ -336,17 +336,17 @@ void nfc_worker_read_emv(NfcWorker* nfc_worker) { } else { FURI_LOG_E(NFC_WORKER_TAG, "Can't read card number"); } - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); } } else { // Can't find EMV card FURI_LOG_W(NFC_WORKER_TAG, "Card doesn't support EMV"); - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); } } else { // Can't find EMV card FURI_LOG_W(NFC_WORKER_TAG, "Can't find any cards"); - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); } osDelay(20); } @@ -406,47 +406,47 @@ void nfc_worker_emulate_apdu(NfcWorker* nfc_worker) { 0x00, 0x00}; while(nfc_worker->state == NfcWorkerStateEmulateApdu) { - if(api_hal_nfc_listen(params.uid, params.uid_len, params.atqa, params.sak, 300)) { + if(furi_hal_nfc_listen(params.uid, params.uid_len, params.atqa, params.sak, 300)) { FURI_LOG_I(NFC_WORKER_TAG, "POS terminal detected"); // Read data from POS terminal - err = api_hal_nfc_data_exchange(NULL, 0, &rx_buff, &rx_len, false); + err = furi_hal_nfc_data_exchange(NULL, 0, &rx_buff, &rx_len, false); if(err == ERR_NONE) { FURI_LOG_I(NFC_WORKER_TAG, "Received Select PPSE"); } else { FURI_LOG_E(NFC_WORKER_TAG, "Error in 1st data exchange: select PPSE"); - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); continue; } FURI_LOG_I(NFC_WORKER_TAG, "Transive SELECT PPSE ANS"); tx_len = emv_select_ppse_ans(tx_buff); - err = api_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); + err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); if(err == ERR_NONE) { FURI_LOG_I(NFC_WORKER_TAG, "Received Select APP"); } else { FURI_LOG_E(NFC_WORKER_TAG, "Error in 2nd data exchange: select APP"); - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); continue; } FURI_LOG_I(NFC_WORKER_TAG, "Transive SELECT APP ANS"); tx_len = emv_select_app_ans(tx_buff); - err = api_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); + err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); if(err == ERR_NONE) { FURI_LOG_I(NFC_WORKER_TAG, "Received PDOL"); } else { FURI_LOG_E(NFC_WORKER_TAG, "Error in 3rd data exchange: receive PDOL"); - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); continue; } FURI_LOG_I(NFC_WORKER_TAG, "Transive PDOL ANS"); tx_len = emv_get_proc_opt_ans(tx_buff); - err = api_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); + err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); if(err == ERR_NONE) { FURI_LOG_I(NFC_WORKER_TAG, "Transive PDOL ANS"); } else { FURI_LOG_E(NFC_WORKER_TAG, "Error in 4rd data exchange: Transive PDOL ANS"); - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); continue; } @@ -455,13 +455,13 @@ void nfc_worker_emulate_apdu(NfcWorker* nfc_worker) { } else { FURI_LOG_I(NFC_WORKER_TAG, "Correct debug message received"); tx_len = sizeof(debug_tx); - err = api_hal_nfc_data_exchange( + err = furi_hal_nfc_data_exchange( (uint8_t*)debug_tx, tx_len, &rx_buff, &rx_len, false); if(err == ERR_NONE) { FURI_LOG_I(NFC_WORKER_TAG, "Transive Debug message"); } } - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); } else { FURI_LOG_W(NFC_WORKER_TAG, "Can't find reader"); } @@ -481,9 +481,9 @@ void nfc_worker_read_mifare_ul(NfcWorker* nfc_worker) { NfcDeviceData* result = nfc_worker->dev_data; while(nfc_worker->state == NfcWorkerStateReadMifareUl) { - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); memset(&mf_ul_read, 0, sizeof(mf_ul_read)); - if(api_hal_nfc_detect(&dev_list, &dev_cnt, 300, false)) { + if(furi_hal_nfc_detect(&dev_list, &dev_cnt, 300, false)) { if(dev_list[0].type == RFAL_NFC_LISTEN_TYPE_NFCA && mf_ul_check_card_type( dev_list[0].dev.nfca.sensRes.anticollisionInfo, @@ -492,7 +492,7 @@ void nfc_worker_read_mifare_ul(NfcWorker* nfc_worker) { // Get Mifare Ultralight version FURI_LOG_I(NFC_WORKER_TAG, "Found Mifare Ultralight tag. Reading tag version"); tx_len = mf_ul_prepare_get_version(tx_buff); - err = api_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); + err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); if(err == ERR_NONE) { mf_ul_parse_get_version_response(rx_buff, &mf_ul_read); FURI_LOG_I( @@ -507,8 +507,8 @@ void nfc_worker_read_mifare_ul(NfcWorker* nfc_worker) { err = ERR_NONE; mf_ul_set_default_version(&mf_ul_read); // Reinit device - api_hal_nfc_deactivate(); - if(!api_hal_nfc_detect(&dev_list, &dev_cnt, 300, false)) { + furi_hal_nfc_deactivate(); + if(!furi_hal_nfc_detect(&dev_list, &dev_cnt, 300, false)) { FURI_LOG_E(NFC_WORKER_TAG, "Lost connection. Restarting search"); continue; } @@ -523,7 +523,7 @@ void nfc_worker_read_mifare_ul(NfcWorker* nfc_worker) { if(mf_ul_read.support_fast_read) { FURI_LOG_I(NFC_WORKER_TAG, "Reading pages ..."); tx_len = mf_ul_prepare_fast_read(tx_buff, 0x00, mf_ul_read.pages_to_read - 1); - if(api_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) { + if(furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) { FURI_LOG_E(NFC_WORKER_TAG, "Failed reading pages"); continue; } else { @@ -533,7 +533,7 @@ void nfc_worker_read_mifare_ul(NfcWorker* nfc_worker) { FURI_LOG_I(NFC_WORKER_TAG, "Reading signature ..."); tx_len = mf_ul_prepare_read_signature(tx_buff); - if(api_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) { + if(furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) { FURI_LOG_W(NFC_WORKER_TAG, "Failed reading signature"); memset(mf_ul_read.data.signature, 0, sizeof(mf_ul_read.data.signature)); } else { @@ -543,7 +543,7 @@ void nfc_worker_read_mifare_ul(NfcWorker* nfc_worker) { FURI_LOG_I(NFC_WORKER_TAG, "Reading 3 counters ..."); for(uint8_t i = 0; i < 3; i++) { tx_len = mf_ul_prepare_read_cnt(tx_buff, i); - if(api_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) { + if(furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) { FURI_LOG_W(NFC_WORKER_TAG, "Failed reading Counter %d", i); mf_ul_read.data.counter[i] = 0; } else { @@ -554,7 +554,7 @@ void nfc_worker_read_mifare_ul(NfcWorker* nfc_worker) { FURI_LOG_I(NFC_WORKER_TAG, "Checking tearing flags ..."); for(uint8_t i = 0; i < 3; i++) { tx_len = mf_ul_prepare_check_tearing(tx_buff, i); - if(api_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) { + if(furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) { FURI_LOG_E(NFC_WORKER_TAG, "Error checking tearing flag %d", i); mf_ul_read.data.tearing[i] = MF_UL_TEARING_FLAG_DEFAULT; } else { @@ -566,7 +566,7 @@ void nfc_worker_read_mifare_ul(NfcWorker* nfc_worker) { for(uint8_t page = 0; page < mf_ul_read.pages_to_read; page += 4) { FURI_LOG_I(NFC_WORKER_TAG, "Reading pages %d - %d ...", page, page + 3); tx_len = mf_ul_prepare_read(tx_buff, page); - if(api_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) { + if(furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) { FURI_LOG_E( NFC_WORKER_TAG, "Read pages %d - %d failed", page, page + 3); continue; @@ -610,7 +610,7 @@ void nfc_worker_emulate_mifare_ul(NfcWorker* nfc_worker) { NfcDeviceData* data = nfc_worker->dev_data; while(nfc_worker->state == NfcWorkerStateEmulateMifareUl) { - if(api_hal_nfc_listen( + if(furi_hal_nfc_listen( data->nfc_data.uid, data->nfc_data.uid_len, data->nfc_data.atqa, @@ -620,7 +620,7 @@ void nfc_worker_emulate_mifare_ul(NfcWorker* nfc_worker) { // Prepare version answer tx_len = sizeof(data->mf_ul_data.version); memcpy(tx_buff, &data->mf_ul_data.version, tx_len); - err = api_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); + err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); if(err == ERR_NONE) { FURI_LOG_I(NFC_WORKER_TAG, "Received 1st message:"); for(uint16_t i = 0; i < *rx_len; i++) { @@ -629,7 +629,7 @@ void nfc_worker_emulate_mifare_ul(NfcWorker* nfc_worker) { printf("\r\n"); } else { FURI_LOG_E(NFC_WORKER_TAG, "Error in 1st data exchange: select PPSE"); - api_hal_nfc_deactivate(); + furi_hal_nfc_deactivate(); continue; } } @@ -639,9 +639,9 @@ void nfc_worker_emulate_mifare_ul(NfcWorker* nfc_worker) { } void nfc_worker_field(NfcWorker* nfc_worker) { - api_hal_nfc_field_on(); + furi_hal_nfc_field_on(); while(nfc_worker->state == NfcWorkerStateField) { osDelay(50); } - api_hal_nfc_field_off(); + furi_hal_nfc_field_off(); } diff --git a/applications/notification/notification-app-api.c b/applications/notification/notification-app-api.c index 5905d30a..c14ca5e1 100644 --- a/applications/notification/notification-app-api.c +++ b/applications/notification/notification-app-api.c @@ -1,5 +1,5 @@ #include -#include +#include #include "notification.h" #include "notification-messages.h" #include "notification-app.h" diff --git a/applications/notification/notification-app.c b/applications/notification/notification-app.c index 6e8f045a..69ac043d 100644 --- a/applications/notification/notification-app.c +++ b/applications/notification/notification-app.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "notification.h" #include "notification-messages.h" @@ -41,7 +41,7 @@ void notification_apply_internal_led_layer(NotificationLedLayer* layer, uint8_t // apply if current layer is internal if(layer->index == LayerInternal) { - api_hal_light_set(layer->light, layer->value[LayerInternal]); + furi_hal_light_set(layer->light, layer->value[LayerInternal]); } } @@ -71,7 +71,7 @@ void notification_apply_notification_led_layer( // set layer layer->value[LayerNotification] = layer_value; // apply - api_hal_light_set(layer->light, layer->value[LayerNotification]); + furi_hal_light_set(layer->light, layer->value[LayerNotification]); } void notification_reset_notification_led_layer(NotificationLedLayer* layer) { @@ -84,7 +84,7 @@ void notification_reset_notification_led_layer(NotificationLedLayer* layer) { layer->index = LayerInternal; // apply - api_hal_light_set(layer->light, layer->value[LayerInternal]); + furi_hal_light_set(layer->light, layer->value[LayerInternal]); } void notification_reset_notification_layer(NotificationApp* app, uint8_t reset_mask) { @@ -130,11 +130,11 @@ uint32_t notification_settings_display_off_delay_ticks(NotificationApp* app) { // generics void notification_vibro_on() { - api_hal_vibro_on(true); + furi_hal_vibro_on(true); } void notification_vibro_off() { - api_hal_vibro_on(false); + furi_hal_vibro_on(false); } void notification_sound_on(float pwm, float freq) { diff --git a/applications/notification/notification-app.h b/applications/notification/notification-app.h index a6e5ba84..78c58f6d 100644 --- a/applications/notification/notification-app.h +++ b/applications/notification/notification-app.h @@ -1,5 +1,5 @@ #include -#include +#include #include "notification.h" #include "notification-messages.h" diff --git a/applications/power-observer/power-observer.c b/applications/power-observer/power-observer.c index d7b9b2f7..7d2388c0 100644 --- a/applications/power-observer/power-observer.c +++ b/applications/power-observer/power-observer.c @@ -1,5 +1,5 @@ #include -#include +#include #include const NotificationMessage message_green_110 = { @@ -20,7 +20,7 @@ int32_t power_observer_srv(void* p) { const float overconsumption_limit = 0.03f; while(true) { - float current = -api_hal_power_get_battery_current(ApiHalPowerICFuelGauge); + float current = -furi_hal_power_get_battery_current(FuriHalPowerICFuelGauge); if(current >= overconsumption_limit) { notification_message_block(notifications, &sequence_overconsumption); diff --git a/applications/power/power.c b/applications/power/power.c index 1ab852fc..b083f6ea 100644 --- a/applications/power/power.c +++ b/applications/power/power.c @@ -3,7 +3,7 @@ #include "power_views.h" #include -#include +#include #include #include @@ -86,11 +86,11 @@ void power_menu_reset_callback(void* context) { } void power_menu_enable_otg_callback(void* context) { - api_hal_power_enable_otg(); + furi_hal_power_enable_otg(); } void power_menu_disable_otg_callback(void* context) { - api_hal_power_disable_otg(); + furi_hal_power_disable_otg(); } void power_menu_info_callback(void* context) { @@ -157,22 +157,22 @@ void power_free(Power* power) { void power_off(Power* power) { furi_assert(power); - api_hal_power_off(); + furi_hal_power_off(); view_dispatcher_switch_to_view(power->view_dispatcher, PowerViewDisconnect); } void power_reboot(Power* power, PowerBootMode mode) { if(mode == PowerBootModeNormal) { - api_hal_boot_set_mode(ApiHalBootModeNormal); + furi_hal_boot_set_mode(FuriHalBootModeNormal); } else if(mode == PowerBootModeDfu) { - api_hal_boot_set_mode(ApiHalBootModeDFU); + furi_hal_boot_set_mode(FuriHalBootModeDFU); } - api_hal_power_reset(); + furi_hal_power_reset(); } static void power_charging_indication_handler(Power* power, NotificationApp* notifications) { - if(api_hal_power_is_charging()) { - if(api_hal_power_get_pct() == 100) { + if(furi_hal_power_is_charging()) { + if(furi_hal_power_get_pct() == 100) { if(power->state != PowerStateCharged) { notification_internal_message(notifications, &sequence_charged); power->state = PowerStateCharged; @@ -185,7 +185,7 @@ static void power_charging_indication_handler(Power* power, NotificationApp* not } } - if(!api_hal_power_is_charging()) { + if(!furi_hal_power_is_charging()) { if(power->state != PowerStateNotCharging) { notification_internal_message(notifications, &sequence_not_charging); power->state = PowerStateNotCharging; @@ -212,19 +212,19 @@ int32_t power_srv(void* p) { with_view_model( power->info_view, (PowerInfoModel * model) { - model->charge = api_hal_power_get_pct(); - model->health = api_hal_power_get_bat_health_pct(); - model->capacity_remaining = api_hal_power_get_battery_remaining_capacity(); - model->capacity_full = api_hal_power_get_battery_full_capacity(); - model->current_charger = api_hal_power_get_battery_current(ApiHalPowerICCharger); - model->current_gauge = api_hal_power_get_battery_current(ApiHalPowerICFuelGauge); - model->voltage_charger = api_hal_power_get_battery_voltage(ApiHalPowerICCharger); - model->voltage_gauge = api_hal_power_get_battery_voltage(ApiHalPowerICFuelGauge); - model->voltage_vbus = api_hal_power_get_usb_voltage(); + model->charge = furi_hal_power_get_pct(); + model->health = furi_hal_power_get_bat_health_pct(); + model->capacity_remaining = furi_hal_power_get_battery_remaining_capacity(); + model->capacity_full = furi_hal_power_get_battery_full_capacity(); + model->current_charger = furi_hal_power_get_battery_current(FuriHalPowerICCharger); + model->current_gauge = furi_hal_power_get_battery_current(FuriHalPowerICFuelGauge); + model->voltage_charger = furi_hal_power_get_battery_voltage(FuriHalPowerICCharger); + model->voltage_gauge = furi_hal_power_get_battery_voltage(FuriHalPowerICFuelGauge); + model->voltage_vbus = furi_hal_power_get_usb_voltage(); model->temperature_charger = - api_hal_power_get_battery_temperature(ApiHalPowerICCharger); + furi_hal_power_get_battery_temperature(FuriHalPowerICCharger); model->temperature_gauge = - api_hal_power_get_battery_temperature(ApiHalPowerICFuelGauge); + furi_hal_power_get_battery_temperature(FuriHalPowerICFuelGauge); if(model->charge == 0 && model->voltage_vbus < 4.0f) { battery_low = true; diff --git a/applications/power/power_cli.c b/applications/power/power_cli.c index e66e82b1..c39cafde 100644 --- a/applications/power/power_cli.c +++ b/applications/power/power_cli.c @@ -1,5 +1,5 @@ #include "power_cli.h" -#include +#include void power_cli_poweroff(Cli* cli, string_t args, void* context) { Power* power = context; @@ -22,7 +22,7 @@ void power_cli_factory_reset(Cli* cli, string_t args, void* context) { char c = cli_getc(cli); if(c == 'y' || c == 'Y') { printf("Data will be wiped after reboot.\r\n"); - api_hal_boot_set_flags(ApiHalBootFlagFactoryReset); + furi_hal_boot_set_flags(FuriHalBootFlagFactoryReset); power_reboot(power, PowerBootModeNormal); } else { printf("Safe choice.\r\n"); @@ -30,14 +30,14 @@ void power_cli_factory_reset(Cli* cli, string_t args, void* context) { } void power_cli_info(Cli* cli, string_t args, void* context) { - api_hal_power_dump_state(); + furi_hal_power_dump_state(); } void power_cli_otg(Cli* cli, string_t args, void* context) { if(!string_cmp(args, "0")) { - api_hal_power_disable_otg(); + furi_hal_power_disable_otg(); } else if(!string_cmp(args, "1")) { - api_hal_power_enable_otg(); + furi_hal_power_enable_otg(); } else { cli_print_usage("power_otg", "<1|0>", string_get_cstr(args)); } @@ -45,9 +45,9 @@ void power_cli_otg(Cli* cli, string_t args, void* context) { void power_cli_ext(Cli* cli, string_t args, void* context) { if(!string_cmp(args, "0")) { - api_hal_power_disable_external_3_3v(); + furi_hal_power_disable_external_3_3v(); } else if(!string_cmp(args, "1")) { - api_hal_power_enable_external_3_3v(); + furi_hal_power_enable_external_3_3v(); } else { cli_print_usage("power_ext", "<1|0>", string_get_cstr(args)); } diff --git a/applications/scened-app-example/scened-app.h b/applications/scened-app-example/scened-app.h index d45dbf83..b5e2bbf1 100644 --- a/applications/scened-app-example/scened-app.h +++ b/applications/scened-app-example/scened-app.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include #include diff --git a/applications/storage-settings/scenes/storage-settings-scene-internal-info.c b/applications/storage-settings/scenes/storage-settings-scene-internal-info.c index 5dff893a..49008bcd 100644 --- a/applications/storage-settings/scenes/storage-settings-scene-internal-info.c +++ b/applications/storage-settings/scenes/storage-settings-scene-internal-info.c @@ -1,5 +1,5 @@ #include "../storage-settings.h" -#include +#include static void storage_settings_scene_internal_info_dialog_callback(DialogExResult result, void* context) { @@ -28,7 +28,7 @@ void storage_settings_scene_internal_info_on_enter(void* context) { string_printf( app->text_string, "Label: %s\nType: LittleFS\n%lu KB total\n%lu KB free", - api_hal_version_get_name_ptr(), + furi_hal_version_get_name_ptr(), (uint32_t)(total_space / 1024), (uint32_t)(free_space / 1024)); dialog_ex_set_text( diff --git a/applications/storage/storage-cli.c b/applications/storage/storage-cli.c index 684e9a8b..ed76b2d1 100644 --- a/applications/storage/storage-cli.c +++ b/applications/storage/storage-cli.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #define MAX_NAME_LENGTH 255 @@ -64,7 +64,7 @@ void storage_cli_info(Cli* cli, string_t path) { } else { printf( "Label: %s\r\nType: LittleFS\r\n%lu KB total\r\n%lu KB free\r\n", - api_hal_version_get_name_ptr(), + furi_hal_version_get_name_ptr(), (uint32_t)(total_space / 1024), (uint32_t)(free_space / 1024)); } diff --git a/applications/storage/storage-glue.c b/applications/storage/storage-glue.c index 9477712d..8f115f53 100644 --- a/applications/storage/storage-glue.c +++ b/applications/storage/storage-glue.c @@ -1,5 +1,5 @@ #include "storage-glue.h" -#include +#include /****************** storage file ******************/ @@ -39,12 +39,12 @@ void storage_data_init(StorageData* storage) { } bool storage_data_lock(StorageData* storage) { - api_hal_power_insomnia_enter(); + furi_hal_power_insomnia_enter(); return (osMutexAcquire(storage->mutex, osWaitForever) == osOK); } bool storage_data_unlock(StorageData* storage) { - api_hal_power_insomnia_exit(); + furi_hal_power_insomnia_exit(); return (osMutexRelease(storage->mutex) == osOK); } diff --git a/applications/storage/storage-test-app.c b/applications/storage/storage-test-app.c index 7e3f0a58..022181a5 100644 --- a/applications/storage/storage-test-app.c +++ b/applications/storage/storage-test-app.c @@ -1,5 +1,5 @@ #include -#include +#include #include #define TAG "storage-test" diff --git a/applications/storage/storages/storage-ext.c b/applications/storage/storages/storage-ext.c index 6d0f7b68..b29fdf7a 100644 --- a/applications/storage/storages/storage-ext.c +++ b/applications/storage/storages/storage-ext.c @@ -1,9 +1,9 @@ #include "fatfs.h" #include "../filesystem-api-internal.h" #include "storage-ext.h" -#include +#include #include "sd-notify.h" -#include +#include typedef FIL SDFile; typedef DIR SDDir; diff --git a/applications/storage/storages/storage-int.c b/applications/storage/storages/storage-int.c index 625ded6d..473ac4f5 100644 --- a/applications/storage/storages/storage-int.c +++ b/applications/storage/storages/storage-int.c @@ -1,6 +1,6 @@ #include "storage-int.h" #include -#include +#include #define TAG "storage-int" #define STORAGE_PATH "/int" @@ -103,7 +103,7 @@ static int storage_int_device_prog( int ret = 0; while(size > 0) { - if(!api_hal_flash_write_dword(address, *(uint64_t*)buffer)) { + if(!furi_hal_flash_write_dword(address, *(uint64_t*)buffer)) { ret = -1; break; } @@ -121,7 +121,7 @@ static int storage_int_device_erase(const struct lfs_config* c, lfs_block_t bloc FURI_LOG_D(TAG, "Device erase: page %d, translated page: %d", block, page); - if(api_hal_flash_erase(page, 1)) { + if(furi_hal_flash_erase(page, 1)) { return 0; } else { return -1; @@ -137,9 +137,9 @@ static LFSData* storage_int_lfs_data_alloc() { LFSData* lfs_data = furi_alloc(sizeof(LFSData)); // Internal storage start address - *(size_t*)(&lfs_data->start_address) = api_hal_flash_get_free_page_start_address(); + *(size_t*)(&lfs_data->start_address) = furi_hal_flash_get_free_page_start_address(); *(size_t*)(&lfs_data->start_page) = - (lfs_data->start_address - api_hal_flash_get_base()) / api_hal_flash_get_page_size(); + (lfs_data->start_address - furi_hal_flash_get_base()) / furi_hal_flash_get_page_size(); // LFS configuration // Glue and context @@ -150,11 +150,11 @@ static LFSData* storage_int_lfs_data_alloc() { lfs_data->config.sync = storage_int_device_sync; // Block device description - lfs_data->config.read_size = api_hal_flash_get_read_block_size(); - lfs_data->config.prog_size = api_hal_flash_get_write_block_size(); - lfs_data->config.block_size = api_hal_flash_get_page_size(); - lfs_data->config.block_count = api_hal_flash_get_free_page_count(); - lfs_data->config.block_cycles = api_hal_flash_get_cycles_count(); + lfs_data->config.read_size = furi_hal_flash_get_read_block_size(); + lfs_data->config.prog_size = furi_hal_flash_get_write_block_size(); + lfs_data->config.block_size = furi_hal_flash_get_page_size(); + lfs_data->config.block_count = furi_hal_flash_get_free_page_count(); + lfs_data->config.block_cycles = furi_hal_flash_get_cycles_count(); lfs_data->config.cache_size = 16; lfs_data->config.lookahead_size = 16; @@ -163,15 +163,15 @@ static LFSData* storage_int_lfs_data_alloc() { static void storage_int_lfs_mount(LFSData* lfs_data, StorageData* storage) { int err; - ApiHalBootFlag boot_flags = api_hal_boot_get_flags(); + FuriHalBootFlag boot_flags = furi_hal_boot_get_flags(); lfs_t* lfs = &lfs_data->lfs; - if(boot_flags & ApiHalBootFlagFactoryReset) { + if(boot_flags & FuriHalBootFlagFactoryReset) { // Factory reset err = lfs_format(lfs, &lfs_data->config); if(err == 0) { FURI_LOG_I(TAG, "Factory reset: Format successful, trying to mount"); - api_hal_boot_set_flags(boot_flags & ~ApiHalBootFlagFactoryReset); + furi_hal_boot_set_flags(boot_flags & ~FuriHalBootFlagFactoryReset); err = lfs_mount(lfs, &lfs_data->config); if(err == 0) { FURI_LOG_I(TAG, "Factory reset: Mounted"); diff --git a/applications/subghz/subghz_cli.c b/applications/subghz/subghz_cli.c index a6f4f5f3..d6197869 100644 --- a/applications/subghz/subghz_cli.c +++ b/applications/subghz/subghz_cli.c @@ -1,7 +1,7 @@ #include "subghz_cli.h" #include -#include +#include #include #include @@ -31,7 +31,7 @@ void subghz_cli_command_tx_carrier(Cli* cli, string_t args, void* context) { cli_print_usage("subghz_tx_carrier", "", string_get_cstr(args)); return; } - if(!api_hal_subghz_is_frequency_valid(frequency)) { + if(!furi_hal_subghz_is_frequency_valid(frequency)) { printf( "Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n", frequency); @@ -39,14 +39,14 @@ void subghz_cli_command_tx_carrier(Cli* cli, string_t args, void* context) { } } - api_hal_subghz_reset(); - api_hal_subghz_load_preset(ApiHalSubGhzPresetOokAsync); - frequency = api_hal_subghz_set_frequency_and_path(frequency); + furi_hal_subghz_reset(); + furi_hal_subghz_load_preset(FuriHalSubGhzPresetOokAsync); + frequency = furi_hal_subghz_set_frequency_and_path(frequency); hal_gpio_init(&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); hal_gpio_write(&gpio_cc1101_g0, true); - api_hal_subghz_tx(); + furi_hal_subghz_tx(); printf("Transmitting at frequency %lu Hz\r\n", frequency); printf("Press CTRL+C to stop\r\n"); @@ -54,8 +54,8 @@ void subghz_cli_command_tx_carrier(Cli* cli, string_t args, void* context) { osDelay(250); } - api_hal_subghz_set_path(ApiHalSubGhzPathIsolate); - api_hal_subghz_sleep(); + furi_hal_subghz_set_path(FuriHalSubGhzPathIsolate); + furi_hal_subghz_sleep(); } void subghz_cli_command_rx_carrier(Cli* cli, string_t args, void* context) { @@ -68,7 +68,7 @@ void subghz_cli_command_rx_carrier(Cli* cli, string_t args, void* context) { cli_print_usage("subghz_tx_carrier", "", string_get_cstr(args)); return; } - if(!api_hal_subghz_is_frequency_valid(frequency)) { + if(!furi_hal_subghz_is_frequency_valid(frequency)) { printf( "Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n", frequency); @@ -76,22 +76,22 @@ void subghz_cli_command_rx_carrier(Cli* cli, string_t args, void* context) { } } - api_hal_subghz_reset(); - api_hal_subghz_load_preset(ApiHalSubGhzPresetOokAsync); - frequency = api_hal_subghz_set_frequency_and_path(frequency); + furi_hal_subghz_reset(); + furi_hal_subghz_load_preset(FuriHalSubGhzPresetOokAsync); + frequency = furi_hal_subghz_set_frequency_and_path(frequency); printf("Receiving at frequency %lu Hz\r\n", frequency); printf("Press CTRL+C to stop\r\n"); - api_hal_subghz_rx(); + furi_hal_subghz_rx(); while(!cli_cmd_interrupt_received(cli)) { osDelay(250); - printf("RSSI: %03.1fdbm\r", api_hal_subghz_get_rssi()); + printf("RSSI: %03.1fdbm\r", furi_hal_subghz_get_rssi()); fflush(stdout); } - api_hal_subghz_set_path(ApiHalSubGhzPathIsolate); - api_hal_subghz_sleep(); + furi_hal_subghz_set_path(FuriHalSubGhzPathIsolate); + furi_hal_subghz_sleep(); } #define SUBGHZ_PT_SHORT 376 @@ -118,7 +118,7 @@ void subghz_cli_command_tx(Cli* cli, string_t args, void* context) { string_get_cstr(args)); return; } - if(!api_hal_subghz_is_frequency_valid(frequency)) { + if(!furi_hal_subghz_is_frequency_valid(frequency)) { printf( "Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n", frequency); @@ -151,16 +151,16 @@ void subghz_cli_command_tx(Cli* cli, string_t args, void* context) { key, repeat); - api_hal_subghz_reset(); - api_hal_subghz_load_preset(ApiHalSubGhzPresetOokAsync); - frequency = api_hal_subghz_set_frequency_and_path(frequency); + furi_hal_subghz_reset(); + furi_hal_subghz_load_preset(FuriHalSubGhzPresetOokAsync); + frequency = furi_hal_subghz_set_frequency_and_path(frequency); - api_hal_subghz_start_async_tx(subghz_test_data, subghz_test_data_size, repeat); - api_hal_subghz_wait_async_tx(); - api_hal_subghz_stop_async_tx(); + furi_hal_subghz_start_async_tx(subghz_test_data, subghz_test_data_size, repeat); + furi_hal_subghz_wait_async_tx(); + furi_hal_subghz_stop_async_tx(); free(subghz_test_data); - api_hal_subghz_sleep(); + furi_hal_subghz_sleep(); } typedef struct { @@ -200,7 +200,7 @@ void subghz_cli_command_rx(Cli* cli, string_t args, void* context) { cli_print_usage("subghz_rx", "", string_get_cstr(args)); return; } - if(!api_hal_subghz_is_frequency_valid(frequency)) { + if(!furi_hal_subghz_is_frequency_valid(frequency)) { printf( "Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n", frequency); @@ -219,14 +219,14 @@ void subghz_cli_command_rx(Cli* cli, string_t args, void* context) { subghz_protocol_enable_dump_text(protocol, subghz_cli_command_rx_text_callback, instance); // Configure radio - api_hal_subghz_reset(); - api_hal_subghz_load_preset(ApiHalSubGhzPresetOokAsync); - frequency = api_hal_subghz_set_frequency_and_path(frequency); + furi_hal_subghz_reset(); + furi_hal_subghz_load_preset(FuriHalSubGhzPresetOokAsync); + frequency = furi_hal_subghz_set_frequency_and_path(frequency); hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow); // Prepare and start RX - api_hal_subghz_set_async_rx_callback(subghz_cli_command_rx_callback, instance); - api_hal_subghz_start_async_rx(); + furi_hal_subghz_set_async_rx_callback(subghz_cli_command_rx_callback, instance); + furi_hal_subghz_start_async_rx(); // Wait for packets to arrive printf("Listening at %lu. Press CTRL+C to stop\r\n", frequency); @@ -247,8 +247,8 @@ void subghz_cli_command_rx(Cli* cli, string_t args, void* context) { } // Shutdown radio - api_hal_subghz_stop_async_rx(); - api_hal_subghz_sleep(); + furi_hal_subghz_stop_async_rx(); + furi_hal_subghz_sleep(); printf("\r\nPackets recieved %u\r\n", instance->packet_count); diff --git a/applications/subghz/subghz_i.h b/applications/subghz/subghz_i.h index ccf41b71..b2da67b6 100644 --- a/applications/subghz/subghz_i.h +++ b/applications/subghz/subghz_i.h @@ -7,7 +7,7 @@ #include "views/subghz_static.h" #include -#include +#include #include #include #include diff --git a/applications/subghz/views/subghz_capture.c b/applications/subghz/views/subghz_capture.c index 4df825b9..c8927e95 100644 --- a/applications/subghz/views/subghz_capture.c +++ b/applications/subghz/views/subghz_capture.c @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include #include @@ -85,10 +85,10 @@ bool subghz_capture_input(InputEvent* event, void* context) { } if(reconfigure) { - api_hal_subghz_idle(); + furi_hal_subghz_idle(); model->real_frequency = - api_hal_subghz_set_frequency_and_path(subghz_frequencies[model->frequency]); - api_hal_subghz_rx(); + furi_hal_subghz_set_frequency_and_path(subghz_frequencies[model->frequency]); + furi_hal_subghz_rx(); } return reconfigure; @@ -141,28 +141,28 @@ void subghz_capture_enter(void* context) { furi_assert(context); SubghzCapture* subghz_capture = context; - api_hal_subghz_reset(); - api_hal_subghz_idle(); - api_hal_subghz_load_preset(ApiHalSubGhzPresetOokAsync); + furi_hal_subghz_reset(); + furi_hal_subghz_idle(); + furi_hal_subghz_load_preset(FuriHalSubGhzPresetOokAsync); with_view_model( subghz_capture->view, (SubghzCaptureModel * model) { model->frequency = subghz_frequencies_433_92; model->real_frequency = - api_hal_subghz_set_frequency_and_path(subghz_frequencies[model->frequency]); + furi_hal_subghz_set_frequency_and_path(subghz_frequencies[model->frequency]); model->scene = 1; return true; }); hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow); - api_hal_subghz_set_async_rx_callback(subghz_worker_rx_callback, subghz_capture->worker); - api_hal_subghz_start_async_rx(); + furi_hal_subghz_set_async_rx_callback(subghz_worker_rx_callback, subghz_capture->worker); + furi_hal_subghz_start_async_rx(); subghz_worker_start(subghz_capture->worker); - api_hal_subghz_flush_rx(); - api_hal_subghz_rx(); + furi_hal_subghz_flush_rx(); + furi_hal_subghz_rx(); } void subghz_capture_exit(void* context) { @@ -171,8 +171,8 @@ void subghz_capture_exit(void* context) { subghz_worker_stop(subghz_capture->worker); - api_hal_subghz_stop_async_rx(); - api_hal_subghz_sleep(); + furi_hal_subghz_stop_async_rx(); + furi_hal_subghz_sleep(); } uint32_t subghz_capture_back(void* context) { diff --git a/applications/subghz/views/subghz_static.c b/applications/subghz/views/subghz_static.c index ad86d458..0dd91e60 100644 --- a/applications/subghz/views/subghz_static.c +++ b/applications/subghz/views/subghz_static.c @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include @@ -80,10 +80,10 @@ bool subghz_static_input(InputEvent* event, void* context) { } if(reconfigure) { - api_hal_subghz_idle(); + furi_hal_subghz_idle(); model->real_frequency = - api_hal_subghz_set_frequency_and_path(subghz_frequencies[model->frequency]); - api_hal_subghz_tx(); + furi_hal_subghz_set_frequency_and_path(subghz_frequencies[model->frequency]); + furi_hal_subghz_tx(); } if(event->key == InputKeyOk) { @@ -128,8 +128,8 @@ void subghz_static_enter(void* context) { furi_assert(context); SubghzStatic* subghz_static = context; - api_hal_subghz_reset(); - api_hal_subghz_load_preset(ApiHalSubGhzPresetOokAsync); + furi_hal_subghz_reset(); + furi_hal_subghz_load_preset(FuriHalSubGhzPresetOokAsync); hal_gpio_init(&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); hal_gpio_write(&gpio_cc1101_g0, false); @@ -138,12 +138,12 @@ void subghz_static_enter(void* context) { subghz_static->view, (SubghzStaticModel * model) { model->frequency = subghz_frequencies_433_92; model->real_frequency = - api_hal_subghz_set_frequency_and_path(subghz_frequencies[model->frequency]); + furi_hal_subghz_set_frequency_and_path(subghz_frequencies[model->frequency]); model->button = 0; return true; }); - api_hal_subghz_tx(); + furi_hal_subghz_tx(); } void subghz_static_exit(void* context) { @@ -151,7 +151,7 @@ void subghz_static_exit(void* context) { // SubghzStatic* subghz_static = context; // Reinitialize IC to default state - api_hal_subghz_sleep(); + furi_hal_subghz_sleep(); } uint32_t subghz_static_back(void* context) { diff --git a/applications/subghz/views/subghz_test_basic.c b/applications/subghz/views/subghz_test_basic.c index b3107d54..1c954ad6 100644 --- a/applications/subghz/views/subghz_test_basic.c +++ b/applications/subghz/views/subghz_test_basic.c @@ -3,7 +3,7 @@ #include #include -#include +#include #include struct SubghzTestBasic { @@ -19,7 +19,7 @@ typedef enum { typedef struct { uint8_t frequency; uint32_t real_frequency; - ApiHalSubGhzPath path; + FuriHalSubGhzPath path; float rssi; SubghzTestBasicModelStatus status; } SubghzTestBasicModel; @@ -43,13 +43,13 @@ void subghz_test_basic_draw(Canvas* canvas, SubghzTestBasicModel* model) { canvas_draw_str(canvas, 0, 20, buffer); // Path char* path_name = "Unknown"; - if(model->path == ApiHalSubGhzPathIsolate) { + if(model->path == FuriHalSubGhzPathIsolate) { path_name = "isolate"; - } else if(model->path == ApiHalSubGhzPath433) { + } else if(model->path == FuriHalSubGhzPath433) { path_name = "433MHz"; - } else if(model->path == ApiHalSubGhzPath315) { + } else if(model->path == FuriHalSubGhzPath315) { path_name = "315MHz"; - } else if(model->path == ApiHalSubGhzPath868) { + } else if(model->path == FuriHalSubGhzPath868) { path_name = "868MHz"; } snprintf(buffer, sizeof(buffer), "Path: %d - %s", model->path, path_name); @@ -78,7 +78,7 @@ bool subghz_test_basic_input(InputEvent* event, void* context) { with_view_model( subghz_test_basic->view, (SubghzTestBasicModel * model) { osTimerStop(subghz_test_basic->timer); - api_hal_subghz_idle(); + furi_hal_subghz_idle(); if(event->type == InputTypeShort) { if(event->key == InputKeyLeft) { @@ -88,7 +88,7 @@ bool subghz_test_basic_input(InputEvent* event, void* context) { } else if(event->key == InputKeyDown) { if(model->path > 0) model->path--; } else if(event->key == InputKeyUp) { - if(model->path < ApiHalSubGhzPath868) model->path++; + if(model->path < FuriHalSubGhzPath868) model->path++; } else if(event->key == InputKeyOk) { if(model->status == SubghzTestBasicModelStatusTx) { model->status = SubghzTestBasicModelStatusRx; @@ -98,18 +98,18 @@ bool subghz_test_basic_input(InputEvent* event, void* context) { } model->real_frequency = - api_hal_subghz_set_frequency(subghz_frequencies[model->frequency]); - api_hal_subghz_set_path(model->path); + furi_hal_subghz_set_frequency(subghz_frequencies[model->frequency]); + furi_hal_subghz_set_path(model->path); } if(model->status == SubghzTestBasicModelStatusRx) { hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow); - api_hal_subghz_rx(); + furi_hal_subghz_rx(); osTimerStart(subghz_test_basic->timer, 1024 / 4); } else { hal_gpio_init(&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); hal_gpio_write(&gpio_cc1101_g0, true); - api_hal_subghz_tx(); + furi_hal_subghz_tx(); } return true; @@ -122,8 +122,8 @@ void subghz_test_basic_enter(void* context) { furi_assert(context); SubghzTestBasic* subghz_test_basic = context; - api_hal_subghz_reset(); - api_hal_subghz_load_preset(ApiHalSubGhzPresetOokAsync); + furi_hal_subghz_reset(); + furi_hal_subghz_load_preset(FuriHalSubGhzPresetOokAsync); hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow); @@ -131,14 +131,14 @@ void subghz_test_basic_enter(void* context) { subghz_test_basic->view, (SubghzTestBasicModel * model) { model->frequency = subghz_frequencies_433_92; // 433 model->real_frequency = - api_hal_subghz_set_frequency(subghz_frequencies[model->frequency]); - model->path = ApiHalSubGhzPathIsolate; // isolate + furi_hal_subghz_set_frequency(subghz_frequencies[model->frequency]); + model->path = FuriHalSubGhzPathIsolate; // isolate model->rssi = 0.0f; model->status = SubghzTestBasicModelStatusRx; return true; }); - api_hal_subghz_rx(); + furi_hal_subghz_rx(); osTimerStart(subghz_test_basic->timer, 1024 / 4); } @@ -150,7 +150,7 @@ void subghz_test_basic_exit(void* context) { osTimerStop(subghz_test_basic->timer); // Reinitialize IC to default state - api_hal_subghz_sleep(); + furi_hal_subghz_sleep(); } void subghz_test_basic_rssi_timer_callback(void* context) { @@ -159,7 +159,7 @@ void subghz_test_basic_rssi_timer_callback(void* context) { with_view_model( subghz_test_basic->view, (SubghzTestBasicModel * model) { - model->rssi = api_hal_subghz_get_rssi(); + model->rssi = furi_hal_subghz_get_rssi(); return true; }); } diff --git a/applications/subghz/views/subghz_test_packet.c b/applications/subghz/views/subghz_test_packet.c index 188cbea0..530585e5 100644 --- a/applications/subghz/views/subghz_test_packet.c +++ b/applications/subghz/views/subghz_test_packet.c @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include #include @@ -32,7 +32,7 @@ typedef enum { typedef struct { uint8_t frequency; uint32_t real_frequency; - ApiHalSubGhzPath path; + FuriHalSubGhzPath path; float rssi; size_t packets; SubghzTestPacketModelStatus status; @@ -59,11 +59,11 @@ static void subghz_test_packet_rssi_timer_callback(void* context) { with_view_model( instance->view, (SubghzTestPacketModel * model) { if(model->status == SubghzTestPacketModelStatusRx) { - model->rssi = api_hal_subghz_get_rssi(); + model->rssi = furi_hal_subghz_get_rssi(); model->packets = instance->packet_rx; } else { model->packets = - SUBGHZ_TEST_PACKET_COUNT - api_hal_subghz_get_async_tx_repeat_left(); + SUBGHZ_TEST_PACKET_COUNT - furi_hal_subghz_get_async_tx_repeat_left(); } return true; }); @@ -88,13 +88,13 @@ static void subghz_test_packet_draw(Canvas* canvas, SubghzTestPacketModel* model canvas_draw_str(canvas, 0, 20, buffer); // Path char* path_name = "Unknown"; - if(model->path == ApiHalSubGhzPathIsolate) { + if(model->path == FuriHalSubGhzPathIsolate) { path_name = "isolate"; - } else if(model->path == ApiHalSubGhzPath433) { + } else if(model->path == FuriHalSubGhzPath433) { path_name = "433MHz"; - } else if(model->path == ApiHalSubGhzPath315) { + } else if(model->path == FuriHalSubGhzPath315) { path_name = "315MHz"; - } else if(model->path == ApiHalSubGhzPath868) { + } else if(model->path == FuriHalSubGhzPath868) { path_name = "868MHz"; } snprintf(buffer, sizeof(buffer), "Path: %d - %s", model->path, path_name); @@ -127,9 +127,9 @@ static bool subghz_test_packet_input(InputEvent* event, void* context) { with_view_model( instance->view, (SubghzTestPacketModel * model) { if(model->status == SubghzTestPacketModelStatusRx) { - api_hal_subghz_stop_async_rx(); + furi_hal_subghz_stop_async_rx(); } else { - api_hal_subghz_stop_async_tx(); + furi_hal_subghz_stop_async_tx(); } if(event->type == InputTypeShort) { @@ -140,7 +140,7 @@ static bool subghz_test_packet_input(InputEvent* event, void* context) { } else if(event->key == InputKeyDown) { if(model->path > 0) model->path--; } else if(event->key == InputKeyUp) { - if(model->path < ApiHalSubGhzPath868) model->path++; + if(model->path < FuriHalSubGhzPath868) model->path++; } else if(event->key == InputKeyOk) { if(model->status == SubghzTestPacketModelStatusTx) { model->status = SubghzTestPacketModelStatusRx; @@ -150,14 +150,14 @@ static bool subghz_test_packet_input(InputEvent* event, void* context) { } model->real_frequency = - api_hal_subghz_set_frequency(subghz_frequencies[model->frequency]); - api_hal_subghz_set_path(model->path); + furi_hal_subghz_set_frequency(subghz_frequencies[model->frequency]); + furi_hal_subghz_set_path(model->path); } if(model->status == SubghzTestPacketModelStatusRx) { - api_hal_subghz_start_async_rx(); + furi_hal_subghz_start_async_rx(); } else { - api_hal_subghz_start_async_tx( + furi_hal_subghz_start_async_tx( instance->tx_buffer, instance->tx_buffer_size, SUBGHZ_TEST_PACKET_COUNT); } @@ -192,22 +192,22 @@ void subghz_test_packet_enter(void* context) { instance->tx_buffer[pos++] = SUBGHZ_PT_SHORT; instance->tx_buffer[pos++] = SUBGHZ_PT_SHORT + SUBGHZ_PT_GUARD; - api_hal_subghz_reset(); - api_hal_subghz_load_preset(ApiHalSubGhzPresetOokAsync); - api_hal_subghz_set_async_rx_callback(subghz_test_packet_rx_callback, instance); + furi_hal_subghz_reset(); + furi_hal_subghz_load_preset(FuriHalSubGhzPresetOokAsync); + furi_hal_subghz_set_async_rx_callback(subghz_test_packet_rx_callback, instance); with_view_model( instance->view, (SubghzTestPacketModel * model) { model->frequency = subghz_frequencies_433_92; model->real_frequency = - api_hal_subghz_set_frequency(subghz_frequencies[model->frequency]); - model->path = ApiHalSubGhzPathIsolate; // isolate + furi_hal_subghz_set_frequency(subghz_frequencies[model->frequency]); + model->path = FuriHalSubGhzPathIsolate; // isolate model->rssi = 0.0f; model->status = SubghzTestPacketModelStatusRx; return true; }); - api_hal_subghz_start_async_rx(); + furi_hal_subghz_start_async_rx(); osTimerStart(instance->timer, 1024 / 4); } @@ -222,14 +222,14 @@ void subghz_test_packet_exit(void* context) { with_view_model( instance->view, (SubghzTestPacketModel * model) { if(model->status == SubghzTestPacketModelStatusRx) { - api_hal_subghz_stop_async_rx(); + furi_hal_subghz_stop_async_rx(); } else { - api_hal_subghz_stop_async_tx(); + furi_hal_subghz_stop_async_tx(); } return true; }); - api_hal_subghz_set_async_rx_callback(NULL, NULL); - api_hal_subghz_sleep(); + furi_hal_subghz_set_async_rx_callback(NULL, NULL); + furi_hal_subghz_sleep(); } uint32_t subghz_test_packet_back(void* context) { diff --git a/applications/tests/furi_valuemutex_test.c b/applications/tests/furi_valuemutex_test.c index c0e1755c..43383f94 100644 --- a/applications/tests/furi_valuemutex_test.c +++ b/applications/tests/furi_valuemutex_test.c @@ -1,7 +1,7 @@ #include #include #include -#include "api-hal-delay.h" +#include "furi-hal-delay.h" #include "minunit.h" diff --git a/applications/tests/test_index.c b/applications/tests/test_index.c index f8756dce..c0f8919a 100644 --- a/applications/tests/test_index.c +++ b/applications/tests/test_index.c @@ -1,6 +1,6 @@ #include #include -#include +#include #include "minunit_vars.h" #include diff --git a/bootloader/Makefile b/bootloader/Makefile index c6600a21..fb55d63f 100644 --- a/bootloader/Makefile +++ b/bootloader/Makefile @@ -3,7 +3,7 @@ PROJECT = bootloader include $(PROJECT_ROOT)/make/base.mk -CFLAGS += -I$(PROJECT_ROOT) -Itargets/api-hal-include +CFLAGS += -I$(PROJECT_ROOT) -Itargets/furi-hal-include ASM_SOURCES += $(wildcard src/*.s) C_SOURCES += $(wildcard src/*.c) CPP_SOURCES += $(wildcard src/*.cpp) diff --git a/bootloader/targets/f6/api-hal/api-hal.c b/bootloader/targets/f6/api-hal/api-hal.c deleted file mode 100644 index 2d3afc71..00000000 --- a/bootloader/targets/f6/api-hal/api-hal.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -void api_hal_init() { - api_hal_i2c_init(); - api_hal_light_init(); -} \ No newline at end of file diff --git a/bootloader/targets/f6/api-hal/api-hal.h b/bootloader/targets/f6/api-hal/api-hal.h deleted file mode 100644 index 9230b28a..00000000 --- a/bootloader/targets/f6/api-hal/api-hal.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#include -#include - -void api_hal_init(); \ No newline at end of file diff --git a/bootloader/targets/f6/api-hal/api-hal-i2c.c b/bootloader/targets/f6/furi-hal/furi-hal-i2c.c similarity index 92% rename from bootloader/targets/f6/api-hal/api-hal-i2c.c rename to bootloader/targets/f6/furi-hal/furi-hal-i2c.c index 2ff0b8e9..c40a70af 100644 --- a/bootloader/targets/f6/api-hal/api-hal-i2c.c +++ b/bootloader/targets/f6/furi-hal/furi-hal-i2c.c @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -6,7 +6,7 @@ #include #include -void api_hal_i2c_init() { +void furi_hal_i2c_init() { LL_I2C_InitTypeDef I2C_InitStruct = {0}; LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; @@ -38,7 +38,7 @@ void api_hal_i2c_init() { LL_I2C_EnableClockStretching(I2C1); } -bool api_hal_i2c_tx( +bool furi_hal_i2c_tx( I2C_TypeDef* instance, uint8_t address, const uint8_t* data, @@ -79,7 +79,7 @@ bool api_hal_i2c_tx( return ret; } -bool api_hal_i2c_rx( +bool furi_hal_i2c_rx( I2C_TypeDef* instance, uint8_t address, uint8_t* data, @@ -120,7 +120,7 @@ bool api_hal_i2c_rx( return ret; } -bool api_hal_i2c_trx( +bool furi_hal_i2c_trx( I2C_TypeDef* instance, uint8_t address, const uint8_t* tx_data, @@ -128,8 +128,8 @@ bool api_hal_i2c_trx( uint8_t* rx_data, uint8_t rx_size, uint32_t timeout) { - if(api_hal_i2c_tx(instance, address, tx_data, tx_size, timeout) && - api_hal_i2c_rx(instance, address, rx_data, rx_size, timeout)) { + if(furi_hal_i2c_tx(instance, address, tx_data, tx_size, timeout) && + furi_hal_i2c_rx(instance, address, rx_data, rx_size, timeout)) { return true; } else { return false; diff --git a/bootloader/targets/f6/api-hal/api-hal-i2c.h b/bootloader/targets/f6/furi-hal/furi-hal-i2c.h similarity index 78% rename from bootloader/targets/f6/api-hal/api-hal-i2c.h rename to bootloader/targets/f6/furi-hal/furi-hal-i2c.h index 835693a6..5db562e0 100644 --- a/bootloader/targets/f6/api-hal/api-hal-i2c.h +++ b/bootloader/targets/f6/furi-hal/furi-hal-i2c.h @@ -2,29 +2,29 @@ #include #include -#include +#include #ifdef __cplusplus extern "C" { #endif -void api_hal_i2c_init(); +void furi_hal_i2c_init(); -bool api_hal_i2c_tx( +bool furi_hal_i2c_tx( I2C_TypeDef* instance, const uint8_t address, const uint8_t* data, const uint8_t size, uint32_t timeout); -bool api_hal_i2c_rx( +bool furi_hal_i2c_rx( I2C_TypeDef* instance, const uint8_t address, uint8_t* data, const uint8_t size, uint32_t timeout); -bool api_hal_i2c_trx( +bool furi_hal_i2c_trx( I2C_TypeDef* instance, const uint8_t address, const uint8_t* tx_data, @@ -33,7 +33,7 @@ bool api_hal_i2c_trx( const uint8_t rx_size, uint32_t timeout); -#define with_api_hal_i2c(type, pointer, function_body) \ +#define with_furi_hal_i2c(type, pointer, function_body) \ { \ *pointer = ({ type __fn__ function_body __fn__; })(); \ } diff --git a/bootloader/targets/f6/api-hal/api-hal-light.c b/bootloader/targets/f6/furi-hal/furi-hal-light.c similarity index 91% rename from bootloader/targets/f6/api-hal/api-hal-light.c rename to bootloader/targets/f6/furi-hal/furi-hal-light.c index 425018a1..d5f54f6d 100644 --- a/bootloader/targets/f6/api-hal/api-hal-light.c +++ b/bootloader/targets/f6/furi-hal/furi-hal-light.c @@ -1,4 +1,4 @@ -#include +#include #include #define LED_CURRENT_RED 50 @@ -6,7 +6,7 @@ #define LED_CURRENT_BLUE 50 #define LED_CURRENT_WHITE 150 -void api_hal_light_init() { +void furi_hal_light_init() { lp5562_reset(); lp5562_set_channel_current(LP5562ChannelRed, LED_CURRENT_RED); @@ -23,7 +23,7 @@ void api_hal_light_init() { lp5562_configure(); } -void api_hal_light_set(Light light, uint8_t value) { +void furi_hal_light_set(Light light, uint8_t value) { switch(light) { case LightRed: lp5562_set_channel_value(LP5562ChannelRed, value); diff --git a/bootloader/targets/f6/api-hal/api-hal-light.h b/bootloader/targets/f6/furi-hal/furi-hal-light.h similarity index 52% rename from bootloader/targets/f6/api-hal/api-hal-light.h rename to bootloader/targets/f6/furi-hal/furi-hal-light.h index 1d571f06..de976103 100644 --- a/bootloader/targets/f6/api-hal/api-hal-light.h +++ b/bootloader/targets/f6/furi-hal/furi-hal-light.h @@ -2,15 +2,15 @@ #include #include -#include +#include #ifdef __cplusplus extern "C" { #endif -void api_hal_light_init(); +void furi_hal_light_init(); -void api_hal_light_set(Light light, uint8_t value); +void furi_hal_light_set(Light light, uint8_t value); #ifdef __cplusplus } diff --git a/bootloader/targets/f6/api-hal/api-hal-resources.h b/bootloader/targets/f6/furi-hal/furi-hal-resources.h similarity index 100% rename from bootloader/targets/f6/api-hal/api-hal-resources.h rename to bootloader/targets/f6/furi-hal/furi-hal-resources.h diff --git a/bootloader/targets/f6/furi-hal/furi-hal.c b/bootloader/targets/f6/furi-hal/furi-hal.c new file mode 100644 index 00000000..d4420f44 --- /dev/null +++ b/bootloader/targets/f6/furi-hal/furi-hal.c @@ -0,0 +1,6 @@ +#include + +void furi_hal_init() { + furi_hal_i2c_init(); + furi_hal_light_init(); +} \ No newline at end of file diff --git a/bootloader/targets/f6/furi-hal/furi-hal.h b/bootloader/targets/f6/furi-hal/furi-hal.h new file mode 100644 index 00000000..112549b4 --- /dev/null +++ b/bootloader/targets/f6/furi-hal/furi-hal.h @@ -0,0 +1,6 @@ +#pragma once + +#include +#include + +void furi_hal_init(); \ No newline at end of file diff --git a/bootloader/targets/f6/target.c b/bootloader/targets/f6/target.c index 761959f3..1947a4ca 100644 --- a/bootloader/targets/f6/target.c +++ b/bootloader/targets/f6/target.c @@ -10,7 +10,7 @@ #include #include -#include +#include // Boot request enum #define BOOT_REQUEST_TAINTED 0x00000000 @@ -28,32 +28,32 @@ #define RTC_CLOCK_IS_READY() (LL_RCC_LSE_IsReady() && LL_RCC_LSI1_IsReady()) void target_led_control(char* c) { - api_hal_light_set(LightRed, 0x00); - api_hal_light_set(LightGreen, 0x00); - api_hal_light_set(LightBlue, 0x00); + furi_hal_light_set(LightRed, 0x00); + furi_hal_light_set(LightGreen, 0x00); + furi_hal_light_set(LightBlue, 0x00); do { if(*c == 'R') { - api_hal_light_set(LightRed, 0xFF); + furi_hal_light_set(LightRed, 0xFF); } else if(*c == 'G') { - api_hal_light_set(LightGreen, 0xFF); + furi_hal_light_set(LightGreen, 0xFF); } else if(*c == 'B') { - api_hal_light_set(LightBlue, 0xFF); + furi_hal_light_set(LightBlue, 0xFF); } else if(*c == '.') { LL_mDelay(125); - api_hal_light_set(LightRed, 0x00); - api_hal_light_set(LightGreen, 0x00); - api_hal_light_set(LightBlue, 0x00); + furi_hal_light_set(LightRed, 0x00); + furi_hal_light_set(LightGreen, 0x00); + furi_hal_light_set(LightBlue, 0x00); LL_mDelay(125); } else if(*c == '-') { LL_mDelay(250); - api_hal_light_set(LightRed, 0x00); - api_hal_light_set(LightGreen, 0x00); - api_hal_light_set(LightBlue, 0x00); + furi_hal_light_set(LightRed, 0x00); + furi_hal_light_set(LightGreen, 0x00); + furi_hal_light_set(LightBlue, 0x00); LL_mDelay(250); } else if(*c == '|') { - api_hal_light_set(LightRed, 0x00); - api_hal_light_set(LightGreen, 0x00); - api_hal_light_set(LightBlue, 0x00); + furi_hal_light_set(LightRed, 0x00); + furi_hal_light_set(LightGreen, 0x00); + furi_hal_light_set(LightBlue, 0x00); } c++; } while(*c != 0); @@ -125,7 +125,7 @@ void usb_wire_reset() { void target_init() { clock_init(); gpio_init(); - api_hal_init(); + furi_hal_init(); target_led_control("RGB"); rtc_init(); version_save(); diff --git a/bootloader/targets/f6/target.mk b/bootloader/targets/f6/target.mk index ab0c24b4..751c5dbb 100644 --- a/bootloader/targets/f6/target.mk +++ b/bootloader/targets/f6/target.mk @@ -34,8 +34,8 @@ CFLAGS += -I$(DRIVERS_DIR) C_SOURCES += $(DRIVERS_DIR)/lp5562.c # API-HAL -CFLAGS += -I$(TARGET_DIR)/api-hal -C_SOURCES += $(wildcard $(TARGET_DIR)/api-hal/*.c) +CFLAGS += -I$(TARGET_DIR)/furi-hal +C_SOURCES += $(wildcard $(TARGET_DIR)/furi-hal/*.c) # Version generation C_SOURCES += $(PROJECT_ROOT)/lib/toolbox/version.c diff --git a/bootloader/targets/api-hal-include/target.h b/bootloader/targets/furi-hal-include/target.h similarity index 100% rename from bootloader/targets/api-hal-include/target.h rename to bootloader/targets/furi-hal-include/target.h diff --git a/core/core.mk b/core/core.mk index 5e8fd51e..4a824343 100644 --- a/core/core.mk +++ b/core/core.mk @@ -4,5 +4,5 @@ CFLAGS += -I$(CORE_DIR) -D_GNU_SOURCE ASM_SOURCES += $(wildcard $(CORE_DIR)/*.s) C_SOURCES += $(wildcard $(CORE_DIR)/*.c) C_SOURCES += $(wildcard $(CORE_DIR)/furi/*.c) -C_SOURCES += $(wildcard $(CORE_DIR)/api-hal/*.c) +C_SOURCES += $(wildcard $(CORE_DIR)/furi-hal/*.c) CPP_SOURCES += $(wildcard $(CORE_DIR)/*.cpp) diff --git a/core/flipper.c b/core/flipper.c index ffd44742..785a4463 100755 --- a/core/flipper.c +++ b/core/flipper.c @@ -1,7 +1,7 @@ #include "flipper.h" #include #include -#include +#include static void flipper_print_version(const char* target, const Version* version) { if(version) { @@ -25,10 +25,10 @@ static void flipper_print_version(const char* target, const Version* version) { void flipper_init() { const Version* version; - version = (const Version*)api_hal_version_get_boot_version(); + version = (const Version*)furi_hal_version_get_boot_version(); flipper_print_version("Bootloader", version); - version = (const Version*)api_hal_version_get_firmware_version(); + version = (const Version*)furi_hal_version_get_firmware_version(); flipper_print_version("Firmware", version); FURI_LOG_I("FLIPPER", "starting services"); diff --git a/core/api-hal/api-interrupt-mgr.c b/core/furi-hal/api-interrupt-mgr.c similarity index 100% rename from core/api-hal/api-interrupt-mgr.c rename to core/furi-hal/api-interrupt-mgr.c diff --git a/core/api-hal/api-interrupt-mgr.h b/core/furi-hal/api-interrupt-mgr.h similarity index 100% rename from core/api-hal/api-interrupt-mgr.h rename to core/furi-hal/api-interrupt-mgr.h diff --git a/core/api-hal/api-spi.h b/core/furi-hal/api-spi.h similarity index 100% rename from core/api-hal/api-spi.h rename to core/furi-hal/api-spi.h diff --git a/core/furi.h b/core/furi.h index 3ebccc66..681855d0 100644 --- a/core/furi.h +++ b/core/furi.h @@ -13,8 +13,8 @@ #include #include -#include -#include +#include +#include #include diff --git a/core/furi/check.c b/core/furi/check.c index 5bd019ca..13d176bf 100644 --- a/core/furi/check.c +++ b/core/furi/check.c @@ -1,5 +1,5 @@ #include "check.h" -#include "api-hal-task.h" +#include "furi-hal-task.h" #include void __furi_abort(void); diff --git a/core/furi/stdglue.c b/core/furi/stdglue.c index 26d0095e..4755c7ab 100644 --- a/core/furi/stdglue.c +++ b/core/furi/stdglue.c @@ -2,7 +2,7 @@ #include "check.h" #include "memmgr.h" -#include +#include #include DICT_DEF2( @@ -58,7 +58,7 @@ static ssize_t stdout_write(void* _cookie, const char* data, size_t size) { return 0; } // Debug uart - if(!consumed) api_hal_console_tx((const uint8_t*)data, size); + if(!consumed) furi_hal_console_tx((const uint8_t*)data, size); // All data consumed return size; } diff --git a/firmware/Makefile b/firmware/Makefile index ccceb450..0b6e6e49 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -8,7 +8,7 @@ include $(PROJECT_ROOT)/core/core.mk include $(PROJECT_ROOT)/applications/applications.mk include $(PROJECT_ROOT)/lib/lib.mk -CFLAGS += -I$(PROJECT_ROOT) -Itargets/api-hal-include +CFLAGS += -I$(PROJECT_ROOT) -Itargets/furi-hal-include CFLAGS += -Werror -Wno-address-of-packed-member CPPFLAGS += -Werror diff --git a/firmware/ReadMe.md b/firmware/ReadMe.md index a50f0740..d3d61b23 100644 --- a/firmware/ReadMe.md +++ b/firmware/ReadMe.md @@ -31,7 +31,7 @@ You can find platform code for STM32WB55 version in `f4` folder: ``` ├── Inc # CubeMX generated headers ├── Src # CubeMX generated code -├── api-hal # Our HAL wrappers and platform specifics +├── furi-hal # Our HAL wrappers and platform specifics ├── ble-glue # BLE specific code(Glue for STMWPAN) ├── f4.ioc # CubeMX project file ├── startup_stm32wb55xx_cm4.s # Board startup/initialization assembler code @@ -46,7 +46,7 @@ Working with CubeMX: 3. Do whatever you want to 3. Click `generate code` 4. After regenerating, look at git status, regeneration may brake some files. -5. Check one more time that things that you've changes are not covered in platform api-hal. Because you know... +5. Check one more time that things that you've changes are not covered in platform furi-hal. Because you know... # Flipper Universal Registry Implementation (FURI) diff --git a/firmware/targets/api-hal-include/api-hal-boot.h b/firmware/targets/api-hal-include/api-hal-boot.h deleted file mode 100644 index cd5a7a4e..00000000 --- a/firmware/targets/api-hal-include/api-hal-boot.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** Boot modes */ -typedef enum { - ApiHalBootModeNormal, - ApiHalBootModeDFU -} ApiHalBootMode; - -/** Boot flags */ -typedef enum { - ApiHalBootFlagDefault=0, - ApiHalBootFlagFactoryReset=1, -} ApiHalBootFlag; - -/** Initialize boot subsystem */ -void api_hal_boot_init(); - -/** Set boot mode */ -void api_hal_boot_set_mode(ApiHalBootMode mode); - -/** Set boot flags */ -void api_hal_boot_set_flags(ApiHalBootFlag flags); - -/** Get boot flag */ -ApiHalBootFlag api_hal_boot_get_flags(); - -#ifdef __cplusplus -} -#endif diff --git a/firmware/targets/api-hal-include/api-hal-ibutton.h b/firmware/targets/api-hal-include/api-hal-ibutton.h deleted file mode 100644 index cc19e7e9..00000000 --- a/firmware/targets/api-hal-include/api-hal-ibutton.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include - -#ifdef __cplusplus -extern "C" { -#endif - -void api_hal_ibutton_start(); - -void api_hal_ibutton_stop(); - -void api_hal_ibutton_pin_low(); - -void api_hal_ibutton_pin_high(); - -bool api_hal_ibutton_pin_get_level(); - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/firmware/targets/api-hal-include/api-hal-nfc.h b/firmware/targets/api-hal-include/api-hal-nfc.h deleted file mode 100644 index dda13e3b..00000000 --- a/firmware/targets/api-hal-include/api-hal-nfc.h +++ /dev/null @@ -1,66 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define API_HAL_NFC_UID_MAX_LEN 10 - -/** - * Init nfc - */ -void api_hal_nfc_init(); - -/** - * Check if nfc worker is busy - */ -bool api_hal_nfc_is_busy(); - -/** - * NFC field on - */ -void api_hal_nfc_field_on(); - -/** - * NFC field off - */ -void api_hal_nfc_field_off(); - -/** - * NFC start sleep - */ -void api_hal_nfc_start_sleep(); - -/** - * NFC stop sleep - */ -void api_hal_nfc_exit_sleep(); - -/** - * NFC poll - */ -bool api_hal_nfc_detect(rfalNfcDevice** dev_list, uint8_t* dev_cnt, uint32_t timeout, bool deactivate); - -/** - * NFC listen - */ -bool api_hal_nfc_listen(uint8_t* uid, uint8_t uid_len, uint8_t* atqa, uint8_t sak, uint32_t timeout); - -/** - * NFC data exchange - */ -ReturnCode api_hal_nfc_data_exchange(uint8_t* tx_buff, uint16_t tx_len, uint8_t** rx_buff, uint16_t** rx_len, bool deactivate); - -/** - * NFC deactivate and start sleep - */ -void api_hal_nfc_deactivate(); - -#ifdef __cplusplus -} -#endif diff --git a/firmware/targets/api-hal-include/api-hal-version.h b/firmware/targets/api-hal-include/api-hal-version.h deleted file mode 100644 index edf4d9f0..00000000 --- a/firmware/targets/api-hal-include/api-hal-version.h +++ /dev/null @@ -1,90 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** Device Colors */ -typedef enum { - ApiHalVersionColorUnknown=0x00, - ApiHalVersionColorBlack=0x01, - ApiHalVersionColorWhite=0x02, -} ApiHalVersionColor; - -/** Device Regions */ -typedef enum { - ApiHalVersionRegionUnknown=0x00, - ApiHalVersionRegionEuRu=0x01, - ApiHalVersionRegionUsCaAu=0x02, - ApiHalVersionRegionJp=0x03, -} ApiHalVersionRegion; - -/** Init flipper version */ -void api_hal_version_init(); - -/** Check target firmware version */ -bool api_hal_version_do_i_belong_here(); - -/** Get model name */ -const char* api_hal_version_get_model_name(); - -/** Get hardware version */ -const uint8_t api_hal_version_get_hw_version(); - -/** Get hardware target */ -const uint8_t api_hal_version_get_hw_target(); - -/** Get hardware body */ -const uint8_t api_hal_version_get_hw_body(); - -/** Get hardware body color */ -const ApiHalVersionColor api_hal_version_get_hw_color(); - -/** Get hardware connect */ -const uint8_t api_hal_version_get_hw_connect(); - -/** Get hardware region */ -const ApiHalVersionRegion api_hal_version_get_hw_region(); - -/** Get hardware timestamp */ -const uint32_t api_hal_version_get_hw_timestamp(); - -/** Get pointer to target name */ -const char* api_hal_version_get_name_ptr(); - -/** Get pointer to target device name */ -const char* api_hal_version_get_device_name_ptr(); - -/** Get pointer to target ble local device name */ -const char* api_hal_version_get_ble_local_device_name_ptr(); - -const uint8_t* api_hal_version_get_ble_mac(); - -/** - * Get address of version structure of bootloader, stored in chip flash. - * - * @return Address of boot version structure. - */ -const struct Version* api_hal_version_get_boot_version(void); - -/** - * Get address of version structure of firmware. - * - * @return Address of firmware version structure. - */ -const struct Version* api_hal_version_get_firmware_version(void); - -/** Get platform UID size in bytes */ -size_t api_hal_version_uid_size(); - -/** Get const pointer to UID */ -const uint8_t* api_hal_version_uid(); - -#ifdef __cplusplus -} -#endif diff --git a/firmware/targets/api-hal-include/api-hal.h b/firmware/targets/api-hal-include/api-hal.h deleted file mode 100644 index e6b30db0..00000000 --- a/firmware/targets/api-hal-include/api-hal.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#ifdef __cplusplus -template struct STOP_EXTERNING_ME {}; -#endif - -#include "api-hal-boot.h" -#include "api-hal-clock.h" -#include "api-hal-console.h" -#include "api-hal-os.h" -#include "api-hal-i2c.h" -#include "api-hal-resources.h" -#include "api-hal-gpio.h" -#include "api-hal-light.h" -#include "api-hal-delay.h" -#include "api-hal-pwm.h" -#include "api-hal-task.h" -#include "api-hal-power.h" -#include "api-hal-vcp.h" -#include "api-hal-interrupt.h" -#include "api-hal-version.h" -#include "api-hal-bt.h" -#include "api-hal-spi.h" -#include "api-hal-flash.h" -#include "api-hal-subghz.h" -#include "api-hal-vibro.h" -#include "api-hal-ibutton.h" -#include "api-hal-rfid.h" -#include "api-hal-nfc.h" - -/** Init api-hal */ -void api_hal_init(); diff --git a/firmware/targets/f6/Src/fatfs/spi_sd_hal.c b/firmware/targets/f6/Src/fatfs/spi_sd_hal.c index 386c8081..74058c47 100644 --- a/firmware/targets/f6/Src/fatfs/spi_sd_hal.c +++ b/firmware/targets/f6/Src/fatfs/spi_sd_hal.c @@ -1,11 +1,11 @@ #include "main.h" -#include "api-hal-spi.h" +#include "furi-hal-spi.h" #define SD_DUMMY_BYTE 0xFF const uint32_t SpiTimeout = 1000; uint8_t SD_IO_WriteByte(uint8_t Data); -static const ApiHalSpiDevice* sd_spi_dev = &api_hal_spi_devices[ApiHalSpiDeviceIdSdCardFast]; +static const FuriHalSpiDevice* sd_spi_dev = &furi_hal_spi_devices[FuriHalSpiDeviceIdSdCardFast]; /****************************************************************************** @@ -18,7 +18,7 @@ static const ApiHalSpiDevice* sd_spi_dev = &api_hal_spi_devices[ApiHalSpiDeviceI */ static void SPIx_Error(void) { /* Re-Initiaize the SPI communication BUS */ - api_hal_spi_bus_reset(sd_spi_dev->bus); + furi_hal_spi_bus_reset(sd_spi_dev->bus); } /** @@ -29,7 +29,7 @@ static void SPIx_Error(void) { * @retval None */ static void SPIx_WriteReadData(const uint8_t* DataIn, uint8_t* DataOut, uint16_t DataLength) { - bool status = api_hal_spi_bus_trx(sd_spi_dev->bus, (uint8_t*)DataIn, DataOut, DataLength, SpiTimeout); + bool status = furi_hal_spi_bus_trx(sd_spi_dev->bus, (uint8_t*)DataIn, DataOut, DataLength, SpiTimeout); /* Check the communication status */ if(!status) { @@ -46,7 +46,7 @@ static void SPIx_WriteReadData(const uint8_t* DataIn, uint8_t* DataOut, uint16_t __attribute__((unused)) static void SPIx_Write(uint8_t Value) { uint8_t data; - bool status = api_hal_spi_bus_trx(sd_spi_dev->bus, (uint8_t*)&Value, &data, 1, SpiTimeout); + bool status = furi_hal_spi_bus_trx(sd_spi_dev->bus, (uint8_t*)&Value, &data, 1, SpiTimeout); /* Check the communication status */ if(!status) { diff --git a/firmware/targets/f6/Src/fatfs/stm32_adafruit_sd.c b/firmware/targets/f6/Src/fatfs/stm32_adafruit_sd.c index c00ed04a..3a036e38 100644 --- a/firmware/targets/f6/Src/fatfs/stm32_adafruit_sd.c +++ b/firmware/targets/f6/Src/fatfs/stm32_adafruit_sd.c @@ -92,10 +92,10 @@ #include "string.h" #include "stdio.h" #include "spi.h" -#include -#include -#include -#include +#include +#include +#include +#include /** @addtogroup BSP * @{ @@ -295,14 +295,14 @@ static uint8_t SD_ReadData(void); */ uint8_t BSP_SD_Init(bool reset_card) { /* Slow speed init */ - const ApiHalSpiDevice* sd_spi_slow_dev = &api_hal_spi_devices[ApiHalSpiDeviceIdSdCardSlow]; - api_hal_spi_bus_lock(sd_spi_slow_dev->bus); - api_hal_spi_bus_configure(sd_spi_slow_dev->bus, sd_spi_slow_dev->config); + const FuriHalSpiDevice* sd_spi_slow_dev = &furi_hal_spi_devices[FuriHalSpiDeviceIdSdCardSlow]; + furi_hal_spi_bus_lock(sd_spi_slow_dev->bus); + furi_hal_spi_bus_configure(sd_spi_slow_dev->bus, sd_spi_slow_dev->config); /* We must reset card in spi_lock context */ if(reset_card) { /* disable power and set low on all bus pins */ - api_hal_power_disable_external_3_3v(); + furi_hal_power_disable_external_3_3v(); SD_SPI_Bus_To_Down_State(); hal_sd_detect_set_low(); delay(250); @@ -310,7 +310,7 @@ uint8_t BSP_SD_Init(bool reset_card) { /* reinit bus and enable power */ SD_SPI_Bus_To_Normal_State(); hal_sd_detect_init(); - api_hal_power_enable_external_3_3v(); + furi_hal_power_enable_external_3_3v(); delay(100); } @@ -326,7 +326,7 @@ uint8_t BSP_SD_Init(bool reset_card) { if(res == BSP_SD_OK) break; } - api_hal_spi_bus_unlock(sd_spi_slow_dev->bus); + furi_hal_spi_bus_unlock(sd_spi_slow_dev->bus); /* SD initialized and set to SPI mode properly */ return res; diff --git a/firmware/targets/f6/Src/fatfs/user_diskio.c b/firmware/targets/f6/Src/fatfs/user_diskio.c index f0f03560..811a11e6 100644 --- a/firmware/targets/f6/Src/fatfs/user_diskio.c +++ b/firmware/targets/f6/Src/fatfs/user_diskio.c @@ -36,7 +36,7 @@ /* Includes ------------------------------------------------------------------*/ #include "user_diskio.h" #include "spi.h" -#include "api-hal-spi.h" +#include "furi-hal-spi.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ @@ -53,7 +53,7 @@ static DSTATUS User_CheckStatus(BYTE lun) { return Stat; } -static const ApiHalSpiDevice* sd_spi_fast_dev = &api_hal_spi_devices[ApiHalSpiDeviceIdSdCardFast]; +static const FuriHalSpiDevice* sd_spi_fast_dev = &furi_hal_spi_devices[FuriHalSpiDeviceIdSdCardFast]; /* USER CODE END DECL */ /* Private function prototypes -----------------------------------------------*/ @@ -89,12 +89,12 @@ Diskio_drvTypeDef USER_Driver = { DSTATUS USER_initialize(BYTE pdrv) { /* USER CODE BEGIN INIT */ - api_hal_spi_bus_lock(sd_spi_fast_dev->bus); - api_hal_spi_bus_configure(sd_spi_fast_dev->bus, sd_spi_fast_dev->config); + furi_hal_spi_bus_lock(sd_spi_fast_dev->bus); + furi_hal_spi_bus_configure(sd_spi_fast_dev->bus, sd_spi_fast_dev->config); DSTATUS status = User_CheckStatus(pdrv); - api_hal_spi_bus_unlock(sd_spi_fast_dev->bus); + furi_hal_spi_bus_unlock(sd_spi_fast_dev->bus); return status; /* USER CODE END INIT */ @@ -123,8 +123,8 @@ DRESULT USER_read(BYTE pdrv, BYTE* buff, DWORD sector, UINT count) { /* USER CODE BEGIN READ */ DRESULT res = RES_ERROR; - api_hal_spi_bus_lock(sd_spi_fast_dev->bus); - api_hal_spi_bus_configure(sd_spi_fast_dev->bus, sd_spi_fast_dev->config); + furi_hal_spi_bus_lock(sd_spi_fast_dev->bus); + furi_hal_spi_bus_configure(sd_spi_fast_dev->bus, sd_spi_fast_dev->config); if(BSP_SD_ReadBlocks((uint32_t*)buff, (uint32_t)(sector), count, SD_DATATIMEOUT) == MSD_OK) { /* wait until the read operation is finished */ @@ -133,7 +133,7 @@ DRESULT USER_read(BYTE pdrv, BYTE* buff, DWORD sector, UINT count) { res = RES_OK; } - api_hal_spi_bus_unlock(sd_spi_fast_dev->bus); + furi_hal_spi_bus_unlock(sd_spi_fast_dev->bus); return res; /* USER CODE END READ */ @@ -153,8 +153,8 @@ DRESULT USER_write(BYTE pdrv, const BYTE* buff, DWORD sector, UINT count) { /* USER CODE HERE */ DRESULT res = RES_ERROR; - api_hal_spi_bus_lock(sd_spi_fast_dev->bus); - api_hal_spi_bus_configure(sd_spi_fast_dev->bus, sd_spi_fast_dev->config); + furi_hal_spi_bus_lock(sd_spi_fast_dev->bus); + furi_hal_spi_bus_configure(sd_spi_fast_dev->bus, sd_spi_fast_dev->config); if(BSP_SD_WriteBlocks((uint32_t*)buff, (uint32_t)(sector), count, SD_DATATIMEOUT) == MSD_OK) { /* wait until the Write operation is finished */ @@ -163,7 +163,7 @@ DRESULT USER_write(BYTE pdrv, const BYTE* buff, DWORD sector, UINT count) { res = RES_OK; } - api_hal_spi_bus_unlock(sd_spi_fast_dev->bus); + furi_hal_spi_bus_unlock(sd_spi_fast_dev->bus); return res; /* USER CODE END WRITE */ @@ -185,8 +185,8 @@ DRESULT USER_ioctl(BYTE pdrv, BYTE cmd, void* buff) { if(Stat & STA_NOINIT) return RES_NOTRDY; - api_hal_spi_bus_lock(sd_spi_fast_dev->bus); - api_hal_spi_bus_configure(sd_spi_fast_dev->bus, sd_spi_fast_dev->config); + furi_hal_spi_bus_lock(sd_spi_fast_dev->bus); + furi_hal_spi_bus_configure(sd_spi_fast_dev->bus, sd_spi_fast_dev->config); switch(cmd) { /* Make sure that no pending write process */ @@ -219,7 +219,7 @@ DRESULT USER_ioctl(BYTE pdrv, BYTE cmd, void* buff) { res = RES_PARERR; } - api_hal_spi_bus_unlock(sd_spi_fast_dev->bus); + furi_hal_spi_bus_unlock(sd_spi_fast_dev->bus); return res; /* USER CODE END IOCTL */ diff --git a/firmware/targets/f6/Src/main.c b/firmware/targets/f6/Src/main.c index 8af59229..b9deedf2 100644 --- a/firmware/targets/f6/Src/main.c +++ b/firmware/targets/f6/Src/main.c @@ -3,7 +3,7 @@ #include "fatfs/fatfs.h" #include -#include +#include #include int main(void) { @@ -13,8 +13,8 @@ int main(void) { // Initialize ST HAL HAL_Init(); - // Flipper API HAL - api_hal_init(); + // Flipper FURI HAL + furi_hal_init(); // 3rd party MX_FATFS_Init(); diff --git a/firmware/targets/f6/Src/usbd_cdc_if.c b/firmware/targets/f6/Src/usbd_cdc_if.c index cd6946c4..8a7b5913 100644 --- a/firmware/targets/f6/Src/usbd_cdc_if.c +++ b/firmware/targets/f6/Src/usbd_cdc_if.c @@ -51,11 +51,11 @@ /* USER CODE BEGIN PRIVATE_TYPES */ -extern void _api_hal_vcp_init(); -extern void _api_hal_vcp_deinit(); -extern void _api_hal_vcp_control_line(uint8_t state); -extern void _api_hal_vcp_rx_callback(char* buffer, size_t size); -extern void _api_hal_vcp_tx_complete(size_t size); +extern void _furi_hal_vcp_init(); +extern void _furi_hal_vcp_deinit(); +extern void _furi_hal_vcp_control_line(uint8_t state); +extern void _furi_hal_vcp_rx_callback(char* buffer, size_t size); +extern void _furi_hal_vcp_tx_complete(size_t size); /* USER CODE END PRIVATE_TYPES */ @@ -162,7 +162,7 @@ static int8_t CDC_Init_FS(void) /* Set Application Buffers */ USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0); USBD_CDC_SetRxBuffer(&hUsbDeviceFS, UserRxBufferFS); - _api_hal_vcp_init(); + _furi_hal_vcp_init(); return (USBD_OK); /* USER CODE END 3 */ } @@ -174,7 +174,7 @@ static int8_t CDC_Init_FS(void) static int8_t CDC_DeInit_FS(void) { /* USER CODE BEGIN 4 */ - _api_hal_vcp_deinit(); + _furi_hal_vcp_deinit(); return (USBD_OK); /* USER CODE END 4 */ } @@ -214,7 +214,7 @@ static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length) /*******************************************************************************/ } else if (cmd == CDC_GET_LINE_CODING) { } else if (cmd == CDC_SET_CONTROL_LINE_STATE) { - _api_hal_vcp_control_line(((USBD_SetupReqTypedef*)pbuf)->wValue); + _furi_hal_vcp_control_line(((USBD_SetupReqTypedef*)pbuf)->wValue); } else if (cmd == CDC_SEND_BREAK) { } else { } @@ -241,7 +241,7 @@ static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length) static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len) { /* USER CODE BEGIN 6 */ - _api_hal_vcp_rx_callback((char*)Buf, *Len); + _furi_hal_vcp_rx_callback((char*)Buf, *Len); USBD_CDC_ReceivePacket(&hUsbDeviceFS); return (USBD_OK); /* USER CODE END 6 */ @@ -291,7 +291,7 @@ static int8_t CDC_TransmitCplt_FS(uint8_t *Buf, uint32_t *Len, uint8_t epnum) /* USER CODE BEGIN 13 */ UNUSED(Buf); UNUSED(epnum); - _api_hal_vcp_tx_complete(*Len); + _furi_hal_vcp_tx_complete(*Len); /* USER CODE END 13 */ return result; } diff --git a/firmware/targets/f6/Src/usbd_desc.c b/firmware/targets/f6/Src/usbd_desc.c index 360353ff..9e7c5483 100644 --- a/firmware/targets/f6/Src/usbd_desc.c +++ b/firmware/targets/f6/Src/usbd_desc.c @@ -23,7 +23,7 @@ #include "usbd_core.h" #include "usbd_desc.h" #include "usbd_conf.h" -#include "api-hal-version.h" +#include "furi-hal-version.h" /* USER CODE BEGIN INCLUDE */ /* USER CODE END INCLUDE */ @@ -245,7 +245,7 @@ uint8_t * USBD_CDC_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length */ uint8_t * USBD_CDC_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { - USBD_GetString((uint8_t*)api_hal_version_get_device_name_ptr(), USBD_StrDesc, length); + USBD_GetString((uint8_t*)furi_hal_version_get_device_name_ptr(), USBD_StrDesc, length); return USBD_StrDesc; } @@ -275,9 +275,9 @@ uint8_t * USBD_CDC_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length /* Update the serial number string descriptor with the data from the unique * ID */ - if(api_hal_version_get_name_ptr()){ + if(furi_hal_version_get_name_ptr()){ char buffer[14] = "flip_"; - strncat(buffer, api_hal_version_get_name_ptr(), 8); + strncat(buffer, furi_hal_version_get_name_ptr(), 8); USBD_GetString((uint8_t*) buffer, USBD_StringSerial, length); } else { Get_SerialNum(); diff --git a/firmware/targets/f6/api-hal/api-hal-clock.h b/firmware/targets/f6/api-hal/api-hal-clock.h deleted file mode 100644 index 077d4f3f..00000000 --- a/firmware/targets/f6/api-hal/api-hal-clock.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -/** Initialize clocks */ -void api_hal_clock_init(); - -/** Switch to HSI clock */ -void api_hal_clock_switch_to_hsi(); - -/** Switch to PLL clock */ -void api_hal_clock_switch_to_pll(); diff --git a/firmware/targets/f6/api-hal/api-hal-flash.c b/firmware/targets/f6/api-hal/api-hal-flash.c deleted file mode 100644 index 97a9afa2..00000000 --- a/firmware/targets/f6/api-hal/api-hal-flash.c +++ /dev/null @@ -1,88 +0,0 @@ -#include -#include -#include -#include - -/* Free flash space borders, exported by linker */ -extern const void __free_flash_start__; -extern const void __free_flash_end__; - -#define API_HAL_FLASH_READ_BLOCK 8 -#define API_HAL_FLASH_WRITE_BLOCK 8 -#define API_HAL_FLASH_PAGE_SIZE 4096 -#define API_HAL_FLASH_CYCLES_COUNT 10000 - -size_t api_hal_flash_get_base() { - return FLASH_BASE; -} - -size_t api_hal_flash_get_read_block_size() { - return API_HAL_FLASH_READ_BLOCK; -} - -size_t api_hal_flash_get_write_block_size() { - return API_HAL_FLASH_WRITE_BLOCK; -} - -size_t api_hal_flash_get_page_size() { - return API_HAL_FLASH_PAGE_SIZE; -} - -size_t api_hal_flash_get_cycles_count() { - return API_HAL_FLASH_CYCLES_COUNT; -} - -const void* api_hal_flash_get_free_start_address() { - return &__free_flash_start__; -} - -const void* api_hal_flash_get_free_end_address() { - return &__free_flash_end__; -} - -size_t api_hal_flash_get_free_page_start_address() { - size_t start = (size_t)api_hal_flash_get_free_start_address(); - size_t page_start = start - start % API_HAL_FLASH_PAGE_SIZE; - if (page_start != start) { - page_start += API_HAL_FLASH_PAGE_SIZE; - } - return page_start; -} - -size_t api_hal_flash_get_free_page_count() { - size_t end = (size_t)api_hal_flash_get_free_end_address(); - size_t page_start = (size_t)api_hal_flash_get_free_page_start_address(); - return (end-page_start) / API_HAL_FLASH_PAGE_SIZE; -} - -bool api_hal_flash_erase(uint8_t page, uint8_t count) { - if (!api_hal_bt_lock_flash()) { - return false; - } - FLASH_EraseInitTypeDef erase; - erase.TypeErase = FLASH_TYPEERASE_PAGES; - erase.Page = page; - erase.NbPages = count; - uint32_t error; - HAL_StatusTypeDef status = HAL_FLASHEx_Erase(&erase, &error); - api_hal_bt_unlock_flash(); - return status == HAL_OK; -} - -bool api_hal_flash_write_dword(size_t address, uint64_t data) { - if (!api_hal_bt_lock_flash()) { - return false; - } - HAL_StatusTypeDef status = HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, address, data); - api_hal_bt_unlock_flash(); - return status == HAL_OK; -} - -bool api_hal_flash_write_dword_from(size_t address, size_t source_address) { - if (!api_hal_bt_lock_flash()) { - return false; - } - HAL_StatusTypeDef status = HAL_FLASH_Program(FLASH_TYPEPROGRAM_FAST, address, source_address); - api_hal_bt_unlock_flash(); - return status == HAL_OK; -} diff --git a/firmware/targets/f6/api-hal/api-hal-os-timer.h b/firmware/targets/f6/api-hal/api-hal-os-timer.h deleted file mode 100644 index f700e6b6..00000000 --- a/firmware/targets/f6/api-hal/api-hal-os-timer.h +++ /dev/null @@ -1,64 +0,0 @@ -#pragma once - -#include -#include -#include - -// Timer used for system ticks -#define API_HAL_OS_TIMER_MAX 0xFFFF -#define API_HAL_OS_TIMER_REG_LOAD_DLY 0x1 -#define API_HAL_OS_TIMER LPTIM2 -#define API_HAL_OS_TIMER_IRQ LPTIM2_IRQn - -static inline void api_hal_os_timer_init() { - // Configure clock source - LL_RCC_SetLPTIMClockSource(LL_RCC_LPTIM2_CLKSOURCE_LSE); - LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_LPTIM2); - // Set interrupt priority and enable them - NVIC_SetPriority(API_HAL_OS_TIMER_IRQ, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 15, 0)); - NVIC_EnableIRQ(API_HAL_OS_TIMER_IRQ); -} - -static inline void api_hal_os_timer_continuous(uint32_t count) { - // Enable timer - LL_LPTIM_Enable(API_HAL_OS_TIMER); - while(!LL_LPTIM_IsEnabled(API_HAL_OS_TIMER)); - - // Enable rutoreload match interrupt - LL_LPTIM_EnableIT_ARRM(API_HAL_OS_TIMER); - - // Set autoreload and start counter - LL_LPTIM_SetAutoReload(API_HAL_OS_TIMER, count); - LL_LPTIM_StartCounter(API_HAL_OS_TIMER, LL_LPTIM_OPERATING_MODE_CONTINUOUS); -} - -static inline void api_hal_os_timer_single(uint32_t count) { - // Enable timer - LL_LPTIM_Enable(API_HAL_OS_TIMER); - while(!LL_LPTIM_IsEnabled(API_HAL_OS_TIMER)); - - // Enable compare match interrupt - LL_LPTIM_EnableIT_CMPM(API_HAL_OS_TIMER); - - // Set compare, autoreload and start counter - // Include some marging to workaround ARRM behaviour - LL_LPTIM_SetCompare(API_HAL_OS_TIMER, count-3); - LL_LPTIM_SetAutoReload(API_HAL_OS_TIMER, count); - LL_LPTIM_StartCounter(API_HAL_OS_TIMER, LL_LPTIM_OPERATING_MODE_ONESHOT); -} - -static inline void api_hal_os_timer_reset() { - // Hard reset timer - // THE ONLY RELIABLEWAY to stop it according to errata - LL_LPTIM_DeInit(API_HAL_OS_TIMER); -} - -static inline uint32_t api_hal_os_timer_get_cnt() { - uint32_t counter = LL_LPTIM_GetCounter(API_HAL_OS_TIMER); - uint32_t counter_shadow = LL_LPTIM_GetCounter(API_HAL_OS_TIMER); - while(counter != counter_shadow) { - counter = counter_shadow; - counter_shadow = LL_LPTIM_GetCounter(API_HAL_OS_TIMER); - } - return counter; -} diff --git a/firmware/targets/f6/api-hal/api-hal-spi-config.h b/firmware/targets/f6/api-hal/api-hal-spi-config.h deleted file mode 100644 index c8a3da1b..00000000 --- a/firmware/targets/f6/api-hal/api-hal-spi-config.h +++ /dev/null @@ -1,67 +0,0 @@ -#pragma once - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -extern const SPI_InitTypeDef api_hal_spi_config_nfc; -extern const SPI_InitTypeDef api_hal_spi_config_subghz; -extern const SPI_InitTypeDef api_hal_spi_config_display; -extern const SPI_InitTypeDef api_hal_spi_config_sd_fast; -extern const SPI_InitTypeDef api_hal_spi_config_sd_slow; - -/** API HAL SPI BUS handler - * Structure content may change at some point - */ -typedef struct { - const SPI_HandleTypeDef* spi; - const osMutexId_t* mutex; - const GpioPin* miso; - const GpioPin* mosi; - const GpioPin* clk; -} ApiHalSpiBus; - -/** API HAL SPI Device handler - * Structure content may change at some point - */ -typedef struct { - const ApiHalSpiBus* bus; - const SPI_InitTypeDef* config; - const GpioPin* chip_select; -} ApiHalSpiDevice; - -/** API HAL SPI Standard Device IDs */ -typedef enum { - ApiHalSpiDeviceIdSubGhz, /** SubGhz: CC1101, non-standard SPI usage */ - ApiHalSpiDeviceIdDisplay, /** Display: ERC12864, only have MOSI */ - ApiHalSpiDeviceIdSdCardFast, /** SDCARD: fast mode, after initialization */ - ApiHalSpiDeviceIdSdCardSlow, /** SDCARD: slow mode, before initialization */ - ApiHalSpiDeviceIdNfc, /** NFC: ST25R3916, pretty standard, but RFAL makes it complex */ - - ApiHalSpiDeviceIdMax, /** Service Value, do not use */ -} ApiHalSpiDeviceId; - -/** Api Hal Spi Bus R - * CC1101, Nfc - */ -extern const ApiHalSpiBus spi_r; - -/** Api Hal Spi Bus D - * Display, SdCard - */ -extern const ApiHalSpiBus spi_d; - -/** Api Hal Spi devices */ -extern const ApiHalSpiDevice api_hal_spi_devices[ApiHalSpiDeviceIdMax]; - -typedef struct { - const ApiHalSpiBus* bus; - const SPI_InitTypeDef config; -} SPIDevice; - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/firmware/targets/f6/api-hal/api-hal-vcp.c b/firmware/targets/f6/api-hal/api-hal-vcp.c deleted file mode 100644 index 296ee1e8..00000000 --- a/firmware/targets/f6/api-hal/api-hal-vcp.c +++ /dev/null @@ -1,106 +0,0 @@ -#include -#include -#include -#include - -#define API_HAL_VCP_RX_BUFFER_SIZE 600 - -typedef struct { - StreamBufferHandle_t rx_stream; - osSemaphoreId_t tx_semaphore; - volatile bool alive; - volatile bool underrun; -} ApiHalVcp; - -static ApiHalVcp* api_hal_vcp = NULL; - -static const uint8_t ascii_soh = 0x01; -static const uint8_t ascii_eot = 0x04; - -void _api_hal_vcp_init(); -void _api_hal_vcp_deinit(); -void _api_hal_vcp_control_line(uint8_t state); -void _api_hal_vcp_rx_callback(const uint8_t* buffer, size_t size); -void _api_hal_vcp_tx_complete(size_t size); - -void api_hal_vcp_init() { - api_hal_vcp = furi_alloc(sizeof(ApiHalVcp)); - api_hal_vcp->rx_stream = xStreamBufferCreate(API_HAL_VCP_RX_BUFFER_SIZE, 1); - api_hal_vcp->tx_semaphore = osSemaphoreNew(1, 1, NULL); - api_hal_vcp->alive = false; - api_hal_vcp->underrun = false; - FURI_LOG_I("FuriHalVcp", "Init OK"); -} - -void _api_hal_vcp_init() { - osSemaphoreRelease(api_hal_vcp->tx_semaphore); -} - -void _api_hal_vcp_deinit() { - api_hal_vcp->alive = false; - osSemaphoreRelease(api_hal_vcp->tx_semaphore); -} - -void _api_hal_vcp_control_line(uint8_t state) { - // bit 0: DTR state, bit 1: RTS state - // bool dtr = state & 0b01; - bool dtr = state & 0b1; - - if (dtr) { - if (!api_hal_vcp->alive) { - api_hal_vcp->alive = true; - _api_hal_vcp_rx_callback(&ascii_soh, 1); // SOH - } - } else { - if (api_hal_vcp->alive) { - _api_hal_vcp_rx_callback(&ascii_eot, 1); // EOT - api_hal_vcp->alive = false; - } - } - - osSemaphoreRelease(api_hal_vcp->tx_semaphore); -} - -void _api_hal_vcp_rx_callback(const uint8_t* buffer, size_t size) { - BaseType_t xHigherPriorityTaskWoken = pdFALSE; - size_t ret = xStreamBufferSendFromISR(api_hal_vcp->rx_stream, buffer, size, &xHigherPriorityTaskWoken); - if (ret != size) { - api_hal_vcp->underrun = true; - } - portYIELD_FROM_ISR(xHigherPriorityTaskWoken); -} - -void _api_hal_vcp_tx_complete(size_t size) { - osSemaphoreRelease(api_hal_vcp->tx_semaphore); -} - -size_t api_hal_vcp_rx(uint8_t* buffer, size_t size) { - furi_assert(api_hal_vcp); - return xStreamBufferReceive(api_hal_vcp->rx_stream, buffer, size, portMAX_DELAY); -} - -size_t api_hal_vcp_rx_with_timeout(uint8_t* buffer, size_t size, uint32_t timeout) { - furi_assert(api_hal_vcp); - return xStreamBufferReceive(api_hal_vcp->rx_stream, buffer, size, timeout); -} - -void api_hal_vcp_tx(const uint8_t* buffer, size_t size) { - furi_assert(api_hal_vcp); - - while (size > 0 && api_hal_vcp->alive) { - furi_check(osSemaphoreAcquire(api_hal_vcp->tx_semaphore, osWaitForever) == osOK); - - size_t batch_size = size; - if (batch_size > APP_TX_DATA_SIZE) { - batch_size = APP_TX_DATA_SIZE; - } - - if (CDC_Transmit_FS((uint8_t*)buffer, batch_size) == USBD_OK) { - size -= batch_size; - buffer += batch_size; - } else { - // Shouldn't be there - osDelay(100); - } - } -} diff --git a/firmware/targets/f6/api-hal/api-hal-version.c b/firmware/targets/f6/api-hal/api-hal-version.c deleted file mode 100644 index 761f57e1..00000000 --- a/firmware/targets/f6/api-hal/api-hal-version.c +++ /dev/null @@ -1,242 +0,0 @@ -#include - -#include -#include -#include - -#include -#include "ble.h" - -#define API_HAL_VERSION_OTP_HEADER_MAGIC 0xBABE -#define API_HAL_VERSION_NAME_LENGTH 8 -#define API_HAL_VERSION_ARRAY_NAME_LENGTH (API_HAL_VERSION_NAME_LENGTH + 1) -/** BLE symbol + "Flipper " + name */ -#define API_HAL_VERSION_DEVICE_NAME_LENGTH (1 + 8 + API_HAL_VERSION_ARRAY_NAME_LENGTH) -#define API_HAL_VERSION_OTP_ADDRESS OTP_AREA_BASE - -/** OTP Versions enum */ -typedef enum { - ApiHalVersionOtpVersion0=0x00, - ApiHalVersionOtpVersion1=0x01, - ApiHalVersionOtpVersionEmpty=0xFFFFFFFE, - ApiHalVersionOtpVersionUnknown=0xFFFFFFFF, -} ApiHalVersionOtpVersion; - -/** OTP V0 Structure: prototypes and early EVT */ -typedef struct { - uint8_t board_version; - uint8_t board_target; - uint8_t board_body; - uint8_t board_connect; - uint32_t header_timestamp; - char name[API_HAL_VERSION_NAME_LENGTH]; -} ApiHalVersionOTPv0; - -/** OTP V1 Structure: late EVT, DVT, PVT, Production */ -typedef struct { - /* First 64 bits: header */ - uint16_t header_magic; - uint8_t header_version; - uint8_t header_reserved; - uint32_t header_timestamp; - - /* Second 64 bits: board info */ - uint8_t board_version; /** Board version */ - uint8_t board_target; /** Board target firmware */ - uint8_t board_body; /** Board body */ - uint8_t board_connect; /** Board interconnect */ - uint8_t board_color; /** Board color */ - uint8_t board_region; /** Board region */ - uint16_t board_reserved; /** Reserved for future use, 0x0000 */ - - /* Third 64 bits: Unique Device Name */ - char name[API_HAL_VERSION_NAME_LENGTH]; /** Unique Device Name */ -} ApiHalVersionOTPv1; - -/** Represenation Model: */ -typedef struct { - ApiHalVersionOtpVersion otp_version; - - uint32_t timestamp; - - uint8_t board_version; /** Board version */ - uint8_t board_target; /** Board target firmware */ - uint8_t board_body; /** Board body */ - uint8_t board_connect; /** Board interconnect */ - uint8_t board_color; /** Board color */ - uint8_t board_region; /** Board region */ - - char name[API_HAL_VERSION_ARRAY_NAME_LENGTH]; /** \0 terminated name */ - char device_name[API_HAL_VERSION_DEVICE_NAME_LENGTH]; /** device name for special needs */ - uint8_t ble_mac[6]; -} ApiHalVersion; - -static ApiHalVersion api_hal_version = {0}; - -static ApiHalVersionOtpVersion api_hal_version_get_otp_version() { - if (*(uint64_t*)API_HAL_VERSION_OTP_ADDRESS == 0xFFFFFFFF) { - return ApiHalVersionOtpVersionEmpty; - } else { - if (((ApiHalVersionOTPv1*)API_HAL_VERSION_OTP_ADDRESS)->header_magic == API_HAL_VERSION_OTP_HEADER_MAGIC) { - return ApiHalVersionOtpVersion1; - } else if (((ApiHalVersionOTPv0*)API_HAL_VERSION_OTP_ADDRESS)->board_version <= 10) { - return ApiHalVersionOtpVersion0; - } else { - return ApiHalVersionOtpVersionUnknown; - } - } -} - -static void api_hal_version_set_name(const char* name) { - if(name != NULL) { - strlcpy(api_hal_version.name, name, API_HAL_VERSION_ARRAY_NAME_LENGTH); - snprintf( - api_hal_version.device_name, - API_HAL_VERSION_DEVICE_NAME_LENGTH, - "xFlipper %s", - api_hal_version.name); - } else { - snprintf( - api_hal_version.device_name, - API_HAL_VERSION_DEVICE_NAME_LENGTH, - "xFlipper"); - } - - api_hal_version.device_name[0] = AD_TYPE_COMPLETE_LOCAL_NAME; - - // BLE Mac address - uint32_t udn = LL_FLASH_GetUDN(); - uint32_t company_id = LL_FLASH_GetSTCompanyID(); - uint32_t device_id = LL_FLASH_GetDeviceID(); - api_hal_version.ble_mac[0] = (uint8_t)(udn & 0x000000FF); - api_hal_version.ble_mac[1] = (uint8_t)( (udn & 0x0000FF00) >> 8 ); - api_hal_version.ble_mac[2] = (uint8_t)( (udn & 0x00FF0000) >> 16 ); - api_hal_version.ble_mac[3] = (uint8_t)device_id; - api_hal_version.ble_mac[4] = (uint8_t)(company_id & 0x000000FF); - api_hal_version.ble_mac[5] = (uint8_t)( (company_id & 0x0000FF00) >> 8 ); -} - -static void api_hal_version_load_otp_default() { - api_hal_version_set_name(NULL); -} - -static void api_hal_version_load_otp_v0() { - const ApiHalVersionOTPv0* otp = (ApiHalVersionOTPv0*)API_HAL_VERSION_OTP_ADDRESS; - - api_hal_version.timestamp = otp->header_timestamp; - api_hal_version.board_version = otp->board_version; - api_hal_version.board_target = otp->board_target; - api_hal_version.board_body = otp->board_body; - api_hal_version.board_connect = otp->board_connect; - api_hal_version.board_color = 0; - api_hal_version.board_region = 0; - - api_hal_version_set_name(otp->name); -} - -static void api_hal_version_load_otp_v1() { - const ApiHalVersionOTPv1* otp = (ApiHalVersionOTPv1*)API_HAL_VERSION_OTP_ADDRESS; - - api_hal_version.timestamp = otp->header_timestamp; - api_hal_version.board_version = otp->board_version; - api_hal_version.board_target = otp->board_target; - api_hal_version.board_body = otp->board_body; - api_hal_version.board_connect = otp->board_connect; - api_hal_version.board_color = otp->board_color; - api_hal_version.board_region = otp->board_region; - - api_hal_version_set_name(otp->name); -} - -void api_hal_version_init() { - api_hal_version.otp_version = api_hal_version_get_otp_version(); - switch(api_hal_version.otp_version) { - case ApiHalVersionOtpVersionUnknown: - api_hal_version_load_otp_default(); - break; - case ApiHalVersionOtpVersionEmpty: - api_hal_version_load_otp_default(); - break; - case ApiHalVersionOtpVersion0: - api_hal_version_load_otp_v0(); - break; - case ApiHalVersionOtpVersion1: - api_hal_version_load_otp_v1(); - break; - default: furi_check(0); - } - FURI_LOG_I("FuriHalVersion", "Init OK"); -} - -bool api_hal_version_do_i_belong_here() { - return api_hal_version_get_hw_target() == 6; -} - -const char* api_hal_version_get_model_name() { - return "Flipper Zero"; -} - -const uint8_t api_hal_version_get_hw_version() { - return api_hal_version.board_version; -} - -const uint8_t api_hal_version_get_hw_target() { - return api_hal_version.board_target; -} - -const uint8_t api_hal_version_get_hw_body() { - return api_hal_version.board_body; -} - -const ApiHalVersionColor api_hal_version_get_hw_color() { - return api_hal_version.board_color; -} - -const uint8_t api_hal_version_get_hw_connect() { - return api_hal_version.board_connect; -} - -const ApiHalVersionRegion api_hal_version_get_hw_region() { - return api_hal_version.board_region; -} - -const uint32_t api_hal_version_get_hw_timestamp() { - return api_hal_version.timestamp; -} - -const char* api_hal_version_get_name_ptr() { - return *api_hal_version.name == 0x00 ? NULL : api_hal_version.name; -} - -const char* api_hal_version_get_device_name_ptr() { - return api_hal_version.device_name + 1; -} - -const char* api_hal_version_get_ble_local_device_name_ptr() { - return api_hal_version.device_name; -} - -const uint8_t* api_hal_version_get_ble_mac() { - return api_hal_version.ble_mac; -} - -const struct Version* api_hal_version_get_firmware_version(void) { - return version_get(); -} - -const struct Version* api_hal_version_get_boot_version(void) { -#ifdef NO_BOOTLOADER - return 0; -#else - /* Backup register which points to structure in flash memory */ - return (const struct Version*)LL_RTC_BAK_GetRegister(RTC, LL_RTC_BKP_DR1); -#endif -} - -size_t api_hal_version_uid_size() { - return 64/8; -} - -const uint8_t* api_hal_version_uid() { - return (const uint8_t *)UID64_BASE; -} diff --git a/firmware/targets/f6/ble-glue/app_ble.c b/firmware/targets/f6/ble-glue/app_ble.c index 634001c3..18ca03ae 100644 --- a/firmware/targets/f6/ble-glue/app_ble.c +++ b/firmware/targets/f6/ble-glue/app_ble.c @@ -14,7 +14,7 @@ #include "dis_app.h" #include "hrs_app.h" -#include +#include typedef struct _tSecurityParams { uint8_t ioCapability; @@ -223,7 +223,7 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt ) } /* restart advertising */ Adv_Request(APP_BLE_FAST_ADV); - api_hal_power_insomnia_exit(); + furi_hal_power_insomnia_exit(); } break; /* EVT_DISCONN_COMPLETE */ @@ -272,7 +272,7 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt ) break; case EVT_LE_CONN_COMPLETE: { - api_hal_power_insomnia_enter(); + furi_hal_power_insomnia_enter(); hci_le_connection_complete_event_rp0 *connection_complete_event; /** @@ -538,7 +538,7 @@ static void Ble_Hci_Gap_Gatt_Init() { if (role > 0) { - const char *name = api_hal_version_get_device_name_ptr(); + const char *name = furi_hal_version_get_device_name_ptr(); aci_gap_init(role, 0, strlen(name), &gap_service_handle, &gap_dev_name_char_handle, &gap_appearance_char_handle); @@ -640,7 +640,7 @@ static void Adv_Request(APP_BLE_ConnStatus_t New_Status) BleApplicationContext.Device_Connection_Status = New_Status; - const char* name = api_hal_version_get_ble_local_device_name_ptr(); + const char* name = furi_hal_version_get_ble_local_device_name_ptr(); /* Start Fast or Low Power Advertising */ ret = aci_gap_set_discoverable( diff --git a/firmware/targets/f6/ble-glue/app_debug.c b/firmware/targets/f6/ble-glue/app_debug.c index f5b2036d..0e09f44f 100644 --- a/firmware/targets/f6/ble-glue/app_debug.c +++ b/firmware/targets/f6/ble-glue/app_debug.c @@ -27,7 +27,7 @@ #include "shci.h" #include "tl.h" #include "dbg_trace.h" -#include +#include /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -358,7 +358,7 @@ void DbgOutputInit( void ) void DbgOutputTraces( uint8_t *p_data, uint16_t size, void (*cb)(void) ) { - api_hal_console_tx(p_data, size); + furi_hal_console_tx(p_data, size); cb(); } #endif diff --git a/firmware/targets/f6/ble-glue/app_entry.c b/firmware/targets/f6/ble-glue/app_entry.c index 394669b5..2a8e35cc 100644 --- a/firmware/targets/f6/ble-glue/app_entry.c +++ b/firmware/targets/f6/ble-glue/app_entry.c @@ -8,7 +8,7 @@ #include "shci_tl.h" #include "stm32_lpm.h" #include "app_debug.h" -#include +#include extern RTC_HandleTypeDef hrtc; @@ -52,7 +52,7 @@ void APPE_Init() { HW_TS_Init(hw_ts_InitMode_Full, &hrtc); /**< Initialize the TimerServer */ // APPD_Init(); - api_hal_power_insomnia_enter(); + furi_hal_power_insomnia_enter(); appe_Tl_Init(); /* Initialize all transport layers */ @@ -144,7 +144,7 @@ static void APPE_SysUserEvtRx( void * pPayload ) { } else { ble_glue_status = BleGlueStatusBroken; } - api_hal_power_insomnia_exit(); + furi_hal_power_insomnia_exit(); } /************************************************************* diff --git a/firmware/targets/f6/ble-glue/dis_app.c b/firmware/targets/f6/ble-glue/dis_app.c index 45bc4685..0bf6d4c0 100644 --- a/firmware/targets/f6/ble-glue/dis_app.c +++ b/firmware/targets/f6/ble-glue/dis_app.c @@ -1,7 +1,7 @@ #include "app_common.h" #include "ble.h" #include "dis_app.h" -#include +#include #if ((BLE_CFG_DIS_SYSTEM_ID != 0) || (CFG_MENU_DEVICE_INFORMATION != 0)) static const uint8_t system_id[BLE_CFG_DIS_SYSTEM_ID_LEN_MAX] = { @@ -58,7 +58,7 @@ void DISAPP_Init(void) { * @param pPData * @return */ - const char* name = api_hal_version_get_device_name_ptr(); + const char* name = furi_hal_version_get_device_name_ptr(); dis_information_data.pPayload = (uint8_t*)name; dis_information_data.Length = strlen(name) + 1; DIS_UpdateChar(MODEL_NUMBER_UUID, &dis_information_data); diff --git a/firmware/targets/f6/ble-glue/tl_dbg_conf.h b/firmware/targets/f6/ble-glue/tl_dbg_conf.h index 81d924e3..4c38cfb5 100644 --- a/firmware/targets/f6/ble-glue/tl_dbg_conf.h +++ b/firmware/targets/f6/ble-glue/tl_dbg_conf.h @@ -66,7 +66,7 @@ extern "C" { #endif #if (TL_SHCI_CMD_DBG_RAW_EN != 0) -#define TL_SHCI_CMD_DBG_RAW(_PDATA_, _SIZE_) api_hal_console_tx(_PDATA_, _SIZE_) +#define TL_SHCI_CMD_DBG_RAW(_PDATA_, _SIZE_) furi_hal_console_tx(_PDATA_, _SIZE_) #else #define TL_SHCI_CMD_DBG_RAW(...) #endif @@ -80,7 +80,7 @@ extern "C" { #endif #if (TL_SHCI_EVT_DBG_RAW_EN != 0) -#define TL_SHCI_EVT_DBG_RAW(_PDATA_, _SIZE_) api_hal_console_tx(_PDATA_, _SIZE_) +#define TL_SHCI_EVT_DBG_RAW(_PDATA_, _SIZE_) furi_hal_console_tx(_PDATA_, _SIZE_) #else #define TL_SHCI_EVT_DBG_RAW(...) #endif @@ -97,7 +97,7 @@ extern "C" { #endif #if (TL_HCI_CMD_DBG_RAW_EN != 0) -#define TL_HCI_CMD_DBG_RAW(_PDATA_, _SIZE_) api_hal_console_tx(_PDATA_, _SIZE_) +#define TL_HCI_CMD_DBG_RAW(_PDATA_, _SIZE_) furi_hal_console_tx(_PDATA_, _SIZE_) #else #define TL_HCI_CMD_DBG_RAW(...) #endif @@ -111,7 +111,7 @@ extern "C" { #endif #if (TL_HCI_EVT_DBG_RAW_EN != 0) -#define TL_HCI_EVT_DBG_RAW(_PDATA_, _SIZE_) api_hal_console_tx(_PDATA_, _SIZE_) +#define TL_HCI_EVT_DBG_RAW(_PDATA_, _SIZE_) furi_hal_console_tx(_PDATA_, _SIZE_) #else #define TL_HCI_EVT_DBG_RAW(...) #endif diff --git a/firmware/targets/f6/api-hal/api-hal-boot.c b/firmware/targets/f6/furi-hal/furi-hal-boot.c similarity index 66% rename from firmware/targets/f6/api-hal/api-hal-boot.c rename to firmware/targets/f6/furi-hal/furi-hal-boot.c index 5a868a93..978711c5 100644 --- a/firmware/targets/f6/api-hal/api-hal-boot.c +++ b/firmware/targets/f6/furi-hal/furi-hal-boot.c @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -7,25 +7,25 @@ #define BOOT_REQUEST_CLEAN 0xDADEDADE #define BOOT_REQUEST_DFU 0xDF00B000 -void api_hal_boot_init() { +void furi_hal_boot_init() { #ifndef DEBUG LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR0, BOOT_REQUEST_TAINTED); #endif FURI_LOG_I("FuriHalBoot", "Init OK"); } -void api_hal_boot_set_mode(ApiHalBootMode mode) { - if (mode == ApiHalBootModeNormal) { +void furi_hal_boot_set_mode(FuriHalBootMode mode) { + if (mode == FuriHalBootModeNormal) { LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR0, BOOT_REQUEST_CLEAN); - } else if (mode == ApiHalBootModeDFU) { + } else if (mode == FuriHalBootModeDFU) { LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR0, BOOT_REQUEST_DFU); } } -void api_hal_boot_set_flags(ApiHalBootFlag flags) { +void furi_hal_boot_set_flags(FuriHalBootFlag flags) { LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR2, flags); } -ApiHalBootFlag api_hal_boot_get_flags() { +FuriHalBootFlag furi_hal_boot_get_flags() { return LL_RTC_BAK_GetRegister(RTC, LL_RTC_BKP_DR2); } \ No newline at end of file diff --git a/firmware/targets/f6/api-hal/api-hal-bt.c b/firmware/targets/f6/furi-hal/furi-hal-bt.c similarity index 80% rename from firmware/targets/f6/api-hal/api-hal-bt.c rename to firmware/targets/f6/furi-hal/furi-hal-bt.c index bf432530..ec14e85f 100644 --- a/firmware/targets/f6/api-hal/api-hal-bt.c +++ b/firmware/targets/f6/furi-hal/furi-hal-bt.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -6,18 +6,18 @@ #include #include -void api_hal_bt_init() { +void furi_hal_bt_init() { // Explicitly tell that we are in charge of CLK48 domain HAL_HSEM_FastTake(CFG_HW_CLK48_CONFIG_SEMID); // Start Core2, init HCI and start GAP/GATT APPE_Init(); } -bool api_hal_bt_start_app() { +bool furi_hal_bt_start_app() { return APP_BLE_Start(); } -void api_hal_bt_dump_state(string_t buffer) { +void furi_hal_bt_dump_state(string_t buffer) { BleGlueStatus status = APPE_Status(); if (status == BleGlueStatusStarted) { uint8_t HCI_Version; @@ -39,11 +39,11 @@ void api_hal_bt_dump_state(string_t buffer) { } } -bool api_hal_bt_is_alive() { +bool furi_hal_bt_is_alive() { return APPE_Status() == BleGlueStatusStarted; } -bool api_hal_bt_wait_transition() { +bool furi_hal_bt_wait_transition() { uint8_t counter = 0; while (APPE_Status() == BleGlueStatusStartup) { osDelay(10); @@ -55,8 +55,8 @@ bool api_hal_bt_wait_transition() { return true; } -bool api_hal_bt_lock_flash() { - if (!api_hal_bt_wait_transition()) { +bool furi_hal_bt_lock_flash() { + if (!furi_hal_bt_wait_transition()) { return false; } if (APPE_Status() == BleGlueStatusUninitialized) { @@ -72,7 +72,7 @@ bool api_hal_bt_lock_flash() { return true; } -void api_hal_bt_unlock_flash() { +void furi_hal_bt_unlock_flash() { if (APPE_Status() == BleGlueStatusUninitialized) { HAL_FLASH_Lock(); } else { @@ -82,34 +82,34 @@ void api_hal_bt_unlock_flash() { } } -void api_hal_bt_start_tone_tx(uint8_t channel, uint8_t power) { +void furi_hal_bt_start_tone_tx(uint8_t channel, uint8_t power) { aci_hal_set_tx_power_level(0, power); aci_hal_tone_start(channel, 0); } -void api_hal_bt_stop_tone_tx() { +void furi_hal_bt_stop_tone_tx() { aci_hal_tone_stop(); } -void api_hal_bt_start_packet_tx(uint8_t channel, uint8_t pattern, uint8_t datarate) { +void furi_hal_bt_start_packet_tx(uint8_t channel, uint8_t pattern, uint8_t datarate) { hci_le_enhanced_transmitter_test(channel, 0x25, pattern, datarate); } -void api_hal_bt_start_packet_rx(uint8_t channel, uint8_t datarate) { +void furi_hal_bt_start_packet_rx(uint8_t channel, uint8_t datarate) { hci_le_enhanced_receiver_test(channel, datarate, 0); } -uint16_t api_hal_bt_stop_packet_test() { +uint16_t furi_hal_bt_stop_packet_test() { uint16_t num_of_packets; hci_le_test_end(&num_of_packets); return num_of_packets; } -void api_hal_bt_start_rx(uint8_t channel) { +void furi_hal_bt_start_rx(uint8_t channel) { aci_hal_rx_start(channel); } -float api_hal_bt_get_rssi() { +float furi_hal_bt_get_rssi() { float val; uint8_t rssi_raw[3]; @@ -133,12 +133,12 @@ float api_hal_bt_get_rssi() { return val; } -uint32_t api_hal_bt_get_transmitted_packets() { +uint32_t furi_hal_bt_get_transmitted_packets() { uint32_t packets = 0; aci_hal_le_tx_test_packet_number(&packets); return packets; } -void api_hal_bt_stop_rx() { +void furi_hal_bt_stop_rx() { aci_hal_rx_stop(); } diff --git a/firmware/targets/f6/api-hal/api-hal-clock.c b/firmware/targets/f6/furi-hal/furi-hal-clock.c similarity index 97% rename from firmware/targets/f6/api-hal/api-hal-clock.c rename to firmware/targets/f6/furi-hal/furi-hal-clock.c index 8611a975..fa45892f 100644 --- a/firmware/targets/f6/api-hal/api-hal-clock.c +++ b/firmware/targets/f6/furi-hal/furi-hal-clock.c @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -8,7 +8,7 @@ #define HS_CLOCK_IS_READY() (LL_RCC_HSE_IsReady() && LL_RCC_HSI_IsReady()) #define LS_CLOCK_IS_READY() (LL_RCC_LSE_IsReady() && LL_RCC_LSI1_IsReady()) -void api_hal_clock_init() { +void furi_hal_clock_init() { /* Prepare Flash memory for 64mHz system clock */ LL_FLASH_SetLatency(LL_FLASH_LATENCY_3); while(LL_FLASH_GetLatency() != LL_FLASH_LATENCY_3); @@ -113,7 +113,7 @@ void api_hal_clock_init() { LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1); } -void api_hal_clock_switch_to_hsi() { +void furi_hal_clock_switch_to_hsi() { LL_RCC_HSI_Enable( ); while(!LL_RCC_HSI_IsReady()); @@ -124,7 +124,7 @@ void api_hal_clock_switch_to_hsi() { while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSI); } -void api_hal_clock_switch_to_pll() { +void furi_hal_clock_switch_to_pll() { LL_RCC_HSE_Enable(); LL_RCC_PLL_Enable(); diff --git a/firmware/targets/f6/furi-hal/furi-hal-clock.h b/firmware/targets/f6/furi-hal/furi-hal-clock.h new file mode 100644 index 00000000..3ec59205 --- /dev/null +++ b/firmware/targets/f6/furi-hal/furi-hal-clock.h @@ -0,0 +1,10 @@ +#pragma once + +/** Initialize clocks */ +void furi_hal_clock_init(); + +/** Switch to HSI clock */ +void furi_hal_clock_switch_to_hsi(); + +/** Switch to PLL clock */ +void furi_hal_clock_switch_to_pll(); diff --git a/firmware/targets/f6/api-hal/api-hal-console.c b/firmware/targets/f6/furi-hal/furi-hal-console.c similarity index 86% rename from firmware/targets/f6/api-hal/api-hal-console.c rename to firmware/targets/f6/furi-hal/furi-hal-console.c index 7fbfa17a..d34f214a 100644 --- a/firmware/targets/f6/api-hal/api-hal-console.c +++ b/firmware/targets/f6/furi-hal/furi-hal-console.c @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -6,9 +6,9 @@ #include -volatile bool api_hal_console_alive = false; +volatile bool furi_hal_console_alive = false; -void api_hal_console_init() { +void furi_hal_console_init() { LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitStruct.Pin = LL_GPIO_PIN_6|LL_GPIO_PIN_7; GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; @@ -35,13 +35,13 @@ void api_hal_console_init() { LL_USART_Enable(USART1); while(!LL_USART_IsActiveFlag_TEACK(USART1)) ; - api_hal_console_alive = true; + furi_hal_console_alive = true; FURI_LOG_I("FuriHalConsole", "Init OK"); } -void api_hal_console_tx(const uint8_t* buffer, size_t buffer_size) { - if (!api_hal_console_alive) +void furi_hal_console_tx(const uint8_t* buffer, size_t buffer_size) { + if (!furi_hal_console_alive) return; while(buffer_size > 0) { diff --git a/firmware/targets/f6/api-hal/api-hal-console.h b/firmware/targets/f6/furi-hal/furi-hal-console.h similarity index 55% rename from firmware/targets/f6/api-hal/api-hal-console.h rename to firmware/targets/f6/furi-hal/furi-hal-console.h index b15cf913..1254083f 100644 --- a/firmware/targets/f6/api-hal/api-hal-console.h +++ b/firmware/targets/f6/furi-hal/furi-hal-console.h @@ -7,9 +7,9 @@ extern "C" { #endif -void api_hal_console_init(); +void furi_hal_console_init(); -void api_hal_console_tx(const uint8_t* buffer, size_t buffer_size); +void furi_hal_console_tx(const uint8_t* buffer, size_t buffer_size); #ifdef __cplusplus } diff --git a/firmware/targets/f6/api-hal/api-hal-delay.c b/firmware/targets/f6/furi-hal/furi-hal-delay.c similarity index 92% rename from firmware/targets/f6/api-hal/api-hal-delay.c rename to firmware/targets/f6/furi-hal/furi-hal-delay.c index bb33fb0e..e886e23e 100644 --- a/firmware/targets/f6/api-hal/api-hal-delay.c +++ b/firmware/targets/f6/furi-hal/furi-hal-delay.c @@ -1,11 +1,11 @@ -#include "api-hal-delay.h" +#include "furi-hal-delay.h" #include #include static uint32_t clk_per_microsecond; -void api_hal_delay_init(void) { +void furi_hal_delay_init(void) { CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; DWT->CYCCNT = 0U; diff --git a/firmware/targets/f6/furi-hal/furi-hal-flash.c b/firmware/targets/f6/furi-hal/furi-hal-flash.c new file mode 100644 index 00000000..0cd80313 --- /dev/null +++ b/firmware/targets/f6/furi-hal/furi-hal-flash.c @@ -0,0 +1,88 @@ +#include +#include +#include +#include + +/* Free flash space borders, exported by linker */ +extern const void __free_flash_start__; +extern const void __free_flash_end__; + +#define FURI_HAL_FLASH_READ_BLOCK 8 +#define FURI_HAL_FLASH_WRITE_BLOCK 8 +#define FURI_HAL_FLASH_PAGE_SIZE 4096 +#define FURI_HAL_FLASH_CYCLES_COUNT 10000 + +size_t furi_hal_flash_get_base() { + return FLASH_BASE; +} + +size_t furi_hal_flash_get_read_block_size() { + return FURI_HAL_FLASH_READ_BLOCK; +} + +size_t furi_hal_flash_get_write_block_size() { + return FURI_HAL_FLASH_WRITE_BLOCK; +} + +size_t furi_hal_flash_get_page_size() { + return FURI_HAL_FLASH_PAGE_SIZE; +} + +size_t furi_hal_flash_get_cycles_count() { + return FURI_HAL_FLASH_CYCLES_COUNT; +} + +const void* furi_hal_flash_get_free_start_address() { + return &__free_flash_start__; +} + +const void* furi_hal_flash_get_free_end_address() { + return &__free_flash_end__; +} + +size_t furi_hal_flash_get_free_page_start_address() { + size_t start = (size_t)furi_hal_flash_get_free_start_address(); + size_t page_start = start - start % FURI_HAL_FLASH_PAGE_SIZE; + if (page_start != start) { + page_start += FURI_HAL_FLASH_PAGE_SIZE; + } + return page_start; +} + +size_t furi_hal_flash_get_free_page_count() { + size_t end = (size_t)furi_hal_flash_get_free_end_address(); + size_t page_start = (size_t)furi_hal_flash_get_free_page_start_address(); + return (end-page_start) / FURI_HAL_FLASH_PAGE_SIZE; +} + +bool furi_hal_flash_erase(uint8_t page, uint8_t count) { + if (!furi_hal_bt_lock_flash()) { + return false; + } + FLASH_EraseInitTypeDef erase; + erase.TypeErase = FLASH_TYPEERASE_PAGES; + erase.Page = page; + erase.NbPages = count; + uint32_t error; + HAL_StatusTypeDef status = HAL_FLASHEx_Erase(&erase, &error); + furi_hal_bt_unlock_flash(); + return status == HAL_OK; +} + +bool furi_hal_flash_write_dword(size_t address, uint64_t data) { + if (!furi_hal_bt_lock_flash()) { + return false; + } + HAL_StatusTypeDef status = HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, address, data); + furi_hal_bt_unlock_flash(); + return status == HAL_OK; +} + +bool furi_hal_flash_write_dword_from(size_t address, size_t source_address) { + if (!furi_hal_bt_lock_flash()) { + return false; + } + HAL_StatusTypeDef status = HAL_FLASH_Program(FLASH_TYPEPROGRAM_FAST, address, source_address); + furi_hal_bt_unlock_flash(); + return status == HAL_OK; +} diff --git a/firmware/targets/f6/api-hal/api-hal-flash.h b/firmware/targets/f6/furi-hal/furi-hal-flash.h similarity index 67% rename from firmware/targets/f6/api-hal/api-hal-flash.h rename to firmware/targets/f6/furi-hal/furi-hal-flash.h index eb7270be..3ef9b730 100644 --- a/firmware/targets/f6/api-hal/api-hal-flash.h +++ b/firmware/targets/f6/furi-hal/furi-hal-flash.h @@ -7,47 +7,47 @@ /** Get flash base address * @return pointer to flash base */ -size_t api_hal_flash_get_base(); +size_t furi_hal_flash_get_base(); /** Get flash read block size * @return size in bytes */ -size_t api_hal_flash_get_read_block_size(); +size_t furi_hal_flash_get_read_block_size(); /** Get flash write block size * @return size in bytes */ -size_t api_hal_flash_get_write_block_size(); +size_t furi_hal_flash_get_write_block_size(); /** Get flash page size * @return size in bytes */ -size_t api_hal_flash_get_page_size(); +size_t furi_hal_flash_get_page_size(); /** Get expected flash cycles count * @return count of erase-write operations */ -size_t api_hal_flash_get_cycles_count(); +size_t furi_hal_flash_get_cycles_count(); /** Get free flash start address * @return pointer to free region start */ -const void* api_hal_flash_get_free_start_address(); +const void* furi_hal_flash_get_free_start_address(); /** Get free flash end address * @return pointer to free region end */ -const void* api_hal_flash_get_free_end_address(); +const void* furi_hal_flash_get_free_end_address(); /** Get first free page start address * @return first free page memory address */ -size_t api_hal_flash_get_free_page_start_address(); +size_t furi_hal_flash_get_free_page_start_address(); /** Get free page count * @return free page count */ -size_t api_hal_flash_get_free_page_count(); +size_t furi_hal_flash_get_free_page_count(); /* * Erase Flash @@ -55,7 +55,7 @@ size_t api_hal_flash_get_free_page_count(); * @param page, page number * @param count, page count to erase */ -bool api_hal_flash_erase(uint8_t page, uint8_t count); +bool furi_hal_flash_erase(uint8_t page, uint8_t count); /* * Write double word (64 bits) @@ -63,7 +63,7 @@ bool api_hal_flash_erase(uint8_t page, uint8_t count); * @param address - destination address, must be double word aligned. * @param data - data to write */ -bool api_hal_flash_write_dword(size_t address, uint64_t data); +bool furi_hal_flash_write_dword(size_t address, uint64_t data); /* * Write double word (64 bits) from address @@ -71,4 +71,4 @@ bool api_hal_flash_write_dword(size_t address, uint64_t data); * @param address - destination address, must be block aligned * @param source_address - source address */ -bool api_hal_flash_write_dword_from(size_t address, size_t source_address); +bool furi_hal_flash_write_dword_from(size_t address, size_t source_address); diff --git a/firmware/targets/f6/api-hal/api-hal-gpio.c b/firmware/targets/f6/furi-hal/furi-hal-gpio.c similarity index 98% rename from firmware/targets/f6/api-hal/api-hal-gpio.c rename to firmware/targets/f6/furi-hal/furi-hal-gpio.c index 338ee00b..65a8009b 100644 --- a/firmware/targets/f6/api-hal/api-hal-gpio.c +++ b/firmware/targets/f6/furi-hal/furi-hal-gpio.c @@ -1,6 +1,6 @@ #include -#include -#include +#include +#include #define GET_SYSCFG_EXTI_PORT(gpio) \ (((gpio) == (GPIOA)) ? LL_SYSCFG_EXTI_PORTA : \ @@ -284,7 +284,7 @@ extern COMP_HandleTypeDef hcomp1; bool hal_gpio_get_rfid_in_level() { bool value = false; - if(api_hal_version_get_hw_version() > 7) { + if(furi_hal_version_get_hw_version() > 7) { value = (HAL_COMP_GetOutputLevel(&hcomp1) == COMP_OUTPUT_LEVEL_LOW); } else { value = (HAL_COMP_GetOutputLevel(&hcomp1) == COMP_OUTPUT_LEVEL_HIGH); diff --git a/firmware/targets/f6/api-hal/api-hal-gpio.h b/firmware/targets/f6/furi-hal/furi-hal-gpio.h similarity index 100% rename from firmware/targets/f6/api-hal/api-hal-gpio.h rename to firmware/targets/f6/furi-hal/furi-hal-gpio.h diff --git a/firmware/targets/f6/api-hal/api-hal-i2c.c b/firmware/targets/f6/furi-hal/furi-hal-i2c.c similarity index 83% rename from firmware/targets/f6/api-hal/api-hal-i2c.c rename to firmware/targets/f6/furi-hal/furi-hal-i2c.c index 110a5d26..196a2a7b 100644 --- a/firmware/targets/f6/api-hal/api-hal-i2c.c +++ b/firmware/targets/f6/furi-hal/furi-hal-i2c.c @@ -1,16 +1,16 @@ -#include -#include +#include +#include #include #include #include #include -osMutexId_t api_hal_i2c_mutex = NULL; +osMutexId_t furi_hal_i2c_mutex = NULL; -void api_hal_i2c_init() { - api_hal_i2c_mutex = osMutexNew(NULL); - furi_check(api_hal_i2c_mutex); +void furi_hal_i2c_init() { + furi_hal_i2c_mutex = osMutexNew(NULL); + furi_check(furi_hal_i2c_mutex); LL_I2C_InitTypeDef I2C_InitStruct = {0}; LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; @@ -31,7 +31,7 @@ void api_hal_i2c_init() { I2C_InitStruct.OwnAddress1 = 0; I2C_InitStruct.TypeAcknowledge = LL_I2C_ACK; I2C_InitStruct.OwnAddrSize = LL_I2C_OWNADDRESS1_7BIT; - if (api_hal_version_get_hw_version() > 10) { + if (furi_hal_version_get_hw_version() > 10) { I2C_InitStruct.Timing = POWER_I2C_TIMINGS_400; } else { I2C_InitStruct.Timing = POWER_I2C_TIMINGS_100; @@ -45,7 +45,7 @@ void api_hal_i2c_init() { FURI_LOG_I("FuriHalI2C", "Init OK"); } -bool api_hal_i2c_tx( +bool furi_hal_i2c_tx( I2C_TypeDef* instance, uint8_t address, const uint8_t* data, @@ -86,7 +86,7 @@ bool api_hal_i2c_tx( return ret; } -bool api_hal_i2c_rx( +bool furi_hal_i2c_rx( I2C_TypeDef* instance, uint8_t address, uint8_t* data, @@ -127,7 +127,7 @@ bool api_hal_i2c_rx( return ret; } -bool api_hal_i2c_trx( +bool furi_hal_i2c_trx( I2C_TypeDef* instance, uint8_t address, const uint8_t* tx_data, @@ -135,18 +135,18 @@ bool api_hal_i2c_trx( uint8_t* rx_data, uint8_t rx_size, uint32_t timeout) { - if(api_hal_i2c_tx(instance, address, tx_data, tx_size, timeout) && - api_hal_i2c_rx(instance, address, rx_data, rx_size, timeout)) { + if(furi_hal_i2c_tx(instance, address, tx_data, tx_size, timeout) && + furi_hal_i2c_rx(instance, address, rx_data, rx_size, timeout)) { return true; } else { return false; } } -void api_hal_i2c_lock() { - furi_check(osMutexAcquire(api_hal_i2c_mutex, osWaitForever) == osOK); +void furi_hal_i2c_lock() { + furi_check(osMutexAcquire(furi_hal_i2c_mutex, osWaitForever) == osOK); } -void api_hal_i2c_unlock() { - furi_check(osMutexRelease(api_hal_i2c_mutex) == osOK); +void furi_hal_i2c_unlock() { + furi_check(osMutexRelease(furi_hal_i2c_mutex) == osOK); } diff --git a/firmware/targets/f6/api-hal/api-hal-ibutton.c b/firmware/targets/f6/furi-hal/furi-hal-ibutton.c similarity index 50% rename from firmware/targets/f6/api-hal/api-hal-ibutton.c rename to firmware/targets/f6/furi-hal/furi-hal-ibutton.c index 87addbbc..6e3c8bee 100644 --- a/firmware/targets/f6/api-hal/api-hal-ibutton.c +++ b/firmware/targets/f6/furi-hal/furi-hal-ibutton.c @@ -1,24 +1,24 @@ -#include -#include +#include +#include -void api_hal_ibutton_start() { - api_hal_ibutton_pin_high(); +void furi_hal_ibutton_start() { + furi_hal_ibutton_pin_high(); hal_gpio_init(&ibutton_gpio, GpioModeOutputOpenDrain, GpioSpeedLow, GpioPullNo); } -void api_hal_ibutton_stop() { - api_hal_ibutton_pin_high(); +void furi_hal_ibutton_stop() { + furi_hal_ibutton_pin_high(); hal_gpio_init(&ibutton_gpio, GpioModeAnalog, GpioSpeedLow, GpioPullNo); } -void api_hal_ibutton_pin_low() { +void furi_hal_ibutton_pin_low() { hal_gpio_write(&ibutton_gpio, false); } -void api_hal_ibutton_pin_high() { +void furi_hal_ibutton_pin_high() { hal_gpio_write(&ibutton_gpio, true); } -bool api_hal_ibutton_pin_get_level() { +bool furi_hal_ibutton_pin_get_level() { return hal_gpio_read(&ibutton_gpio); } diff --git a/firmware/targets/f6/api-hal/api-hal-interrupt.c b/firmware/targets/f6/furi-hal/furi-hal-interrupt.c similarity index 57% rename from firmware/targets/f6/api-hal/api-hal-interrupt.c rename to firmware/targets/f6/furi-hal/furi-hal-interrupt.c index fd5cd2be..69cdc4b6 100644 --- a/firmware/targets/f6/api-hal/api-hal-interrupt.c +++ b/firmware/targets/f6/furi-hal/furi-hal-interrupt.c @@ -1,18 +1,18 @@ -#include "api-hal-interrupt.h" +#include "furi-hal-interrupt.h" #include #include #include -volatile ApiHalInterruptISR api_hal_tim_tim2_isr = NULL; -volatile ApiHalInterruptISR api_hal_tim_tim1_isr = NULL; +volatile FuriHalInterruptISR furi_hal_tim_tim2_isr = NULL; +volatile FuriHalInterruptISR furi_hal_tim_tim1_isr = NULL; -#define API_HAL_INTERRUPT_DMA_COUNT 2 -#define API_HAL_INTERRUPT_DMA_CHANNELS_COUNT 8 +#define FURI_HAL_INTERRUPT_DMA_COUNT 2 +#define FURI_HAL_INTERRUPT_DMA_CHANNELS_COUNT 8 -volatile ApiHalInterruptISR api_hal_dma_channel_isr[API_HAL_INTERRUPT_DMA_COUNT][API_HAL_INTERRUPT_DMA_CHANNELS_COUNT] = {0}; +volatile FuriHalInterruptISR furi_hal_dma_channel_isr[FURI_HAL_INTERRUPT_DMA_COUNT][FURI_HAL_INTERRUPT_DMA_CHANNELS_COUNT] = {0}; -void api_hal_interrupt_init() { +void furi_hal_interrupt_init() { NVIC_SetPriority(RCC_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0)); NVIC_EnableIRQ(RCC_IRQn); @@ -25,34 +25,34 @@ void api_hal_interrupt_init() { FURI_LOG_I("FuriHalInterrupt", "Init OK"); } -void api_hal_interrupt_set_timer_isr(TIM_TypeDef* timer, ApiHalInterruptISR isr) { +void furi_hal_interrupt_set_timer_isr(TIM_TypeDef* timer, FuriHalInterruptISR isr) { if (timer == TIM2) { if (isr) { - furi_assert(api_hal_tim_tim2_isr == NULL); + furi_assert(furi_hal_tim_tim2_isr == NULL); } else { - furi_assert(api_hal_tim_tim2_isr != NULL); + furi_assert(furi_hal_tim_tim2_isr != NULL); } - api_hal_tim_tim2_isr = isr; + furi_hal_tim_tim2_isr = isr; } else if (timer == TIM1) { if (isr) { - furi_assert(api_hal_tim_tim1_isr == NULL); + furi_assert(furi_hal_tim_tim1_isr == NULL); } else { - furi_assert(api_hal_tim_tim1_isr != NULL); + furi_assert(furi_hal_tim_tim1_isr != NULL); } - api_hal_tim_tim1_isr = isr; + furi_hal_tim_tim1_isr = isr; } else { furi_check(0); } } -void api_hal_interrupt_set_dma_channel_isr(DMA_TypeDef* dma, uint32_t channel, ApiHalInterruptISR isr) { +void furi_hal_interrupt_set_dma_channel_isr(DMA_TypeDef* dma, uint32_t channel, FuriHalInterruptISR isr) { --channel; // Pascal furi_check(dma); - furi_check(channel < API_HAL_INTERRUPT_DMA_CHANNELS_COUNT); + furi_check(channel < FURI_HAL_INTERRUPT_DMA_CHANNELS_COUNT); if (dma == DMA1) { - api_hal_dma_channel_isr[0][channel] = isr; + furi_hal_dma_channel_isr[0][channel] = isr; } else if (dma == DMA2) { - api_hal_dma_channel_isr[1][channel] = isr; + furi_hal_dma_channel_isr[1][channel] = isr; } else { furi_check(0); } @@ -74,8 +74,8 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef* htim) { /* Timer 2 */ void TIM2_IRQHandler(void) { - if (api_hal_tim_tim2_isr) { - api_hal_tim_tim2_isr(); + if (furi_hal_tim_tim2_isr) { + furi_hal_tim_tim2_isr(); } else { HAL_TIM_IRQHandler(&htim2); } @@ -83,8 +83,8 @@ void TIM2_IRQHandler(void) { /* Timer 1 Update */ void TIM1_UP_TIM16_IRQHandler(void) { - if (api_hal_tim_tim1_isr) { - api_hal_tim_tim1_isr(); + if (furi_hal_tim_tim1_isr) { + furi_hal_tim_tim1_isr(); } else { HAL_TIM_IRQHandler(&htim1); } @@ -92,68 +92,68 @@ void TIM1_UP_TIM16_IRQHandler(void) { /* DMA 1 */ void DMA1_Channel1_IRQHandler(void) { - if (api_hal_dma_channel_isr[0][0]) api_hal_dma_channel_isr[0][0](); + if (furi_hal_dma_channel_isr[0][0]) furi_hal_dma_channel_isr[0][0](); } void DMA1_Channel2_IRQHandler(void) { - if (api_hal_dma_channel_isr[0][1]) api_hal_dma_channel_isr[0][1](); + if (furi_hal_dma_channel_isr[0][1]) furi_hal_dma_channel_isr[0][1](); } void DMA1_Channel3_IRQHandler(void) { - if (api_hal_dma_channel_isr[0][2]) api_hal_dma_channel_isr[0][2](); + if (furi_hal_dma_channel_isr[0][2]) furi_hal_dma_channel_isr[0][2](); } void DMA1_Channel4_IRQHandler(void) { - if (api_hal_dma_channel_isr[0][3]) api_hal_dma_channel_isr[0][3](); + if (furi_hal_dma_channel_isr[0][3]) furi_hal_dma_channel_isr[0][3](); } void DMA1_Channel5_IRQHandler(void) { - if (api_hal_dma_channel_isr[0][4]) api_hal_dma_channel_isr[0][4](); + if (furi_hal_dma_channel_isr[0][4]) furi_hal_dma_channel_isr[0][4](); } void DMA1_Channel6_IRQHandler(void) { - if (api_hal_dma_channel_isr[0][5]) api_hal_dma_channel_isr[0][5](); + if (furi_hal_dma_channel_isr[0][5]) furi_hal_dma_channel_isr[0][5](); } void DMA1_Channel7_IRQHandler(void) { - if (api_hal_dma_channel_isr[0][6]) api_hal_dma_channel_isr[0][6](); + if (furi_hal_dma_channel_isr[0][6]) furi_hal_dma_channel_isr[0][6](); } void DMA1_Channel8_IRQHandler(void) { - if (api_hal_dma_channel_isr[0][7]) api_hal_dma_channel_isr[0][7](); + if (furi_hal_dma_channel_isr[0][7]) furi_hal_dma_channel_isr[0][7](); } /* DMA 2 */ void DMA2_Channel1_IRQHandler(void) { - if (api_hal_dma_channel_isr[1][0]) api_hal_dma_channel_isr[1][0](); + if (furi_hal_dma_channel_isr[1][0]) furi_hal_dma_channel_isr[1][0](); } void DMA2_Channel2_IRQHandler(void) { - if (api_hal_dma_channel_isr[1][1]) api_hal_dma_channel_isr[1][1](); + if (furi_hal_dma_channel_isr[1][1]) furi_hal_dma_channel_isr[1][1](); } void DMA2_Channel3_IRQHandler(void) { - if (api_hal_dma_channel_isr[1][2]) api_hal_dma_channel_isr[1][2](); + if (furi_hal_dma_channel_isr[1][2]) furi_hal_dma_channel_isr[1][2](); } void DMA2_Channel4_IRQHandler(void) { - if (api_hal_dma_channel_isr[1][3]) api_hal_dma_channel_isr[1][3](); + if (furi_hal_dma_channel_isr[1][3]) furi_hal_dma_channel_isr[1][3](); } void DMA2_Channel5_IRQHandler(void) { - if (api_hal_dma_channel_isr[1][4]) api_hal_dma_channel_isr[1][4](); + if (furi_hal_dma_channel_isr[1][4]) furi_hal_dma_channel_isr[1][4](); } void DMA2_Channel6_IRQHandler(void) { - if (api_hal_dma_channel_isr[1][5]) api_hal_dma_channel_isr[1][5](); + if (furi_hal_dma_channel_isr[1][5]) furi_hal_dma_channel_isr[1][5](); } void DMA2_Channel7_IRQHandler(void) { - if (api_hal_dma_channel_isr[1][6]) api_hal_dma_channel_isr[1][6](); + if (furi_hal_dma_channel_isr[1][6]) furi_hal_dma_channel_isr[1][6](); } void DMA2_Channel8_IRQHandler(void) { - if (api_hal_dma_channel_isr[1][7]) api_hal_dma_channel_isr[1][7](); + if (furi_hal_dma_channel_isr[1][7]) furi_hal_dma_channel_isr[1][7](); } diff --git a/firmware/targets/f6/api-hal/api-hal-interrupt.h b/firmware/targets/f6/furi-hal/furi-hal-interrupt.h similarity index 71% rename from firmware/targets/f6/api-hal/api-hal-interrupt.h rename to firmware/targets/f6/furi-hal/furi-hal-interrupt.h index eeb0afe9..693924e6 100644 --- a/firmware/targets/f6/api-hal/api-hal-interrupt.h +++ b/firmware/targets/f6/furi-hal/furi-hal-interrupt.h @@ -7,10 +7,10 @@ extern "C" { #endif /** Timer ISR */ -typedef void (*ApiHalInterruptISR)(); +typedef void (*FuriHalInterruptISR)(); /** Initialize interrupt subsystem */ -void api_hal_interrupt_init(); +void furi_hal_interrupt_init(); /** Set DMA Channel ISR * We don't clear interrupt flags for you, do it by your self. @@ -18,7 +18,7 @@ void api_hal_interrupt_init(); * @param channel - DMA channel * @param isr - your interrupt service routine or use NULL to clear */ -void api_hal_interrupt_set_dma_channel_isr(DMA_TypeDef* dma, uint32_t channel, ApiHalInterruptISR isr); +void furi_hal_interrupt_set_dma_channel_isr(DMA_TypeDef* dma, uint32_t channel, FuriHalInterruptISR isr); /** Set Timer ISR * By default ISR is serviced by ST HAL. Use this function to override it. @@ -26,7 +26,7 @@ void api_hal_interrupt_set_dma_channel_isr(DMA_TypeDef* dma, uint32_t channel, A * @param timer - timer instance * @param isr - your interrupt service routine or use NULL to clear */ -void api_hal_interrupt_set_timer_isr(TIM_TypeDef *timer, ApiHalInterruptISR isr); +void furi_hal_interrupt_set_timer_isr(TIM_TypeDef *timer, FuriHalInterruptISR isr); #ifdef __cplusplus diff --git a/firmware/targets/f6/api-hal/api-hal-irda.c b/firmware/targets/f6/furi-hal/furi-hal-irda.c similarity index 71% rename from firmware/targets/f6/api-hal/api-hal-irda.c rename to firmware/targets/f6/furi-hal/furi-hal-irda.c index 345f68b5..0fe9b3cd 100644 --- a/firmware/targets/f6/api-hal/api-hal-irda.c +++ b/firmware/targets/f6/furi-hal/furi-hal-irda.c @@ -1,11 +1,11 @@ -#include "api-hal-irda.h" -#include "api-hal-delay.h" +#include "furi-hal-irda.h" +#include "furi-hal-delay.h" #include "furi/check.h" #include "stm32wbxx_ll_dma.h" #include "sys/_stdint.h" #include -#include -#include +#include +#include #include #include @@ -15,7 +15,7 @@ #include #include #include -#include +#include #define IRDA_TIM_TX_DMA_BUFFER_SIZE 200 #define IRDA_POLARITY_SHIFT 1 @@ -24,9 +24,9 @@ #define IRDA_TX_CCMR_LOW (TIM_CCMR2_OC3PE | LL_TIM_OCMODE_FORCED_INACTIVE) /* Space time - force low */ typedef struct{ - ApiHalIrdaRxCaptureCallback capture_callback; + FuriHalIrdaRxCaptureCallback capture_callback; void *capture_context; - ApiHalIrdaRxTimeoutCallback timeout_callback; + FuriHalIrdaRxTimeoutCallback timeout_callback; void *timeout_context; } IrdaTimRx; @@ -40,14 +40,14 @@ typedef struct{ typedef struct { float cycle_duration; - ApiHalIrdaTxGetDataCallback data_callback; + FuriHalIrdaTxGetDataCallback data_callback; void* data_context; IrdaTxBuf buffer[2]; osSemaphoreId_t stop_semaphore; } IrdaTimTx; typedef enum { - IrdaStateIdle, /** Api Hal Irda is ready to start RX or TX */ + IrdaStateIdle, /** Furi Hal Irda is ready to start RX or TX */ IrdaStateAsyncRx, /** Async RX started */ IrdaStateAsyncTx, /** Async TX started, DMA and timer is on */ IrdaStateAsyncTxStopReq, /** Async TX started, async stop request received */ @@ -56,25 +56,25 @@ typedef enum { IrdaStateMAX, } IrdaState; -static volatile IrdaState api_hal_irda_state = IrdaStateIdle; +static volatile IrdaState furi_hal_irda_state = IrdaStateIdle; static IrdaTimTx irda_tim_tx; static IrdaTimRx irda_tim_rx; -static bool api_hal_irda_tx_fill_buffer(uint8_t buf_num, uint8_t polarity_shift); -static void api_hal_irda_async_tx_free_resources(void); -static void api_hal_irda_tx_dma_set_polarity(uint8_t buf_num, uint8_t polarity_shift); -static void api_hal_irda_tx_dma_set_buffer(uint8_t buf_num); -static void api_hal_irda_tx_fill_buffer_last(uint8_t buf_num); -static uint8_t api_hal_irda_get_current_dma_tx_buffer(void); -static void api_hal_irda_tx_dma_polarity_isr(); -static void api_hal_irda_tx_dma_isr(); +static bool furi_hal_irda_tx_fill_buffer(uint8_t buf_num, uint8_t polarity_shift); +static void furi_hal_irda_async_tx_free_resources(void); +static void furi_hal_irda_tx_dma_set_polarity(uint8_t buf_num, uint8_t polarity_shift); +static void furi_hal_irda_tx_dma_set_buffer(uint8_t buf_num); +static void furi_hal_irda_tx_fill_buffer_last(uint8_t buf_num); +static uint8_t furi_hal_irda_get_current_dma_tx_buffer(void); +static void furi_hal_irda_tx_dma_polarity_isr(); +static void furi_hal_irda_tx_dma_isr(); -static void api_hal_irda_tim_rx_isr() { +static void furi_hal_irda_tim_rx_isr() { /* Timeout */ if(LL_TIM_IsActiveFlag_CC3(TIM2)) { LL_TIM_ClearFlag_CC3(TIM2); - furi_assert(api_hal_irda_state == IrdaStateAsyncRx); + furi_assert(furi_hal_irda_state == IrdaStateAsyncRx); /* Timers CNT register starts to counting from 0 to ARR, but it is * reseted when Channel 1 catches interrupt. It is not reseted by @@ -91,7 +91,7 @@ static void api_hal_irda_tim_rx_isr() { /* Rising Edge */ if(LL_TIM_IsActiveFlag_CC1(TIM2)) { LL_TIM_ClearFlag_CC1(TIM2); - furi_assert(api_hal_irda_state == IrdaStateAsyncRx); + furi_assert(furi_hal_irda_state == IrdaStateAsyncRx); if(READ_BIT(TIM2->CCMR1, TIM_CCMR1_CC1S)) { /* Low pin level is a Mark state of IRDA signal. Invert level for further processing. */ @@ -106,7 +106,7 @@ static void api_hal_irda_tim_rx_isr() { /* Falling Edge */ if(LL_TIM_IsActiveFlag_CC2(TIM2)) { LL_TIM_ClearFlag_CC2(TIM2); - furi_assert(api_hal_irda_state == IrdaStateAsyncRx); + furi_assert(furi_hal_irda_state == IrdaStateAsyncRx); if(READ_BIT(TIM2->CCMR1, TIM_CCMR1_CC2S)) { /* High pin level is a Space state of IRDA signal. Invert level for further processing. */ @@ -119,8 +119,8 @@ static void api_hal_irda_tim_rx_isr() { } } -void api_hal_irda_async_rx_start(void) { - furi_assert(api_hal_irda_state == IrdaStateIdle); +void furi_hal_irda_async_rx_start(void) { + furi_assert(furi_hal_irda_state == IrdaStateIdle); LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2); LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); @@ -152,8 +152,8 @@ void api_hal_irda_async_rx_start(void) { LL_TIM_IC_SetActiveInput(TIM2, LL_TIM_CHANNEL_CH2, LL_TIM_ACTIVEINPUT_INDIRECTTI); LL_TIM_IC_SetPrescaler(TIM2, LL_TIM_CHANNEL_CH2, LL_TIM_ICPSC_DIV1); - api_hal_interrupt_set_timer_isr(TIM2, api_hal_irda_tim_rx_isr); - api_hal_irda_state = IrdaStateAsyncRx; + furi_hal_interrupt_set_timer_isr(TIM2, furi_hal_irda_tim_rx_isr); + furi_hal_irda_state = IrdaStateAsyncRx; LL_TIM_EnableIT_CC1(TIM2); LL_TIM_EnableIT_CC2(TIM2); @@ -167,41 +167,41 @@ void api_hal_irda_async_rx_start(void) { NVIC_EnableIRQ(TIM2_IRQn); } -void api_hal_irda_async_rx_stop(void) { - furi_assert(api_hal_irda_state == IrdaStateAsyncRx); +void furi_hal_irda_async_rx_stop(void) { + furi_assert(furi_hal_irda_state == IrdaStateAsyncRx); LL_TIM_DeInit(TIM2); - api_hal_interrupt_set_timer_isr(TIM2, NULL); + furi_hal_interrupt_set_timer_isr(TIM2, NULL); LL_APB1_GRP1_DisableClock(LL_APB1_GRP1_PERIPH_TIM2); - api_hal_irda_state = IrdaStateIdle; + furi_hal_irda_state = IrdaStateIdle; } -void api_hal_irda_async_rx_set_timeout(uint32_t timeout_ms) { +void furi_hal_irda_async_rx_set_timeout(uint32_t timeout_ms) { LL_TIM_OC_SetCompareCH3(TIM2, timeout_ms * 1000); LL_TIM_OC_SetMode(TIM2, LL_TIM_CHANNEL_CH3, LL_TIM_OCMODE_ACTIVE); LL_TIM_CC_EnableChannel(TIM2, LL_TIM_CHANNEL_CH3); LL_TIM_EnableIT_CC3(TIM2); } -bool api_hal_irda_is_busy(void) { - return api_hal_irda_state != IrdaStateIdle; +bool furi_hal_irda_is_busy(void) { + return furi_hal_irda_state != IrdaStateIdle; } -void api_hal_irda_async_rx_set_capture_isr_callback(ApiHalIrdaRxCaptureCallback callback, void *ctx) { +void furi_hal_irda_async_rx_set_capture_isr_callback(FuriHalIrdaRxCaptureCallback callback, void *ctx) { irda_tim_rx.capture_callback = callback; irda_tim_rx.capture_context = ctx; } -void api_hal_irda_async_rx_set_timeout_isr_callback(ApiHalIrdaRxTimeoutCallback callback, void *ctx) { +void furi_hal_irda_async_rx_set_timeout_isr_callback(FuriHalIrdaRxTimeoutCallback callback, void *ctx) { irda_tim_rx.timeout_callback = callback; irda_tim_rx.timeout_context = ctx; } -static void api_hal_irda_tx_dma_terminate(void) { +static void furi_hal_irda_tx_dma_terminate(void) { LL_DMA_DisableIT_TC(DMA1, LL_DMA_CHANNEL_1); LL_DMA_DisableIT_HT(DMA1, LL_DMA_CHANNEL_2); LL_DMA_DisableIT_TC(DMA1, LL_DMA_CHANNEL_2); - furi_assert(api_hal_irda_state == IrdaStateAsyncTxStopInProgress); + furi_assert(furi_hal_irda_state == IrdaStateAsyncTxStopInProgress); LL_DMA_DisableIT_TC(DMA1, LL_DMA_CHANNEL_1); LL_DMA_DisableChannel(DMA1, LL_DMA_CHANNEL_2); @@ -209,10 +209,10 @@ static void api_hal_irda_tx_dma_terminate(void) { LL_TIM_DisableCounter(TIM1); osStatus_t status = osSemaphoreRelease(irda_tim_tx.stop_semaphore); furi_check(status == osOK); - api_hal_irda_state = IrdaStateAsyncTxStopped; + furi_hal_irda_state = IrdaStateAsyncTxStopped; } -static uint8_t api_hal_irda_get_current_dma_tx_buffer(void) { +static uint8_t furi_hal_irda_get_current_dma_tx_buffer(void) { uint8_t buf_num = 0; uint32_t buffer_adr = LL_DMA_GetMemoryAddress(DMA1, LL_DMA_CHANNEL_2); if (buffer_adr == (uint32_t) irda_tim_tx.buffer[0].data) { @@ -225,7 +225,7 @@ static uint8_t api_hal_irda_get_current_dma_tx_buffer(void) { return buf_num; } -static void api_hal_irda_tx_dma_polarity_isr() { +static void furi_hal_irda_tx_dma_polarity_isr() { if (LL_DMA_IsActiveFlag_TE1(DMA1)) { LL_DMA_ClearFlag_TE1(DMA1); furi_check(0); @@ -233,36 +233,36 @@ static void api_hal_irda_tx_dma_polarity_isr() { if (LL_DMA_IsActiveFlag_TC1(DMA1) && LL_DMA_IsEnabledIT_TC(DMA1, LL_DMA_CHANNEL_1)) { LL_DMA_ClearFlag_TC1(DMA1); - furi_check((api_hal_irda_state == IrdaStateAsyncTx) - || (api_hal_irda_state == IrdaStateAsyncTxStopReq) - || (api_hal_irda_state == IrdaStateAsyncTxStopInProgress)); + furi_check((furi_hal_irda_state == IrdaStateAsyncTx) + || (furi_hal_irda_state == IrdaStateAsyncTxStopReq) + || (furi_hal_irda_state == IrdaStateAsyncTxStopInProgress)); /* actually TC2 is processed and buffer is next buffer */ - uint8_t next_buf_num = api_hal_irda_get_current_dma_tx_buffer(); - api_hal_irda_tx_dma_set_polarity(next_buf_num, 0); + uint8_t next_buf_num = furi_hal_irda_get_current_dma_tx_buffer(); + furi_hal_irda_tx_dma_set_polarity(next_buf_num, 0); } } -static void api_hal_irda_tx_dma_isr() { +static void furi_hal_irda_tx_dma_isr() { if (LL_DMA_IsActiveFlag_TE2(DMA1)) { LL_DMA_ClearFlag_TE2(DMA1); furi_check(0); } if (LL_DMA_IsActiveFlag_HT2(DMA1) && LL_DMA_IsEnabledIT_HT(DMA1, LL_DMA_CHANNEL_2)) { LL_DMA_ClearFlag_HT2(DMA1); - uint8_t buf_num = api_hal_irda_get_current_dma_tx_buffer(); + uint8_t buf_num = furi_hal_irda_get_current_dma_tx_buffer(); uint8_t next_buf_num = !buf_num; if (irda_tim_tx.buffer[buf_num].last_packet_end) { LL_DMA_DisableIT_HT(DMA1, LL_DMA_CHANNEL_2); - } else if (!irda_tim_tx.buffer[buf_num].packet_end || (api_hal_irda_state == IrdaStateAsyncTx)) { - bool result = api_hal_irda_tx_fill_buffer(next_buf_num, 0); + } else if (!irda_tim_tx.buffer[buf_num].packet_end || (furi_hal_irda_state == IrdaStateAsyncTx)) { + bool result = furi_hal_irda_tx_fill_buffer(next_buf_num, 0); if (irda_tim_tx.buffer[next_buf_num].last_packet_end) { LL_DMA_DisableIT_HT(DMA1, LL_DMA_CHANNEL_2); } if (!result) { furi_assert(0); - api_hal_irda_state = IrdaStateAsyncTxStopReq; + furi_hal_irda_state = IrdaStateAsyncTxStopReq; } - } else if (api_hal_irda_state == IrdaStateAsyncTxStopReq) { + } else if (furi_hal_irda_state == IrdaStateAsyncTxStopReq) { /* fallthrough */ } else { furi_check(0); @@ -270,27 +270,27 @@ static void api_hal_irda_tx_dma_isr() { } if (LL_DMA_IsActiveFlag_TC2(DMA1) && LL_DMA_IsEnabledIT_TC(DMA1, LL_DMA_CHANNEL_2)) { LL_DMA_ClearFlag_TC2(DMA1); - furi_check((api_hal_irda_state == IrdaStateAsyncTxStopInProgress) - || (api_hal_irda_state == IrdaStateAsyncTxStopReq) - || (api_hal_irda_state == IrdaStateAsyncTx)); + furi_check((furi_hal_irda_state == IrdaStateAsyncTxStopInProgress) + || (furi_hal_irda_state == IrdaStateAsyncTxStopReq) + || (furi_hal_irda_state == IrdaStateAsyncTx)); - uint8_t buf_num = api_hal_irda_get_current_dma_tx_buffer(); + uint8_t buf_num = furi_hal_irda_get_current_dma_tx_buffer(); uint8_t next_buf_num = !buf_num; - if (api_hal_irda_state == IrdaStateAsyncTxStopInProgress) { - api_hal_irda_tx_dma_terminate(); + if (furi_hal_irda_state == IrdaStateAsyncTxStopInProgress) { + furi_hal_irda_tx_dma_terminate(); } else if (irda_tim_tx.buffer[buf_num].last_packet_end - || (irda_tim_tx.buffer[buf_num].packet_end && (api_hal_irda_state == IrdaStateAsyncTxStopReq))) { - api_hal_irda_state = IrdaStateAsyncTxStopInProgress; - api_hal_irda_tx_fill_buffer_last(next_buf_num); - api_hal_irda_tx_dma_set_buffer(next_buf_num); + || (irda_tim_tx.buffer[buf_num].packet_end && (furi_hal_irda_state == IrdaStateAsyncTxStopReq))) { + furi_hal_irda_state = IrdaStateAsyncTxStopInProgress; + furi_hal_irda_tx_fill_buffer_last(next_buf_num); + furi_hal_irda_tx_dma_set_buffer(next_buf_num); } else { /* if it's not end of the packet - continue receiving */ - api_hal_irda_tx_dma_set_buffer(next_buf_num); + furi_hal_irda_tx_dma_set_buffer(next_buf_num); } } } -static void api_hal_irda_configure_tim_pwm_tx(uint32_t freq, float duty_cycle) +static void furi_hal_irda_configure_tim_pwm_tx(uint32_t freq, float duty_cycle) { LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_TIM1); /* LL_DBGMCU_APB2_GRP1_FreezePeriph(LL_DBGMCU_APB2_GRP1_TIM1_STOP); */ @@ -319,7 +319,7 @@ static void api_hal_irda_configure_tim_pwm_tx(uint32_t freq, float duty_cycle) NVIC_EnableIRQ(TIM1_UP_TIM16_IRQn); } -static void api_hal_irda_configure_tim_cmgr2_dma_tx(void) { +static void furi_hal_irda_configure_tim_cmgr2_dma_tx(void) { LL_C2_AHB1_GRP1_EnableClock(LL_C2_AHB1_GRP1_PERIPH_DMA1); LL_DMA_InitTypeDef dma_config = {0}; @@ -336,7 +336,7 @@ static void api_hal_irda_configure_tim_cmgr2_dma_tx(void) { dma_config.PeriphRequest = LL_DMAMUX_REQ_TIM1_UP; dma_config.Priority = LL_DMA_PRIORITY_VERYHIGH; LL_DMA_Init(DMA1, LL_DMA_CHANNEL_1, &dma_config); - api_hal_interrupt_set_dma_channel_isr(DMA1, LL_DMA_CHANNEL_1, api_hal_irda_tx_dma_polarity_isr); + furi_hal_interrupt_set_dma_channel_isr(DMA1, LL_DMA_CHANNEL_1, furi_hal_irda_tx_dma_polarity_isr); LL_DMA_ClearFlag_TE1(DMA1); LL_DMA_ClearFlag_TC1(DMA1); LL_DMA_EnableIT_TE(DMA1, LL_DMA_CHANNEL_1); @@ -346,7 +346,7 @@ static void api_hal_irda_configure_tim_cmgr2_dma_tx(void) { NVIC_EnableIRQ(DMA1_Channel1_IRQn); } -static void api_hal_irda_configure_tim_rcr_dma_tx(void) { +static void furi_hal_irda_configure_tim_rcr_dma_tx(void) { LL_C2_AHB1_GRP1_EnableClock(LL_C2_AHB1_GRP1_PERIPH_DMA1); LL_DMA_InitTypeDef dma_config = {0}; @@ -362,7 +362,7 @@ static void api_hal_irda_configure_tim_rcr_dma_tx(void) { dma_config.PeriphRequest = LL_DMAMUX_REQ_TIM1_UP; dma_config.Priority = LL_DMA_PRIORITY_MEDIUM; LL_DMA_Init(DMA1, LL_DMA_CHANNEL_2, &dma_config); - api_hal_interrupt_set_dma_channel_isr(DMA1, LL_DMA_CHANNEL_2, api_hal_irda_tx_dma_isr); + furi_hal_interrupt_set_dma_channel_isr(DMA1, LL_DMA_CHANNEL_2, furi_hal_irda_tx_dma_isr); LL_DMA_ClearFlag_TC2(DMA1); LL_DMA_ClearFlag_HT2(DMA1); LL_DMA_ClearFlag_TE2(DMA1); @@ -374,10 +374,10 @@ static void api_hal_irda_configure_tim_rcr_dma_tx(void) { NVIC_EnableIRQ(DMA1_Channel2_IRQn); } -static void api_hal_irda_tx_fill_buffer_last(uint8_t buf_num) { +static void furi_hal_irda_tx_fill_buffer_last(uint8_t buf_num) { furi_assert(buf_num < 2); - furi_assert(api_hal_irda_state != IrdaStateAsyncRx); - furi_assert(api_hal_irda_state < IrdaStateMAX); + furi_assert(furi_hal_irda_state != IrdaStateAsyncRx); + furi_assert(furi_hal_irda_state < IrdaStateMAX); furi_assert(irda_tim_tx.data_callback); IrdaTxBuf* buffer = &irda_tim_tx.buffer[buf_num]; furi_assert(buffer->data != NULL); @@ -392,16 +392,16 @@ static void api_hal_irda_tx_fill_buffer_last(uint8_t buf_num) { irda_tim_tx.buffer[buf_num].packet_end = true; } -static bool api_hal_irda_tx_fill_buffer(uint8_t buf_num, uint8_t polarity_shift) { +static bool furi_hal_irda_tx_fill_buffer(uint8_t buf_num, uint8_t polarity_shift) { furi_assert(buf_num < 2); - furi_assert(api_hal_irda_state != IrdaStateAsyncRx); - furi_assert(api_hal_irda_state < IrdaStateMAX); + furi_assert(furi_hal_irda_state != IrdaStateAsyncRx); + furi_assert(furi_hal_irda_state < IrdaStateMAX); furi_assert(irda_tim_tx.data_callback); IrdaTxBuf* buffer = &irda_tim_tx.buffer[buf_num]; furi_assert(buffer->data != NULL); furi_assert(buffer->polarity != NULL); - ApiHalIrdaTxGetDataState status = ApiHalIrdaTxGetDataStateOk; + FuriHalIrdaTxGetDataState status = FuriHalIrdaTxGetDataStateOk; uint32_t duration = 0; bool level = 0; size_t *size = &buffer->size; @@ -410,9 +410,9 @@ static bool api_hal_irda_tx_fill_buffer(uint8_t buf_num, uint8_t polarity_shift) buffer->polarity[polarity_counter++] = IRDA_TX_CCMR_LOW; } - for (*size = 0; (*size < IRDA_TIM_TX_DMA_BUFFER_SIZE) && (status == ApiHalIrdaTxGetDataStateOk); ++(*size), ++polarity_counter) { + for (*size = 0; (*size < IRDA_TIM_TX_DMA_BUFFER_SIZE) && (status == FuriHalIrdaTxGetDataStateOk); ++(*size), ++polarity_counter) { status = irda_tim_tx.data_callback(irda_tim_tx.data_context, &duration, &level); - if (status == ApiHalIrdaTxGetDataStateError) { + if (status == FuriHalIrdaTxGetDataStateError) { furi_assert(0); break; } @@ -421,7 +421,7 @@ static bool api_hal_irda_tx_fill_buffer(uint8_t buf_num, uint8_t polarity_shift) if ((buffer->data[*size] + num_of_impulses - 1) > 0xFFFF) { furi_assert(0); - status = ApiHalIrdaTxGetDataStateError; + status = FuriHalIrdaTxGetDataStateError; break; } @@ -429,15 +429,15 @@ static bool api_hal_irda_tx_fill_buffer(uint8_t buf_num, uint8_t polarity_shift) buffer->data[*size] = num_of_impulses - 1; } - buffer->last_packet_end = (status == ApiHalIrdaTxGetDataStateLastDone); - buffer->packet_end = buffer->last_packet_end || (status == ApiHalIrdaTxGetDataStateDone); + buffer->last_packet_end = (status == FuriHalIrdaTxGetDataStateLastDone); + buffer->packet_end = buffer->last_packet_end || (status == FuriHalIrdaTxGetDataStateDone); - return status != ApiHalIrdaTxGetDataStateError; + return status != FuriHalIrdaTxGetDataStateError; } -static void api_hal_irda_tx_dma_set_polarity(uint8_t buf_num, uint8_t polarity_shift) { +static void furi_hal_irda_tx_dma_set_polarity(uint8_t buf_num, uint8_t polarity_shift) { furi_assert(buf_num < 2); - furi_assert(api_hal_irda_state < IrdaStateMAX); + furi_assert(furi_hal_irda_state < IrdaStateMAX); IrdaTxBuf* buffer = &irda_tim_tx.buffer[buf_num]; furi_assert(buffer->polarity != NULL); @@ -454,9 +454,9 @@ static void api_hal_irda_tx_dma_set_polarity(uint8_t buf_num, uint8_t polarity_s __enable_irq(); } -static void api_hal_irda_tx_dma_set_buffer(uint8_t buf_num) { +static void furi_hal_irda_tx_dma_set_buffer(uint8_t buf_num) { furi_assert(buf_num < 2); - furi_assert(api_hal_irda_state < IrdaStateMAX); + furi_assert(furi_hal_irda_state < IrdaStateMAX); IrdaTxBuf* buffer = &irda_tim_tx.buffer[buf_num]; furi_assert(buffer->data != NULL); @@ -474,13 +474,13 @@ static void api_hal_irda_tx_dma_set_buffer(uint8_t buf_num) { __enable_irq(); } -static void api_hal_irda_async_tx_free_resources(void) { - furi_assert((api_hal_irda_state == IrdaStateIdle) || (api_hal_irda_state == IrdaStateAsyncTxStopped)); +static void furi_hal_irda_async_tx_free_resources(void) { + furi_assert((furi_hal_irda_state == IrdaStateIdle) || (furi_hal_irda_state == IrdaStateAsyncTxStopped)); osStatus_t status; hal_gpio_init_ex(&gpio_irda_tx, GpioModeOutputOpenDrain, GpioPullDown, GpioSpeedLow, 0); - api_hal_interrupt_set_dma_channel_isr(DMA1, LL_DMA_CHANNEL_1, NULL); - api_hal_interrupt_set_dma_channel_isr(DMA1, LL_DMA_CHANNEL_2, NULL); + furi_hal_interrupt_set_dma_channel_isr(DMA1, LL_DMA_CHANNEL_1, NULL); + furi_hal_interrupt_set_dma_channel_isr(DMA1, LL_DMA_CHANNEL_2, NULL); LL_TIM_DeInit(TIM1); LL_APB2_GRP1_DisableClock(LL_APB2_GRP1_PERIPH_TIM1); LL_C2_AHB1_GRP1_DisableClock(LL_C2_AHB1_GRP1_PERIPH_DMA1); @@ -498,13 +498,13 @@ static void api_hal_irda_async_tx_free_resources(void) { irda_tim_tx.buffer[1].polarity = NULL; } -bool api_hal_irda_async_tx_start(uint32_t freq, float duty_cycle) { +bool furi_hal_irda_async_tx_start(uint32_t freq, float duty_cycle) { if ((duty_cycle > 1) || (duty_cycle < 0) || (freq > 40000) || (freq < 10000) || (irda_tim_tx.data_callback == NULL)) { furi_assert(0); return false; } - furi_assert(api_hal_irda_state == IrdaStateIdle); + furi_assert(furi_hal_irda_state == IrdaStateIdle); furi_assert(irda_tim_tx.buffer[0].data == NULL); furi_assert(irda_tim_tx.buffer[1].data == NULL); furi_assert(irda_tim_tx.buffer[0].polarity == NULL); @@ -521,16 +521,16 @@ bool api_hal_irda_async_tx_start(uint32_t freq, float duty_cycle) { irda_tim_tx.stop_semaphore = osSemaphoreNew(1, 0, NULL); irda_tim_tx.cycle_duration = 1000000.0 / freq; - bool result = api_hal_irda_tx_fill_buffer(0, IRDA_POLARITY_SHIFT); + bool result = furi_hal_irda_tx_fill_buffer(0, IRDA_POLARITY_SHIFT); if (result) { - api_hal_irda_configure_tim_pwm_tx(freq, duty_cycle); - api_hal_irda_configure_tim_cmgr2_dma_tx(); - api_hal_irda_configure_tim_rcr_dma_tx(); - api_hal_irda_tx_dma_set_polarity(0, IRDA_POLARITY_SHIFT); - api_hal_irda_tx_dma_set_buffer(0); + furi_hal_irda_configure_tim_pwm_tx(freq, duty_cycle); + furi_hal_irda_configure_tim_cmgr2_dma_tx(); + furi_hal_irda_configure_tim_rcr_dma_tx(); + furi_hal_irda_tx_dma_set_polarity(0, IRDA_POLARITY_SHIFT); + furi_hal_irda_tx_dma_set_buffer(0); - api_hal_irda_state = IrdaStateAsyncTx; + furi_hal_irda_state = IrdaStateAsyncTx; LL_TIM_ClearFlag_UPDATE(TIM1); LL_DMA_EnableChannel(DMA1, LL_DMA_CHANNEL_1); @@ -547,37 +547,37 @@ bool api_hal_irda_async_tx_start(uint32_t freq, float duty_cycle) { __enable_irq(); } else { - api_hal_irda_async_tx_free_resources(); + furi_hal_irda_async_tx_free_resources(); } return result; } -void api_hal_irda_async_tx_wait_termination(void) { - furi_assert(api_hal_irda_state >= IrdaStateAsyncTx); - furi_assert(api_hal_irda_state < IrdaStateMAX); +void furi_hal_irda_async_tx_wait_termination(void) { + furi_assert(furi_hal_irda_state >= IrdaStateAsyncTx); + furi_assert(furi_hal_irda_state < IrdaStateMAX); osStatus_t status; status = osSemaphoreAcquire(irda_tim_tx.stop_semaphore, osWaitForever); furi_check(status == osOK); - api_hal_irda_async_tx_free_resources(); - api_hal_irda_state = IrdaStateIdle; + furi_hal_irda_async_tx_free_resources(); + furi_hal_irda_state = IrdaStateIdle; } -void api_hal_irda_async_tx_stop(void) { - furi_assert(api_hal_irda_state >= IrdaStateAsyncTx); - furi_assert(api_hal_irda_state < IrdaStateMAX); +void furi_hal_irda_async_tx_stop(void) { + furi_assert(furi_hal_irda_state >= IrdaStateAsyncTx); + furi_assert(furi_hal_irda_state < IrdaStateMAX); __disable_irq(); - if (api_hal_irda_state == IrdaStateAsyncTx) - api_hal_irda_state = IrdaStateAsyncTxStopReq; + if (furi_hal_irda_state == IrdaStateAsyncTx) + furi_hal_irda_state = IrdaStateAsyncTxStopReq; __enable_irq(); - api_hal_irda_async_tx_wait_termination(); + furi_hal_irda_async_tx_wait_termination(); } -void api_hal_irda_async_tx_set_data_isr_callback(ApiHalIrdaTxGetDataCallback callback, void* context) { - furi_assert(api_hal_irda_state == IrdaStateIdle); +void furi_hal_irda_async_tx_set_data_isr_callback(FuriHalIrdaTxGetDataCallback callback, void* context) { + furi_assert(furi_hal_irda_state == IrdaStateIdle); irda_tim_tx.data_callback = callback; irda_tim_tx.data_context = context; } diff --git a/firmware/targets/f6/api-hal/api-hal-light.c b/firmware/targets/f6/furi-hal/furi-hal-light.c similarity index 91% rename from firmware/targets/f6/api-hal/api-hal-light.c rename to firmware/targets/f6/furi-hal/furi-hal-light.c index b01a9ab9..fba1bec4 100644 --- a/firmware/targets/f6/api-hal/api-hal-light.c +++ b/firmware/targets/f6/furi-hal/furi-hal-light.c @@ -1,4 +1,4 @@ -#include +#include #include #define LED_CURRENT_RED 50 @@ -6,7 +6,7 @@ #define LED_CURRENT_BLUE 50 #define LED_CURRENT_WHITE 150 -void api_hal_light_init() { +void furi_hal_light_init() { lp5562_reset(); lp5562_set_channel_current(LP5562ChannelRed, LED_CURRENT_RED); @@ -24,7 +24,7 @@ void api_hal_light_init() { FURI_LOG_I("FuriHalLight", "Init OK"); } -void api_hal_light_set(Light light, uint8_t value) { +void furi_hal_light_set(Light light, uint8_t value) { switch(light) { case LightRed: lp5562_set_channel_value(LP5562ChannelRed, value); diff --git a/firmware/targets/f6/api-hal/api-hal-nfc.c b/firmware/targets/f6/furi-hal/furi-hal-nfc.c similarity index 86% rename from firmware/targets/f6/api-hal/api-hal-nfc.c rename to firmware/targets/f6/furi-hal/furi-hal-nfc.c index cb75dd26..d64a344e 100644 --- a/firmware/targets/f6/api-hal/api-hal-nfc.c +++ b/firmware/targets/f6/furi-hal/furi-hal-nfc.c @@ -1,41 +1,41 @@ -#include "api-hal-nfc.h" +#include "furi-hal-nfc.h" #include static const uint32_t clocks_in_ms = 64 * 1000; -void api_hal_nfc_init() { +void furi_hal_nfc_init() { ReturnCode ret = rfalNfcInitialize(); if(ret == ERR_NONE) { - api_hal_nfc_start_sleep(); + furi_hal_nfc_start_sleep(); FURI_LOG_I("FuriHalNfc", "Init OK"); } else { FURI_LOG_W("FuriHalNfc", "Initialization failed, RFAL returned: %d", ret); } } -bool api_hal_nfc_is_busy() { +bool furi_hal_nfc_is_busy() { return rfalNfcGetState() != RFAL_NFC_STATE_IDLE; } -void api_hal_nfc_field_on() { - api_hal_nfc_exit_sleep(); +void furi_hal_nfc_field_on() { + furi_hal_nfc_exit_sleep(); st25r3916TxRxOn(); } -void api_hal_nfc_field_off() { +void furi_hal_nfc_field_off() { st25r3916TxRxOff(); - api_hal_nfc_start_sleep(); + furi_hal_nfc_start_sleep(); } -void api_hal_nfc_start_sleep() { +void furi_hal_nfc_start_sleep() { rfalLowPowerModeStart(); } -void api_hal_nfc_exit_sleep() { +void furi_hal_nfc_exit_sleep() { rfalLowPowerModeStop(); } -bool api_hal_nfc_detect(rfalNfcDevice **dev_list, uint8_t* dev_cnt, uint32_t timeout, bool deactivate) { +bool furi_hal_nfc_detect(rfalNfcDevice **dev_list, uint8_t* dev_cnt, uint32_t timeout, bool deactivate) { furi_assert(dev_list); furi_assert(dev_cnt); @@ -86,7 +86,7 @@ bool api_hal_nfc_detect(rfalNfcDevice **dev_list, uint8_t* dev_cnt, uint32_t tim return true; } -bool api_hal_nfc_listen(uint8_t* uid, uint8_t uid_len, uint8_t* atqa, uint8_t sak, uint32_t timeout) { +bool furi_hal_nfc_listen(uint8_t* uid, uint8_t uid_len, uint8_t* atqa, uint8_t sak, uint32_t timeout) { rfalNfcState state = rfalNfcGetState(); if(state == RFAL_NFC_STATE_NOTINIT) { @@ -129,7 +129,7 @@ bool api_hal_nfc_listen(uint8_t* uid, uint8_t uid_len, uint8_t* atqa, uint8_t sa return true; } -ReturnCode api_hal_nfc_data_exchange(uint8_t* tx_buff, uint16_t tx_len, uint8_t** rx_buff, uint16_t** rx_len, bool deactivate) { +ReturnCode furi_hal_nfc_data_exchange(uint8_t* tx_buff, uint16_t tx_len, uint8_t** rx_buff, uint16_t** rx_len, bool deactivate) { furi_assert(rx_buff); furi_assert(rx_len); @@ -165,7 +165,7 @@ ReturnCode api_hal_nfc_data_exchange(uint8_t* tx_buff, uint16_t tx_len, uint8_t* return ERR_NONE; } -void api_hal_nfc_deactivate() { +void furi_hal_nfc_deactivate() { rfalNfcDeactivate(false); rfalLowPowerModeStart(); } diff --git a/firmware/targets/f6/furi-hal/furi-hal-os-timer.h b/firmware/targets/f6/furi-hal/furi-hal-os-timer.h new file mode 100644 index 00000000..f210b539 --- /dev/null +++ b/firmware/targets/f6/furi-hal/furi-hal-os-timer.h @@ -0,0 +1,64 @@ +#pragma once + +#include +#include +#include + +// Timer used for system ticks +#define FURI_HAL_OS_TIMER_MAX 0xFFFF +#define FURI_HAL_OS_TIMER_REG_LOAD_DLY 0x1 +#define FURI_HAL_OS_TIMER LPTIM2 +#define FURI_HAL_OS_TIMER_IRQ LPTIM2_IRQn + +static inline void furi_hal_os_timer_init() { + // Configure clock source + LL_RCC_SetLPTIMClockSource(LL_RCC_LPTIM2_CLKSOURCE_LSE); + LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_LPTIM2); + // Set interrupt priority and enable them + NVIC_SetPriority(FURI_HAL_OS_TIMER_IRQ, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 15, 0)); + NVIC_EnableIRQ(FURI_HAL_OS_TIMER_IRQ); +} + +static inline void furi_hal_os_timer_continuous(uint32_t count) { + // Enable timer + LL_LPTIM_Enable(FURI_HAL_OS_TIMER); + while(!LL_LPTIM_IsEnabled(FURI_HAL_OS_TIMER)); + + // Enable rutoreload match interrupt + LL_LPTIM_EnableIT_ARRM(FURI_HAL_OS_TIMER); + + // Set autoreload and start counter + LL_LPTIM_SetAutoReload(FURI_HAL_OS_TIMER, count); + LL_LPTIM_StartCounter(FURI_HAL_OS_TIMER, LL_LPTIM_OPERATING_MODE_CONTINUOUS); +} + +static inline void furi_hal_os_timer_single(uint32_t count) { + // Enable timer + LL_LPTIM_Enable(FURI_HAL_OS_TIMER); + while(!LL_LPTIM_IsEnabled(FURI_HAL_OS_TIMER)); + + // Enable compare match interrupt + LL_LPTIM_EnableIT_CMPM(FURI_HAL_OS_TIMER); + + // Set compare, autoreload and start counter + // Include some marging to workaround ARRM behaviour + LL_LPTIM_SetCompare(FURI_HAL_OS_TIMER, count-3); + LL_LPTIM_SetAutoReload(FURI_HAL_OS_TIMER, count); + LL_LPTIM_StartCounter(FURI_HAL_OS_TIMER, LL_LPTIM_OPERATING_MODE_ONESHOT); +} + +static inline void furi_hal_os_timer_reset() { + // Hard reset timer + // THE ONLY RELIABLEWAY to stop it according to errata + LL_LPTIM_DeInit(FURI_HAL_OS_TIMER); +} + +static inline uint32_t furi_hal_os_timer_get_cnt() { + uint32_t counter = LL_LPTIM_GetCounter(FURI_HAL_OS_TIMER); + uint32_t counter_shadow = LL_LPTIM_GetCounter(FURI_HAL_OS_TIMER); + while(counter != counter_shadow) { + counter = counter_shadow; + counter_shadow = LL_LPTIM_GetCounter(FURI_HAL_OS_TIMER); + } + return counter; +} diff --git a/firmware/targets/f6/api-hal/api-hal-os.c b/firmware/targets/f6/furi-hal/furi-hal-os.c similarity index 55% rename from firmware/targets/f6/api-hal/api-hal-os.c rename to firmware/targets/f6/furi-hal/furi-hal-os.c index 2f4d8363..0e55df53 100644 --- a/firmware/targets/f6/api-hal/api-hal-os.c +++ b/firmware/targets/f6/furi-hal/furi-hal-os.c @@ -1,17 +1,17 @@ -#include -#include -#include +#include +#include +#include #include #include -#define API_HAL_OS_CLK_FREQUENCY 32768 -#define API_HAL_OS_TICK_PER_SECOND 1024 -#define API_HAL_OS_CLK_PER_TICK (API_HAL_OS_CLK_FREQUENCY / API_HAL_OS_TICK_PER_SECOND) -#define API_HAL_OS_TICK_PER_EPOCH (API_HAL_OS_TIMER_MAX / API_HAL_OS_CLK_PER_TICK) -#define API_HAL_OS_MAX_SLEEP (API_HAL_OS_TICK_PER_EPOCH - 1) +#define FURI_HAL_OS_CLK_FREQUENCY 32768 +#define FURI_HAL_OS_TICK_PER_SECOND 1024 +#define FURI_HAL_OS_CLK_PER_TICK (FURI_HAL_OS_CLK_FREQUENCY / FURI_HAL_OS_TICK_PER_SECOND) +#define FURI_HAL_OS_TICK_PER_EPOCH (FURI_HAL_OS_TIMER_MAX / FURI_HAL_OS_CLK_PER_TICK) +#define FURI_HAL_OS_MAX_SLEEP (FURI_HAL_OS_TICK_PER_EPOCH - 1) -#ifdef API_HAL_OS_DEBUG +#ifdef FURI_HAL_OS_DEBUG #include #define LED_SLEEP_PORT GPIOA @@ -21,24 +21,24 @@ #define LED_SECOND_PORT GPIOA #define LED_SECOND_PIN LL_GPIO_PIN_4 -void api_hal_os_timer_callback() { +void furi_hal_os_timer_callback() { LL_GPIO_TogglePin(LED_SECOND_PORT, LED_SECOND_PIN); } #endif -volatile uint32_t api_hal_os_skew = 0; +volatile uint32_t furi_hal_os_skew = 0; -void api_hal_os_init() { +void furi_hal_os_init() { LL_DBGMCU_APB1_GRP2_FreezePeriph(LL_DBGMCU_APB1_GRP2_LPTIM2_STOP); - api_hal_os_timer_init(); - api_hal_os_timer_continuous(API_HAL_OS_CLK_PER_TICK); + furi_hal_os_timer_init(); + furi_hal_os_timer_continuous(FURI_HAL_OS_CLK_PER_TICK); -#ifdef API_HAL_OS_DEBUG +#ifdef FURI_HAL_OS_DEBUG LL_GPIO_SetPinMode(LED_SLEEP_PORT, LED_SLEEP_PIN, LL_GPIO_MODE_OUTPUT); LL_GPIO_SetPinMode(LED_TICK_PORT, LED_TICK_PIN, LL_GPIO_MODE_OUTPUT); LL_GPIO_SetPinMode(LED_SECOND_PORT, LED_SECOND_PIN, LL_GPIO_MODE_OUTPUT); - osTimerId_t second_timer = osTimerNew(api_hal_os_timer_callback, osTimerPeriodic, NULL, NULL); + osTimerId_t second_timer = osTimerNew(furi_hal_os_timer_callback, osTimerPeriodic, NULL, NULL); osTimerStart(second_timer, 1024); #endif @@ -47,67 +47,67 @@ void api_hal_os_init() { void LPTIM2_IRQHandler(void) { // Autoreload - if(LL_LPTIM_IsActiveFlag_ARRM(API_HAL_OS_TIMER)) { - LL_LPTIM_ClearFLAG_ARRM(API_HAL_OS_TIMER); + if(LL_LPTIM_IsActiveFlag_ARRM(FURI_HAL_OS_TIMER)) { + LL_LPTIM_ClearFLAG_ARRM(FURI_HAL_OS_TIMER); if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) { - #ifdef API_HAL_OS_DEBUG + #ifdef FURI_HAL_OS_DEBUG LL_GPIO_TogglePin(LED_TICK_PORT, LED_TICK_PIN); #endif xPortSysTickHandler(); } } - if(LL_LPTIM_IsActiveFlag_CMPM(API_HAL_OS_TIMER)) { - LL_LPTIM_ClearFLAG_CMPM(API_HAL_OS_TIMER); + if(LL_LPTIM_IsActiveFlag_CMPM(FURI_HAL_OS_TIMER)) { + LL_LPTIM_ClearFLAG_CMPM(FURI_HAL_OS_TIMER); } } -static inline uint32_t api_hal_os_sleep(TickType_t expected_idle_ticks) { +static inline uint32_t furi_hal_os_sleep(TickType_t expected_idle_ticks) { // Stop ticks - api_hal_os_timer_reset(); + furi_hal_os_timer_reset(); LL_SYSTICK_DisableIT(); // Start wakeup timer - api_hal_os_timer_single(expected_idle_ticks * API_HAL_OS_CLK_PER_TICK); + furi_hal_os_timer_single(expected_idle_ticks * FURI_HAL_OS_CLK_PER_TICK); -#ifdef API_HAL_OS_DEBUG +#ifdef FURI_HAL_OS_DEBUG LL_GPIO_ResetOutputPin(LED_SLEEP_PORT, LED_SLEEP_PIN); #endif // Go to sleep mode - api_hal_power_sleep(); + furi_hal_power_sleep(); -#ifdef API_HAL_OS_DEBUG +#ifdef FURI_HAL_OS_DEBUG LL_GPIO_SetOutputPin(LED_SLEEP_PORT, LED_SLEEP_PIN); #endif // Calculate how much time we spent in the sleep - uint32_t after_cnt = api_hal_os_timer_get_cnt() + api_hal_os_skew; - uint32_t after_tick = after_cnt / API_HAL_OS_CLK_PER_TICK; - api_hal_os_skew = after_cnt % API_HAL_OS_CLK_PER_TICK; + uint32_t after_cnt = furi_hal_os_timer_get_cnt() + furi_hal_os_skew; + uint32_t after_tick = after_cnt / FURI_HAL_OS_CLK_PER_TICK; + furi_hal_os_skew = after_cnt % FURI_HAL_OS_CLK_PER_TICK; - bool cmpm = LL_LPTIM_IsActiveFlag_CMPM(API_HAL_OS_TIMER); - bool arrm = LL_LPTIM_IsActiveFlag_ARRM(API_HAL_OS_TIMER); + bool cmpm = LL_LPTIM_IsActiveFlag_CMPM(FURI_HAL_OS_TIMER); + bool arrm = LL_LPTIM_IsActiveFlag_ARRM(FURI_HAL_OS_TIMER); if (cmpm && arrm) after_tick += expected_idle_ticks; // Prepare tick timer for new round - api_hal_os_timer_reset(); + furi_hal_os_timer_reset(); // Resume ticks LL_SYSTICK_EnableIT(); - api_hal_os_timer_continuous(API_HAL_OS_CLK_PER_TICK); + furi_hal_os_timer_continuous(FURI_HAL_OS_CLK_PER_TICK); return after_tick; } void vPortSuppressTicksAndSleep(TickType_t expected_idle_ticks) { - if(!api_hal_power_sleep_available()) { + if(!furi_hal_power_sleep_available()) { __WFI(); return; } // Limit mount of ticks to maximum that timer can count - if (expected_idle_ticks > API_HAL_OS_MAX_SLEEP) { - expected_idle_ticks = API_HAL_OS_MAX_SLEEP; + if (expected_idle_ticks > FURI_HAL_OS_MAX_SLEEP) { + expected_idle_ticks = FURI_HAL_OS_MAX_SLEEP; } // Stop IRQ handling, no one should disturb us till we finish @@ -120,7 +120,7 @@ void vPortSuppressTicksAndSleep(TickType_t expected_idle_ticks) { } // Sleep and track how much ticks we spent sleeping - uint32_t completed_ticks = api_hal_os_sleep(expected_idle_ticks); + uint32_t completed_ticks = furi_hal_os_sleep(expected_idle_ticks); // Reenable IRQ __enable_irq(); diff --git a/firmware/targets/f6/api-hal/api-hal-os.h b/firmware/targets/f6/furi-hal/furi-hal-os.h similarity index 83% rename from firmware/targets/f6/api-hal/api-hal-os.h rename to firmware/targets/f6/furi-hal/furi-hal-os.h index 45666889..72ae74fc 100644 --- a/firmware/targets/f6/api-hal/api-hal-os.h +++ b/firmware/targets/f6/furi-hal/furi-hal-os.h @@ -10,7 +10,7 @@ extern "C" { /* Initialize OS helpers * Configure and start tick timer */ -void api_hal_os_init(); +void furi_hal_os_init(); #ifdef __cplusplus } diff --git a/firmware/targets/f6/api-hal/api-hal-power.c b/firmware/targets/f6/furi-hal/furi-hal-power.c similarity index 73% rename from firmware/targets/f6/api-hal/api-hal-power.c rename to firmware/targets/f6/furi-hal/furi-hal-power.c index 24533e73..4dd0127f 100644 --- a/firmware/targets/f6/api-hal/api-hal-power.c +++ b/firmware/targets/f6/furi-hal/furi-hal-power.c @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include #include #include @@ -18,9 +18,9 @@ typedef struct { volatile uint32_t insomnia; volatile uint32_t deep_insomnia; -} ApiHalPower; +} FuriHalPower; -static volatile ApiHalPower api_hal_power = { +static volatile FuriHalPower furi_hal_power = { .insomnia = 0, .deep_insomnia = 1, }; @@ -64,10 +64,10 @@ const ParamCEDV cedv = { void HAL_RCC_CSSCallback(void) { // TODO: notify user about issue with HSE - api_hal_power_reset(); + furi_hal_power_reset(); } -void api_hal_power_init() { +void furi_hal_power_init() { LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1); LL_PWR_SMPS_SetMode(LL_PWR_SMPS_STEP_DOWN); bq27220_init(&cedv); @@ -75,31 +75,31 @@ void api_hal_power_init() { FURI_LOG_I("FuriHalPower", "Init OK"); } -uint16_t api_hal_power_insomnia_level() { - return api_hal_power.insomnia; +uint16_t furi_hal_power_insomnia_level() { + return furi_hal_power.insomnia; } -void api_hal_power_insomnia_enter() { - api_hal_power.insomnia++; +void furi_hal_power_insomnia_enter() { + furi_hal_power.insomnia++; } -void api_hal_power_insomnia_exit() { - api_hal_power.insomnia--; +void furi_hal_power_insomnia_exit() { + furi_hal_power.insomnia--; } -bool api_hal_power_sleep_available() { - return api_hal_power.insomnia == 0; +bool furi_hal_power_sleep_available() { + return furi_hal_power.insomnia == 0; } -bool api_hal_power_deep_sleep_available() { - return api_hal_bt_is_alive() && api_hal_power.deep_insomnia == 0; +bool furi_hal_power_deep_sleep_available() { + return furi_hal_bt_is_alive() && furi_hal_power.deep_insomnia == 0; } -void api_hal_power_light_sleep() { +void furi_hal_power_light_sleep() { __WFI(); } -void api_hal_power_deep_sleep() { +void furi_hal_power_deep_sleep() { while( LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID)); if (!LL_HSEM_1StepLock(HSEM, CFG_HW_ENTRY_STOP_MODE_SEMID)) { @@ -108,13 +108,13 @@ void api_hal_power_deep_sleep() { LL_HSEM_ReleaseLock(HSEM, CFG_HW_ENTRY_STOP_MODE_SEMID, 0); // The switch on HSI before entering Stop Mode is required - api_hal_clock_switch_to_hsi(); + furi_hal_clock_switch_to_hsi(); } } else { /** * The switch on HSI before entering Stop Mode is required */ - api_hal_clock_switch_to_hsi(); + furi_hal_clock_switch_to_hsi(); } /* Release RCC semaphore */ @@ -137,82 +137,82 @@ void api_hal_power_deep_sleep() { while(LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID)); if(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) { - api_hal_clock_switch_to_pll(); + furi_hal_clock_switch_to_pll(); } LL_HSEM_ReleaseLock(HSEM, CFG_HW_RCC_SEMID, 0); } -void api_hal_power_sleep() { - if(api_hal_power_deep_sleep_available()) { - api_hal_power_deep_sleep(); +void furi_hal_power_sleep() { + if(furi_hal_power_deep_sleep_available()) { + furi_hal_power_deep_sleep(); } else { - api_hal_power_light_sleep(); + furi_hal_power_light_sleep(); } } -uint8_t api_hal_power_get_pct() { +uint8_t furi_hal_power_get_pct() { return bq27220_get_state_of_charge(); } -uint8_t api_hal_power_get_bat_health_pct() { +uint8_t furi_hal_power_get_bat_health_pct() { return bq27220_get_state_of_health(); } -bool api_hal_power_is_charging() { +bool furi_hal_power_is_charging() { return bq25896_is_charging(); } -void api_hal_power_off() { +void furi_hal_power_off() { bq25896_poweroff(); } -void api_hal_power_reset() { +void furi_hal_power_reset() { NVIC_SystemReset(); } -void api_hal_power_enable_otg() { +void furi_hal_power_enable_otg() { bq25896_enable_otg(); } -void api_hal_power_disable_otg() { +void furi_hal_power_disable_otg() { bq25896_disable_otg(); } -uint32_t api_hal_power_get_battery_remaining_capacity() { +uint32_t furi_hal_power_get_battery_remaining_capacity() { return bq27220_get_remaining_capacity(); } -uint32_t api_hal_power_get_battery_full_capacity() { +uint32_t furi_hal_power_get_battery_full_capacity() { return bq27220_get_full_charge_capacity(); } -float api_hal_power_get_battery_voltage(ApiHalPowerIC ic) { - if (ic == ApiHalPowerICCharger) { +float furi_hal_power_get_battery_voltage(FuriHalPowerIC ic) { + if (ic == FuriHalPowerICCharger) { return (float)bq25896_get_vbat_voltage() / 1000.0f; - } else if (ic == ApiHalPowerICFuelGauge) { + } else if (ic == FuriHalPowerICFuelGauge) { return (float)bq27220_get_voltage() / 1000.0f; } else { return 0.0f; } } -float api_hal_power_get_battery_current(ApiHalPowerIC ic) { - if (ic == ApiHalPowerICCharger) { +float furi_hal_power_get_battery_current(FuriHalPowerIC ic) { + if (ic == FuriHalPowerICCharger) { return (float)bq25896_get_vbat_current() / 1000.0f; - } else if (ic == ApiHalPowerICFuelGauge) { + } else if (ic == FuriHalPowerICFuelGauge) { return (float)bq27220_get_current() / 1000.0f; } else { return 0.0f; } } -float api_hal_power_get_battery_temperature(ApiHalPowerIC ic) { - if (ic == ApiHalPowerICCharger) { +float furi_hal_power_get_battery_temperature(FuriHalPowerIC ic) { + if (ic == FuriHalPowerICCharger) { // Linear approximation, +/- 5 C return (71.0f - (float)bq25896_get_ntc_mpct()/1000) / 0.6f; - } else if (ic == ApiHalPowerICFuelGauge) { + } else if (ic == FuriHalPowerICFuelGauge) { return ((float)bq27220_get_temperature() - 2731.0f) / 10.0f; } else { return 0.0f; @@ -220,11 +220,11 @@ float api_hal_power_get_battery_temperature(ApiHalPowerIC ic) { } -float api_hal_power_get_usb_voltage(){ +float furi_hal_power_get_usb_voltage(){ return (float)bq25896_get_vbus_voltage() / 1000.0f; } -void api_hal_power_dump_state() { +void furi_hal_power_dump_state() { BatteryStatus battery_status; OperationStatus operation_status; if (bq27220_get_battery_status(&battery_status) == BQ27220_ERROR @@ -259,7 +259,7 @@ void api_hal_power_dump_state() { ); printf( "bq27220: Voltage: %dmV, Current: %dmA, Temperature: %dC\r\n", - bq27220_get_voltage(), bq27220_get_current(), (int)api_hal_power_get_battery_temperature(ApiHalPowerICFuelGauge) + bq27220_get_voltage(), bq27220_get_current(), (int)furi_hal_power_get_battery_temperature(FuriHalPowerICFuelGauge) ); } @@ -271,10 +271,10 @@ void api_hal_power_dump_state() { ); } -void api_hal_power_enable_external_3_3v(){ +void furi_hal_power_enable_external_3_3v(){ LL_GPIO_SetOutputPin(PERIPH_POWER_GPIO_Port, PERIPH_POWER_Pin); } -void api_hal_power_disable_external_3_3v(){ +void furi_hal_power_disable_external_3_3v(){ LL_GPIO_ResetOutputPin(PERIPH_POWER_GPIO_Port, PERIPH_POWER_Pin); } diff --git a/firmware/targets/f6/api-hal/api-hal-pwm.c b/firmware/targets/f6/furi-hal/furi-hal-pwm.c similarity index 98% rename from firmware/targets/f6/api-hal/api-hal-pwm.c rename to firmware/targets/f6/furi-hal/furi-hal-pwm.c index 7ffdd566..972d28ba 100644 --- a/firmware/targets/f6/api-hal/api-hal-pwm.c +++ b/firmware/targets/f6/furi-hal/furi-hal-pwm.c @@ -1,4 +1,4 @@ -#include "api-hal-pwm.h" +#include "furi-hal-pwm.h" void hal_pwm_set(float value, float freq, TIM_HandleTypeDef* tim, uint32_t channel) { tim->Init.CounterMode = TIM_COUNTERMODE_UP; diff --git a/firmware/targets/f6/api-hal/api-hal-pwm.h b/firmware/targets/f6/furi-hal/furi-hal-pwm.h similarity index 100% rename from firmware/targets/f6/api-hal/api-hal-pwm.h rename to firmware/targets/f6/furi-hal/furi-hal-pwm.h diff --git a/firmware/targets/f6/api-hal/api-hal-resources.c b/firmware/targets/f6/furi-hal/furi-hal-resources.c similarity index 98% rename from firmware/targets/f6/api-hal/api-hal-resources.c rename to firmware/targets/f6/furi-hal/furi-hal-resources.c index 29974876..f1d2003f 100644 --- a/firmware/targets/f6/api-hal/api-hal-resources.c +++ b/firmware/targets/f6/furi-hal/furi-hal-resources.c @@ -1,4 +1,4 @@ -#include +#include #include "main.h" #include diff --git a/firmware/targets/f6/api-hal/api-hal-resources.h b/firmware/targets/f6/furi-hal/furi-hal-resources.h similarity index 100% rename from firmware/targets/f6/api-hal/api-hal-resources.h rename to firmware/targets/f6/furi-hal/furi-hal-resources.h diff --git a/firmware/targets/f6/api-hal/api-hal-rfid.c b/firmware/targets/f6/furi-hal/furi-hal-rfid.c similarity index 88% rename from firmware/targets/f6/api-hal/api-hal-rfid.c rename to firmware/targets/f6/furi-hal/furi-hal-rfid.c index be8e3c5f..ac556f0b 100644 --- a/firmware/targets/f6/api-hal/api-hal-rfid.c +++ b/firmware/targets/f6/furi-hal/furi-hal-rfid.c @@ -1,15 +1,15 @@ -#include -#include -#include +#include +#include +#include #define LFRFID_READ_TIM htim1 #define LFRFID_READ_CHANNEL TIM_CHANNEL_1 #define LFRFID_EMULATE_TIM htim2 #define LFRFID_EMULATE_CHANNEL TIM_CHANNEL_3 -void api_hal_rfid_pins_reset() { +void furi_hal_rfid_pins_reset() { // ibutton bus disable - api_hal_ibutton_stop(); + furi_hal_ibutton_stop(); // pulldown rfid antenna hal_gpio_init(&gpio_rfid_carrier_out, GpioModeOutputPushPull, GpioSpeedLow, GpioPullNo); @@ -20,10 +20,10 @@ void api_hal_rfid_pins_reset() { hal_gpio_write(&gpio_rfid_pull, true); } -void api_hal_rfid_pins_emulate() { +void furi_hal_rfid_pins_emulate() { // ibutton low - api_hal_ibutton_start(); - api_hal_ibutton_pin_low(); + furi_hal_ibutton_start(); + furi_hal_ibutton_pin_low(); // pull pin to timer out hal_gpio_init_ex( @@ -34,10 +34,10 @@ void api_hal_rfid_pins_emulate() { hal_gpio_write(&gpio_rfid_carrier_out, false); } -void api_hal_rfid_pins_read() { +void furi_hal_rfid_pins_read() { // ibutton low - api_hal_ibutton_start(); - api_hal_ibutton_pin_low(); + furi_hal_ibutton_start(); + furi_hal_ibutton_pin_low(); // dont pull rfid antenna hal_gpio_init(&gpio_rfid_pull, GpioModeOutputPushPull, GpioSpeedLow, GpioPullNo); @@ -55,7 +55,7 @@ void api_hal_rfid_pins_read() { hal_gpio_init(&gpio_rfid_data_in, GpioModeAnalog, GpioSpeedLow, GpioPullNo); } -void api_hal_rfid_tim_read(float freq, float duty_cycle) { +void furi_hal_rfid_tim_read(float freq, float duty_cycle) { // TODO LL init uint32_t period = (uint32_t)((SystemCoreClock) / freq) - 1; @@ -121,15 +121,15 @@ void api_hal_rfid_tim_read(float freq, float duty_cycle) { } } -void api_hal_rfid_tim_read_start() { +void furi_hal_rfid_tim_read_start() { HAL_TIMEx_PWMN_Start(&LFRFID_READ_TIM, LFRFID_READ_CHANNEL); } -void api_hal_rfid_tim_read_stop() { +void furi_hal_rfid_tim_read_stop() { HAL_TIMEx_PWMN_Stop(&LFRFID_READ_TIM, LFRFID_READ_CHANNEL); } -void api_hal_rfid_tim_emulate(float freq) { +void furi_hal_rfid_tim_emulate(float freq) { // TODO LL init uint32_t prescaler = (uint32_t)((SystemCoreClock) / freq) - 1; @@ -196,7 +196,7 @@ void api_hal_rfid_tim_emulate(float freq) { } } -void api_hal_rfid_tim_emulate_start() { +void furi_hal_rfid_tim_emulate_start() { // TODO make api for interrupts priority for(size_t i = WWDG_IRQn; i <= DMAMUX1_OVR_IRQn; i++) { HAL_NVIC_SetPriority(i, 15, 0); @@ -209,25 +209,25 @@ void api_hal_rfid_tim_emulate_start() { HAL_TIM_Base_Start_IT(&LFRFID_EMULATE_TIM); } -void api_hal_rfid_tim_emulate_stop() { +void furi_hal_rfid_tim_emulate_stop() { HAL_TIM_Base_Stop(&LFRFID_EMULATE_TIM); HAL_TIM_PWM_Stop(&LFRFID_EMULATE_TIM, LFRFID_EMULATE_CHANNEL); } -void api_hal_rfid_tim_reset() { +void furi_hal_rfid_tim_reset() { HAL_TIM_Base_DeInit(&LFRFID_READ_TIM); HAL_TIM_Base_DeInit(&LFRFID_EMULATE_TIM); } -bool api_hal_rfid_is_tim_emulate(TIM_HandleTypeDef* hw) { +bool furi_hal_rfid_is_tim_emulate(TIM_HandleTypeDef* hw) { return (hw == &LFRFID_EMULATE_TIM); } -void api_hal_rfid_set_emulate_period(uint32_t period) { +void furi_hal_rfid_set_emulate_period(uint32_t period) { LFRFID_EMULATE_TIM.Instance->ARR = period; } -void api_hal_rfid_set_emulate_pulse(uint32_t pulse) { +void furi_hal_rfid_set_emulate_pulse(uint32_t pulse) { switch(LFRFID_EMULATE_CHANNEL) { case TIM_CHANNEL_1: LFRFID_EMULATE_TIM.Instance->CCR1 = pulse; @@ -247,11 +247,11 @@ void api_hal_rfid_set_emulate_pulse(uint32_t pulse) { } } -void api_hal_rfid_set_read_period(uint32_t period) { +void furi_hal_rfid_set_read_period(uint32_t period) { LFRFID_TIM.Instance->ARR = period; } -void api_hal_rfid_set_read_pulse(uint32_t pulse) { +void furi_hal_rfid_set_read_pulse(uint32_t pulse) { switch(LFRFID_READ_CHANNEL) { case TIM_CHANNEL_1: LFRFID_TIM.Instance->CCR1 = pulse; @@ -271,8 +271,8 @@ void api_hal_rfid_set_read_pulse(uint32_t pulse) { } } -void api_hal_rfid_change_read_config(float freq, float duty_cycle) { +void furi_hal_rfid_change_read_config(float freq, float duty_cycle) { uint32_t period = (uint32_t)((SystemCoreClock) / freq) - 1; - api_hal_rfid_set_read_period(period); - api_hal_rfid_set_read_pulse(period * duty_cycle); + furi_hal_rfid_set_read_period(period); + furi_hal_rfid_set_read_pulse(period * duty_cycle); } \ No newline at end of file diff --git a/firmware/targets/f6/api-hal/api-hal-sd.c b/firmware/targets/f6/furi-hal/furi-hal-sd.c similarity index 96% rename from firmware/targets/f6/api-hal/api-hal-sd.c rename to firmware/targets/f6/furi-hal/furi-hal-sd.c index 14aafd4b..01cf9339 100644 --- a/firmware/targets/f6/api-hal/api-hal-sd.c +++ b/firmware/targets/f6/furi-hal/furi-hal-sd.c @@ -1,4 +1,4 @@ -#include "api-hal-sd.h" +#include "furi-hal-sd.h" #include #include diff --git a/firmware/targets/f6/api-hal/api-hal-spi-config.c b/firmware/targets/f6/furi-hal/furi-hal-spi-config.c similarity index 75% rename from firmware/targets/f6/api-hal/api-hal-spi-config.c rename to firmware/targets/f6/furi-hal/furi-hal-spi-config.c index 51a1729e..2212076a 100644 --- a/firmware/targets/f6/api-hal/api-hal-spi-config.c +++ b/firmware/targets/f6/furi-hal/furi-hal-spi-config.c @@ -1,10 +1,10 @@ -#include -#include +#include +#include extern SPI_HandleTypeDef SPI_R; extern SPI_HandleTypeDef SPI_D; -const SPI_InitTypeDef api_hal_spi_config_nfc = { +const SPI_InitTypeDef furi_hal_spi_config_nfc = { .Mode = SPI_MODE_MASTER, .Direction = SPI_DIRECTION_2LINES, .DataSize = SPI_DATASIZE_8BIT, @@ -20,7 +20,7 @@ const SPI_InitTypeDef api_hal_spi_config_nfc = { .NSSPMode = SPI_NSS_PULSE_DISABLE, }; -const SPI_InitTypeDef api_hal_spi_config_subghz = { +const SPI_InitTypeDef furi_hal_spi_config_subghz = { .Mode = SPI_MODE_MASTER, .Direction = SPI_DIRECTION_2LINES, .DataSize = SPI_DATASIZE_8BIT, @@ -36,7 +36,7 @@ const SPI_InitTypeDef api_hal_spi_config_subghz = { .NSSPMode = SPI_NSS_PULSE_DISABLE, }; -const SPI_InitTypeDef api_hal_spi_config_display = { +const SPI_InitTypeDef furi_hal_spi_config_display = { .Mode = SPI_MODE_MASTER, .Direction = SPI_DIRECTION_2LINES, .DataSize = SPI_DATASIZE_8BIT, @@ -55,7 +55,7 @@ const SPI_InitTypeDef api_hal_spi_config_display = { /** * SD Card in fast mode (after init) */ -const SPI_InitTypeDef api_hal_spi_config_sd_fast = { +const SPI_InitTypeDef furi_hal_spi_config_sd_fast = { .Mode = SPI_MODE_MASTER, .Direction = SPI_DIRECTION_2LINES, .DataSize = SPI_DATASIZE_8BIT, @@ -74,7 +74,7 @@ const SPI_InitTypeDef api_hal_spi_config_sd_fast = { /** * SD Card in slow mode (before init) */ -const SPI_InitTypeDef api_hal_spi_config_sd_slow = { +const SPI_InitTypeDef furi_hal_spi_config_sd_slow = { .Mode = SPI_MODE_MASTER, .Direction = SPI_DIRECTION_2LINES, .DataSize = SPI_DATASIZE_8BIT, @@ -93,7 +93,7 @@ const SPI_InitTypeDef api_hal_spi_config_sd_slow = { osMutexId_t spi_mutex_d = NULL; osMutexId_t spi_mutex_r = NULL; -const ApiHalSpiBus spi_r = { +const FuriHalSpiBus spi_r = { .spi=&SPI_R, .mutex=&spi_mutex_r, .miso=&gpio_spi_r_miso, @@ -101,7 +101,7 @@ const ApiHalSpiBus spi_r = { .clk=&gpio_spi_r_sck, }; -const ApiHalSpiBus spi_d = { +const FuriHalSpiBus spi_d = { .spi=&SPI_D, .mutex=&spi_mutex_d, .miso=&gpio_spi_d_miso, @@ -109,10 +109,10 @@ const ApiHalSpiBus spi_d = { .clk=&gpio_spi_d_sck, }; -const ApiHalSpiDevice api_hal_spi_devices[ApiHalSpiDeviceIdMax] = { - { .bus=&spi_r, .config=&api_hal_spi_config_subghz, .chip_select=&gpio_subghz_cs, }, - { .bus=&spi_d, .config=&api_hal_spi_config_display, .chip_select=&gpio_display_cs, }, - { .bus=&spi_d, .config=&api_hal_spi_config_sd_fast, .chip_select=&gpio_sdcard_cs, }, - { .bus=&spi_d, .config=&api_hal_spi_config_sd_slow, .chip_select=&gpio_sdcard_cs, }, - { .bus=&spi_r, .config=&api_hal_spi_config_nfc, .chip_select=&gpio_nfc_cs }, +const FuriHalSpiDevice furi_hal_spi_devices[FuriHalSpiDeviceIdMax] = { + { .bus=&spi_r, .config=&furi_hal_spi_config_subghz, .chip_select=&gpio_subghz_cs, }, + { .bus=&spi_d, .config=&furi_hal_spi_config_display, .chip_select=&gpio_display_cs, }, + { .bus=&spi_d, .config=&furi_hal_spi_config_sd_fast, .chip_select=&gpio_sdcard_cs, }, + { .bus=&spi_d, .config=&furi_hal_spi_config_sd_slow, .chip_select=&gpio_sdcard_cs, }, + { .bus=&spi_r, .config=&furi_hal_spi_config_nfc, .chip_select=&gpio_nfc_cs }, }; diff --git a/firmware/targets/f6/furi-hal/furi-hal-spi-config.h b/firmware/targets/f6/furi-hal/furi-hal-spi-config.h new file mode 100644 index 00000000..1ea641f1 --- /dev/null +++ b/firmware/targets/f6/furi-hal/furi-hal-spi-config.h @@ -0,0 +1,67 @@ +#pragma once + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern const SPI_InitTypeDef furi_hal_spi_config_nfc; +extern const SPI_InitTypeDef furi_hal_spi_config_subghz; +extern const SPI_InitTypeDef furi_hal_spi_config_display; +extern const SPI_InitTypeDef furi_hal_spi_config_sd_fast; +extern const SPI_InitTypeDef furi_hal_spi_config_sd_slow; + +/** FURI HAL SPI BUS handler + * Structure content may change at some point + */ +typedef struct { + const SPI_HandleTypeDef* spi; + const osMutexId_t* mutex; + const GpioPin* miso; + const GpioPin* mosi; + const GpioPin* clk; +} FuriHalSpiBus; + +/** FURI HAL SPI Device handler + * Structure content may change at some point + */ +typedef struct { + const FuriHalSpiBus* bus; + const SPI_InitTypeDef* config; + const GpioPin* chip_select; +} FuriHalSpiDevice; + +/** FURI HAL SPI Standard Device IDs */ +typedef enum { + FuriHalSpiDeviceIdSubGhz, /** SubGhz: CC1101, non-standard SPI usage */ + FuriHalSpiDeviceIdDisplay, /** Display: ERC12864, only have MOSI */ + FuriHalSpiDeviceIdSdCardFast, /** SDCARD: fast mode, after initialization */ + FuriHalSpiDeviceIdSdCardSlow, /** SDCARD: slow mode, before initialization */ + FuriHalSpiDeviceIdNfc, /** NFC: ST25R3916, pretty standard, but RFAL makes it complex */ + + FuriHalSpiDeviceIdMax, /** Service Value, do not use */ +} FuriHalSpiDeviceId; + +/** Furi Hal Spi Bus R + * CC1101, Nfc + */ +extern const FuriHalSpiBus spi_r; + +/** Furi Hal Spi Bus D + * Display, SdCard + */ +extern const FuriHalSpiBus spi_d; + +/** Furi Hal Spi devices */ +extern const FuriHalSpiDevice furi_hal_spi_devices[FuriHalSpiDeviceIdMax]; + +typedef struct { + const FuriHalSpiBus* bus; + const SPI_InitTypeDef config; +} SPIDevice; + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/firmware/targets/f6/api-hal/api-hal-spi.c b/firmware/targets/f6/furi-hal/furi-hal-spi.c similarity index 64% rename from firmware/targets/f6/api-hal/api-hal-spi.c rename to firmware/targets/f6/furi-hal/furi-hal-spi.c index cffdc591..824200f8 100644 --- a/firmware/targets/f6/api-hal/api-hal-spi.c +++ b/firmware/targets/f6/furi-hal/furi-hal-spi.c @@ -1,5 +1,5 @@ -#include "api-hal-spi.h" -#include +#include "furi-hal-spi.h" +#include #include #include #include @@ -8,15 +8,15 @@ extern void Enable_SPI(SPI_HandleTypeDef* spi); -void api_hal_spi_init() { +void furi_hal_spi_init() { // Spi structure is const, but mutex is not // Need some hell-ish casting to make it work *(osMutexId_t*)spi_r.mutex = osMutexNew(NULL); *(osMutexId_t*)spi_d.mutex = osMutexNew(NULL); // - for (size_t i=0; imutex) { osMutexAcquire(*bus->mutex, osWaitForever); } } -void api_hal_spi_bus_unlock(const ApiHalSpiBus* bus) { +void furi_hal_spi_bus_unlock(const FuriHalSpiBus* bus) { furi_assert(bus); if (bus->mutex) { osMutexRelease(*bus->mutex); } } -void api_hal_spi_bus_configure(const ApiHalSpiBus* bus, const SPI_InitTypeDef* config) { +void furi_hal_spi_bus_configure(const FuriHalSpiBus* bus, const SPI_InitTypeDef* config) { furi_assert(bus); if(memcmp(&bus->spi->Init, config, sizeof(SPI_InitTypeDef))) { @@ -51,7 +51,7 @@ void api_hal_spi_bus_configure(const ApiHalSpiBus* bus, const SPI_InitTypeDef* c } } -void api_hal_spi_bus_reset(const ApiHalSpiBus* bus) { +void furi_hal_spi_bus_reset(const FuriHalSpiBus* bus) { furi_assert(bus); HAL_SPI_DeInit((SPI_HandleTypeDef*)bus->spi); @@ -59,7 +59,7 @@ void api_hal_spi_bus_reset(const ApiHalSpiBus* bus) { Enable_SPI((SPI_HandleTypeDef*)bus->spi); } -bool api_hal_spi_bus_rx(const ApiHalSpiBus* bus, uint8_t* buffer, size_t size, uint32_t timeout) { +bool furi_hal_spi_bus_rx(const FuriHalSpiBus* bus, uint8_t* buffer, size_t size, uint32_t timeout) { furi_assert(bus); furi_assert(buffer); furi_assert(size > 0); @@ -69,7 +69,7 @@ bool api_hal_spi_bus_rx(const ApiHalSpiBus* bus, uint8_t* buffer, size_t size, u return ret == HAL_OK; } -bool api_hal_spi_bus_tx(const ApiHalSpiBus* bus, uint8_t* buffer, size_t size, uint32_t timeout) { +bool furi_hal_spi_bus_tx(const FuriHalSpiBus* bus, uint8_t* buffer, size_t size, uint32_t timeout) { furi_assert(bus); furi_assert(buffer); furi_assert(size > 0); @@ -79,7 +79,7 @@ bool api_hal_spi_bus_tx(const ApiHalSpiBus* bus, uint8_t* buffer, size_t size, u return ret == HAL_OK; } -bool api_hal_spi_bus_trx(const ApiHalSpiBus* bus, uint8_t* tx_buffer, uint8_t* rx_buffer, size_t size, uint32_t timeout) { +bool furi_hal_spi_bus_trx(const FuriHalSpiBus* bus, uint8_t* tx_buffer, uint8_t* rx_buffer, size_t size, uint32_t timeout) { furi_assert(bus); furi_assert(tx_buffer); furi_assert(rx_buffer); @@ -90,12 +90,12 @@ bool api_hal_spi_bus_trx(const ApiHalSpiBus* bus, uint8_t* tx_buffer, uint8_t* r return ret == HAL_OK; } -const ApiHalSpiDevice* api_hal_spi_device_get(ApiHalSpiDeviceId device_id) { - furi_assert(device_id < ApiHalSpiDeviceIdMax); +const FuriHalSpiDevice* furi_hal_spi_device_get(FuriHalSpiDeviceId device_id) { + furi_assert(device_id < FuriHalSpiDeviceIdMax); - const ApiHalSpiDevice* device = &api_hal_spi_devices[device_id]; + const FuriHalSpiDevice* device = &furi_hal_spi_devices[device_id]; assert(device); - api_hal_spi_bus_lock(device->bus); + furi_hal_spi_bus_lock(device->bus); if (device->config) { memcpy((SPI_InitTypeDef*)&device->bus->spi->Init, device->config, sizeof(SPI_InitTypeDef)); @@ -108,11 +108,11 @@ const ApiHalSpiDevice* api_hal_spi_device_get(ApiHalSpiDeviceId device_id) { return device; } -void api_hal_spi_device_return(const ApiHalSpiDevice* device) { - api_hal_spi_bus_unlock(device->bus); +void furi_hal_spi_device_return(const FuriHalSpiDevice* device) { + furi_hal_spi_bus_unlock(device->bus); } -bool api_hal_spi_device_rx(const ApiHalSpiDevice* device, uint8_t* buffer, size_t size, uint32_t timeout) { +bool furi_hal_spi_device_rx(const FuriHalSpiDevice* device, uint8_t* buffer, size_t size, uint32_t timeout) { furi_assert(device); furi_assert(buffer); furi_assert(size > 0); @@ -121,7 +121,7 @@ bool api_hal_spi_device_rx(const ApiHalSpiDevice* device, uint8_t* buffer, size_ hal_gpio_write(device->chip_select, false); } - bool ret = api_hal_spi_bus_rx(device->bus, buffer, size, HAL_MAX_DELAY); + bool ret = furi_hal_spi_bus_rx(device->bus, buffer, size, HAL_MAX_DELAY); if (device->chip_select) { hal_gpio_write(device->chip_select, true); @@ -130,7 +130,7 @@ bool api_hal_spi_device_rx(const ApiHalSpiDevice* device, uint8_t* buffer, size_ return ret; } -bool api_hal_spi_device_tx(const ApiHalSpiDevice* device, uint8_t* buffer, size_t size, uint32_t timeout) { +bool furi_hal_spi_device_tx(const FuriHalSpiDevice* device, uint8_t* buffer, size_t size, uint32_t timeout) { furi_assert(device); furi_assert(buffer); furi_assert(size > 0); @@ -139,7 +139,7 @@ bool api_hal_spi_device_tx(const ApiHalSpiDevice* device, uint8_t* buffer, size_ hal_gpio_write(device->chip_select, false); } - bool ret = api_hal_spi_bus_tx(device->bus, buffer, size, HAL_MAX_DELAY); + bool ret = furi_hal_spi_bus_tx(device->bus, buffer, size, HAL_MAX_DELAY); if (device->chip_select) { hal_gpio_write(device->chip_select, true); @@ -148,7 +148,7 @@ bool api_hal_spi_device_tx(const ApiHalSpiDevice* device, uint8_t* buffer, size_ return ret; } -bool api_hal_spi_device_trx(const ApiHalSpiDevice* device, uint8_t* tx_buffer, uint8_t* rx_buffer, size_t size, uint32_t timeout) { +bool furi_hal_spi_device_trx(const FuriHalSpiDevice* device, uint8_t* tx_buffer, uint8_t* rx_buffer, size_t size, uint32_t timeout) { furi_assert(device); furi_assert(tx_buffer); furi_assert(rx_buffer); @@ -158,7 +158,7 @@ bool api_hal_spi_device_trx(const ApiHalSpiDevice* device, uint8_t* tx_buffer, u hal_gpio_write(device->chip_select, false); } - bool ret = api_hal_spi_bus_trx(device->bus, tx_buffer, rx_buffer, size, HAL_MAX_DELAY); + bool ret = furi_hal_spi_bus_trx(device->bus, tx_buffer, rx_buffer, size, HAL_MAX_DELAY); if (device->chip_select) { hal_gpio_write(device->chip_select, true); diff --git a/firmware/targets/f6/api-hal/api-hal-spi.h b/firmware/targets/f6/furi-hal/furi-hal-spi.h similarity index 60% rename from firmware/targets/f6/api-hal/api-hal-spi.h rename to firmware/targets/f6/furi-hal/furi-hal-spi.h index 849bcf5a..4447614b 100644 --- a/firmware/targets/f6/api-hal/api-hal-spi.h +++ b/firmware/targets/f6/furi-hal/furi-hal-spi.h @@ -1,7 +1,7 @@ #pragma once #include "main.h" -#include "api-hal-spi-config.h" -#include +#include "furi-hal-spi-config.h" +#include #include #ifdef __cplusplus @@ -11,32 +11,32 @@ extern "C" { /** * Init SPI API */ -void api_hal_spi_init(); +void furi_hal_spi_init(); /* Bus Level API */ /** Lock SPI bus * Takes bus mutex, if used */ -void api_hal_spi_bus_lock(const ApiHalSpiBus* bus); +void furi_hal_spi_bus_lock(const FuriHalSpiBus* bus); /** Unlock SPI bus * Releases BUS mutex, if used */ -void api_hal_spi_bus_unlock(const ApiHalSpiBus* bus); +void furi_hal_spi_bus_unlock(const FuriHalSpiBus* bus); /** * Configure SPI bus * @param bus - spi bus handler * @param config - spi configuration structure */ -void api_hal_spi_bus_configure(const ApiHalSpiBus* bus, const SPI_InitTypeDef* config); +void furi_hal_spi_bus_configure(const FuriHalSpiBus* bus, const SPI_InitTypeDef* config); /** * Reset SPI bus * @param bus - spi bus handler */ -void api_hal_spi_bus_reset(const ApiHalSpiBus* bus); +void furi_hal_spi_bus_reset(const FuriHalSpiBus* bus); /** SPI Receive * @param bus - spi bus handler @@ -44,7 +44,7 @@ void api_hal_spi_bus_reset(const ApiHalSpiBus* bus); * @param size - transaction size * @param timeout - bus operation timeout in ms */ -bool api_hal_spi_bus_rx(const ApiHalSpiBus* bus, uint8_t* buffer, size_t size, uint32_t timeout); +bool furi_hal_spi_bus_rx(const FuriHalSpiBus* bus, uint8_t* buffer, size_t size, uint32_t timeout); /** SPI Transmit * @param bus - spi bus handler @@ -52,7 +52,7 @@ bool api_hal_spi_bus_rx(const ApiHalSpiBus* bus, uint8_t* buffer, size_t size, u * @param size - transaction size * @param timeout - bus operation timeout in ms */ -bool api_hal_spi_bus_tx(const ApiHalSpiBus* bus, uint8_t* buffer, size_t size, uint32_t timeout); +bool furi_hal_spi_bus_tx(const FuriHalSpiBus* bus, uint8_t* buffer, size_t size, uint32_t timeout); /** SPI Transmit and Receive * @param bus - spi bus handlere @@ -61,7 +61,7 @@ bool api_hal_spi_bus_tx(const ApiHalSpiBus* bus, uint8_t* buffer, size_t size, u * @param size - transaction size * @param timeout - bus operation timeout in ms */ -bool api_hal_spi_bus_trx(const ApiHalSpiBus* bus, uint8_t* tx_buffer, uint8_t* rx_buffer, size_t size, uint32_t timeout); +bool furi_hal_spi_bus_trx(const FuriHalSpiBus* bus, uint8_t* tx_buffer, uint8_t* rx_buffer, size_t size, uint32_t timeout); /* Device Level API */ @@ -70,13 +70,13 @@ bool api_hal_spi_bus_trx(const ApiHalSpiBus* bus, uint8_t* tx_buffer, uint8_t* r * @param device_id - device identifier * @return device handle */ -const ApiHalSpiDevice* api_hal_spi_device_get(ApiHalSpiDeviceId device_id); +const FuriHalSpiDevice* furi_hal_spi_device_get(FuriHalSpiDeviceId device_id); /** Return Device handle * And unlock access to the corresponding SPI BUS * @param device - device handle */ -void api_hal_spi_device_return(const ApiHalSpiDevice* device); +void furi_hal_spi_device_return(const FuriHalSpiDevice* device); /** SPI Recieve * @param device - device handle @@ -84,7 +84,7 @@ void api_hal_spi_device_return(const ApiHalSpiDevice* device); * @param size - transaction size * @param timeout - bus operation timeout in ms */ -bool api_hal_spi_device_rx(const ApiHalSpiDevice* device, uint8_t* buffer, size_t size, uint32_t timeout); +bool furi_hal_spi_device_rx(const FuriHalSpiDevice* device, uint8_t* buffer, size_t size, uint32_t timeout); /** SPI Transmit * @param device - device handle @@ -92,7 +92,7 @@ bool api_hal_spi_device_rx(const ApiHalSpiDevice* device, uint8_t* buffer, size_ * @param size - transaction size * @param timeout - bus operation timeout in ms */ -bool api_hal_spi_device_tx(const ApiHalSpiDevice* device, uint8_t* buffer, size_t size, uint32_t timeout); +bool furi_hal_spi_device_tx(const FuriHalSpiDevice* device, uint8_t* buffer, size_t size, uint32_t timeout); /** SPI Transmit and Receive * @param device - device handle @@ -101,18 +101,18 @@ bool api_hal_spi_device_tx(const ApiHalSpiDevice* device, uint8_t* buffer, size_ * @param size - transaction size * @param timeout - bus operation timeout in ms */ -bool api_hal_spi_device_trx(const ApiHalSpiDevice* device, uint8_t* tx_buffer, uint8_t* rx_buffer, size_t size, uint32_t timeout); +bool furi_hal_spi_device_trx(const FuriHalSpiDevice* device, uint8_t* tx_buffer, uint8_t* rx_buffer, size_t size, uint32_t timeout); /** * Lock SPI device bus and apply config if needed */ -void api_hal_spi_lock_device(const SPIDevice* device); +void furi_hal_spi_lock_device(const SPIDevice* device); /** * Unlock SPI device bus */ -void api_hal_spi_unlock_device(const SPIDevice* device); +void furi_hal_spi_unlock_device(const SPIDevice* device); #ifdef __cplusplus } diff --git a/firmware/targets/f6/api-hal/api-hal-subghz.c b/firmware/targets/f6/furi-hal/furi-hal-subghz.c similarity index 60% rename from firmware/targets/f6/api-hal/api-hal-subghz.c rename to firmware/targets/f6/furi-hal/furi-hal-subghz.c index d941a406..105b5801 100644 --- a/firmware/targets/f6/api-hal/api-hal-subghz.c +++ b/firmware/targets/f6/furi-hal/furi-hal-subghz.c @@ -1,17 +1,17 @@ -#include "api-hal-subghz.h" +#include "furi-hal-subghz.h" -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include -static volatile SubGhzState api_hal_subghz_state = SubGhzStateInit; +static volatile SubGhzState furi_hal_subghz_state = SubGhzStateInit; -static const uint8_t api_hal_subghz_preset_ook_async_regs[][2] = { +static const uint8_t furi_hal_subghz_preset_ook_async_regs[][2] = { // https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/382066/cc1101---don-t-know-the-correct-registers-configuration /* GPIO GD0 */ @@ -65,7 +65,7 @@ static const uint8_t api_hal_subghz_preset_ook_async_regs[][2] = { { 0, 0 }, }; -static const uint8_t api_hal_subghz_preset_ook_async_patable[8] = { +static const uint8_t furi_hal_subghz_preset_ook_async_patable[8] = { 0x00, 0xC0, // 10dBm 0xC0, 7dBm 0xC8, 5dBm 0x84, 0dBm 0x60, -10dBm 0x34, -15dBm 0x1D, -20dBm 0x0E, -30dBm 0x12 0x00, @@ -76,14 +76,14 @@ static const uint8_t api_hal_subghz_preset_ook_async_patable[8] = { 0x00 }; -void api_hal_subghz_init() { - furi_assert(api_hal_subghz_state == SubGhzStateInit); - api_hal_subghz_state = SubGhzStateIdle; +void furi_hal_subghz_init() { + furi_assert(furi_hal_subghz_state == SubGhzStateInit); + furi_hal_subghz_state = SubGhzStateIdle; - const ApiHalSpiDevice* device = api_hal_spi_device_get(ApiHalSpiDeviceIdSubGhz); + const FuriHalSpiDevice* device = furi_hal_spi_device_get(FuriHalSpiDeviceIdSubGhz); -#ifdef API_HAL_SUBGHZ_TX_GPIO - hal_gpio_init(&API_HAL_SUBGHZ_TX_GPIO, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); +#ifdef FURI_HAL_SUBGHZ_TX_GPIO + hal_gpio_init(&FURI_HAL_SUBGHZ_TX_GPIO, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); #endif // Reset @@ -113,13 +113,13 @@ void api_hal_subghz_init() { // Go to sleep cc1101_shutdown(device); - api_hal_spi_device_return(device); + furi_hal_spi_device_return(device); FURI_LOG_I("FuriHalSubGhz", "Init OK"); } -void api_hal_subghz_sleep() { - furi_assert(api_hal_subghz_state == SubGhzStateIdle); - const ApiHalSpiDevice* device = api_hal_spi_device_get(ApiHalSpiDeviceIdSubGhz); +void furi_hal_subghz_sleep() { + furi_assert(furi_hal_subghz_state == SubGhzStateIdle); + const FuriHalSpiDevice* device = furi_hal_spi_device_get(FuriHalSpiDeviceIdSubGhz); cc1101_switch_to_idle(device); @@ -128,110 +128,110 @@ void api_hal_subghz_sleep() { cc1101_shutdown(device); - api_hal_spi_device_return(device); + furi_hal_spi_device_return(device); } -void api_hal_subghz_dump_state() { - const ApiHalSpiDevice* device = api_hal_spi_device_get(ApiHalSpiDeviceIdSubGhz); +void furi_hal_subghz_dump_state() { + const FuriHalSpiDevice* device = furi_hal_spi_device_get(FuriHalSpiDeviceIdSubGhz); printf( - "[api_hal_subghz] cc1101 chip %d, version %d\r\n", + "[furi_hal_subghz] cc1101 chip %d, version %d\r\n", cc1101_get_partnumber(device), cc1101_get_version(device) ); - api_hal_spi_device_return(device); + furi_hal_spi_device_return(device); } -void api_hal_subghz_load_preset(ApiHalSubGhzPreset preset) { - if(preset == ApiHalSubGhzPresetOokAsync) { - api_hal_subghz_load_registers(api_hal_subghz_preset_ook_async_regs); - api_hal_subghz_load_patable(api_hal_subghz_preset_ook_async_patable); +void furi_hal_subghz_load_preset(FuriHalSubGhzPreset preset) { + if(preset == FuriHalSubGhzPresetOokAsync) { + furi_hal_subghz_load_registers(furi_hal_subghz_preset_ook_async_regs); + furi_hal_subghz_load_patable(furi_hal_subghz_preset_ook_async_patable); } else { furi_check(0); } } -uint8_t api_hal_subghz_get_status() { - const ApiHalSpiDevice* device = api_hal_spi_device_get(ApiHalSpiDeviceIdSubGhz); +uint8_t furi_hal_subghz_get_status() { + const FuriHalSpiDevice* device = furi_hal_spi_device_get(FuriHalSpiDeviceIdSubGhz); CC1101StatusRaw st; st.status = cc1101_get_status(device); - api_hal_spi_device_return(device); + furi_hal_spi_device_return(device); return st.status_raw; } -void api_hal_subghz_load_registers(const uint8_t data[][2]) { - const ApiHalSpiDevice* device = api_hal_spi_device_get(ApiHalSpiDeviceIdSubGhz); +void furi_hal_subghz_load_registers(const uint8_t data[][2]) { + const FuriHalSpiDevice* device = furi_hal_spi_device_get(FuriHalSpiDeviceIdSubGhz); cc1101_reset(device); uint32_t i = 0; while (data[i][0]) { cc1101_write_reg(device, data[i][0], data[i][1]); i++; } - api_hal_spi_device_return(device); + furi_hal_spi_device_return(device); } -void api_hal_subghz_load_patable(const uint8_t data[8]) { - const ApiHalSpiDevice* device = api_hal_spi_device_get(ApiHalSpiDeviceIdSubGhz); +void furi_hal_subghz_load_patable(const uint8_t data[8]) { + const FuriHalSpiDevice* device = furi_hal_spi_device_get(FuriHalSpiDeviceIdSubGhz); cc1101_set_pa_table(device, data); - api_hal_spi_device_return(device); + furi_hal_spi_device_return(device); } -void api_hal_subghz_write_packet(const uint8_t* data, uint8_t size) { - const ApiHalSpiDevice* device = api_hal_spi_device_get(ApiHalSpiDeviceIdSubGhz); +void furi_hal_subghz_write_packet(const uint8_t* data, uint8_t size) { + const FuriHalSpiDevice* device = furi_hal_spi_device_get(FuriHalSpiDeviceIdSubGhz); cc1101_flush_tx(device); cc1101_write_fifo(device, data, size); - api_hal_spi_device_return(device); + furi_hal_spi_device_return(device); } -void api_hal_subghz_flush_rx() { - const ApiHalSpiDevice* device = api_hal_spi_device_get(ApiHalSpiDeviceIdSubGhz); +void furi_hal_subghz_flush_rx() { + const FuriHalSpiDevice* device = furi_hal_spi_device_get(FuriHalSpiDeviceIdSubGhz); cc1101_flush_rx(device); - api_hal_spi_device_return(device); + furi_hal_spi_device_return(device); } -void api_hal_subghz_read_packet(uint8_t* data, uint8_t* size) { - const ApiHalSpiDevice* device = api_hal_spi_device_get(ApiHalSpiDeviceIdSubGhz); +void furi_hal_subghz_read_packet(uint8_t* data, uint8_t* size) { + const FuriHalSpiDevice* device = furi_hal_spi_device_get(FuriHalSpiDeviceIdSubGhz); cc1101_read_fifo(device, data, size); - api_hal_spi_device_return(device); + furi_hal_spi_device_return(device); } -void api_hal_subghz_shutdown() { - const ApiHalSpiDevice* device = api_hal_spi_device_get(ApiHalSpiDeviceIdSubGhz); +void furi_hal_subghz_shutdown() { + const FuriHalSpiDevice* device = furi_hal_spi_device_get(FuriHalSpiDeviceIdSubGhz); // Reset and shutdown cc1101_shutdown(device); - api_hal_spi_device_return(device); + furi_hal_spi_device_return(device); } -void api_hal_subghz_reset() { - const ApiHalSpiDevice* device = api_hal_spi_device_get(ApiHalSpiDeviceIdSubGhz); +void furi_hal_subghz_reset() { + const FuriHalSpiDevice* device = furi_hal_spi_device_get(FuriHalSpiDeviceIdSubGhz); hal_gpio_init(&gpio_cc1101_g0, GpioModeAnalog, GpioPullNo, GpioSpeedLow); cc1101_switch_to_idle(device); cc1101_reset(device); cc1101_write_reg(device, CC1101_IOCFG0, CC1101IocfgHighImpedance); - api_hal_spi_device_return(device); + furi_hal_spi_device_return(device); } -void api_hal_subghz_idle() { - const ApiHalSpiDevice* device = api_hal_spi_device_get(ApiHalSpiDeviceIdSubGhz); +void furi_hal_subghz_idle() { + const FuriHalSpiDevice* device = furi_hal_spi_device_get(FuriHalSpiDeviceIdSubGhz); cc1101_switch_to_idle(device); - api_hal_spi_device_return(device); + furi_hal_spi_device_return(device); } -void api_hal_subghz_rx() { - const ApiHalSpiDevice* device = api_hal_spi_device_get(ApiHalSpiDeviceIdSubGhz); +void furi_hal_subghz_rx() { + const FuriHalSpiDevice* device = furi_hal_spi_device_get(FuriHalSpiDeviceIdSubGhz); cc1101_switch_to_rx(device); - api_hal_spi_device_return(device); + furi_hal_spi_device_return(device); } -void api_hal_subghz_tx() { - const ApiHalSpiDevice* device = api_hal_spi_device_get(ApiHalSpiDeviceIdSubGhz); +void furi_hal_subghz_tx() { + const FuriHalSpiDevice* device = furi_hal_spi_device_get(FuriHalSpiDeviceIdSubGhz); cc1101_switch_to_tx(device); - api_hal_spi_device_return(device); + furi_hal_spi_device_return(device); } -float api_hal_subghz_get_rssi() { - const ApiHalSpiDevice* device = api_hal_spi_device_get(ApiHalSpiDeviceIdSubGhz); +float furi_hal_subghz_get_rssi() { + const FuriHalSpiDevice* device = furi_hal_spi_device_get(FuriHalSpiDeviceIdSubGhz); int32_t rssi_dec = cc1101_get_rssi(device); - api_hal_spi_device_return(device); + furi_hal_spi_device_return(device); float rssi = rssi_dec; if(rssi_dec >= 128) { @@ -243,7 +243,7 @@ float api_hal_subghz_get_rssi() { return rssi; } -bool api_hal_subghz_is_frequency_valid(uint32_t value) { +bool furi_hal_subghz_is_frequency_valid(uint32_t value) { if(!(value >= 299999755 && value <= 348000335) && !(value >= 386999938 && value <= 464000000) && !(value >= 778999847 && value <= 928000000)) { @@ -252,85 +252,85 @@ bool api_hal_subghz_is_frequency_valid(uint32_t value) { return true; } -uint32_t api_hal_subghz_set_frequency_and_path(uint32_t value) { - value = api_hal_subghz_set_frequency(value); +uint32_t furi_hal_subghz_set_frequency_and_path(uint32_t value) { + value = furi_hal_subghz_set_frequency(value); if(value >= 299999755 && value <= 348000335) { - api_hal_subghz_set_path(ApiHalSubGhzPath315); + furi_hal_subghz_set_path(FuriHalSubGhzPath315); } else if(value >= 386999938 && value <= 464000000) { - api_hal_subghz_set_path(ApiHalSubGhzPath433); + furi_hal_subghz_set_path(FuriHalSubGhzPath433); } else if(value >= 778999847 && value <= 928000000) { - api_hal_subghz_set_path(ApiHalSubGhzPath868); + furi_hal_subghz_set_path(FuriHalSubGhzPath868); } else { furi_check(0); } return value; } -uint32_t api_hal_subghz_set_frequency(uint32_t value) { - const ApiHalSpiDevice* device = api_hal_spi_device_get(ApiHalSpiDeviceIdSubGhz); +uint32_t furi_hal_subghz_set_frequency(uint32_t value) { + const FuriHalSpiDevice* device = furi_hal_spi_device_get(FuriHalSpiDeviceIdSubGhz); uint32_t real_frequency = cc1101_set_frequency(device, value); cc1101_calibrate(device); - api_hal_spi_device_return(device); + furi_hal_spi_device_return(device); return real_frequency; } -void api_hal_subghz_set_path(ApiHalSubGhzPath path) { - const ApiHalSpiDevice* device = api_hal_spi_device_get(ApiHalSpiDeviceIdSubGhz); - if (path == ApiHalSubGhzPath433) { +void furi_hal_subghz_set_path(FuriHalSubGhzPath path) { + const FuriHalSpiDevice* device = furi_hal_spi_device_get(FuriHalSpiDeviceIdSubGhz); + if (path == FuriHalSubGhzPath433) { hal_gpio_write(&gpio_rf_sw_0, 0); cc1101_write_reg(device, CC1101_IOCFG2, CC1101IocfgHW | CC1101_IOCFG_INV); - } else if (path == ApiHalSubGhzPath315) { + } else if (path == FuriHalSubGhzPath315) { hal_gpio_write(&gpio_rf_sw_0, 1); cc1101_write_reg(device, CC1101_IOCFG2, CC1101IocfgHW); - } else if (path == ApiHalSubGhzPath868) { + } else if (path == FuriHalSubGhzPath868) { hal_gpio_write(&gpio_rf_sw_0, 1); cc1101_write_reg(device, CC1101_IOCFG2, CC1101IocfgHW | CC1101_IOCFG_INV); - } else if (path == ApiHalSubGhzPathIsolate) { + } else if (path == FuriHalSubGhzPathIsolate) { hal_gpio_write(&gpio_rf_sw_0, 0); cc1101_write_reg(device, CC1101_IOCFG2, CC1101IocfgHW); } else { furi_check(0); } - api_hal_spi_device_return(device); + furi_hal_spi_device_return(device); } -volatile uint32_t api_hal_subghz_capture_delta_duration = 0; -volatile ApiHalSubGhzCaptureCallback api_hal_subghz_capture_callback = NULL; -volatile void* api_hal_subghz_capture_callback_context = NULL; +volatile uint32_t furi_hal_subghz_capture_delta_duration = 0; +volatile FuriHalSubGhzCaptureCallback furi_hal_subghz_capture_callback = NULL; +volatile void* furi_hal_subghz_capture_callback_context = NULL; -static void api_hal_subghz_capture_ISR() { +static void furi_hal_subghz_capture_ISR() { // Channel 1 if(LL_TIM_IsActiveFlag_CC1(TIM2)) { LL_TIM_ClearFlag_CC1(TIM2); - api_hal_subghz_capture_delta_duration = LL_TIM_IC_GetCaptureCH1(TIM2); - if (api_hal_subghz_capture_callback) { - api_hal_subghz_capture_callback(true, api_hal_subghz_capture_delta_duration, - (void*)api_hal_subghz_capture_callback_context + furi_hal_subghz_capture_delta_duration = LL_TIM_IC_GetCaptureCH1(TIM2); + if (furi_hal_subghz_capture_callback) { + furi_hal_subghz_capture_callback(true, furi_hal_subghz_capture_delta_duration, + (void*)furi_hal_subghz_capture_callback_context ); } } // Channel 2 if(LL_TIM_IsActiveFlag_CC2(TIM2)) { LL_TIM_ClearFlag_CC2(TIM2); - if (api_hal_subghz_capture_callback) { - api_hal_subghz_capture_callback(false, LL_TIM_IC_GetCaptureCH2(TIM2) - api_hal_subghz_capture_delta_duration, - (void*)api_hal_subghz_capture_callback_context + if (furi_hal_subghz_capture_callback) { + furi_hal_subghz_capture_callback(false, LL_TIM_IC_GetCaptureCH2(TIM2) - furi_hal_subghz_capture_delta_duration, + (void*)furi_hal_subghz_capture_callback_context ); } } } -void api_hal_subghz_set_async_rx_callback(ApiHalSubGhzCaptureCallback callback, void* context) { - api_hal_subghz_capture_callback = callback; - api_hal_subghz_capture_callback_context = context; +void furi_hal_subghz_set_async_rx_callback(FuriHalSubGhzCaptureCallback callback, void* context) { + furi_hal_subghz_capture_callback = callback; + furi_hal_subghz_capture_callback_context = context; } -void api_hal_subghz_start_async_rx() { - furi_assert(api_hal_subghz_state == SubGhzStateIdle); - api_hal_subghz_state = SubGhzStateAsyncRx; +void furi_hal_subghz_start_async_rx() { + furi_assert(furi_hal_subghz_state == SubGhzStateIdle); + furi_hal_subghz_state = SubGhzStateAsyncRx; hal_gpio_init_ex(&gpio_cc1101_g0, GpioModeAltFunctionPushPull, GpioPullNo, GpioSpeedLow, GpioAltFn1TIM2); @@ -366,7 +366,7 @@ void api_hal_subghz_start_async_rx() { LL_TIM_IC_SetFilter(TIM2, LL_TIM_CHANNEL_CH2, LL_TIM_IC_FILTER_FDIV1); // ISR setup - api_hal_interrupt_set_timer_isr(TIM2, api_hal_subghz_capture_ISR); + furi_hal_interrupt_set_timer_isr(TIM2, furi_hal_subghz_capture_ISR); NVIC_SetPriority(TIM2_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),5, 0)); NVIC_EnableIRQ(TIM2_IRQn); @@ -385,50 +385,50 @@ void api_hal_subghz_start_async_rx() { LL_TIM_EnableCounter(TIM2); // Switch to RX - api_hal_subghz_rx(); + furi_hal_subghz_rx(); } -void api_hal_subghz_stop_async_rx() { - furi_assert(api_hal_subghz_state == SubGhzStateAsyncRx); - api_hal_subghz_state = SubGhzStateIdle; +void furi_hal_subghz_stop_async_rx() { + furi_assert(furi_hal_subghz_state == SubGhzStateAsyncRx); + furi_hal_subghz_state = SubGhzStateIdle; // Shutdown radio - api_hal_subghz_idle(); + furi_hal_subghz_idle(); LL_TIM_DeInit(TIM2); LL_APB1_GRP1_DisableClock(LL_APB1_GRP1_PERIPH_TIM2); - api_hal_interrupt_set_timer_isr(TIM2, NULL); + furi_hal_interrupt_set_timer_isr(TIM2, NULL); hal_gpio_init(&gpio_cc1101_g0, GpioModeAnalog, GpioPullNo, GpioSpeedLow); } -volatile size_t api_hal_subghz_tx_repeat = 0; +volatile size_t furi_hal_subghz_tx_repeat = 0; -static void api_hal_subghz_tx_dma_isr() { +static void furi_hal_subghz_tx_dma_isr() { if (LL_DMA_IsActiveFlag_TC1(DMA1)) { LL_DMA_ClearFlag_TC1(DMA1); - furi_assert(api_hal_subghz_state == SubGhzStateAsyncTx); - if (--api_hal_subghz_tx_repeat == 0) { - api_hal_subghz_state = SubGhzStateAsyncTxLast; + furi_assert(furi_hal_subghz_state == SubGhzStateAsyncTx); + if (--furi_hal_subghz_tx_repeat == 0) { + furi_hal_subghz_state = SubGhzStateAsyncTxLast; LL_DMA_DisableChannel(DMA1, LL_DMA_CHANNEL_1); } } } -static void api_hal_subghz_tx_timer_isr() { +static void furi_hal_subghz_tx_timer_isr() { if(LL_TIM_IsActiveFlag_UPDATE(TIM2)) { LL_TIM_ClearFlag_UPDATE(TIM2); - if (api_hal_subghz_state == SubGhzStateAsyncTxLast) { + if (furi_hal_subghz_state == SubGhzStateAsyncTxLast) { LL_TIM_DisableCounter(TIM2); - api_hal_subghz_state = SubGhzStateAsyncTxEnd; + furi_hal_subghz_state = SubGhzStateAsyncTxEnd; } } } -void api_hal_subghz_start_async_tx(uint32_t* buffer, size_t buffer_size, size_t repeat) { - furi_assert(api_hal_subghz_state == SubGhzStateIdle); - api_hal_subghz_state = SubGhzStateAsyncTx; - api_hal_subghz_tx_repeat = repeat; +void furi_hal_subghz_start_async_tx(uint32_t* buffer, size_t buffer_size, size_t repeat) { + furi_assert(furi_hal_subghz_state == SubGhzStateIdle); + furi_hal_subghz_state = SubGhzStateAsyncTx; + furi_hal_subghz_tx_repeat = repeat; // Connect CC1101_GD0 to TIM2 as output hal_gpio_init_ex(&gpio_cc1101_g0, GpioModeAltFunctionPushPull, GpioPullDown, GpioSpeedLow, GpioAltFn1TIM2); @@ -447,7 +447,7 @@ void api_hal_subghz_start_async_tx(uint32_t* buffer, size_t buffer_size, size_t dma_config.PeriphRequest = LL_DMAMUX_REQ_TIM2_UP; dma_config.Priority = LL_DMA_MODE_NORMAL; LL_DMA_Init(DMA1, LL_DMA_CHANNEL_1, &dma_config); - api_hal_interrupt_set_dma_channel_isr(DMA1, LL_DMA_CHANNEL_1, api_hal_subghz_tx_dma_isr); + furi_hal_interrupt_set_dma_channel_isr(DMA1, LL_DMA_CHANNEL_1, furi_hal_subghz_tx_dma_isr); LL_DMA_EnableIT_TC(DMA1, LL_DMA_CHANNEL_1); LL_DMA_EnableChannel(DMA1, LL_DMA_CHANNEL_1); @@ -473,17 +473,17 @@ void api_hal_subghz_start_async_tx(uint32_t* buffer, size_t buffer_size, size_t LL_TIM_OC_DisableFast(TIM2, LL_TIM_CHANNEL_CH2); LL_TIM_DisableMasterSlaveMode(TIM2); - api_hal_interrupt_set_timer_isr(TIM2, api_hal_subghz_tx_timer_isr); + furi_hal_interrupt_set_timer_isr(TIM2, furi_hal_subghz_tx_timer_isr); LL_TIM_EnableIT_UPDATE(TIM2); LL_TIM_EnableDMAReq_UPDATE(TIM2); LL_TIM_CC_EnableChannel(TIM2, LL_TIM_CHANNEL_CH2); // Start counter LL_TIM_GenerateEvent_UPDATE(TIM2); -#ifdef API_HAL_SUBGHZ_TX_GPIO - hal_gpio_write(&API_HAL_SUBGHZ_TX_GPIO, true); +#ifdef FURI_HAL_SUBGHZ_TX_GPIO + hal_gpio_write(&FURI_HAL_SUBGHZ_TX_GPIO, true); #endif - api_hal_subghz_tx(); + furi_hal_subghz_tx(); // Enable NVIC NVIC_SetPriority(TIM2_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),5, 0)); @@ -493,38 +493,38 @@ void api_hal_subghz_start_async_tx(uint32_t* buffer, size_t buffer_size, size_t LL_TIM_EnableCounter(TIM2); } -size_t api_hal_subghz_get_async_tx_repeat_left() { - return api_hal_subghz_tx_repeat; +size_t furi_hal_subghz_get_async_tx_repeat_left() { + return furi_hal_subghz_tx_repeat; } -void api_hal_subghz_wait_async_tx() { - while(api_hal_subghz_state != SubGhzStateAsyncTxEnd) osDelay(1); +void furi_hal_subghz_wait_async_tx() { + while(furi_hal_subghz_state != SubGhzStateAsyncTxEnd) osDelay(1); } -void api_hal_subghz_stop_async_tx() { +void furi_hal_subghz_stop_async_tx() { furi_assert( - api_hal_subghz_state == SubGhzStateAsyncTx - || api_hal_subghz_state == SubGhzStateAsyncTxLast - || api_hal_subghz_state == SubGhzStateAsyncTxEnd + furi_hal_subghz_state == SubGhzStateAsyncTx + || furi_hal_subghz_state == SubGhzStateAsyncTxLast + || furi_hal_subghz_state == SubGhzStateAsyncTxEnd ); // Shutdown radio - api_hal_subghz_idle(); -#ifdef API_HAL_SUBGHZ_TX_GPIO - hal_gpio_write(&API_HAL_SUBGHZ_TX_GPIO, false); + furi_hal_subghz_idle(); +#ifdef FURI_HAL_SUBGHZ_TX_GPIO + hal_gpio_write(&FURI_HAL_SUBGHZ_TX_GPIO, false); #endif // Deinitialize Timer LL_TIM_DeInit(TIM2); LL_APB1_GRP1_DisableClock(LL_APB1_GRP1_PERIPH_TIM2); - api_hal_interrupt_set_timer_isr(TIM2, NULL); + furi_hal_interrupt_set_timer_isr(TIM2, NULL); // Deinitialize DMA LL_DMA_DeInit(DMA1, LL_DMA_CHANNEL_1); - api_hal_interrupt_set_dma_channel_isr(DMA1, LL_DMA_CHANNEL_1, NULL); + furi_hal_interrupt_set_dma_channel_isr(DMA1, LL_DMA_CHANNEL_1, NULL); // Deinitialize GPIO hal_gpio_init(&gpio_cc1101_g0, GpioModeAnalog, GpioPullNo, GpioSpeedLow); - api_hal_subghz_state = SubGhzStateIdle; + furi_hal_subghz_state = SubGhzStateIdle; } diff --git a/firmware/targets/f6/api-hal/api-hal-task.c b/firmware/targets/f6/furi-hal/furi-hal-task.c similarity index 98% rename from firmware/targets/f6/api-hal/api-hal-task.c rename to firmware/targets/f6/furi-hal/furi-hal-task.c index 48df9fa7..aca197a4 100644 --- a/firmware/targets/f6/api-hal/api-hal-task.c +++ b/firmware/targets/f6/furi-hal/furi-hal-task.c @@ -1,5 +1,5 @@ #include "cmsis_os.h" -#include "api-hal-task.h" +#include "furi-hal-task.h" //-----------------------------cmsis_os2.c------------------------------- // helpers to get isr context diff --git a/firmware/targets/f6/api-hal/api-hal-task.h b/firmware/targets/f6/furi-hal/furi-hal-task.h similarity index 100% rename from firmware/targets/f6/api-hal/api-hal-task.h rename to firmware/targets/f6/furi-hal/furi-hal-task.h diff --git a/firmware/targets/f6/furi-hal/furi-hal-vcp.c b/firmware/targets/f6/furi-hal/furi-hal-vcp.c new file mode 100644 index 00000000..9079a5c8 --- /dev/null +++ b/firmware/targets/f6/furi-hal/furi-hal-vcp.c @@ -0,0 +1,106 @@ +#include +#include +#include +#include + +#define FURI_HAL_VCP_RX_BUFFER_SIZE 600 + +typedef struct { + StreamBufferHandle_t rx_stream; + osSemaphoreId_t tx_semaphore; + volatile bool alive; + volatile bool underrun; +} FuriHalVcp; + +static FuriHalVcp* furi_hal_vcp = NULL; + +static const uint8_t ascii_soh = 0x01; +static const uint8_t ascii_eot = 0x04; + +void _furi_hal_vcp_init(); +void _furi_hal_vcp_deinit(); +void _furi_hal_vcp_control_line(uint8_t state); +void _furi_hal_vcp_rx_callback(const uint8_t* buffer, size_t size); +void _furi_hal_vcp_tx_complete(size_t size); + +void furi_hal_vcp_init() { + furi_hal_vcp = furi_alloc(sizeof(FuriHalVcp)); + furi_hal_vcp->rx_stream = xStreamBufferCreate(FURI_HAL_VCP_RX_BUFFER_SIZE, 1); + furi_hal_vcp->tx_semaphore = osSemaphoreNew(1, 1, NULL); + furi_hal_vcp->alive = false; + furi_hal_vcp->underrun = false; + FURI_LOG_I("FuriHalVcp", "Init OK"); +} + +void _furi_hal_vcp_init() { + osSemaphoreRelease(furi_hal_vcp->tx_semaphore); +} + +void _furi_hal_vcp_deinit() { + furi_hal_vcp->alive = false; + osSemaphoreRelease(furi_hal_vcp->tx_semaphore); +} + +void _furi_hal_vcp_control_line(uint8_t state) { + // bit 0: DTR state, bit 1: RTS state + // bool dtr = state & 0b01; + bool dtr = state & 0b1; + + if (dtr) { + if (!furi_hal_vcp->alive) { + furi_hal_vcp->alive = true; + _furi_hal_vcp_rx_callback(&ascii_soh, 1); // SOH + } + } else { + if (furi_hal_vcp->alive) { + _furi_hal_vcp_rx_callback(&ascii_eot, 1); // EOT + furi_hal_vcp->alive = false; + } + } + + osSemaphoreRelease(furi_hal_vcp->tx_semaphore); +} + +void _furi_hal_vcp_rx_callback(const uint8_t* buffer, size_t size) { + BaseType_t xHigherPriorityTaskWoken = pdFALSE; + size_t ret = xStreamBufferSendFromISR(furi_hal_vcp->rx_stream, buffer, size, &xHigherPriorityTaskWoken); + if (ret != size) { + furi_hal_vcp->underrun = true; + } + portYIELD_FROM_ISR(xHigherPriorityTaskWoken); +} + +void _furi_hal_vcp_tx_complete(size_t size) { + osSemaphoreRelease(furi_hal_vcp->tx_semaphore); +} + +size_t furi_hal_vcp_rx(uint8_t* buffer, size_t size) { + furi_assert(furi_hal_vcp); + return xStreamBufferReceive(furi_hal_vcp->rx_stream, buffer, size, portMAX_DELAY); +} + +size_t furi_hal_vcp_rx_with_timeout(uint8_t* buffer, size_t size, uint32_t timeout) { + furi_assert(furi_hal_vcp); + return xStreamBufferReceive(furi_hal_vcp->rx_stream, buffer, size, timeout); +} + +void furi_hal_vcp_tx(const uint8_t* buffer, size_t size) { + furi_assert(furi_hal_vcp); + + while (size > 0 && furi_hal_vcp->alive) { + furi_check(osSemaphoreAcquire(furi_hal_vcp->tx_semaphore, osWaitForever) == osOK); + + size_t batch_size = size; + if (batch_size > APP_TX_DATA_SIZE) { + batch_size = APP_TX_DATA_SIZE; + } + + if (CDC_Transmit_FS((uint8_t*)buffer, batch_size) == USBD_OK) { + size -= batch_size; + buffer += batch_size; + } else { + // Shouldn't be there + osDelay(100); + } + } +} diff --git a/firmware/targets/f6/furi-hal/furi-hal-version.c b/firmware/targets/f6/furi-hal/furi-hal-version.c new file mode 100644 index 00000000..a58a9d1c --- /dev/null +++ b/firmware/targets/f6/furi-hal/furi-hal-version.c @@ -0,0 +1,242 @@ +#include + +#include +#include +#include + +#include +#include "ble.h" + +#define FURI_HAL_VERSION_OTP_HEADER_MAGIC 0xBABE +#define FURI_HAL_VERSION_NAME_LENGTH 8 +#define FURI_HAL_VERSION_ARRAY_NAME_LENGTH (FURI_HAL_VERSION_NAME_LENGTH + 1) +/** BLE symbol + "Flipper " + name */ +#define FURI_HAL_VERSION_DEVICE_NAME_LENGTH (1 + 8 + FURI_HAL_VERSION_ARRAY_NAME_LENGTH) +#define FURI_HAL_VERSION_OTP_ADDRESS OTP_AREA_BASE + +/** OTP Versions enum */ +typedef enum { + FuriHalVersionOtpVersion0=0x00, + FuriHalVersionOtpVersion1=0x01, + FuriHalVersionOtpVersionEmpty=0xFFFFFFFE, + FuriHalVersionOtpVersionUnknown=0xFFFFFFFF, +} FuriHalVersionOtpVersion; + +/** OTP V0 Structure: prototypes and early EVT */ +typedef struct { + uint8_t board_version; + uint8_t board_target; + uint8_t board_body; + uint8_t board_connect; + uint32_t header_timestamp; + char name[FURI_HAL_VERSION_NAME_LENGTH]; +} FuriHalVersionOTPv0; + +/** OTP V1 Structure: late EVT, DVT, PVT, Production */ +typedef struct { + /* First 64 bits: header */ + uint16_t header_magic; + uint8_t header_version; + uint8_t header_reserved; + uint32_t header_timestamp; + + /* Second 64 bits: board info */ + uint8_t board_version; /** Board version */ + uint8_t board_target; /** Board target firmware */ + uint8_t board_body; /** Board body */ + uint8_t board_connect; /** Board interconnect */ + uint8_t board_color; /** Board color */ + uint8_t board_region; /** Board region */ + uint16_t board_reserved; /** Reserved for future use, 0x0000 */ + + /* Third 64 bits: Unique Device Name */ + char name[FURI_HAL_VERSION_NAME_LENGTH]; /** Unique Device Name */ +} FuriHalVersionOTPv1; + +/** Represenation Model: */ +typedef struct { + FuriHalVersionOtpVersion otp_version; + + uint32_t timestamp; + + uint8_t board_version; /** Board version */ + uint8_t board_target; /** Board target firmware */ + uint8_t board_body; /** Board body */ + uint8_t board_connect; /** Board interconnect */ + uint8_t board_color; /** Board color */ + uint8_t board_region; /** Board region */ + + char name[FURI_HAL_VERSION_ARRAY_NAME_LENGTH]; /** \0 terminated name */ + char device_name[FURI_HAL_VERSION_DEVICE_NAME_LENGTH]; /** device name for special needs */ + uint8_t ble_mac[6]; +} FuriHalVersion; + +static FuriHalVersion furi_hal_version = {0}; + +static FuriHalVersionOtpVersion furi_hal_version_get_otp_version() { + if (*(uint64_t*)FURI_HAL_VERSION_OTP_ADDRESS == 0xFFFFFFFF) { + return FuriHalVersionOtpVersionEmpty; + } else { + if (((FuriHalVersionOTPv1*)FURI_HAL_VERSION_OTP_ADDRESS)->header_magic == FURI_HAL_VERSION_OTP_HEADER_MAGIC) { + return FuriHalVersionOtpVersion1; + } else if (((FuriHalVersionOTPv0*)FURI_HAL_VERSION_OTP_ADDRESS)->board_version <= 10) { + return FuriHalVersionOtpVersion0; + } else { + return FuriHalVersionOtpVersionUnknown; + } + } +} + +static void furi_hal_version_set_name(const char* name) { + if(name != NULL) { + strlcpy(furi_hal_version.name, name, FURI_HAL_VERSION_ARRAY_NAME_LENGTH); + snprintf( + furi_hal_version.device_name, + FURI_HAL_VERSION_DEVICE_NAME_LENGTH, + "xFlipper %s", + furi_hal_version.name); + } else { + snprintf( + furi_hal_version.device_name, + FURI_HAL_VERSION_DEVICE_NAME_LENGTH, + "xFlipper"); + } + + furi_hal_version.device_name[0] = AD_TYPE_COMPLETE_LOCAL_NAME; + + // BLE Mac address + uint32_t udn = LL_FLASH_GetUDN(); + uint32_t company_id = LL_FLASH_GetSTCompanyID(); + uint32_t device_id = LL_FLASH_GetDeviceID(); + furi_hal_version.ble_mac[0] = (uint8_t)(udn & 0x000000FF); + furi_hal_version.ble_mac[1] = (uint8_t)( (udn & 0x0000FF00) >> 8 ); + furi_hal_version.ble_mac[2] = (uint8_t)( (udn & 0x00FF0000) >> 16 ); + furi_hal_version.ble_mac[3] = (uint8_t)device_id; + furi_hal_version.ble_mac[4] = (uint8_t)(company_id & 0x000000FF); + furi_hal_version.ble_mac[5] = (uint8_t)( (company_id & 0x0000FF00) >> 8 ); +} + +static void furi_hal_version_load_otp_default() { + furi_hal_version_set_name(NULL); +} + +static void furi_hal_version_load_otp_v0() { + const FuriHalVersionOTPv0* otp = (FuriHalVersionOTPv0*)FURI_HAL_VERSION_OTP_ADDRESS; + + furi_hal_version.timestamp = otp->header_timestamp; + furi_hal_version.board_version = otp->board_version; + furi_hal_version.board_target = otp->board_target; + furi_hal_version.board_body = otp->board_body; + furi_hal_version.board_connect = otp->board_connect; + furi_hal_version.board_color = 0; + furi_hal_version.board_region = 0; + + furi_hal_version_set_name(otp->name); +} + +static void furi_hal_version_load_otp_v1() { + const FuriHalVersionOTPv1* otp = (FuriHalVersionOTPv1*)FURI_HAL_VERSION_OTP_ADDRESS; + + furi_hal_version.timestamp = otp->header_timestamp; + furi_hal_version.board_version = otp->board_version; + furi_hal_version.board_target = otp->board_target; + furi_hal_version.board_body = otp->board_body; + furi_hal_version.board_connect = otp->board_connect; + furi_hal_version.board_color = otp->board_color; + furi_hal_version.board_region = otp->board_region; + + furi_hal_version_set_name(otp->name); +} + +void furi_hal_version_init() { + furi_hal_version.otp_version = furi_hal_version_get_otp_version(); + switch(furi_hal_version.otp_version) { + case FuriHalVersionOtpVersionUnknown: + furi_hal_version_load_otp_default(); + break; + case FuriHalVersionOtpVersionEmpty: + furi_hal_version_load_otp_default(); + break; + case FuriHalVersionOtpVersion0: + furi_hal_version_load_otp_v0(); + break; + case FuriHalVersionOtpVersion1: + furi_hal_version_load_otp_v1(); + break; + default: furi_check(0); + } + FURI_LOG_I("FuriHalVersion", "Init OK"); +} + +bool furi_hal_version_do_i_belong_here() { + return furi_hal_version_get_hw_target() == 6; +} + +const char* furi_hal_version_get_model_name() { + return "Flipper Zero"; +} + +const uint8_t furi_hal_version_get_hw_version() { + return furi_hal_version.board_version; +} + +const uint8_t furi_hal_version_get_hw_target() { + return furi_hal_version.board_target; +} + +const uint8_t furi_hal_version_get_hw_body() { + return furi_hal_version.board_body; +} + +const FuriHalVersionColor furi_hal_version_get_hw_color() { + return furi_hal_version.board_color; +} + +const uint8_t furi_hal_version_get_hw_connect() { + return furi_hal_version.board_connect; +} + +const FuriHalVersionRegion furi_hal_version_get_hw_region() { + return furi_hal_version.board_region; +} + +const uint32_t furi_hal_version_get_hw_timestamp() { + return furi_hal_version.timestamp; +} + +const char* furi_hal_version_get_name_ptr() { + return *furi_hal_version.name == 0x00 ? NULL : furi_hal_version.name; +} + +const char* furi_hal_version_get_device_name_ptr() { + return furi_hal_version.device_name + 1; +} + +const char* furi_hal_version_get_ble_local_device_name_ptr() { + return furi_hal_version.device_name; +} + +const uint8_t* furi_hal_version_get_ble_mac() { + return furi_hal_version.ble_mac; +} + +const struct Version* furi_hal_version_get_firmware_version(void) { + return version_get(); +} + +const struct Version* furi_hal_version_get_boot_version(void) { +#ifdef NO_BOOTLOADER + return 0; +#else + /* Backup register which points to structure in flash memory */ + return (const struct Version*)LL_RTC_BAK_GetRegister(RTC, LL_RTC_BKP_DR1); +#endif +} + +size_t furi_hal_version_uid_size() { + return 64/8; +} + +const uint8_t* furi_hal_version_uid() { + return (const uint8_t *)UID64_BASE; +} diff --git a/firmware/targets/f6/api-hal/api-hal-vibro.c b/firmware/targets/f6/furi-hal/furi-hal-vibro.c similarity index 63% rename from firmware/targets/f6/api-hal/api-hal-vibro.c rename to firmware/targets/f6/furi-hal/furi-hal-vibro.c index 71102f7f..7dfddd42 100644 --- a/firmware/targets/f6/api-hal/api-hal-vibro.c +++ b/firmware/targets/f6/furi-hal/furi-hal-vibro.c @@ -1,13 +1,13 @@ -#include -#include +#include +#include -void api_hal_vibro_init() { +void furi_hal_vibro_init() { hal_gpio_init(&vibro_gpio, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); hal_gpio_write(&vibro_gpio, false); FURI_LOG_I("FuriHalVibro", "Init OK"); } -void api_hal_vibro_on(bool value) { +void furi_hal_vibro_on(bool value) { hal_gpio_write(&vibro_gpio, value); } diff --git a/firmware/targets/f6/api-hal/api-hal.c b/firmware/targets/f6/furi-hal/furi-hal.c similarity index 71% rename from firmware/targets/f6/api-hal/api-hal.c rename to firmware/targets/f6/furi-hal/furi-hal.c index d5edd11f..31564cbd 100644 --- a/firmware/targets/f6/api-hal/api-hal.c +++ b/firmware/targets/f6/furi-hal/furi-hal.c @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -13,19 +13,19 @@ #include #include -void api_hal_init() { - api_hal_clock_init(); - api_hal_console_init(); - api_hal_interrupt_init(); - api_hal_delay_init(); +void furi_hal_init() { + furi_hal_clock_init(); + furi_hal_console_init(); + furi_hal_interrupt_init(); + furi_hal_delay_init(); MX_GPIO_Init(); FURI_LOG_I("HAL", "GPIO OK"); MX_RTC_Init(); FURI_LOG_I("HAL", "RTC OK"); - api_hal_boot_init(); - api_hal_version_init(); + furi_hal_boot_init(); + furi_hal_version_init(); MX_ADC1_Init(); FURI_LOG_I("HAL", "ADC1 OK"); @@ -34,7 +34,7 @@ void api_hal_init() { FURI_LOG_I("HAL", "SPI1 OK"); MX_SPI2_Init(); FURI_LOG_I("HAL", "SPI2 OK"); - api_hal_spi_init(); + furi_hal_spi_init(); MX_TIM1_Init(); FURI_LOG_I("HAL", "TIM1 OK"); @@ -58,19 +58,19 @@ void api_hal_init() { FURI_LOG_I("HAL", "CRC OK"); // VCP + USB - api_hal_vcp_init(); + furi_hal_vcp_init(); MX_USB_Device_Init(); FURI_LOG_I("HAL", "USB OK"); - api_hal_i2c_init(); + furi_hal_i2c_init(); // High Level - api_hal_power_init(); - api_hal_light_init(); - api_hal_vibro_init(); - api_hal_subghz_init(); - api_hal_nfc_init(); + furi_hal_power_init(); + furi_hal_light_init(); + furi_hal_vibro_init(); + furi_hal_subghz_init(); + furi_hal_nfc_init(); // FreeRTOS glue - api_hal_os_init(); + furi_hal_os_init(); } diff --git a/firmware/targets/f6/target.mk b/firmware/targets/f6/target.mk index 44df8fe7..484153ef 100644 --- a/firmware/targets/f6/target.mk +++ b/firmware/targets/f6/target.mk @@ -14,14 +14,14 @@ FLASH_ADDRESS = 0x08000000 CFLAGS += -DNO_BOOTLOADER endif -API_HAL_OS_DEBUG ?= 0 -ifeq ($(API_HAL_OS_DEBUG), 1) -CFLAGS += -DAPI_HAL_OS_DEBUG +FURI_HAL_OS_DEBUG ?= 0 +ifeq ($(FURI_HAL_OS_DEBUG), 1) +CFLAGS += -DFURI_HAL_OS_DEBUG endif -API_HAL_SUBGHZ_TX_GPIO ?= 0 -ifneq ($(API_HAL_SUBGHZ_TX_GPIO), 0) -CFLAGS += -DAPI_HAL_SUBGHZ_TX_GPIO=$(API_HAL_SUBGHZ_TX_GPIO) +FURI_HAL_SUBGHZ_TX_GPIO ?= 0 +ifneq ($(FURI_HAL_SUBGHZ_TX_GPIO), 0) +CFLAGS += -DFURI_HAL_SUBGHZ_TX_GPIO=$(FURI_HAL_SUBGHZ_TX_GPIO) endif ifeq ($(INVERT_RFID_IN), 1) @@ -39,7 +39,7 @@ CPPFLAGS += -fno-rtti -fno-use-cxa-atexit -fno-exceptions LDFLAGS += -Wl,--start-group -lstdc++ -lsupc++ -Wl,--end-group MXPROJECT_DIR = $(TARGET_DIR) -API_HAL_DIR = $(TARGET_DIR) +FURI_HAL_DIR = $(TARGET_DIR) CUBE_DIR = ../lib/STM32CubeWB C_SOURCES += \ @@ -96,7 +96,7 @@ C_SOURCES += \ $(CUBE_DIR)/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c \ $(wildcard $(MXPROJECT_DIR)/Src/*.c) \ $(wildcard $(MXPROJECT_DIR)/Src/fatfs/*.c) \ - $(wildcard $(API_HAL_DIR)/api-hal/*.c) + $(wildcard $(FURI_HAL_DIR)/furi-hal/*.c) ASM_SOURCES += $(MXPROJECT_DIR)/startup_stm32wb55xx_cm4.s @@ -124,7 +124,7 @@ CFLAGS += \ -I$(CUBE_DIR)/Drivers/CMSIS/Include \ -I$(MXPROJECT_DIR)/Inc \ -I$(MXPROJECT_DIR)/Src/fatfs \ - -I$(API_HAL_DIR)/api-hal \ + -I$(FURI_HAL_DIR)/furi-hal \ # Ble glue CFLAGS += -I$(TARGET_DIR)/ble-glue \ diff --git a/firmware/targets/furi-hal-include/furi-hal-boot.h b/firmware/targets/furi-hal-include/furi-hal-boot.h new file mode 100644 index 00000000..9731ca1c --- /dev/null +++ b/firmware/targets/furi-hal-include/furi-hal-boot.h @@ -0,0 +1,34 @@ +#pragma once +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** Boot modes */ +typedef enum { + FuriHalBootModeNormal, + FuriHalBootModeDFU +} FuriHalBootMode; + +/** Boot flags */ +typedef enum { + FuriHalBootFlagDefault=0, + FuriHalBootFlagFactoryReset=1, +} FuriHalBootFlag; + +/** Initialize boot subsystem */ +void furi_hal_boot_init(); + +/** Set boot mode */ +void furi_hal_boot_set_mode(FuriHalBootMode mode); + +/** Set boot flags */ +void furi_hal_boot_set_flags(FuriHalBootFlag flags); + +/** Get boot flag */ +FuriHalBootFlag furi_hal_boot_get_flags(); + +#ifdef __cplusplus +} +#endif diff --git a/firmware/targets/api-hal-include/api-hal-bt.h b/firmware/targets/furi-hal-include/furi-hal-bt.h similarity index 54% rename from firmware/targets/api-hal-include/api-hal-bt.h rename to firmware/targets/furi-hal-include/furi-hal-bt.h index 312efe09..d66233a1 100644 --- a/firmware/targets/api-hal-include/api-hal-bt.h +++ b/firmware/targets/furi-hal-include/furi-hal-bt.h @@ -8,52 +8,52 @@ extern "C" { #endif /** Initialize */ -void api_hal_bt_init(); +void furi_hal_bt_init(); /** Start BLE app */ -bool api_hal_bt_start_app(); +bool furi_hal_bt_start_app(); /** Get BT/BLE system component state */ -void api_hal_bt_dump_state(string_t buffer); +void furi_hal_bt_dump_state(string_t buffer); /** Get BT/BLE system component state */ -bool api_hal_bt_is_alive(); +bool furi_hal_bt_is_alive(); /** * Lock shared access to flash controller * @return true if lock was successful, false if not */ -bool api_hal_bt_lock_flash(); +bool furi_hal_bt_lock_flash(); /** Unlock shared access to flash controller */ -void api_hal_bt_unlock_flash(); +void furi_hal_bt_unlock_flash(); /** Start ble tone tx at given channel and power */ -void api_hal_bt_start_tone_tx(uint8_t channel, uint8_t power); +void furi_hal_bt_start_tone_tx(uint8_t channel, uint8_t power); /** Stop ble tone tx */ -void api_hal_bt_stop_tone_tx(); +void furi_hal_bt_stop_tone_tx(); /** Start sending ble packets at a given frequency and datarate */ -void api_hal_bt_start_packet_tx(uint8_t channel, uint8_t pattern, uint8_t datarate); +void furi_hal_bt_start_packet_tx(uint8_t channel, uint8_t pattern, uint8_t datarate); /** Stop sending ble packets */ -uint16_t api_hal_bt_stop_packet_test(); +uint16_t furi_hal_bt_stop_packet_test(); /** Start receiving packets */ -void api_hal_bt_start_packet_rx(uint8_t channel, uint8_t datarate); +void furi_hal_bt_start_packet_rx(uint8_t channel, uint8_t datarate); /** Set up the RF to listen to a given RF channel */ -void api_hal_bt_start_rx(uint8_t channel); +void furi_hal_bt_start_rx(uint8_t channel); /** Stop RF listenning */ -void api_hal_bt_stop_rx(); +void furi_hal_bt_stop_rx(); /** Get RSSI */ -float api_hal_bt_get_rssi(); +float furi_hal_bt_get_rssi(); /** Get number of transmitted packets */ -uint32_t api_hal_bt_get_transmitted_packets(); +uint32_t furi_hal_bt_get_transmitted_packets(); #ifdef __cplusplus } diff --git a/firmware/targets/api-hal-include/api-hal-delay.h b/firmware/targets/furi-hal-include/furi-hal-delay.h similarity index 89% rename from firmware/targets/api-hal-include/api-hal-delay.h rename to firmware/targets/furi-hal-include/furi-hal-delay.h index e01321d7..0f6c0a76 100644 --- a/firmware/targets/api-hal-include/api-hal-delay.h +++ b/firmware/targets/furi-hal-include/furi-hal-delay.h @@ -6,7 +6,7 @@ extern "C" { #endif /** Init DWT */ -void api_hal_delay_init(void); +void furi_hal_delay_init(void); /** * Delay in milliseconds diff --git a/firmware/targets/api-hal-include/api-hal-i2c.h b/firmware/targets/furi-hal-include/furi-hal-i2c.h similarity index 83% rename from firmware/targets/api-hal-include/api-hal-i2c.h rename to firmware/targets/furi-hal-include/furi-hal-i2c.h index e34b5245..90908c8d 100644 --- a/firmware/targets/api-hal-include/api-hal-i2c.h +++ b/firmware/targets/furi-hal-include/furi-hal-i2c.h @@ -2,14 +2,14 @@ #include #include -#include +#include #ifdef __cplusplus extern "C" { #endif /** Init I2C */ -void api_hal_i2c_init(); +void furi_hal_i2c_init(); /** * Perform I2C tx transfer @@ -20,7 +20,7 @@ void api_hal_i2c_init(); * @param timeout timeout in CPU ticks * @return true on successful transfer, false otherwise */ -bool api_hal_i2c_tx( +bool furi_hal_i2c_tx( I2C_TypeDef* instance, const uint8_t address, const uint8_t* data, @@ -36,7 +36,7 @@ bool api_hal_i2c_tx( * @param timeout timeout in CPU ticks * @return true on successful transfer, false otherwise */ -bool api_hal_i2c_rx( +bool furi_hal_i2c_rx( I2C_TypeDef* instance, const uint8_t address, uint8_t* data, @@ -54,7 +54,7 @@ bool api_hal_i2c_rx( * @param timeout timeout in CPU ticks * @return true on successful transfer, false otherwise */ -bool api_hal_i2c_trx( +bool furi_hal_i2c_trx( I2C_TypeDef* instance, const uint8_t address, const uint8_t* tx_data, @@ -64,10 +64,10 @@ bool api_hal_i2c_trx( uint32_t timeout); /** Acquire I2C mutex */ -void api_hal_i2c_lock(); +void furi_hal_i2c_lock(); /** Release I2C mutex */ -void api_hal_i2c_unlock(); +void furi_hal_i2c_unlock(); /** * With clause for I2C peripheral @@ -75,11 +75,11 @@ void api_hal_i2c_unlock(); * @param pointer pointer to return of function_body * @param function_body a (){} lambda declaration, executed with I2C mutex acquired */ -#define with_api_hal_i2c(type, pointer, function_body) \ +#define with_furi_hal_i2c(type, pointer, function_body) \ { \ - api_hal_i2c_lock(); \ + furi_hal_i2c_lock(); \ *pointer = ({ type __fn__ function_body __fn__; })(); \ - api_hal_i2c_unlock(); \ + furi_hal_i2c_unlock(); \ } #ifdef __cplusplus diff --git a/firmware/targets/furi-hal-include/furi-hal-ibutton.h b/firmware/targets/furi-hal-include/furi-hal-ibutton.h new file mode 100644 index 00000000..e31af720 --- /dev/null +++ b/firmware/targets/furi-hal-include/furi-hal-ibutton.h @@ -0,0 +1,20 @@ +#pragma once +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void furi_hal_ibutton_start(); + +void furi_hal_ibutton_stop(); + +void furi_hal_ibutton_pin_low(); + +void furi_hal_ibutton_pin_high(); + +bool furi_hal_ibutton_pin_get_level(); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/firmware/targets/api-hal-include/api-hal-irda.h b/firmware/targets/furi-hal-include/furi-hal-irda.h similarity index 54% rename from firmware/targets/api-hal-include/api-hal-irda.h rename to firmware/targets/furi-hal-include/furi-hal-irda.h index ee3f7106..929fb613 100644 --- a/firmware/targets/api-hal-include/api-hal-irda.h +++ b/firmware/targets/furi-hal-include/furi-hal-irda.h @@ -8,13 +8,13 @@ extern "C" { #endif typedef enum { - ApiHalIrdaTxGetDataStateError, /* An error occured during transmission */ - ApiHalIrdaTxGetDataStateOk, /* New data obtained */ - ApiHalIrdaTxGetDataStateDone, /* New data obtained, and this is end of package */ - ApiHalIrdaTxGetDataStateLastDone, /* New data obtained, and this is end of package and no more data available */ -} ApiHalIrdaTxGetDataState; + FuriHalIrdaTxGetDataStateError, /* An error occured during transmission */ + FuriHalIrdaTxGetDataStateOk, /* New data obtained */ + FuriHalIrdaTxGetDataStateDone, /* New data obtained, and this is end of package */ + FuriHalIrdaTxGetDataStateLastDone, /* New data obtained, and this is end of package and no more data available */ +} FuriHalIrdaTxGetDataState; -typedef ApiHalIrdaTxGetDataState (*ApiHalIrdaTxGetDataCallback) (void* context, uint32_t* duration, bool* level); +typedef FuriHalIrdaTxGetDataState (*FuriHalIrdaTxGetDataCallback) (void* context, uint32_t* duration, bool* level); /** * Signature of callback function for receiving continuous IRDA rx signal. @@ -23,34 +23,34 @@ typedef ApiHalIrdaTxGetDataState (*ApiHalIrdaTxGetDataCallback) (void* context, * @param level[in] - level of input IRDA rx signal * @param duration[in] - duration of continuous rx signal level in us */ -typedef void (*ApiHalIrdaRxCaptureCallback)(void* ctx, bool level, uint32_t duration); +typedef void (*FuriHalIrdaRxCaptureCallback)(void* ctx, bool level, uint32_t duration); /** * Signature of callback function for reaching silence timeout on IRDA port. * * @param ctx[in] - context to pass to callback */ -typedef void (*ApiHalIrdaRxTimeoutCallback)(void* ctx); +typedef void (*FuriHalIrdaRxTimeoutCallback)(void* ctx); /** * Initialize IRDA RX timer to receive interrupts. * It provides interrupts for every RX-signal edge changing * with its duration. */ -void api_hal_irda_async_rx_start(void); +void furi_hal_irda_async_rx_start(void); /** * Deinitialize IRDA RX interrupt. */ -void api_hal_irda_async_rx_stop(void); +void furi_hal_irda_async_rx_stop(void); /** Setup api hal for receiving silence timeout. - * Should be used with 'api_hal_irda_timeout_irq_set_callback()'. + * Should be used with 'furi_hal_irda_timeout_irq_set_callback()'. * * @param[in] timeout_ms - time to wait for silence on IRDA port * before generating IRQ. */ -void api_hal_irda_async_rx_set_timeout(uint32_t timeout_ms); +void furi_hal_irda_async_rx_set_timeout(uint32_t timeout_ms); /** * Setup callback for previously initialized IRDA RX interrupt. @@ -58,40 +58,40 @@ void api_hal_irda_async_rx_set_timeout(uint32_t timeout_ms); * @param[in] callback - callback to call when RX signal edge changing occurs * @param[in] ctx - context for callback */ -void api_hal_irda_async_rx_set_capture_isr_callback(ApiHalIrdaRxCaptureCallback callback, void *ctx); +void furi_hal_irda_async_rx_set_capture_isr_callback(FuriHalIrdaRxCaptureCallback callback, void *ctx); /** * Setup callback for reaching silence timeout on IRDA port. - * Should setup api hal with 'api_hal_irda_setup_rx_timeout_irq()' first. + * Should setup api hal with 'furi_hal_irda_setup_rx_timeout_irq()' first. * * @param[in] callback - callback for silence timeout * @param[in] ctx - context to pass to callback */ -void api_hal_irda_async_rx_set_timeout_isr_callback(ApiHalIrdaRxTimeoutCallback callback, void *ctx); +void furi_hal_irda_async_rx_set_timeout_isr_callback(FuriHalIrdaRxTimeoutCallback callback, void *ctx); /** * Check if IRDA is in use now. * @return true - IRDA is busy, false otherwise. */ -bool api_hal_irda_is_busy(void); +bool furi_hal_irda_is_busy(void); /** * Set callback providing new data. This function has to be called - * before api_hal_irda_async_tx_start(). + * before furi_hal_irda_async_tx_start(). * * @param[in] callback - function to provide new data * @param[in] context - context for callback */ -void api_hal_irda_async_tx_set_data_isr_callback(ApiHalIrdaTxGetDataCallback callback, void* context); +void furi_hal_irda_async_tx_set_data_isr_callback(FuriHalIrdaTxGetDataCallback callback, void* context); /** * Start IR asynchronous transmission. It can be stopped by 2 reasons: - * 1) implicit call for api_hal_irda_async_tx_stop() - * 2) callback can provide ApiHalIrdaTxGetDataStateLastDone response + * 1) implicit call for furi_hal_irda_async_tx_stop() + * 2) callback can provide FuriHalIrdaTxGetDataStateLastDone response * which means no more data available for transmission. * - * Any func (api_hal_irda_async_tx_stop() or - * api_hal_irda_async_tx_wait_termination()) has to be called to wait + * Any func (furi_hal_irda_async_tx_stop() or + * furi_hal_irda_async_tx_wait_termination()) has to be called to wait * end of transmission and free resources. * * @param[in] freq - frequency for PWM @@ -99,21 +99,21 @@ void api_hal_irda_async_tx_set_data_isr_callback(ApiHalIrdaTxGetDataCallback cal * @return true if transmission successfully started, false otherwise. * If start failed no need to free resources. */ -bool api_hal_irda_async_tx_start(uint32_t freq, float duty_cycle); +bool furi_hal_irda_async_tx_start(uint32_t freq, float duty_cycle); /** * Stop IR asynchronous transmission and free resources. * Transmission will stop as soon as transmission reaches end of - * package (ApiHalIrdaTxGetDataStateDone or ApiHalIrdaTxGetDataStateLastDone). + * package (FuriHalIrdaTxGetDataStateDone or FuriHalIrdaTxGetDataStateLastDone). */ -void api_hal_irda_async_tx_stop(void); +void furi_hal_irda_async_tx_stop(void); /** * Wait for end of IR asynchronous transmission and free resources. * Transmission will stop as soon as transmission reaches end of - * transmission (ApiHalIrdaTxGetDataStateLastDone). + * transmission (FuriHalIrdaTxGetDataStateLastDone). */ -void api_hal_irda_async_tx_wait_termination(void); +void furi_hal_irda_async_tx_wait_termination(void); #ifdef __cplusplus } diff --git a/firmware/targets/api-hal-include/api-hal-light.h b/firmware/targets/furi-hal-include/furi-hal-light.h similarity index 68% rename from firmware/targets/api-hal-include/api-hal-light.h rename to firmware/targets/furi-hal-include/furi-hal-light.h index fd5fa458..6b699850 100644 --- a/firmware/targets/api-hal-include/api-hal-light.h +++ b/firmware/targets/furi-hal-include/furi-hal-light.h @@ -2,21 +2,21 @@ #include #include -#include +#include #ifdef __cplusplus extern "C" { #endif /** Init light driver */ -void api_hal_light_init(); +void furi_hal_light_init(); /** * Set light value * @param light - Light * @param value - light brightness [0-255] */ -void api_hal_light_set(Light light, uint8_t value); +void furi_hal_light_set(Light light, uint8_t value); #ifdef __cplusplus } diff --git a/firmware/targets/furi-hal-include/furi-hal-nfc.h b/firmware/targets/furi-hal-include/furi-hal-nfc.h new file mode 100644 index 00000000..aaed2924 --- /dev/null +++ b/firmware/targets/furi-hal-include/furi-hal-nfc.h @@ -0,0 +1,66 @@ +#pragma once + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define FURI_HAL_NFC_UID_MAX_LEN 10 + +/** + * Init nfc + */ +void furi_hal_nfc_init(); + +/** + * Check if nfc worker is busy + */ +bool furi_hal_nfc_is_busy(); + +/** + * NFC field on + */ +void furi_hal_nfc_field_on(); + +/** + * NFC field off + */ +void furi_hal_nfc_field_off(); + +/** + * NFC start sleep + */ +void furi_hal_nfc_start_sleep(); + +/** + * NFC stop sleep + */ +void furi_hal_nfc_exit_sleep(); + +/** + * NFC poll + */ +bool furi_hal_nfc_detect(rfalNfcDevice** dev_list, uint8_t* dev_cnt, uint32_t timeout, bool deactivate); + +/** + * NFC listen + */ +bool furi_hal_nfc_listen(uint8_t* uid, uint8_t uid_len, uint8_t* atqa, uint8_t sak, uint32_t timeout); + +/** + * NFC data exchange + */ +ReturnCode furi_hal_nfc_data_exchange(uint8_t* tx_buff, uint16_t tx_len, uint8_t** rx_buff, uint16_t** rx_len, bool deactivate); + +/** + * NFC deactivate and start sleep + */ +void furi_hal_nfc_deactivate(); + +#ifdef __cplusplus +} +#endif diff --git a/firmware/targets/api-hal-include/api-hal-power.h b/firmware/targets/furi-hal-include/furi-hal-power.h similarity index 51% rename from firmware/targets/api-hal-include/api-hal-power.h rename to firmware/targets/furi-hal-include/furi-hal-power.h index 25b20d5e..aeb6c201 100644 --- a/firmware/targets/api-hal-include/api-hal-power.h +++ b/firmware/targets/furi-hal-include/furi-hal-power.h @@ -10,94 +10,94 @@ extern "C" { /** Power IC type */ typedef enum { - ApiHalPowerICCharger, - ApiHalPowerICFuelGauge, -} ApiHalPowerIC; + FuriHalPowerICCharger, + FuriHalPowerICFuelGauge, +} FuriHalPowerIC; /** Initialize drivers */ -void api_hal_power_init(); +void furi_hal_power_init(); /** * Get current insomnia level * @return insomnia level: 0 - no insomnia, >0 - insomnia, bearer count. */ -uint16_t api_hal_power_insomnia_level(); +uint16_t furi_hal_power_insomnia_level(); /** * Enter insomnia mode * Prevents device from going to sleep * @warning Internally increases insomnia level - * Must be paired with api_hal_power_insomnia_exit + * Must be paired with furi_hal_power_insomnia_exit */ -void api_hal_power_insomnia_enter(); +void furi_hal_power_insomnia_enter(); /** * Exit insomnia mode * Allow device to go to sleep * @warning Internally decreases insomnia level. - * Must be paired with api_hal_power_insomnia_enter + * Must be paired with furi_hal_power_insomnia_enter */ -void api_hal_power_insomnia_exit(); +void furi_hal_power_insomnia_exit(); /** Check if sleep availble */ -bool api_hal_power_sleep_available(); +bool furi_hal_power_sleep_available(); /** Check if deep sleep availble */ -bool api_hal_power_deep_sleep_available(); +bool furi_hal_power_deep_sleep_available(); /** Go to sleep */ -void api_hal_power_sleep(); +void furi_hal_power_sleep(); /** Get predicted remaining battery capacity in percents */ -uint8_t api_hal_power_get_pct(); +uint8_t furi_hal_power_get_pct(); /** Get battery health state in percents */ -uint8_t api_hal_power_get_bat_health_pct(); +uint8_t furi_hal_power_get_bat_health_pct(); /** Get charging status */ -bool api_hal_power_is_charging(); +bool furi_hal_power_is_charging(); /** Poweroff device */ -void api_hal_power_off(); +void furi_hal_power_off(); /** Reset device */ -void api_hal_power_reset(); +void furi_hal_power_reset(); /** OTG enable */ -void api_hal_power_enable_otg(); +void furi_hal_power_enable_otg(); /** OTG disable */ -void api_hal_power_disable_otg(); +void furi_hal_power_disable_otg(); /** Get remaining battery battery capacity in mAh */ -uint32_t api_hal_power_get_battery_remaining_capacity(); +uint32_t furi_hal_power_get_battery_remaining_capacity(); /** Get full charge battery capacity in mAh */ -uint32_t api_hal_power_get_battery_full_capacity(); +uint32_t furi_hal_power_get_battery_full_capacity(); /** Get battery voltage in V */ -float api_hal_power_get_battery_voltage(ApiHalPowerIC ic); +float furi_hal_power_get_battery_voltage(FuriHalPowerIC ic); /** Get battery current in A */ -float api_hal_power_get_battery_current(ApiHalPowerIC ic); +float furi_hal_power_get_battery_current(FuriHalPowerIC ic); /** Get temperature in C */ -float api_hal_power_get_battery_temperature(ApiHalPowerIC ic); +float furi_hal_power_get_battery_temperature(FuriHalPowerIC ic); /** Get System voltage in V */ -float api_hal_power_get_system_voltage(); +float furi_hal_power_get_system_voltage(); /** Get USB voltage in V */ -float api_hal_power_get_usb_voltage(); +float furi_hal_power_get_usb_voltage(); /** Get power system component state */ -void api_hal_power_dump_state(); +void furi_hal_power_dump_state(); /** Enable 3.3v on external gpio and sd card */ -void api_hal_power_enable_external_3_3v(); +void furi_hal_power_enable_external_3_3v(); /** Disable 3.3v on external gpio and sd card */ -void api_hal_power_disable_external_3_3v(); +void furi_hal_power_disable_external_3_3v(); #ifdef __cplusplus } diff --git a/firmware/targets/api-hal-include/api-hal-rfid.h b/firmware/targets/furi-hal-include/furi-hal-rfid.h similarity index 64% rename from firmware/targets/api-hal-include/api-hal-rfid.h rename to firmware/targets/furi-hal-include/furi-hal-rfid.h index 7f2870b0..d0a6aeaa 100644 --- a/firmware/targets/api-hal-include/api-hal-rfid.h +++ b/firmware/targets/furi-hal-include/furi-hal-rfid.h @@ -11,19 +11,19 @@ extern "C" { * @brief config rfid pins to reset state * */ -void api_hal_rfid_pins_reset(); +void furi_hal_rfid_pins_reset(); /** * @brief config rfid pins to emulate state * */ -void api_hal_rfid_pins_emulate(); +void furi_hal_rfid_pins_emulate(); /** * @brief config rfid pins to read state * */ -void api_hal_rfid_pins_read(); +void furi_hal_rfid_pins_read(); /** * @brief config rfid timer to read state @@ -31,86 +31,86 @@ void api_hal_rfid_pins_read(); * @param freq timer frequency * @param duty_cycle timer duty cycle, 0.0-1.0 */ -void api_hal_rfid_tim_read(float freq, float duty_cycle); +void furi_hal_rfid_tim_read(float freq, float duty_cycle); /** * @brief start read timer * */ -void api_hal_rfid_tim_read_start(); +void furi_hal_rfid_tim_read_start(); /** * @brief stop read timer * */ -void api_hal_rfid_tim_read_stop(); +void furi_hal_rfid_tim_read_stop(); /** * @brief config rfid timer to emulate state * * @param freq timer frequency */ -void api_hal_rfid_tim_emulate(float freq); +void furi_hal_rfid_tim_emulate(float freq); /** * @brief start emulation timer * */ -void api_hal_rfid_tim_emulate_start(); +void furi_hal_rfid_tim_emulate_start(); /** * @brief stop emulation timer * */ -void api_hal_rfid_tim_emulate_stop(); +void furi_hal_rfid_tim_emulate_stop(); /** * @brief config rfid timers to reset state * */ -void api_hal_rfid_tim_reset(); +void furi_hal_rfid_tim_reset(); /** * @brief check that timer instance is emulation timer * * @param hw timer instance */ -bool api_hal_rfid_is_tim_emulate(TIM_HandleTypeDef* hw); +bool furi_hal_rfid_is_tim_emulate(TIM_HandleTypeDef* hw); /** * @brief set emulation timer period * * @param period overall duration */ -void api_hal_rfid_set_emulate_period(uint32_t period); +void furi_hal_rfid_set_emulate_period(uint32_t period); /** * @brief set emulation timer pulse * * @param pulse duration of high level */ -void api_hal_rfid_set_emulate_pulse(uint32_t pulse); +void furi_hal_rfid_set_emulate_pulse(uint32_t pulse); /** * @brief set read timer period * * @param period overall duration */ -void api_hal_rfid_set_read_period(uint32_t period); +void furi_hal_rfid_set_read_period(uint32_t period); /** * @brief set read timer pulse * * @param pulse duration of high level */ -void api_hal_rfid_set_read_pulse(uint32_t pulse); +void furi_hal_rfid_set_read_pulse(uint32_t pulse); /** * Сhanges the configuration of the RFID timer "on a fly" * @param freq new frequency * @param duty_cycle new duty cycle */ -void api_hal_rfid_change_read_config(float freq, float duty_cycle); +void furi_hal_rfid_change_read_config(float freq, float duty_cycle); #ifdef __cplusplus } diff --git a/firmware/targets/api-hal-include/api-hal-sd.h b/firmware/targets/furi-hal-include/furi-hal-sd.h similarity index 100% rename from firmware/targets/api-hal-include/api-hal-sd.h rename to firmware/targets/furi-hal-include/furi-hal-sd.h diff --git a/firmware/targets/api-hal-include/api-hal-subghz.h b/firmware/targets/furi-hal-include/furi-hal-subghz.h similarity index 59% rename from firmware/targets/api-hal-include/api-hal-subghz.h rename to firmware/targets/furi-hal-include/furi-hal-subghz.h index d6aa1f8b..683bf709 100644 --- a/firmware/targets/api-hal-include/api-hal-subghz.h +++ b/firmware/targets/furi-hal-include/furi-hal-subghz.h @@ -11,16 +11,16 @@ extern "C" { /** Radio Presets */ typedef enum { - ApiHalSubGhzPresetOokAsync, /** OOK, asynchronous */ -} ApiHalSubGhzPreset; + FuriHalSubGhzPresetOokAsync, /** OOK, asynchronous */ +} FuriHalSubGhzPreset; /** Switchable Radio Paths */ typedef enum { - ApiHalSubGhzPathIsolate, /** Isolate Radio from antenna */ - ApiHalSubGhzPath433, /** Center Frquency: 433MHz. Path 1: SW1RF1-SW2RF2, LCLCL */ - ApiHalSubGhzPath315, /** Center Frquency: 315MHz. Path 2: SW1RF2-SW2RF1, LCLCLCL */ - ApiHalSubGhzPath868, /** Center Frquency: 868MHz. Path 3: SW1RF3-SW2RF3, LCLC */ -} ApiHalSubGhzPath; + FuriHalSubGhzPathIsolate, /** Isolate Radio from antenna */ + FuriHalSubGhzPath433, /** Center Frquency: 433MHz. Path 1: SW1RF1-SW2RF2, LCLCL */ + FuriHalSubGhzPath315, /** Center Frquency: 315MHz. Path 2: SW1RF2-SW2RF1, LCLCLCL */ + FuriHalSubGhzPath868, /** Center Frquency: 868MHz. Path 3: SW1RF3-SW2RF3, LCLC */ +} FuriHalSubGhzPath; /** SubGhz state */ typedef enum { @@ -39,133 +39,133 @@ typedef enum { * Used by internal API-HAL initalization routine * Can be used to reinitialize device to safe state and send it to sleep */ -void api_hal_subghz_init(); +void furi_hal_subghz_init(); /** Send device to sleep mode */ -void api_hal_subghz_sleep(); +void furi_hal_subghz_sleep(); /** Dump info to stdout */ -void api_hal_subghz_dump_state(); +void furi_hal_subghz_dump_state(); /** Load registers from preset by preset name * @param preset to load */ -void api_hal_subghz_load_preset(ApiHalSubGhzPreset preset); +void furi_hal_subghz_load_preset(FuriHalSubGhzPreset preset); /** Get status */ -uint8_t api_hal_subghz_get_status(); +uint8_t furi_hal_subghz_get_status(); /** Load registers * @param register-value pairs array, terminated with {0,0} */ -void api_hal_subghz_load_registers(const uint8_t data[][2]); +void furi_hal_subghz_load_registers(const uint8_t data[][2]); /** Load PATABLE * @param data, 8 uint8_t values */ -void api_hal_subghz_load_patable(const uint8_t data[8]); +void furi_hal_subghz_load_patable(const uint8_t data[8]); /** Write packet to FIFO * @param data, bytes array * @param size, size */ -void api_hal_subghz_write_packet(const uint8_t* data, uint8_t size); +void furi_hal_subghz_write_packet(const uint8_t* data, uint8_t size); /** Read packet from FIFO * @param data, pointer * @param size, size */ -void api_hal_subghz_read_packet(uint8_t* data, uint8_t* size); +void furi_hal_subghz_read_packet(uint8_t* data, uint8_t* size); /** Flush rx FIFO buffer */ -void api_hal_subghz_flush_rx(); +void furi_hal_subghz_flush_rx(); /** Shutdown * Issue spwd command * @warning registers content will be lost */ -void api_hal_subghz_shutdown(); +void furi_hal_subghz_shutdown(); /** Reset * Issue reset command * @warning registers content will be lost */ -void api_hal_subghz_reset(); +void furi_hal_subghz_reset(); /** Switch to Idle */ -void api_hal_subghz_idle(); +void furi_hal_subghz_idle(); /** Switch to Recieve */ -void api_hal_subghz_rx(); +void furi_hal_subghz_rx(); /** Switch to Transmit */ -void api_hal_subghz_tx(); +void furi_hal_subghz_tx(); /** Get RSSI value in dBm */ -float api_hal_subghz_get_rssi(); +float furi_hal_subghz_get_rssi(); /** Check if frequency is in valid range * @return true if frequncy is valid, otherwise false */ -bool api_hal_subghz_is_frequency_valid(uint32_t value); +bool furi_hal_subghz_is_frequency_valid(uint32_t value); /** Set frequency and path * This function automatically selects antenna matching network * @param frequency in herz * @return real frequency in herz */ -uint32_t api_hal_subghz_set_frequency_and_path(uint32_t value); +uint32_t furi_hal_subghz_set_frequency_and_path(uint32_t value); /** Set frequency * @param frequency in herz * @return real frequency in herz */ -uint32_t api_hal_subghz_set_frequency(uint32_t value); +uint32_t furi_hal_subghz_set_frequency(uint32_t value); /** Set path * @param radio path to use */ -void api_hal_subghz_set_path(ApiHalSubGhzPath path); +void furi_hal_subghz_set_path(FuriHalSubGhzPath path); /* High Level API */ /** Signal Timings Capture callback */ -typedef void (*ApiHalSubGhzCaptureCallback)(bool level, uint32_t duration, void* context); +typedef void (*FuriHalSubGhzCaptureCallback)(bool level, uint32_t duration, void* context); /** Set signal timings capture callback * @param callback - your callback for front capture */ -void api_hal_subghz_set_async_rx_callback(ApiHalSubGhzCaptureCallback callback, void* context); +void furi_hal_subghz_set_async_rx_callback(FuriHalSubGhzCaptureCallback callback, void* context); /** Enable signal timings capture * Initializes GPIO and TIM2 for timings capture */ -void api_hal_subghz_start_async_rx(); +void furi_hal_subghz_start_async_rx(); /** Disable signal timings capture * Resets GPIO and TIM2 */ -void api_hal_subghz_stop_async_rx(); +void furi_hal_subghz_stop_async_rx(); /** Send buffer * Initializes GPIO, TIM2 and DMA1 for signal output * @param buffer - pointer to data buffer * @param buffer_size - buffer size in bytes */ -void api_hal_subghz_start_async_tx(uint32_t* buffer, size_t buffer_size, size_t repeat); +void furi_hal_subghz_start_async_tx(uint32_t* buffer, size_t buffer_size, size_t repeat); /** Get repeats left count for async tx * @return packets left to send */ -size_t api_hal_subghz_get_async_tx_repeat_left(); +size_t furi_hal_subghz_get_async_tx_repeat_left(); /** Wait for async transmission to complete */ -void api_hal_subghz_wait_async_tx(); +void furi_hal_subghz_wait_async_tx(); /** Stop async transmission and cleanup resources * Resets GPIO, TIM2, and DMA1 */ -void api_hal_subghz_stop_async_tx(); +void furi_hal_subghz_stop_async_tx(); #ifdef __cplusplus } diff --git a/firmware/targets/api-hal-include/api-hal-vcp.h b/firmware/targets/furi-hal-include/furi-hal-vcp.h similarity index 77% rename from firmware/targets/api-hal-include/api-hal-vcp.h rename to firmware/targets/furi-hal-include/furi-hal-vcp.h index 1baad0a0..1312b20c 100644 --- a/firmware/targets/api-hal-include/api-hal-vcp.h +++ b/firmware/targets/furi-hal-include/furi-hal-vcp.h @@ -12,7 +12,7 @@ extern "C" { * Init VCP HAL * Allocates ring buffer and initializes state */ -void api_hal_vcp_init(); +void furi_hal_vcp_init(); /** * Recieve data from VCP @@ -21,7 +21,7 @@ void api_hal_vcp_init(); * @param size - buffer size * @return items copied in buffer, 0 if channel closed */ -size_t api_hal_vcp_rx(uint8_t* buffer, size_t size); +size_t furi_hal_vcp_rx(uint8_t* buffer, size_t size); /** * Recieve data from VCP with timeout @@ -31,14 +31,14 @@ size_t api_hal_vcp_rx(uint8_t* buffer, size_t size); * @param timeout - rx timeout in ms * @return items copied in buffer, 0 if channel closed or timeout occurs */ -size_t api_hal_vcp_rx_with_timeout(uint8_t* buffer, size_t size, uint32_t timeout); +size_t furi_hal_vcp_rx_with_timeout(uint8_t* buffer, size_t size, uint32_t timeout); /** * Transmit data to VCP * @param buffer - pointer to buffer * @param size - buffer size */ -void api_hal_vcp_tx(const uint8_t* buffer, size_t size); +void furi_hal_vcp_tx(const uint8_t* buffer, size_t size); #ifdef __cplusplus } diff --git a/firmware/targets/furi-hal-include/furi-hal-version.h b/firmware/targets/furi-hal-include/furi-hal-version.h new file mode 100644 index 00000000..1cd702fc --- /dev/null +++ b/firmware/targets/furi-hal-include/furi-hal-version.h @@ -0,0 +1,90 @@ +#pragma once + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** Device Colors */ +typedef enum { + FuriHalVersionColorUnknown=0x00, + FuriHalVersionColorBlack=0x01, + FuriHalVersionColorWhite=0x02, +} FuriHalVersionColor; + +/** Device Regions */ +typedef enum { + FuriHalVersionRegionUnknown=0x00, + FuriHalVersionRegionEuRu=0x01, + FuriHalVersionRegionUsCaAu=0x02, + FuriHalVersionRegionJp=0x03, +} FuriHalVersionRegion; + +/** Init flipper version */ +void furi_hal_version_init(); + +/** Check target firmware version */ +bool furi_hal_version_do_i_belong_here(); + +/** Get model name */ +const char* furi_hal_version_get_model_name(); + +/** Get hardware version */ +const uint8_t furi_hal_version_get_hw_version(); + +/** Get hardware target */ +const uint8_t furi_hal_version_get_hw_target(); + +/** Get hardware body */ +const uint8_t furi_hal_version_get_hw_body(); + +/** Get hardware body color */ +const FuriHalVersionColor furi_hal_version_get_hw_color(); + +/** Get hardware connect */ +const uint8_t furi_hal_version_get_hw_connect(); + +/** Get hardware region */ +const FuriHalVersionRegion furi_hal_version_get_hw_region(); + +/** Get hardware timestamp */ +const uint32_t furi_hal_version_get_hw_timestamp(); + +/** Get pointer to target name */ +const char* furi_hal_version_get_name_ptr(); + +/** Get pointer to target device name */ +const char* furi_hal_version_get_device_name_ptr(); + +/** Get pointer to target ble local device name */ +const char* furi_hal_version_get_ble_local_device_name_ptr(); + +const uint8_t* furi_hal_version_get_ble_mac(); + +/** + * Get address of version structure of bootloader, stored in chip flash. + * + * @return Address of boot version structure. + */ +const struct Version* furi_hal_version_get_boot_version(void); + +/** + * Get address of version structure of firmware. + * + * @return Address of firmware version structure. + */ +const struct Version* furi_hal_version_get_firmware_version(void); + +/** Get platform UID size in bytes */ +size_t furi_hal_version_uid_size(); + +/** Get const pointer to UID */ +const uint8_t* furi_hal_version_uid(); + +#ifdef __cplusplus +} +#endif diff --git a/firmware/targets/api-hal-include/api-hal-vibro.h b/firmware/targets/furi-hal-include/furi-hal-vibro.h similarity index 64% rename from firmware/targets/api-hal-include/api-hal-vibro.h rename to firmware/targets/furi-hal-include/furi-hal-vibro.h index 088dbb40..6a7c4d36 100644 --- a/firmware/targets/api-hal-include/api-hal-vibro.h +++ b/firmware/targets/furi-hal-include/furi-hal-vibro.h @@ -2,17 +2,17 @@ #include #include -#include +#include #ifdef __cplusplus extern "C" { #endif /** Initialize vibro */ -void api_hal_vibro_init(); +void furi_hal_vibro_init(); /** Turn on/off vibro */ -void api_hal_vibro_on(bool value); +void furi_hal_vibro_on(bool value); #ifdef __cplusplus } diff --git a/firmware/targets/furi-hal-include/furi-hal.h b/firmware/targets/furi-hal-include/furi-hal.h new file mode 100644 index 00000000..dc5162b8 --- /dev/null +++ b/firmware/targets/furi-hal-include/furi-hal.h @@ -0,0 +1,32 @@ +#pragma once + +#ifdef __cplusplus +template struct STOP_EXTERNING_ME {}; +#endif + +#include "furi-hal-boot.h" +#include "furi-hal-clock.h" +#include "furi-hal-console.h" +#include "furi-hal-os.h" +#include "furi-hal-i2c.h" +#include "furi-hal-resources.h" +#include "furi-hal-gpio.h" +#include "furi-hal-light.h" +#include "furi-hal-delay.h" +#include "furi-hal-pwm.h" +#include "furi-hal-task.h" +#include "furi-hal-power.h" +#include "furi-hal-vcp.h" +#include "furi-hal-interrupt.h" +#include "furi-hal-version.h" +#include "furi-hal-bt.h" +#include "furi-hal-spi.h" +#include "furi-hal-flash.h" +#include "furi-hal-subghz.h" +#include "furi-hal-vibro.h" +#include "furi-hal-ibutton.h" +#include "furi-hal-rfid.h" +#include "furi-hal-nfc.h" + +/** Init furi-hal */ +void furi_hal_init(); diff --git a/lib/ST25RFAL002/platform.c b/lib/ST25RFAL002/platform.c index c63218ff..c3d7df9c 100644 --- a/lib/ST25RFAL002/platform.c +++ b/lib/ST25RFAL002/platform.c @@ -2,12 +2,12 @@ #include #include #include -#include +#include static osThreadAttr_t platform_irq_thread_attr; static volatile osThreadId_t platform_irq_thread_id = NULL; static volatile PlatformIrqCallback platform_irq_callback = NULL; -static ApiHalSpiDevice* platform_st25r3916 = NULL; +static FuriHalSpiDevice* platform_st25r3916 = NULL; static const GpioPin pin = {ST25R_INT_PORT, ST25R_INT_PIN}; void nfc_isr(void* _ctx) { @@ -52,11 +52,11 @@ HAL_StatusTypeDef platformSpiTxRx(const uint8_t *txBuf, uint8_t *rxBuf, uint16_t furi_assert(platform_st25r3916); bool ret = false; if (txBuf && rxBuf) { - ret = api_hal_spi_bus_trx(platform_st25r3916->bus, (uint8_t*)txBuf, rxBuf, len, 1000); + ret = furi_hal_spi_bus_trx(platform_st25r3916->bus, (uint8_t*)txBuf, rxBuf, len, 1000); } else if (txBuf) { - ret = api_hal_spi_bus_tx(platform_st25r3916->bus, (uint8_t*)txBuf, len, 1000); + ret = furi_hal_spi_bus_tx(platform_st25r3916->bus, (uint8_t*)txBuf, len, 1000); } else if (rxBuf) { - ret = api_hal_spi_bus_rx(platform_st25r3916->bus, (uint8_t*)rxBuf, len, 1000); + ret = furi_hal_spi_bus_rx(platform_st25r3916->bus, (uint8_t*)rxBuf, len, 1000); } if(!ret) { @@ -68,10 +68,10 @@ HAL_StatusTypeDef platformSpiTxRx(const uint8_t *txBuf, uint8_t *rxBuf, uint16_t } void platformProtectST25RComm() { - platform_st25r3916 = (ApiHalSpiDevice*)api_hal_spi_device_get(ApiHalSpiDeviceIdNfc); + platform_st25r3916 = (FuriHalSpiDevice*)furi_hal_spi_device_get(FuriHalSpiDeviceIdNfc); } void platformUnprotectST25RComm() { furi_assert(platform_st25r3916); - api_hal_spi_device_return(platform_st25r3916); + furi_hal_spi_device_return(platform_st25r3916); } diff --git a/lib/ST25RFAL002/platform.h b/lib/ST25RFAL002/platform.h index 4f6705b6..0acc4011 100644 --- a/lib/ST25RFAL002/platform.h +++ b/lib/ST25RFAL002/platform.h @@ -10,9 +10,9 @@ #include "math.h" #include "spi.h" #include "main.h" -#include -#include -#include +#include +#include +#include typedef void (*PlatformIrqCallback)(); void platformSetIrqCallback(PlatformIrqCallback cb); diff --git a/lib/app-template/app-template.h b/lib/app-template/app-template.h index 74c186b3..27949dd0 100644 --- a/lib/app-template/app-template.h +++ b/lib/app-template/app-template.h @@ -2,7 +2,7 @@ #include "callback-connector.h" #include -#include +#include #include #include diff --git a/lib/cyfral/cyfral_emulator.h b/lib/cyfral/cyfral_emulator.h index a8da7668..2ceaae89 100644 --- a/lib/cyfral/cyfral_emulator.h +++ b/lib/cyfral/cyfral_emulator.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include class CyfralTiming { public: diff --git a/lib/drivers/bq25896.c b/lib/drivers/bq25896.c index c07a710e..bcafcb6a 100644 --- a/lib/drivers/bq25896.c +++ b/lib/drivers/bq25896.c @@ -1,7 +1,7 @@ #include "bq25896.h" #include "bq25896_reg.h" -#include +#include #include uint8_t bit_reverse(uint8_t b) { @@ -13,9 +13,9 @@ uint8_t bit_reverse(uint8_t b) { bool bq25896_read(uint8_t address, uint8_t* data, size_t size) { bool ret; - with_api_hal_i2c( + with_furi_hal_i2c( bool, &ret, () { - return api_hal_i2c_trx( + return furi_hal_i2c_trx( POWER_I2C, BQ25896_ADDRESS, &address, 1, data, size, BQ25896_I2C_TIMEOUT); }); return ret; @@ -29,9 +29,9 @@ bool bq25896_read_reg(uint8_t address, uint8_t* data) { bool bq25896_write_reg(uint8_t address, uint8_t* data) { uint8_t buffer[2] = {address, *data}; bool ret; - with_api_hal_i2c( + with_furi_hal_i2c( bool, &ret, () { - return api_hal_i2c_tx(POWER_I2C, BQ25896_ADDRESS, buffer, 2, BQ25896_I2C_TIMEOUT); + return furi_hal_i2c_tx(POWER_I2C, BQ25896_ADDRESS, buffer, 2, BQ25896_I2C_TIMEOUT); }); return ret; } diff --git a/lib/drivers/bq27220.c b/lib/drivers/bq27220.c index 9c62f7a0..d83cae05 100644 --- a/lib/drivers/bq27220.c +++ b/lib/drivers/bq27220.c @@ -1,16 +1,16 @@ #include "bq27220.h" #include "bq27220_reg.h" -#include -#include +#include +#include #include uint16_t bq27220_read_word(uint8_t address) { uint8_t buffer[2] = {address}; uint16_t ret; - with_api_hal_i2c( + with_furi_hal_i2c( uint16_t, &ret, () { - if(api_hal_i2c_trx( + if(furi_hal_i2c_trx( POWER_I2C, BQ27220_ADDRESS, buffer, 1, buffer, 2, BQ27220_I2C_TIMEOUT)) { return *(uint16_t*)buffer; } else { @@ -22,13 +22,13 @@ uint16_t bq27220_read_word(uint8_t address) { bool bq27220_control(uint16_t control) { bool ret; - with_api_hal_i2c( + with_furi_hal_i2c( bool, &ret, () { uint8_t buffer[3]; buffer[0] = CommandControl; buffer[1] = control & 0xFF; buffer[2] = (control >> 8) & 0xFF; - return api_hal_i2c_tx(POWER_I2C, BQ27220_ADDRESS, buffer, 3, BQ27220_I2C_TIMEOUT); + return furi_hal_i2c_tx(POWER_I2C, BQ27220_ADDRESS, buffer, 3, BQ27220_I2C_TIMEOUT); }); return ret; } @@ -44,23 +44,23 @@ uint8_t bq27220_get_checksum(uint8_t* data, uint16_t len) { bool bq27220_set_parameter_u16(uint16_t address, uint16_t value) { bool ret; uint8_t buffer[5]; - with_api_hal_i2c( + with_furi_hal_i2c( bool, &ret, () { buffer[0] = CommandSelectSubclass; buffer[1] = address & 0xFF; buffer[2] = (address >> 8) & 0xFF; buffer[3] = (value >> 8) & 0xFF; buffer[4] = value & 0xFF; - return api_hal_i2c_tx(POWER_I2C, BQ27220_ADDRESS, buffer, 5, BQ27220_I2C_TIMEOUT); + return furi_hal_i2c_tx(POWER_I2C, BQ27220_ADDRESS, buffer, 5, BQ27220_I2C_TIMEOUT); }); delay_us(10000); uint8_t checksum = bq27220_get_checksum(&buffer[1], 4); - with_api_hal_i2c( + with_furi_hal_i2c( bool, &ret, () { buffer[0] = CommandMACDataSum; buffer[1] = checksum; buffer[2] = 6; - return api_hal_i2c_tx(POWER_I2C, BQ27220_ADDRESS, buffer, 3, BQ27220_I2C_TIMEOUT); + return furi_hal_i2c_tx(POWER_I2C, BQ27220_ADDRESS, buffer, 3, BQ27220_I2C_TIMEOUT); }); delay_us(10000); return ret; diff --git a/lib/drivers/cc1101.c b/lib/drivers/cc1101.c index c1f2a4d3..4e020b70 100644 --- a/lib/drivers/cc1101.c +++ b/lib/drivers/cc1101.c @@ -1,43 +1,43 @@ #include "cc1101.h" #include -#include +#include #include #include -CC1101Status cc1101_strobe(const ApiHalSpiDevice* device, uint8_t strobe) { +CC1101Status cc1101_strobe(const FuriHalSpiDevice* device, uint8_t strobe) { uint8_t tx[1] = { strobe }; CC1101Status rx[1] = { 0 }; hal_gpio_write(device->chip_select, false); while(hal_gpio_read(device->bus->miso)); - api_hal_spi_bus_trx(device->bus, tx, (uint8_t*)rx, 1, CC1101_TIMEOUT); + furi_hal_spi_bus_trx(device->bus, tx, (uint8_t*)rx, 1, CC1101_TIMEOUT); hal_gpio_write(device->chip_select, true); assert(rx[0].CHIP_RDYn == 0); return rx[0]; } -CC1101Status cc1101_write_reg(const ApiHalSpiDevice* device, uint8_t reg, uint8_t data) { +CC1101Status cc1101_write_reg(const FuriHalSpiDevice* device, uint8_t reg, uint8_t data) { uint8_t tx[2] = { reg, data }; CC1101Status rx[2] = { 0 }; hal_gpio_write(device->chip_select, false); while(hal_gpio_read(device->bus->miso)); - api_hal_spi_bus_trx(device->bus, tx, (uint8_t*)rx, 2, CC1101_TIMEOUT); + furi_hal_spi_bus_trx(device->bus, tx, (uint8_t*)rx, 2, CC1101_TIMEOUT); hal_gpio_write(device->chip_select, true); assert((rx[0].CHIP_RDYn|rx[1].CHIP_RDYn) == 0); return rx[1]; } -CC1101Status cc1101_read_reg(const ApiHalSpiDevice* device, uint8_t reg, uint8_t* data) { +CC1101Status cc1101_read_reg(const FuriHalSpiDevice* device, uint8_t reg, uint8_t* data) { assert(sizeof(CC1101Status) == 1); uint8_t tx[2] = { reg|CC1101_READ, 0}; CC1101Status rx[2] = { 0 }; hal_gpio_write(device->chip_select, false); while(hal_gpio_read(device->bus->miso)); - api_hal_spi_bus_trx(device->bus, tx, (uint8_t*)rx, 2, CC1101_TIMEOUT); + furi_hal_spi_bus_trx(device->bus, tx, (uint8_t*)rx, 2, CC1101_TIMEOUT); hal_gpio_write(device->chip_select, true); assert((rx[0].CHIP_RDYn) == 0); @@ -45,25 +45,25 @@ CC1101Status cc1101_read_reg(const ApiHalSpiDevice* device, uint8_t reg, uint8_t return rx[0]; } -uint8_t cc1101_get_partnumber(const ApiHalSpiDevice* device) { +uint8_t cc1101_get_partnumber(const FuriHalSpiDevice* device) { uint8_t partnumber=0; cc1101_read_reg(device, CC1101_STATUS_PARTNUM|CC1101_BURST, &partnumber); return partnumber; } -uint8_t cc1101_get_version(const ApiHalSpiDevice* device) { +uint8_t cc1101_get_version(const FuriHalSpiDevice* device) { uint8_t version=0; cc1101_read_reg(device, CC1101_STATUS_VERSION|CC1101_BURST, &version); return version; } -uint8_t cc1101_get_rssi(const ApiHalSpiDevice* device) { +uint8_t cc1101_get_rssi(const FuriHalSpiDevice* device) { uint8_t rssi=0; cc1101_read_reg(device, CC1101_STATUS_RSSI|CC1101_BURST, &rssi); return rssi; } -void cc1101_reset(const ApiHalSpiDevice* device) { +void cc1101_reset(const FuriHalSpiDevice* device) { hal_gpio_write(device->chip_select, false); delay_us(1000); hal_gpio_write(device->chip_select, true); @@ -71,39 +71,39 @@ void cc1101_reset(const ApiHalSpiDevice* device) { cc1101_strobe(device, CC1101_STROBE_SRES); } -CC1101Status cc1101_get_status(const ApiHalSpiDevice* device) { +CC1101Status cc1101_get_status(const FuriHalSpiDevice* device) { return cc1101_strobe(device, CC1101_STROBE_SNOP); } -void cc1101_shutdown(const ApiHalSpiDevice* device) { +void cc1101_shutdown(const FuriHalSpiDevice* device) { cc1101_strobe(device, CC1101_STROBE_SPWD); } -void cc1101_calibrate(const ApiHalSpiDevice* device) { +void cc1101_calibrate(const FuriHalSpiDevice* device) { cc1101_strobe(device, CC1101_STROBE_SCAL); } -void cc1101_switch_to_idle(const ApiHalSpiDevice* device) { +void cc1101_switch_to_idle(const FuriHalSpiDevice* device) { cc1101_strobe(device, CC1101_STROBE_SIDLE); } -void cc1101_switch_to_rx(const ApiHalSpiDevice* device) { +void cc1101_switch_to_rx(const FuriHalSpiDevice* device) { cc1101_strobe(device, CC1101_STROBE_SRX); } -void cc1101_switch_to_tx(const ApiHalSpiDevice* device) { +void cc1101_switch_to_tx(const FuriHalSpiDevice* device) { cc1101_strobe(device, CC1101_STROBE_STX); } -void cc1101_flush_rx(const ApiHalSpiDevice* device) { +void cc1101_flush_rx(const FuriHalSpiDevice* device) { cc1101_strobe(device, CC1101_STROBE_SFRX); } -void cc1101_flush_tx(const ApiHalSpiDevice* device) { +void cc1101_flush_tx(const FuriHalSpiDevice* device) { cc1101_strobe(device, CC1101_STROBE_SFTX); } -uint32_t cc1101_set_frequency(const ApiHalSpiDevice* device, uint32_t value) { +uint32_t cc1101_set_frequency(const FuriHalSpiDevice* device, uint32_t value) { uint64_t real_value = (uint64_t)value * CC1101_FDIV / CC1101_QUARTZ; // Sanity check @@ -118,7 +118,7 @@ uint32_t cc1101_set_frequency(const ApiHalSpiDevice* device, uint32_t value) { return (uint32_t)real_frequency; } -uint32_t cc1101_set_intermediate_frequency(const ApiHalSpiDevice* device, uint32_t value) { +uint32_t cc1101_set_intermediate_frequency(const FuriHalSpiDevice* device, uint32_t value) { uint64_t real_value = value * CC1101_IFDIV / CC1101_QUARTZ; assert((real_value & 0xFF) == real_value); @@ -129,7 +129,7 @@ uint32_t cc1101_set_intermediate_frequency(const ApiHalSpiDevice* device, uint32 return (uint32_t)real_frequency; } -void cc1101_set_pa_table(const ApiHalSpiDevice* device, const uint8_t value[8]) { +void cc1101_set_pa_table(const FuriHalSpiDevice* device, const uint8_t value[8]) { uint8_t tx[9] = { CC1101_PATABLE | CC1101_BURST }; CC1101Status rx[9] = { 0 }; @@ -137,13 +137,13 @@ void cc1101_set_pa_table(const ApiHalSpiDevice* device, const uint8_t value[8]) hal_gpio_write(device->chip_select, false); while(hal_gpio_read(device->bus->miso)); - api_hal_spi_bus_trx(device->bus, tx, (uint8_t*)rx, sizeof(rx), CC1101_TIMEOUT); + furi_hal_spi_bus_trx(device->bus, tx, (uint8_t*)rx, sizeof(rx), CC1101_TIMEOUT); hal_gpio_write(device->chip_select, true); assert((rx[0].CHIP_RDYn|rx[8].CHIP_RDYn) == 0); } -uint8_t cc1101_write_fifo(const ApiHalSpiDevice* device, const uint8_t* data, uint8_t size) { +uint8_t cc1101_write_fifo(const FuriHalSpiDevice* device, const uint8_t* data, uint8_t size) { uint8_t buff_tx[64]; uint8_t buff_rx[64]; buff_tx[0] = CC1101_FIFO | CC1101_BURST; @@ -154,7 +154,7 @@ uint8_t cc1101_write_fifo(const ApiHalSpiDevice* device, const uint8_t* data, ui // Wait IC to become ready while(hal_gpio_read(device->bus->miso)); // Tell IC what we want - api_hal_spi_bus_trx(device->bus, buff_tx, (uint8_t*) buff_rx, size + 1, CC1101_TIMEOUT); + furi_hal_spi_bus_trx(device->bus, buff_tx, (uint8_t*) buff_rx, size + 1, CC1101_TIMEOUT); // Finish transaction hal_gpio_write(device->chip_select, true); @@ -162,7 +162,7 @@ uint8_t cc1101_write_fifo(const ApiHalSpiDevice* device, const uint8_t* data, ui return size; } -uint8_t cc1101_read_fifo(const ApiHalSpiDevice* device, uint8_t* data, uint8_t* size) { +uint8_t cc1101_read_fifo(const FuriHalSpiDevice* device, uint8_t* data, uint8_t* size) { uint8_t buff_tx[64]; buff_tx[0] = CC1101_FIFO | CC1101_READ | CC1101_BURST; uint8_t buff_rx[2]; @@ -173,9 +173,9 @@ uint8_t cc1101_read_fifo(const ApiHalSpiDevice* device, uint8_t* data, uint8_t* while(hal_gpio_read(device->bus->miso)); // First byte - packet length - api_hal_spi_bus_trx(device->bus, buff_tx, buff_rx, 2, CC1101_TIMEOUT); + furi_hal_spi_bus_trx(device->bus, buff_tx, buff_rx, 2, CC1101_TIMEOUT); *size = buff_rx[2]; - api_hal_spi_bus_trx(device->bus, &buff_tx[1], data, *size, CC1101_TIMEOUT); + furi_hal_spi_bus_trx(device->bus, &buff_tx[1], data, *size, CC1101_TIMEOUT); cc1101_flush_rx(device); hal_gpio_write(device->chip_select, true); diff --git a/lib/drivers/cc1101.h b/lib/drivers/cc1101.h index 242ae70f..295e4b61 100644 --- a/lib/drivers/cc1101.h +++ b/lib/drivers/cc1101.h @@ -4,7 +4,7 @@ #include #include -#include +#include #ifdef __cplusplus extern "C" { @@ -13,131 +13,131 @@ extern "C" { /* Low level API */ /** Strobe command to the device - * @param device - pointer to ApiHalSpiDevice + * @param device - pointer to FuriHalSpiDevice * @param strobe - command to execute * @return device status */ -CC1101Status cc1101_strobe(const ApiHalSpiDevice* device, uint8_t strobe); +CC1101Status cc1101_strobe(const FuriHalSpiDevice* device, uint8_t strobe); /** Write device register - * @param device - pointer to ApiHalSpiDevice + * @param device - pointer to FuriHalSpiDevice * @param reg - register * @param data - data to write * @return device status */ -CC1101Status cc1101_write_reg(const ApiHalSpiDevice* device, uint8_t reg, uint8_t data); +CC1101Status cc1101_write_reg(const FuriHalSpiDevice* device, uint8_t reg, uint8_t data); /** Read device register - * @param device - pointer to ApiHalSpiDevice + * @param device - pointer to FuriHalSpiDevice * @param reg - register * @param[out] data - pointer to data * @return device status */ -CC1101Status cc1101_read_reg(const ApiHalSpiDevice* device, uint8_t reg, uint8_t* data); +CC1101Status cc1101_read_reg(const FuriHalSpiDevice* device, uint8_t reg, uint8_t* data); /* High level API */ /** Reset - * @param device - pointer to ApiHalSpiDevice + * @param device - pointer to FuriHalSpiDevice */ -void cc1101_reset(const ApiHalSpiDevice* device); +void cc1101_reset(const FuriHalSpiDevice* device); /** Get status - * @param device - pointer to ApiHalSpiDevice + * @param device - pointer to FuriHalSpiDevice */ -CC1101Status cc1101_get_status(const ApiHalSpiDevice* device); +CC1101Status cc1101_get_status(const FuriHalSpiDevice* device); /** Enable shutdown mode - * @param device - pointer to ApiHalSpiDevice + * @param device - pointer to FuriHalSpiDevice */ -void cc1101_shutdown(const ApiHalSpiDevice* device); +void cc1101_shutdown(const FuriHalSpiDevice* device); /** Get Partnumber - * @param device - pointer to ApiHalSpiDevice + * @param device - pointer to FuriHalSpiDevice */ -uint8_t cc1101_get_partnumber(const ApiHalSpiDevice* device); +uint8_t cc1101_get_partnumber(const FuriHalSpiDevice* device); /** Get Version - * @param device - pointer to ApiHalSpiDevice + * @param device - pointer to FuriHalSpiDevice */ -uint8_t cc1101_get_version(const ApiHalSpiDevice* device); +uint8_t cc1101_get_version(const FuriHalSpiDevice* device); /** Get raw RSSI value - * @param device - pointer to ApiHalSpiDevice + * @param device - pointer to FuriHalSpiDevice */ -uint8_t cc1101_get_rssi(const ApiHalSpiDevice* device); +uint8_t cc1101_get_rssi(const FuriHalSpiDevice* device); /** Calibrate oscillator - * @param device - pointer to ApiHalSpiDevice + * @param device - pointer to FuriHalSpiDevice */ -void cc1101_calibrate(const ApiHalSpiDevice* device); +void cc1101_calibrate(const FuriHalSpiDevice* device); /** Switch to idle - * @param device - pointer to ApiHalSpiDevice + * @param device - pointer to FuriHalSpiDevice */ -void cc1101_switch_to_idle(const ApiHalSpiDevice* device); +void cc1101_switch_to_idle(const FuriHalSpiDevice* device); /** Switch to RX - * @param device - pointer to ApiHalSpiDevice + * @param device - pointer to FuriHalSpiDevice */ -void cc1101_switch_to_rx(const ApiHalSpiDevice* device); +void cc1101_switch_to_rx(const FuriHalSpiDevice* device); /** Switch to TX - * @param device - pointer to ApiHalSpiDevice + * @param device - pointer to FuriHalSpiDevice */ -void cc1101_switch_to_tx(const ApiHalSpiDevice* device); +void cc1101_switch_to_tx(const FuriHalSpiDevice* device); /** Flush RX FIFO - * @param device - pointer to ApiHalSpiDevice + * @param device - pointer to FuriHalSpiDevice */ -void cc1101_flush_rx(const ApiHalSpiDevice* device); +void cc1101_flush_rx(const FuriHalSpiDevice* device); /** Flush TX FIFO - * @param device - pointer to ApiHalSpiDevice + * @param device - pointer to FuriHalSpiDevice */ -void cc1101_flush_tx(const ApiHalSpiDevice* device); +void cc1101_flush_tx(const FuriHalSpiDevice* device); /** Set Frequency - * @param device - pointer to ApiHalSpiDevice + * @param device - pointer to FuriHalSpiDevice * @param value - frequency in herz * @return real frequency that were synthesized */ -uint32_t cc1101_set_frequency(const ApiHalSpiDevice* device, uint32_t value); +uint32_t cc1101_set_frequency(const FuriHalSpiDevice* device, uint32_t value); /** Set Intermediate Frequency - * @param device - pointer to ApiHalSpiDevice + * @param device - pointer to FuriHalSpiDevice * @param value - frequency in herz * @return real inermediate frequency that were synthesized */ -uint32_t cc1101_set_intermediate_frequency(const ApiHalSpiDevice* device, uint32_t value); +uint32_t cc1101_set_intermediate_frequency(const FuriHalSpiDevice* device, uint32_t value); /** Set Power Amplifier level table, ramp - * @param device - pointer to ApiHalSpiDevice + * @param device - pointer to FuriHalSpiDevice * @param value - array of power level values */ -void cc1101_set_pa_table(const ApiHalSpiDevice* device, const uint8_t value[8]); +void cc1101_set_pa_table(const FuriHalSpiDevice* device, const uint8_t value[8]); /** Set Power Amplifier level table, ramp - * @param device - pointer to ApiHalSpiDevice + * @param device - pointer to FuriHalSpiDevice * @param value - array of power level values */ -void cc1101_set_pa_table(const ApiHalSpiDevice* device, const uint8_t value[8]); +void cc1101_set_pa_table(const FuriHalSpiDevice* device, const uint8_t value[8]); /** Write FIFO - * @param device - pointer to ApiHalSpiDevice + * @param device - pointer to FuriHalSpiDevice * @param data, pointer to byte array * @param size, write bytes count * @return size, written bytes count */ -uint8_t cc1101_write_fifo(const ApiHalSpiDevice* device, const uint8_t* data, uint8_t size); +uint8_t cc1101_write_fifo(const FuriHalSpiDevice* device, const uint8_t* data, uint8_t size); /** Read FIFO - * @param device - pointer to ApiHalSpiDevice + * @param device - pointer to FuriHalSpiDevice * @param data, pointer to byte array * @param size, bytes to read from fifo * @return size, read bytes count */ -uint8_t cc1101_read_fifo(const ApiHalSpiDevice* device, uint8_t* data, uint8_t* size); +uint8_t cc1101_read_fifo(const FuriHalSpiDevice* device, uint8_t* data, uint8_t* size); #ifdef __cplusplus } diff --git a/lib/drivers/lp5562.c b/lib/drivers/lp5562.c index 1f3f8e8b..954fa65e 100644 --- a/lib/drivers/lp5562.c +++ b/lib/drivers/lp5562.c @@ -1,15 +1,15 @@ #include "lp5562.h" #include "lp5562_reg.h" -#include +#include #include bool lp5562_write_reg(uint8_t address, uint8_t* data) { uint8_t buffer[2] = {address, *data}; bool ret; - with_api_hal_i2c( + with_furi_hal_i2c( bool, &ret, () { - return api_hal_i2c_tx(POWER_I2C, LP5562_ADDRESS, buffer, 2, LP5562_I2C_TIMEOUT); + return furi_hal_i2c_tx(POWER_I2C, LP5562_ADDRESS, buffer, 2, LP5562_I2C_TIMEOUT); }); return ret; } diff --git a/lib/irda/encoder_decoder/irda.c b/lib/irda/encoder_decoder/irda.c index da6e17d1..9f5df893 100644 --- a/lib/irda/encoder_decoder/irda.c +++ b/lib/irda/encoder_decoder/irda.c @@ -7,7 +7,7 @@ #include #include #include "irda_i.h" -#include +#include struct IrdaDecoderHandler { void** ctx; diff --git a/lib/irda/worker/irda_transmit.c b/lib/irda/worker/irda_transmit.c index d06bf460..89b193e4 100644 --- a/lib/irda/worker/irda_transmit.c +++ b/lib/irda/worker/irda_transmit.c @@ -3,8 +3,8 @@ #include #include #include -#include -#include +#include +#include static uint32_t irda_tx_number_of_transmissions = 0; static uint32_t irda_tx_raw_timings_index = 0; @@ -12,12 +12,12 @@ static uint32_t irda_tx_raw_timings_number = 0; static uint32_t irda_tx_raw_start_from_mark = 0; static bool irda_tx_raw_add_silence = false; -ApiHalIrdaTxGetDataState irda_get_raw_data_callback (void* context, uint32_t* duration, bool* level) { +FuriHalIrdaTxGetDataState irda_get_raw_data_callback (void* context, uint32_t* duration, bool* level) { furi_assert(duration); furi_assert(level); furi_assert(context); - ApiHalIrdaTxGetDataState state = ApiHalIrdaTxGetDataStateOk; + FuriHalIrdaTxGetDataState state = FuriHalIrdaTxGetDataStateOk; const uint32_t* timings = context; if (irda_tx_raw_add_silence && (irda_tx_raw_timings_index == 0)) { @@ -30,7 +30,7 @@ ApiHalIrdaTxGetDataState irda_get_raw_data_callback (void* context, uint32_t* du } if (irda_tx_raw_timings_number == irda_tx_raw_timings_index) { - state = ApiHalIrdaTxGetDataStateLastDone; + state = FuriHalIrdaTxGetDataStateLastDone; } return state; @@ -44,19 +44,19 @@ void irda_send_raw_ext(const uint32_t timings[], uint32_t timings_cnt, bool star irda_tx_raw_timings_index = 0; irda_tx_raw_timings_number = timings_cnt; irda_tx_raw_add_silence = start_from_mark; - api_hal_irda_async_tx_set_data_isr_callback(irda_get_raw_data_callback, (void*) timings); - api_hal_irda_async_tx_start(frequency, duty_cycle); - api_hal_irda_async_tx_wait_termination(); + furi_hal_irda_async_tx_set_data_isr_callback(irda_get_raw_data_callback, (void*) timings); + furi_hal_irda_async_tx_start(frequency, duty_cycle); + furi_hal_irda_async_tx_wait_termination(); - furi_assert(!api_hal_irda_is_busy()); + furi_assert(!furi_hal_irda_is_busy()); } void irda_send_raw(const uint32_t timings[], uint32_t timings_cnt, bool start_from_mark) { irda_send_raw_ext(timings, timings_cnt, start_from_mark, IRDA_COMMON_CARRIER_FREQUENCY, IRDA_COMMON_DUTY_CYCLE); } -ApiHalIrdaTxGetDataState irda_get_data_callback (void* context, uint32_t* duration, bool* level) { - ApiHalIrdaTxGetDataState state = ApiHalIrdaTxGetDataStateError; +FuriHalIrdaTxGetDataState irda_get_data_callback (void* context, uint32_t* duration, bool* level) { + FuriHalIrdaTxGetDataState state = FuriHalIrdaTxGetDataStateError; IrdaEncoderHandler* handler = context; IrdaStatus status = IrdaStatusError; @@ -65,17 +65,17 @@ ApiHalIrdaTxGetDataState irda_get_data_callback (void* context, uint32_t* durati } if (status == IrdaStatusError) { - state = ApiHalIrdaTxGetDataStateError; + state = FuriHalIrdaTxGetDataStateError; } else if (status == IrdaStatusOk) { - state = ApiHalIrdaTxGetDataStateOk; + state = FuriHalIrdaTxGetDataStateOk; } else if (status == IrdaStatusDone) { - state = ApiHalIrdaTxGetDataStateDone; + state = FuriHalIrdaTxGetDataStateDone; if (--irda_tx_number_of_transmissions == 0) { - state = ApiHalIrdaTxGetDataStateLastDone; + state = FuriHalIrdaTxGetDataStateLastDone; } } else { furi_assert(0); - state = ApiHalIrdaTxGetDataStateError; + state = FuriHalIrdaTxGetDataStateError; } return state; @@ -90,12 +90,12 @@ void irda_send(const IrdaMessage* message, int times) { irda_reset_encoder(handler, message); irda_tx_number_of_transmissions = times; - api_hal_irda_async_tx_set_data_isr_callback(irda_get_data_callback, handler); - api_hal_irda_async_tx_start(IRDA_COMMON_CARRIER_FREQUENCY, IRDA_COMMON_DUTY_CYCLE); - api_hal_irda_async_tx_wait_termination(); + furi_hal_irda_async_tx_set_data_isr_callback(irda_get_data_callback, handler); + furi_hal_irda_async_tx_start(IRDA_COMMON_CARRIER_FREQUENCY, IRDA_COMMON_DUTY_CYCLE); + furi_hal_irda_async_tx_wait_termination(); irda_free_encoder(handler); - furi_assert(!api_hal_irda_is_busy()); + furi_assert(!furi_hal_irda_is_busy()); } diff --git a/lib/irda/worker/irda_transmit.h b/lib/irda/worker/irda_transmit.h index 9d56019e..1a6edcc3 100644 --- a/lib/irda/worker/irda_transmit.h +++ b/lib/irda/worker/irda_transmit.h @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/lib/irda/worker/irda_worker.c b/lib/irda/worker/irda_worker.c index 45ea7dfc..da8b72fc 100644 --- a/lib/irda/worker/irda_worker.c +++ b/lib/irda/worker/irda_worker.c @@ -1,6 +1,6 @@ #include "irda_worker.h" #include -#include +#include #include #include #include @@ -190,19 +190,19 @@ void irda_worker_start(IrdaWorker* instance) { furi_thread_start(instance->thread); instance->worker_handle = furi_thread_get_thread_id(instance->thread); - api_hal_irda_async_rx_start(); - api_hal_irda_async_rx_set_timeout(IRDA_WORKER_RX_TIMEOUT); - api_hal_irda_async_rx_set_capture_isr_callback(irda_worker_rx_callback, instance); - api_hal_irda_async_rx_set_timeout_isr_callback(irda_worker_rx_timeout_callback, instance); + furi_hal_irda_async_rx_start(); + furi_hal_irda_async_rx_set_timeout(IRDA_WORKER_RX_TIMEOUT); + furi_hal_irda_async_rx_set_capture_isr_callback(irda_worker_rx_callback, instance); + furi_hal_irda_async_rx_set_timeout_isr_callback(irda_worker_rx_timeout_callback, instance); } void irda_worker_stop(IrdaWorker* instance) { furi_assert(instance); furi_assert(instance->worker_handle); - api_hal_irda_async_rx_set_timeout_isr_callback(NULL, NULL); - api_hal_irda_async_rx_set_capture_isr_callback(NULL, NULL); - api_hal_irda_async_rx_stop(); + furi_hal_irda_async_rx_set_timeout_isr_callback(NULL, NULL); + furi_hal_irda_async_rx_set_capture_isr_callback(NULL, NULL); + furi_hal_irda_async_rx_stop(); xTaskNotify(instance->worker_handle, IRDA_WORKER_EXIT, eSetBits); diff --git a/lib/irda/worker/irda_worker.h b/lib/irda/worker/irda_worker.h index caac873d..92b48725 100644 --- a/lib/irda/worker/irda_worker.h +++ b/lib/irda/worker/irda_worker.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #ifdef __cplusplus extern "C" { @@ -41,13 +41,13 @@ void irda_worker_set_received_signal_callback(IrdaWorker* instance, IrdaWorkerRe */ void irda_worker_set_context(IrdaWorker* instance, void* context); -/** Start IrdaWorker thread, initialise api-hal, prepare all work. +/** Start IrdaWorker thread, initialise furi-hal, prepare all work. * * @param[in] instance - IrdaWorker instance */ void irda_worker_start(IrdaWorker* instance); -/** Stop IrdaWorker thread, deinitialize api-hal. +/** Stop IrdaWorker thread, deinitialize furi-hal. * * @param[in] instance - IrdaWorker instance */ diff --git a/lib/onewire/blanks_writer.cpp b/lib/onewire/blanks_writer.cpp index 651511f8..bfd3fe92 100644 --- a/lib/onewire/blanks_writer.cpp +++ b/lib/onewire/blanks_writer.cpp @@ -40,7 +40,7 @@ public: #include #include #include -#include +#include void BlanksWriter::onewire_release(void) { hal_gpio_write(gpio, true); diff --git a/lib/onewire/one_wire_master.h b/lib/onewire/one_wire_master.h index 3bdc8eaf..1075de98 100644 --- a/lib/onewire/one_wire_master.h +++ b/lib/onewire/one_wire_master.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include "one_wire_timings.h" class OneWireMaster { diff --git a/lib/onewire/one_wire_slave.h b/lib/onewire/one_wire_slave.h index 98d99ed1..95a9da57 100644 --- a/lib/onewire/one_wire_slave.h +++ b/lib/onewire/one_wire_slave.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include "one_wire_timings.h" class OneWireDevice; diff --git a/lib/subghz/protocols/subghz_protocol_common.h b/lib/subghz/protocols/subghz_protocol_common.h index cd4c9ec8..298bdeb7 100644 --- a/lib/subghz/protocols/subghz_protocol_common.h +++ b/lib/subghz/protocols/subghz_protocol_common.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #define bit_read(value, bit) (((value) >> (bit)) & 0x01) diff --git a/lib/subghz/subghz_worker.h b/lib/subghz/subghz_worker.h index 53af3102..6ef10190 100644 --- a/lib/subghz/subghz_worker.h +++ b/lib/subghz/subghz_worker.h @@ -1,6 +1,6 @@ #pragma once -#include +#include typedef struct SubGhzWorker SubGhzWorker;