Skip to content

Commit

Permalink
Furi: core refactoring and CMSIS removal part 2 (#1410)
Browse files Browse the repository at this point in the history
* Furi: rename and move core
* Furi: drop CMSIS_OS header and unused api, partially refactor and cleanup the rest
* Furi: CMSIS_OS drop and refactoring.
* Furi: refactoring, remove cmsis legacy
* Furi: fix incorrect assert on queue deallocation, cleanup timer
* Furi: improve delay api, get rid of floats
* hal: dropped furi_hal_crc
* Furi: move DWT based delay to cortex HAL
* Furi: update core documentation

Co-authored-by: hedger <[email protected]>
  • Loading branch information
skotopes and hedger authored Jul 20, 2022
1 parent f9c2287 commit e3c7201
Show file tree
Hide file tree
Showing 264 changed files with 2,569 additions and 3,883 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
/assets/ @skotopes @DrZlo13 @hedger

# Furi Core
/core/ @skotopes @DrZlo13 @hedger
/furi/ @skotopes @DrZlo13 @hedger

# Debug tools and plugins
/debug/ @skotopes @DrZlo13 @hedger
Expand Down
2 changes: 1 addition & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Connect your device via ST-Link and run:

- `applications` - Applications and services used in firmware
- `assets` - Assets used by applications and services
- `core` - Furi Core: os level primitives and helpers
- `furi` - Furi Core: os level primitives and helpers
- `debug` - Debug tool: GDB-plugins, SVD-file and etc
- `docker` - Docker image sources (used for firmware build automation)
- `documentation` - Documentation generation system configs and input files
Expand Down
10 changes: 5 additions & 5 deletions applications/accessor/accessor_view_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <callback-connector.h>

AccessorAppViewManager::AccessorAppViewManager() {
event_queue = osMessageQueueNew(10, sizeof(AccessorEvent), NULL);
event_queue = furi_message_queue_alloc(10, sizeof(AccessorEvent));

view_dispatcher = view_dispatcher_alloc();
auto callback = cbc::obtain_connector(this, &AccessorAppViewManager::previous_view_callback);
Expand Down Expand Up @@ -38,7 +38,7 @@ AccessorAppViewManager::~AccessorAppViewManager() {
view_dispatcher_free(view_dispatcher);

// free event queue
osMessageQueueDelete(event_queue);
furi_message_queue_free(event_queue);
}

void AccessorAppViewManager::switch_to(ViewType type) {
Expand All @@ -54,14 +54,14 @@ Popup* AccessorAppViewManager::get_popup() {
}

void AccessorAppViewManager::receive_event(AccessorEvent* event) {
if(osMessageQueueGet(event_queue, event, NULL, 100) != osOK) {
if(furi_message_queue_get(event_queue, event, 100) != FuriStatusOk) {
event->type = AccessorEvent::Type::Tick;
}
}

void AccessorAppViewManager::send_event(AccessorEvent* event) {
osStatus_t result = osMessageQueuePut(event_queue, event, 0, 0);
furi_check(result == osOK);
FuriStatus result = furi_message_queue_put(event_queue, event, 0);
furi_check(result == FuriStatusOk);
}

uint32_t AccessorAppViewManager::previous_view_callback(void*) {
Expand Down
2 changes: 1 addition & 1 deletion applications/accessor/accessor_view_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AccessorAppViewManager {
Tune,
};

osMessageQueueId_t event_queue;
FuriMessageQueue* event_queue;

AccessorAppViewManager();
~AccessorAppViewManager();
Expand Down
4 changes: 2 additions & 2 deletions applications/archive/helpers/archive_browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include "archive_files.h"
#include "archive_apps.h"
#include "archive_browser.h"
#include "furi/common_defines.h"
#include "furi/log.h"
#include <core/common_defines.h>
#include <core/log.h>
#include "gui/modules/file_browser_worker.h"
#include "m-string.h"
#include <math.h>
Expand Down
22 changes: 11 additions & 11 deletions applications/bad_usb/bad_usb_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ static int32_t bad_usb_worker(void* context) {

} else if(worker_state == BadUsbStateNotConnected) { // State: USB not connected
uint32_t flags = furi_thread_flags_wait(
WorkerEvtEnd | WorkerEvtConnect, osFlagsWaitAny, osWaitForever);
furi_check((flags & osFlagsError) == 0);
WorkerEvtEnd | WorkerEvtConnect, FuriFlagWaitAny, FuriWaitForever);
furi_check((flags & FuriFlagError) == 0);
if(flags & WorkerEvtEnd) {
break;
} else if(flags & WorkerEvtConnect) {
Expand All @@ -497,9 +497,9 @@ static int32_t bad_usb_worker(void* context) {
} else if(worker_state == BadUsbStateIdle) { // State: ready to start
uint32_t flags = furi_thread_flags_wait(
WorkerEvtEnd | WorkerEvtToggle | WorkerEvtDisconnect,
osFlagsWaitAny,
osWaitForever);
furi_check((flags & osFlagsError) == 0);
FuriFlagWaitAny,
FuriWaitForever);
furi_check((flags & FuriFlagError) == 0);
if(flags & WorkerEvtEnd) {
break;
} else if(flags & WorkerEvtToggle) { // Start executing script
Expand All @@ -520,9 +520,9 @@ static int32_t bad_usb_worker(void* context) {
} else if(worker_state == BadUsbStateRunning) { // State: running
uint16_t delay_cur = (delay_val > 1000) ? (1000) : (delay_val);
uint32_t flags = furi_thread_flags_wait(
WorkerEvtEnd | WorkerEvtToggle | WorkerEvtDisconnect, osFlagsWaitAny, delay_cur);
WorkerEvtEnd | WorkerEvtToggle | WorkerEvtDisconnect, FuriFlagWaitAny, delay_cur);
delay_val -= delay_cur;
if(!(flags & osFlagsError)) {
if(!(flags & FuriFlagError)) {
if(flags & WorkerEvtEnd) {
break;
} else if(flags & WorkerEvtToggle) {
Expand All @@ -534,7 +534,7 @@ static int32_t bad_usb_worker(void* context) {
}
bad_usb->st.state = worker_state;
continue;
} else if((flags == osFlagsErrorTimeout) || (flags == osFlagsErrorResource)) {
} else if((flags == FuriFlagErrorTimeout) || (flags == FuriFlagErrorResource)) {
if(delay_val > 0) {
bad_usb->st.delay_remain--;
continue;
Expand All @@ -556,15 +556,15 @@ static int32_t bad_usb_worker(void* context) {
bad_usb->st.delay_remain = delay_val / 1000;
}
} else {
furi_check((flags & osFlagsError) == 0);
furi_check((flags & FuriFlagError) == 0);
}

} else if(
(worker_state == BadUsbStateFileError) ||
(worker_state == BadUsbStateScriptError)) { // State: error
uint32_t flags = furi_thread_flags_wait(
WorkerEvtEnd, osFlagsWaitAny, osWaitForever); // Waiting for exit command
furi_check((flags & osFlagsError) == 0);
WorkerEvtEnd, FuriFlagWaitAny, FuriWaitForever); // Waiting for exit command
furi_check((flags & FuriFlagError) == 0);
if(flags & WorkerEvtEnd) {
break;
}
Expand Down
8 changes: 4 additions & 4 deletions applications/bt/bt_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static void bt_cli_command_carrier_tx(Cli* cli, string_t args, void* context) {
furi_hal_bt_start_tone_tx(channel, 0x19 + power);

while(!cli_cmd_interrupt_received(cli)) {
osDelay(250);
furi_delay_ms(250);
}
furi_hal_bt_stop_tone_tx();

Expand Down Expand Up @@ -69,7 +69,7 @@ static void bt_cli_command_carrier_rx(Cli* cli, string_t args, void* context) {
furi_hal_bt_start_packet_rx(channel, 1);

while(!cli_cmd_interrupt_received(cli)) {
osDelay(250);
furi_delay_ms(250);
printf("RSSI: %6.1f dB\r", (double)furi_hal_bt_get_rssi());
fflush(stdout);
}
Expand Down Expand Up @@ -119,7 +119,7 @@ static void bt_cli_command_packet_tx(Cli* cli, string_t args, void* context) {
furi_hal_bt_start_packet_tx(channel, pattern, datarate);

while(!cli_cmd_interrupt_received(cli)) {
osDelay(250);
furi_delay_ms(250);
}
furi_hal_bt_stop_packet_test();
printf("Transmitted %lu packets", furi_hal_bt_get_transmitted_packets());
Expand Down Expand Up @@ -152,7 +152,7 @@ static void bt_cli_command_packet_rx(Cli* cli, string_t args, void* context) {
furi_hal_bt_start_packet_rx(channel, datarate);

while(!cli_cmd_interrupt_received(cli)) {
osDelay(250);
furi_delay_ms(250);
printf("RSSI: %03.1f dB\r", (double)furi_hal_bt_get_rssi());
fflush(stdout);
}
Expand Down
14 changes: 7 additions & 7 deletions applications/bt/bt_debug_app/views/bt_carrier_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct BtCarrierTest {
BtTestMode mode;
BtTestChannel channel;
BtTestPower power;
osTimerId_t timer;
FuriTimer* timer;
};

static BtTestParamValue bt_param_mode[] = {
Expand All @@ -35,10 +35,10 @@ static void bt_carrier_test_start(BtCarrierTest* bt_carrier_test) {
furi_assert(bt_carrier_test);
if(bt_carrier_test->mode == BtTestModeRx) {
furi_hal_bt_start_packet_rx(bt_carrier_test->channel, 1);
osTimerStart(bt_carrier_test->timer, osKernelGetTickFreq() / 4);
furi_timer_start(bt_carrier_test->timer, furi_kernel_get_tick_frequency() / 4);
} else if(bt_carrier_test->mode == BtTestModeTxHopping) {
furi_hal_bt_start_tone_tx(bt_carrier_test->channel, bt_carrier_test->power);
osTimerStart(bt_carrier_test->timer, osKernelGetTickFreq() * 2);
furi_timer_start(bt_carrier_test->timer, furi_kernel_get_tick_frequency() * 2);
} else if(bt_carrier_test->mode == BtTestModeTx) {
furi_hal_bt_start_tone_tx(bt_carrier_test->channel, bt_carrier_test->power);
}
Expand Down Expand Up @@ -68,12 +68,12 @@ static void bt_carrier_test_stop(BtCarrierTest* bt_carrier_test) {
furi_assert(bt_carrier_test);
if(bt_carrier_test->mode == BtTestModeTxHopping) {
furi_hal_bt_stop_tone_tx();
osTimerStop(bt_carrier_test->timer);
furi_timer_stop(bt_carrier_test->timer);
} else if(bt_carrier_test->mode == BtTestModeTx) {
furi_hal_bt_stop_tone_tx();
} else if(bt_carrier_test->mode == BtTestModeRx) {
furi_hal_bt_stop_packet_test();
osTimerStop(bt_carrier_test->timer);
furi_timer_stop(bt_carrier_test->timer);
}
}

Expand Down Expand Up @@ -170,15 +170,15 @@ BtCarrierTest* bt_carrier_test_alloc() {
bt_carrier_test->power = BtPower0dB;

bt_carrier_test->timer =
osTimerNew(bt_test_carrier_timer_callback, osTimerPeriodic, bt_carrier_test, NULL);
furi_timer_alloc(bt_test_carrier_timer_callback, FuriTimerTypePeriodic, bt_carrier_test);

return bt_carrier_test;
}

void bt_carrier_test_free(BtCarrierTest* bt_carrier_test) {
furi_assert(bt_carrier_test);
bt_test_free(bt_carrier_test->bt_test);
osTimerDelete(bt_carrier_test->timer);
furi_timer_free(bt_carrier_test->timer);
free(bt_carrier_test);
}

Expand Down
10 changes: 5 additions & 5 deletions applications/bt/bt_debug_app/views/bt_packet_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct BtPacketTest {
BtTestMode mode;
BtTestChannel channel;
BtTestDataRate data_rate;
osTimerId_t timer;
FuriTimer* timer;
};

static BtTestParamValue bt_param_mode[] = {
Expand All @@ -31,7 +31,7 @@ static void bt_packet_test_start(BtPacketTest* bt_packet_test) {
furi_assert(bt_packet_test);
if(bt_packet_test->mode == BtTestModeRx) {
furi_hal_bt_start_packet_rx(bt_packet_test->channel, bt_packet_test->data_rate);
osTimerStart(bt_packet_test->timer, osKernelGetTickFreq() / 4);
furi_timer_start(bt_packet_test->timer, furi_kernel_get_tick_frequency() / 4);
} else if(bt_packet_test->mode == BtTestModeTx) {
furi_hal_bt_start_packet_tx(bt_packet_test->channel, 1, bt_packet_test->data_rate);
}
Expand All @@ -44,7 +44,7 @@ static void bt_packet_test_stop(BtPacketTest* bt_packet_test) {
bt_test_set_packets_tx(bt_packet_test->bt_test, furi_hal_bt_get_transmitted_packets());
} else if(bt_packet_test->mode == BtTestModeRx) {
bt_test_set_packets_rx(bt_packet_test->bt_test, furi_hal_bt_stop_packet_test());
osTimerStop(bt_packet_test->timer);
furi_timer_stop(bt_packet_test->timer);
}
}

Expand Down Expand Up @@ -137,15 +137,15 @@ BtPacketTest* bt_packet_test_alloc() {
bt_packet_test->data_rate = BtDataRate1M;

bt_packet_test->timer =
osTimerNew(bt_test_packet_timer_callback, osTimerPeriodic, bt_packet_test, NULL);
furi_timer_alloc(bt_test_packet_timer_callback, FuriTimerTypePeriodic, bt_packet_test);

return bt_packet_test;
}

void bt_packet_test_free(BtPacketTest* bt_packet_test) {
furi_assert(bt_packet_test);
bt_test_free(bt_packet_test->bt_test);
osTimerDelete(bt_packet_test->timer);
furi_timer_free(bt_packet_test->timer);
free(bt_packet_test);
}

Expand Down
Loading

0 comments on commit e3c7201

Please sign in to comment.