mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-22 12:33:11 +00:00
Furi: core refactoring and CMSIS removal part 2 (#1410)
* Furi: rename and move core * Furi: drop CMSIS_OS header and unused api, partially refactor and cleanup the rest * Furi: CMSIS_OS drop and refactoring. * Furi: refactoring, remove cmsis legacy * Furi: fix incorrect assert on queue deallocation, cleanup timer * Furi: improve delay api, get rid of floats * hal: dropped furi_hal_crc * Furi: move DWT based delay to cortex HAL * Furi: update core documentation Co-authored-by: hedger <hedger@nanode.su>
This commit is contained in:
parent
f9c2287ea7
commit
e3c7201a20
264 changed files with 2569 additions and 3883 deletions
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <callback-connector.h>
|
||||
|
||||
AccessorAppViewManager::AccessorAppViewManager() {
|
||||
event_queue = osMessageQueueNew(10, sizeof(AccessorEvent), NULL);
|
||||
event_queue = furi_message_queue_alloc(10, sizeof(AccessorEvent));
|
||||
|
||||
view_dispatcher = view_dispatcher_alloc();
|
||||
auto callback = cbc::obtain_connector(this, &AccessorAppViewManager::previous_view_callback);
|
||||
|
@ -38,7 +38,7 @@ AccessorAppViewManager::~AccessorAppViewManager() {
|
|||
view_dispatcher_free(view_dispatcher);
|
||||
|
||||
// free event queue
|
||||
osMessageQueueDelete(event_queue);
|
||||
furi_message_queue_free(event_queue);
|
||||
}
|
||||
|
||||
void AccessorAppViewManager::switch_to(ViewType type) {
|
||||
|
@ -54,14 +54,14 @@ Popup* AccessorAppViewManager::get_popup() {
|
|||
}
|
||||
|
||||
void AccessorAppViewManager::receive_event(AccessorEvent* event) {
|
||||
if(osMessageQueueGet(event_queue, event, NULL, 100) != osOK) {
|
||||
if(furi_message_queue_get(event_queue, event, 100) != FuriStatusOk) {
|
||||
event->type = AccessorEvent::Type::Tick;
|
||||
}
|
||||
}
|
||||
|
||||
void AccessorAppViewManager::send_event(AccessorEvent* event) {
|
||||
osStatus_t result = osMessageQueuePut(event_queue, event, 0, 0);
|
||||
furi_check(result == osOK);
|
||||
FuriStatus result = furi_message_queue_put(event_queue, event, 0);
|
||||
furi_check(result == FuriStatusOk);
|
||||
}
|
||||
|
||||
uint32_t AccessorAppViewManager::previous_view_callback(void*) {
|
||||
|
|
|
@ -13,7 +13,7 @@ public:
|
|||
Tune,
|
||||
};
|
||||
|
||||
osMessageQueueId_t event_queue;
|
||||
FuriMessageQueue* event_queue;
|
||||
|
||||
AccessorAppViewManager();
|
||||
~AccessorAppViewManager();
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -485,8 +485,8 @@ static int32_t bad_usb_worker(void* context) {
|
|||
|
||||
} else if(worker_state == BadUsbStateNotConnected) { // State: USB not connected
|
||||
uint32_t flags = furi_thread_flags_wait(
|
||||
WorkerEvtEnd | WorkerEvtConnect, osFlagsWaitAny, osWaitForever);
|
||||
furi_check((flags & osFlagsError) == 0);
|
||||
WorkerEvtEnd | WorkerEvtConnect, FuriFlagWaitAny, FuriWaitForever);
|
||||
furi_check((flags & FuriFlagError) == 0);
|
||||
if(flags & WorkerEvtEnd) {
|
||||
break;
|
||||
} else if(flags & WorkerEvtConnect) {
|
||||
|
@ -497,9 +497,9 @@ static int32_t bad_usb_worker(void* context) {
|
|||
} else if(worker_state == BadUsbStateIdle) { // State: ready to start
|
||||
uint32_t flags = furi_thread_flags_wait(
|
||||
WorkerEvtEnd | WorkerEvtToggle | WorkerEvtDisconnect,
|
||||
osFlagsWaitAny,
|
||||
osWaitForever);
|
||||
furi_check((flags & osFlagsError) == 0);
|
||||
FuriFlagWaitAny,
|
||||
FuriWaitForever);
|
||||
furi_check((flags & FuriFlagError) == 0);
|
||||
if(flags & WorkerEvtEnd) {
|
||||
break;
|
||||
} else if(flags & WorkerEvtToggle) { // Start executing script
|
||||
|
@ -520,9 +520,9 @@ static int32_t bad_usb_worker(void* context) {
|
|||
} else if(worker_state == BadUsbStateRunning) { // State: running
|
||||
uint16_t delay_cur = (delay_val > 1000) ? (1000) : (delay_val);
|
||||
uint32_t flags = furi_thread_flags_wait(
|
||||
WorkerEvtEnd | WorkerEvtToggle | WorkerEvtDisconnect, osFlagsWaitAny, delay_cur);
|
||||
WorkerEvtEnd | WorkerEvtToggle | WorkerEvtDisconnect, FuriFlagWaitAny, delay_cur);
|
||||
delay_val -= delay_cur;
|
||||
if(!(flags & osFlagsError)) {
|
||||
if(!(flags & FuriFlagError)) {
|
||||
if(flags & WorkerEvtEnd) {
|
||||
break;
|
||||
} else if(flags & WorkerEvtToggle) {
|
||||
|
@ -534,7 +534,7 @@ static int32_t bad_usb_worker(void* context) {
|
|||
}
|
||||
bad_usb->st.state = worker_state;
|
||||
continue;
|
||||
} else if((flags == osFlagsErrorTimeout) || (flags == osFlagsErrorResource)) {
|
||||
} else if((flags == FuriFlagErrorTimeout) || (flags == FuriFlagErrorResource)) {
|
||||
if(delay_val > 0) {
|
||||
bad_usb->st.delay_remain--;
|
||||
continue;
|
||||
|
@ -556,15 +556,15 @@ static int32_t bad_usb_worker(void* context) {
|
|||
bad_usb->st.delay_remain = delay_val / 1000;
|
||||
}
|
||||
} else {
|
||||
furi_check((flags & osFlagsError) == 0);
|
||||
furi_check((flags & FuriFlagError) == 0);
|
||||
}
|
||||
|
||||
} else if(
|
||||
(worker_state == BadUsbStateFileError) ||
|
||||
(worker_state == BadUsbStateScriptError)) { // State: error
|
||||
uint32_t flags = furi_thread_flags_wait(
|
||||
WorkerEvtEnd, osFlagsWaitAny, osWaitForever); // Waiting for exit command
|
||||
furi_check((flags & osFlagsError) == 0);
|
||||
WorkerEvtEnd, FuriFlagWaitAny, FuriWaitForever); // Waiting for exit command
|
||||
furi_check((flags & FuriFlagError) == 0);
|
||||
if(flags & WorkerEvtEnd) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ static void bt_cli_command_carrier_tx(Cli* cli, string_t args, void* context) {
|
|||
furi_hal_bt_start_tone_tx(channel, 0x19 + power);
|
||||
|
||||
while(!cli_cmd_interrupt_received(cli)) {
|
||||
osDelay(250);
|
||||
furi_delay_ms(250);
|
||||
}
|
||||
furi_hal_bt_stop_tone_tx();
|
||||
|
||||
|
@ -69,7 +69,7 @@ static void bt_cli_command_carrier_rx(Cli* cli, string_t args, void* context) {
|
|||
furi_hal_bt_start_packet_rx(channel, 1);
|
||||
|
||||
while(!cli_cmd_interrupt_received(cli)) {
|
||||
osDelay(250);
|
||||
furi_delay_ms(250);
|
||||
printf("RSSI: %6.1f dB\r", (double)furi_hal_bt_get_rssi());
|
||||
fflush(stdout);
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ static void bt_cli_command_packet_tx(Cli* cli, string_t args, void* context) {
|
|||
furi_hal_bt_start_packet_tx(channel, pattern, datarate);
|
||||
|
||||
while(!cli_cmd_interrupt_received(cli)) {
|
||||
osDelay(250);
|
||||
furi_delay_ms(250);
|
||||
}
|
||||
furi_hal_bt_stop_packet_test();
|
||||
printf("Transmitted %lu packets", furi_hal_bt_get_transmitted_packets());
|
||||
|
@ -152,7 +152,7 @@ static void bt_cli_command_packet_rx(Cli* cli, string_t args, void* context) {
|
|||
furi_hal_bt_start_packet_rx(channel, datarate);
|
||||
|
||||
while(!cli_cmd_interrupt_received(cli)) {
|
||||
osDelay(250);
|
||||
furi_delay_ms(250);
|
||||
printf("RSSI: %03.1f dB\r", (double)furi_hal_bt_get_rssi());
|
||||
fflush(stdout);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ struct BtCarrierTest {
|
|||
BtTestMode mode;
|
||||
BtTestChannel channel;
|
||||
BtTestPower power;
|
||||
osTimerId_t timer;
|
||||
FuriTimer* timer;
|
||||
};
|
||||
|
||||
static BtTestParamValue bt_param_mode[] = {
|
||||
|
@ -35,10 +35,10 @@ static void bt_carrier_test_start(BtCarrierTest* bt_carrier_test) {
|
|||
furi_assert(bt_carrier_test);
|
||||
if(bt_carrier_test->mode == BtTestModeRx) {
|
||||
furi_hal_bt_start_packet_rx(bt_carrier_test->channel, 1);
|
||||
osTimerStart(bt_carrier_test->timer, osKernelGetTickFreq() / 4);
|
||||
furi_timer_start(bt_carrier_test->timer, furi_kernel_get_tick_frequency() / 4);
|
||||
} else if(bt_carrier_test->mode == BtTestModeTxHopping) {
|
||||
furi_hal_bt_start_tone_tx(bt_carrier_test->channel, bt_carrier_test->power);
|
||||
osTimerStart(bt_carrier_test->timer, osKernelGetTickFreq() * 2);
|
||||
furi_timer_start(bt_carrier_test->timer, furi_kernel_get_tick_frequency() * 2);
|
||||
} else if(bt_carrier_test->mode == BtTestModeTx) {
|
||||
furi_hal_bt_start_tone_tx(bt_carrier_test->channel, bt_carrier_test->power);
|
||||
}
|
||||
|
@ -68,12 +68,12 @@ static void bt_carrier_test_stop(BtCarrierTest* bt_carrier_test) {
|
|||
furi_assert(bt_carrier_test);
|
||||
if(bt_carrier_test->mode == BtTestModeTxHopping) {
|
||||
furi_hal_bt_stop_tone_tx();
|
||||
osTimerStop(bt_carrier_test->timer);
|
||||
furi_timer_stop(bt_carrier_test->timer);
|
||||
} else if(bt_carrier_test->mode == BtTestModeTx) {
|
||||
furi_hal_bt_stop_tone_tx();
|
||||
} else if(bt_carrier_test->mode == BtTestModeRx) {
|
||||
furi_hal_bt_stop_packet_test();
|
||||
osTimerStop(bt_carrier_test->timer);
|
||||
furi_timer_stop(bt_carrier_test->timer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ BtCarrierTest* bt_carrier_test_alloc() {
|
|||
bt_carrier_test->power = BtPower0dB;
|
||||
|
||||
bt_carrier_test->timer =
|
||||
osTimerNew(bt_test_carrier_timer_callback, osTimerPeriodic, bt_carrier_test, NULL);
|
||||
furi_timer_alloc(bt_test_carrier_timer_callback, FuriTimerTypePeriodic, bt_carrier_test);
|
||||
|
||||
return bt_carrier_test;
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ BtCarrierTest* bt_carrier_test_alloc() {
|
|||
void bt_carrier_test_free(BtCarrierTest* bt_carrier_test) {
|
||||
furi_assert(bt_carrier_test);
|
||||
bt_test_free(bt_carrier_test->bt_test);
|
||||
osTimerDelete(bt_carrier_test->timer);
|
||||
furi_timer_free(bt_carrier_test->timer);
|
||||
free(bt_carrier_test);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ struct BtPacketTest {
|
|||
BtTestMode mode;
|
||||
BtTestChannel channel;
|
||||
BtTestDataRate data_rate;
|
||||
osTimerId_t timer;
|
||||
FuriTimer* timer;
|
||||
};
|
||||
|
||||
static BtTestParamValue bt_param_mode[] = {
|
||||
|
@ -31,7 +31,7 @@ static void bt_packet_test_start(BtPacketTest* bt_packet_test) {
|
|||
furi_assert(bt_packet_test);
|
||||
if(bt_packet_test->mode == BtTestModeRx) {
|
||||
furi_hal_bt_start_packet_rx(bt_packet_test->channel, bt_packet_test->data_rate);
|
||||
osTimerStart(bt_packet_test->timer, osKernelGetTickFreq() / 4);
|
||||
furi_timer_start(bt_packet_test->timer, furi_kernel_get_tick_frequency() / 4);
|
||||
} else if(bt_packet_test->mode == BtTestModeTx) {
|
||||
furi_hal_bt_start_packet_tx(bt_packet_test->channel, 1, bt_packet_test->data_rate);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ static void bt_packet_test_stop(BtPacketTest* bt_packet_test) {
|
|||
bt_test_set_packets_tx(bt_packet_test->bt_test, furi_hal_bt_get_transmitted_packets());
|
||||
} else if(bt_packet_test->mode == BtTestModeRx) {
|
||||
bt_test_set_packets_rx(bt_packet_test->bt_test, furi_hal_bt_stop_packet_test());
|
||||
osTimerStop(bt_packet_test->timer);
|
||||
furi_timer_stop(bt_packet_test->timer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ BtPacketTest* bt_packet_test_alloc() {
|
|||
bt_packet_test->data_rate = BtDataRate1M;
|
||||
|
||||
bt_packet_test->timer =
|
||||
osTimerNew(bt_test_packet_timer_callback, osTimerPeriodic, bt_packet_test, NULL);
|
||||
furi_timer_alloc(bt_test_packet_timer_callback, FuriTimerTypePeriodic, bt_packet_test);
|
||||
|
||||
return bt_packet_test;
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ BtPacketTest* bt_packet_test_alloc() {
|
|||
void bt_packet_test_free(BtPacketTest* bt_packet_test) {
|
||||
furi_assert(bt_packet_test);
|
||||
bt_test_free(bt_packet_test->bt_test);
|
||||
osTimerDelete(bt_packet_test->timer);
|
||||
furi_timer_free(bt_packet_test->timer);
|
||||
free(bt_packet_test);
|
||||
}
|
||||
|
||||
|
|
|
@ -96,12 +96,14 @@ static void bt_battery_level_changed_callback(const void* _event, void* context)
|
|||
if(event->type == PowerEventTypeBatteryLevelChanged) {
|
||||
message.type = BtMessageTypeUpdateBatteryLevel;
|
||||
message.data.battery_level = event->data.battery_level;
|
||||
furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
|
||||
} else if(
|
||||
event->type == PowerEventTypeStartCharging || event->type == PowerEventTypeFullyCharged ||
|
||||
event->type == PowerEventTypeStopCharging) {
|
||||
message.type = BtMessageTypeUpdatePowerState;
|
||||
furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,7 +117,7 @@ Bt* bt_alloc() {
|
|||
bt_settings_save(&bt->bt_settings);
|
||||
}
|
||||
// Alloc queue
|
||||
bt->message_queue = osMessageQueueNew(8, sizeof(BtMessage), NULL);
|
||||
bt->message_queue = furi_message_queue_alloc(8, sizeof(BtMessage));
|
||||
|
||||
// Setup statusbar view port
|
||||
bt->statusbar_view_port = bt_statusbar_view_port_alloc(bt);
|
||||
|
@ -139,10 +141,10 @@ Bt* bt_alloc() {
|
|||
|
||||
// RPC
|
||||
bt->rpc = furi_record_open("rpc");
|
||||
bt->rpc_event = osEventFlagsNew(NULL);
|
||||
bt->rpc_event = furi_event_flag_alloc();
|
||||
|
||||
// API evnent
|
||||
bt->api_event = osEventFlagsNew(NULL);
|
||||
bt->api_event = furi_event_flag_alloc();
|
||||
|
||||
return bt;
|
||||
}
|
||||
|
@ -162,7 +164,7 @@ static uint16_t bt_serial_event_callback(SerialServiceEvent event, void* context
|
|||
}
|
||||
ret = rpc_session_get_available_size(bt->rpc_session);
|
||||
} else if(event.event == SerialServiceEventTypeDataSent) {
|
||||
osEventFlagsSet(bt->rpc_event, BT_RPC_EVENT_BUFF_SENT);
|
||||
furi_event_flag_set(bt->rpc_event, BT_RPC_EVENT_BUFF_SENT);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -172,11 +174,11 @@ static void bt_rpc_send_bytes_callback(void* context, uint8_t* bytes, size_t byt
|
|||
furi_assert(context);
|
||||
Bt* bt = context;
|
||||
|
||||
if(osEventFlagsGet(bt->rpc_event) & BT_RPC_EVENT_DISCONNECTED) {
|
||||
if(furi_event_flag_get(bt->rpc_event) & BT_RPC_EVENT_DISCONNECTED) {
|
||||
// Early stop from sending if we're already disconnected
|
||||
return;
|
||||
}
|
||||
osEventFlagsClear(bt->rpc_event, BT_RPC_EVENT_ALL & (~BT_RPC_EVENT_DISCONNECTED));
|
||||
furi_event_flag_clear(bt->rpc_event, BT_RPC_EVENT_ALL & (~BT_RPC_EVENT_DISCONNECTED));
|
||||
size_t bytes_sent = 0;
|
||||
while(bytes_sent < bytes_len) {
|
||||
size_t bytes_remain = bytes_len - bytes_sent;
|
||||
|
@ -188,13 +190,13 @@ static void bt_rpc_send_bytes_callback(void* context, uint8_t* bytes, size_t byt
|
|||
bytes_sent += bytes_remain;
|
||||
}
|
||||
// We want BT_RPC_EVENT_DISCONNECTED to stick, so don't clear
|
||||
uint32_t event_flag = osEventFlagsWait(
|
||||
bt->rpc_event, BT_RPC_EVENT_ALL, osFlagsWaitAny | osFlagsNoClear, osWaitForever);
|
||||
uint32_t event_flag = furi_event_flag_wait(
|
||||
bt->rpc_event, BT_RPC_EVENT_ALL, FuriFlagWaitAny | FuriFlagNoClear, FuriWaitForever);
|
||||
if(event_flag & BT_RPC_EVENT_DISCONNECTED) {
|
||||
break;
|
||||
} else {
|
||||
// If we didn't get BT_RPC_EVENT_DISCONNECTED, then clear everything else
|
||||
osEventFlagsClear(bt->rpc_event, BT_RPC_EVENT_ALL & (~BT_RPC_EVENT_DISCONNECTED));
|
||||
furi_event_flag_clear(bt->rpc_event, BT_RPC_EVENT_ALL & (~BT_RPC_EVENT_DISCONNECTED));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -209,9 +211,10 @@ static bool bt_on_gap_event_callback(GapEvent event, void* context) {
|
|||
// Update status bar
|
||||
bt->status = BtStatusConnected;
|
||||
BtMessage message = {.type = BtMessageTypeUpdateStatus};
|
||||
furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
|
||||
// Clear BT_RPC_EVENT_DISCONNECTED because it might be set from previous session
|
||||
osEventFlagsClear(bt->rpc_event, BT_RPC_EVENT_DISCONNECTED);
|
||||
furi_event_flag_clear(bt->rpc_event, BT_RPC_EVENT_DISCONNECTED);
|
||||
if(bt->profile == BtProfileSerial) {
|
||||
// Open RPC session
|
||||
bt->rpc_session = rpc_session_open(bt->rpc);
|
||||
|
@ -232,12 +235,13 @@ static bool bt_on_gap_event_callback(GapEvent event, void* context) {
|
|||
power_get_info(bt->power, &info);
|
||||
message.type = BtMessageTypeUpdateBatteryLevel;
|
||||
message.data.battery_level = info.charge;
|
||||
furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
|
||||
ret = true;
|
||||
} else if(event.type == GapEventTypeDisconnected) {
|
||||
if(bt->profile == BtProfileSerial && bt->rpc_session) {
|
||||
FURI_LOG_I(TAG, "Close RPC connection");
|
||||
osEventFlagsSet(bt->rpc_event, BT_RPC_EVENT_DISCONNECTED);
|
||||
furi_event_flag_set(bt->rpc_event, BT_RPC_EVENT_DISCONNECTED);
|
||||
rpc_session_close(bt->rpc_session);
|
||||
furi_hal_bt_serial_set_event_callback(0, NULL, NULL);
|
||||
bt->rpc_session = NULL;
|
||||
|
@ -246,17 +250,20 @@ static bool bt_on_gap_event_callback(GapEvent event, void* context) {
|
|||
} else if(event.type == GapEventTypeStartAdvertising) {
|
||||
bt->status = BtStatusAdvertising;
|
||||
BtMessage message = {.type = BtMessageTypeUpdateStatus};
|
||||
furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
|
||||
ret = true;
|
||||
} else if(event.type == GapEventTypeStopAdvertising) {
|
||||
bt->status = BtStatusOff;
|
||||
BtMessage message = {.type = BtMessageTypeUpdateStatus};
|
||||
furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
|
||||
ret = true;
|
||||
} else if(event.type == GapEventTypePinCodeShow) {
|
||||
BtMessage message = {
|
||||
.type = BtMessageTypePinCodeShow, .data.pin_code = event.data.pin_code};
|
||||
furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
|
||||
ret = true;
|
||||
} else if(event.type == GapEventTypePinCodeVerify) {
|
||||
ret = bt_pin_code_verify_event_handler(bt, event.data.pin_code);
|
||||
|
@ -272,7 +279,8 @@ static void bt_on_key_storage_change_callback(uint8_t* addr, uint16_t size, void
|
|||
Bt* bt = context;
|
||||
FURI_LOG_I(TAG, "Changed addr start: %08lX, size changed: %d", addr, size);
|
||||
BtMessage message = {.type = BtMessageTypeKeysStorageUpdated};
|
||||
furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
|
||||
static void bt_statusbar_update(Bt* bt) {
|
||||
|
@ -296,7 +304,7 @@ static void bt_show_warning(Bt* bt, const char* text) {
|
|||
static void bt_close_rpc_connection(Bt* bt) {
|
||||
if(bt->profile == BtProfileSerial && bt->rpc_session) {
|
||||
FURI_LOG_I(TAG, "Close RPC connection");
|
||||
osEventFlagsSet(bt->rpc_event, BT_RPC_EVENT_DISCONNECTED);
|
||||
furi_event_flag_set(bt->rpc_event, BT_RPC_EVENT_DISCONNECTED);
|
||||
rpc_session_close(bt->rpc_session);
|
||||
furi_hal_bt_serial_set_event_callback(0, NULL, NULL);
|
||||
bt->rpc_session = NULL;
|
||||
|
@ -331,12 +339,12 @@ static void bt_change_profile(Bt* bt, BtMessage* message) {
|
|||
bt_show_warning(bt, "Radio stack doesn't support this app");
|
||||
*message->result = false;
|
||||
}
|
||||
osEventFlagsSet(bt->api_event, BT_API_UNLOCK_EVENT);
|
||||
furi_event_flag_set(bt->api_event, BT_API_UNLOCK_EVENT);
|
||||
}
|
||||
|
||||
static void bt_close_connection(Bt* bt) {
|
||||
bt_close_rpc_connection(bt);
|
||||
osEventFlagsSet(bt->api_event, BT_API_UNLOCK_EVENT);
|
||||
furi_event_flag_set(bt->api_event, BT_API_UNLOCK_EVENT);
|
||||
}
|
||||
|
||||
int32_t bt_srv() {
|
||||
|
@ -377,7 +385,8 @@ int32_t bt_srv() {
|
|||
|
||||
BtMessage message;
|
||||
while(1) {
|
||||
furi_check(osMessageQueueGet(bt->message_queue, &message, NULL, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
furi_message_queue_get(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
|
||||
if(message.type == BtMessageTypeUpdateStatus) {
|
||||
// Update view ports
|
||||
bt_statusbar_update(bt);
|
||||
|
|
13
applications/bt/bt_service/bt_api.c
Executable file → Normal file
13
applications/bt/bt_service/bt_api.c
Executable file → Normal file
|
@ -7,9 +7,10 @@ bool bt_set_profile(Bt* bt, BtProfile profile) {
|
|||
bool result = false;
|
||||
BtMessage message = {
|
||||
.type = BtMessageTypeSetProfile, .data.profile = profile, .result = &result};
|
||||
furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
|
||||
// Wait for unlock
|
||||
osEventFlagsWait(bt->api_event, BT_API_UNLOCK_EVENT, osFlagsWaitAny, osWaitForever);
|
||||
furi_event_flag_wait(bt->api_event, BT_API_UNLOCK_EVENT, FuriFlagWaitAny, FuriWaitForever);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -19,9 +20,10 @@ void bt_disconnect(Bt* bt) {
|
|||
|
||||
// Send message
|
||||
BtMessage message = {.type = BtMessageTypeDisconnect};
|
||||
furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
|
||||
// Wait for unlock
|
||||
osEventFlagsWait(bt->api_event, BT_API_UNLOCK_EVENT, osFlagsWaitAny, osWaitForever);
|
||||
furi_event_flag_wait(bt->api_event, BT_API_UNLOCK_EVENT, FuriFlagWaitAny, FuriWaitForever);
|
||||
}
|
||||
|
||||
void bt_set_status_changed_callback(Bt* bt, BtStatusChangedCallback callback, void* context) {
|
||||
|
@ -34,5 +36,6 @@ void bt_set_status_changed_callback(Bt* bt, BtStatusChangedCallback callback, vo
|
|||
void bt_forget_bonded_devices(Bt* bt) {
|
||||
furi_assert(bt);
|
||||
BtMessage message = {.type = BtMessageTypeForgetBondedDevices};
|
||||
furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ struct Bt {
|
|||
BtSettings bt_settings;
|
||||
BtStatus status;
|
||||
BtProfile profile;
|
||||
osMessageQueueId_t message_queue;
|
||||
FuriMessageQueue* message_queue;
|
||||
NotificationApp* notification;
|
||||
Gui* gui;
|
||||
ViewPort* statusbar_view_port;
|
||||
|
@ -59,8 +59,8 @@ struct Bt {
|
|||
Power* power;
|
||||
Rpc* rpc;
|
||||
RpcSession* rpc_session;
|
||||
osEventFlagsId_t rpc_event;
|
||||
osEventFlagsId_t api_event;
|
||||
FuriEventFlag* rpc_event;
|
||||
FuriEventFlag* api_event;
|
||||
BtStatusChangedCallback status_changed_cb;
|
||||
void* status_changed_ctx;
|
||||
};
|
||||
|
|
|
@ -16,10 +16,10 @@ Cli* cli_alloc() {
|
|||
|
||||
cli->session = NULL;
|
||||
|
||||
cli->mutex = osMutexNew(NULL);
|
||||
cli->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
furi_check(cli->mutex);
|
||||
|
||||
cli->idle_sem = osSemaphoreNew(1, 0, NULL);
|
||||
cli->idle_sem = furi_semaphore_alloc(1, 0);
|
||||
|
||||
return cli;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ char cli_getc(Cli* cli) {
|
|||
furi_assert(cli);
|
||||
char c = 0;
|
||||
if(cli->session != NULL) {
|
||||
if(cli->session->rx((uint8_t*)&c, 1, osWaitForever) == 0) {
|
||||
if(cli->session->rx((uint8_t*)&c, 1, FuriWaitForever) == 0) {
|
||||
cli_reset(cli);
|
||||
}
|
||||
} else {
|
||||
|
@ -54,7 +54,7 @@ void cli_write(Cli* cli, const uint8_t* buffer, size_t size) {
|
|||
size_t cli_read(Cli* cli, uint8_t* buffer, size_t size) {
|
||||
furi_assert(cli);
|
||||
if(cli->session != NULL) {
|
||||
return cli->session->rx(buffer, size, osWaitForever);
|
||||
return cli->session->rx(buffer, size, FuriWaitForever);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
@ -228,17 +228,17 @@ static void cli_handle_enter(Cli* cli) {
|
|||
}
|
||||
|
||||
// Search for command
|
||||
furi_check(osMutexAcquire(cli->mutex, osWaitForever) == osOK);
|
||||
furi_check(furi_mutex_acquire(cli->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
CliCommand* cli_command_ptr = CliCommandTree_get(cli->commands, command);
|
||||
|
||||
if(cli_command_ptr) {
|
||||
CliCommand cli_command;
|
||||
memcpy(&cli_command, cli_command_ptr, sizeof(CliCommand));
|
||||
furi_check(osMutexRelease(cli->mutex) == osOK);
|
||||
furi_check(furi_mutex_release(cli->mutex) == FuriStatusOk);
|
||||
cli_nl(cli);
|
||||
cli_execute_command(cli, &cli_command, args);
|
||||
} else {
|
||||
furi_check(osMutexRelease(cli->mutex) == osOK);
|
||||
furi_check(furi_mutex_release(cli->mutex) == FuriStatusOk);
|
||||
cli_nl(cli);
|
||||
printf(
|
||||
"`%s` command not found, use `help` or `?` to list all available commands",
|
||||
|
@ -339,7 +339,7 @@ void cli_process_input(Cli* cli) {
|
|||
if(in_chr == CliSymbolAsciiTab) {
|
||||
cli_handle_autocomplete(cli);
|
||||
} else if(in_chr == CliSymbolAsciiSOH) {
|
||||
osDelay(33); // We are too fast, Minicom is not ready yet
|
||||
furi_delay_ms(33); // We are too fast, Minicom is not ready yet
|
||||
cli_motd();
|
||||
cli_prompt(cli);
|
||||
} else if(in_chr == CliSymbolAsciiETX) {
|
||||
|
@ -406,9 +406,9 @@ void cli_add_command(
|
|||
c.context = context;
|
||||
c.flags = flags;
|
||||
|
||||
furi_check(osMutexAcquire(cli->mutex, osWaitForever) == osOK);
|
||||
furi_check(furi_mutex_acquire(cli->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
CliCommandTree_set_at(cli->commands, name_str, c);
|
||||
furi_check(osMutexRelease(cli->mutex) == osOK);
|
||||
furi_check(furi_mutex_release(cli->mutex) == FuriStatusOk);
|
||||
|
||||
string_clear(name_str);
|
||||
}
|
||||
|
@ -423,9 +423,9 @@ void cli_delete_command(Cli* cli, const char* name) {
|
|||
name_replace = string_replace_str(name_str, " ", "_");
|
||||
} while(name_replace != STRING_FAILURE);
|
||||
|
||||
furi_check(osMutexAcquire(cli->mutex, osWaitForever) == osOK);
|
||||
furi_check(furi_mutex_acquire(cli->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
CliCommandTree_erase(cli->commands, name_str);
|
||||
furi_check(osMutexRelease(cli->mutex) == osOK);
|
||||
furi_check(furi_mutex_release(cli->mutex) == FuriStatusOk);
|
||||
|
||||
string_clear(name_str);
|
||||
}
|
||||
|
@ -433,7 +433,7 @@ void cli_delete_command(Cli* cli, const char* name) {
|
|||
void cli_session_open(Cli* cli, void* session) {
|
||||
furi_assert(cli);
|
||||
|
||||
furi_check(osMutexAcquire(cli->mutex, osWaitForever) == osOK);
|
||||
furi_check(furi_mutex_acquire(cli->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
cli->session = session;
|
||||
if(cli->session != NULL) {
|
||||
cli->session->init();
|
||||
|
@ -441,20 +441,20 @@ void cli_session_open(Cli* cli, void* session) {
|
|||
} else {
|
||||
furi_stdglue_set_thread_stdout_callback(NULL);
|
||||
}
|
||||
osSemaphoreRelease(cli->idle_sem);
|
||||
furi_check(osMutexRelease(cli->mutex) == osOK);
|
||||
furi_semaphore_release(cli->idle_sem);
|
||||
furi_check(furi_mutex_release(cli->mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void cli_session_close(Cli* cli) {
|
||||
furi_assert(cli);
|
||||
|
||||
furi_check(osMutexAcquire(cli->mutex, osWaitForever) == osOK);
|
||||
furi_check(furi_mutex_acquire(cli->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
if(cli->session != NULL) {
|
||||
cli->session->deinit();
|
||||
}
|
||||
cli->session = NULL;
|
||||
furi_stdglue_set_thread_stdout_callback(NULL);
|
||||
furi_check(osMutexRelease(cli->mutex) == osOK);
|
||||
furi_check(furi_mutex_release(cli->mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
int32_t cli_srv(void* p) {
|
||||
|
@ -482,7 +482,7 @@ int32_t cli_srv(void* p) {
|
|||
if(cli->session != NULL) {
|
||||
cli_process_input(cli);
|
||||
} else {
|
||||
furi_check(osSemaphoreAcquire(cli->idle_sem, osWaitForever) == osOK);
|
||||
furi_check(furi_semaphore_acquire(cli->idle_sem, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@ BPTREE_DEF2(
|
|||
|
||||
struct Cli {
|
||||
CliCommandTree_t commands;
|
||||
osMutexId_t mutex;
|
||||
osSemaphoreId_t idle_sem;
|
||||
FuriMutex* mutex;
|
||||
FuriSemaphore* idle_sem;
|
||||
string_t last_line;
|
||||
string_t line;
|
||||
CliSession* session;
|
||||
|
|
|
@ -103,8 +103,8 @@ static int32_t vcp_worker(void* context) {
|
|||
|
||||
while(1) {
|
||||
uint32_t flags =
|
||||
furi_thread_flags_wait(VCP_THREAD_FLAG_ALL, osFlagsWaitAny, osWaitForever);
|
||||
furi_assert((flags & osFlagsError) == 0);
|
||||
furi_thread_flags_wait(VCP_THREAD_FLAG_ALL, FuriFlagWaitAny, FuriWaitForever);
|
||||
furi_assert((flags & FuriFlagError) == 0);
|
||||
|
||||
// VCP session opened
|
||||
if(flags & VcpEvtConnect) {
|
||||
|
@ -113,7 +113,7 @@ static int32_t vcp_worker(void* context) {
|
|||
#endif
|
||||
if(vcp->connected == false) {
|
||||
vcp->connected = true;
|
||||
xStreamBufferSend(vcp->rx_stream, &ascii_soh, 1, osWaitForever);
|
||||
xStreamBufferSend(vcp->rx_stream, &ascii_soh, 1, FuriWaitForever);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ static int32_t vcp_worker(void* context) {
|
|||
if(vcp->connected == true) {
|
||||
vcp->connected = false;
|
||||
xStreamBufferReceive(vcp->tx_stream, vcp->data_buffer, USB_CDC_PKT_LEN, 0);
|
||||
xStreamBufferSend(vcp->rx_stream, &ascii_eot, 1, osWaitForever);
|
||||
xStreamBufferSend(vcp->rx_stream, &ascii_eot, 1, FuriWaitForever);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ static int32_t vcp_worker(void* context) {
|
|||
#endif
|
||||
if(len > 0) {
|
||||
furi_check(
|
||||
xStreamBufferSend(vcp->rx_stream, vcp->data_buffer, len, osWaitForever) ==
|
||||
xStreamBufferSend(vcp->rx_stream, vcp->data_buffer, len, FuriWaitForever) ==
|
||||
(size_t)len);
|
||||
}
|
||||
} else {
|
||||
|
@ -203,7 +203,7 @@ static int32_t vcp_worker(void* context) {
|
|||
furi_hal_usb_set_config(vcp->usb_if_prev, NULL);
|
||||
}
|
||||
xStreamBufferReceive(vcp->tx_stream, vcp->data_buffer, USB_CDC_PKT_LEN, 0);
|
||||
xStreamBufferSend(vcp->rx_stream, &ascii_eot, 1, osWaitForever);
|
||||
xStreamBufferSend(vcp->rx_stream, &ascii_eot, 1, FuriWaitForever);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ static void cli_vcp_tx(const uint8_t* buffer, size_t size) {
|
|||
size_t batch_size = size;
|
||||
if(batch_size > USB_CDC_PKT_LEN) batch_size = USB_CDC_PKT_LEN;
|
||||
|
||||
xStreamBufferSend(vcp->tx_stream, buffer, batch_size, osWaitForever);
|
||||
xStreamBufferSend(vcp->tx_stream, buffer, batch_size, FuriWaitForever);
|
||||
furi_thread_flags_set(furi_thread_get_id(vcp->thread), VcpEvtStreamTx);
|
||||
#ifdef CLI_VCP_DEBUG
|
||||
FURI_LOG_D(TAG, "tx %u", batch_size);
|
||||
|
@ -304,7 +304,7 @@ static void vcp_on_cdc_control_line(void* context, uint8_t state) {
|
|||
static void vcp_on_cdc_rx(void* context) {
|
||||
UNUSED(context);
|
||||
uint32_t ret = furi_thread_flags_set(furi_thread_get_id(vcp->thread), VcpEvtRx);
|
||||
furi_check((ret & osFlagsError) == 0);
|
||||
furi_check((ret & FuriFlagError) == 0);
|
||||
}
|
||||
|
||||
static void vcp_on_cdc_tx_complete(void* context) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "furi/common_defines.h"
|
||||
#include <core/common_defines.h>
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
|
||||
|
@ -55,10 +55,10 @@ static const NotificationSequence* blink_test_colors[] = {
|
|||
|
||||
static void blink_test_update(void* ctx) {
|
||||
furi_assert(ctx);
|
||||
osMessageQueueId_t event_queue = ctx;
|
||||
FuriMessageQueue* event_queue = ctx;
|
||||
BlinkEvent event = {.type = BlinkEventTypeTick};
|
||||
// It's OK to loose this event if system overloaded
|
||||
osMessageQueuePut(event_queue, &event, 0, 0);
|
||||
furi_message_queue_put(event_queue, &event, 0);
|
||||
}
|
||||
|
||||
static void blink_test_draw_callback(Canvas* canvas, void* ctx) {
|
||||
|
@ -70,22 +70,22 @@ static void blink_test_draw_callback(Canvas* canvas, void* ctx) {
|
|||
|
||||
static void blink_test_input_callback(InputEvent* input_event, void* ctx) {
|
||||
furi_assert(ctx);
|
||||
osMessageQueueId_t event_queue = ctx;
|
||||
FuriMessageQueue* event_queue = ctx;
|
||||
|
||||
BlinkEvent event = {.type = BlinkEventTypeInput, .input = *input_event};
|
||||
osMessageQueuePut(event_queue, &event, 0, osWaitForever);
|
||||
furi_message_queue_put(event_queue, &event, FuriWaitForever);
|
||||
}
|
||||
|
||||
int32_t blink_test_app(void* p) {
|
||||
UNUSED(p);
|
||||
osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(BlinkEvent), NULL);
|
||||
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(BlinkEvent));
|
||||
|
||||
// Configure view port
|
||||
ViewPort* view_port = view_port_alloc();
|
||||
view_port_draw_callback_set(view_port, blink_test_draw_callback, NULL);
|
||||
view_port_input_callback_set(view_port, blink_test_input_callback, event_queue);
|
||||
osTimerId_t timer = osTimerNew(blink_test_update, osTimerPeriodic, event_queue, NULL);
|
||||
osTimerStart(timer, osKernelGetTickFreq());
|
||||
FuriTimer* timer = furi_timer_alloc(blink_test_update, FuriTimerTypePeriodic, event_queue);
|
||||
furi_timer_start(timer, furi_kernel_get_tick_frequency());
|
||||
|
||||
// Register view port in GUI
|
||||
Gui* gui = furi_record_open("gui");
|
||||
|
@ -97,7 +97,7 @@ int32_t blink_test_app(void* p) {
|
|||
BlinkEvent event;
|
||||
|
||||
while(1) {
|
||||
furi_check(osMessageQueueGet(event_queue, &event, NULL, osWaitForever) == osOK);
|
||||
furi_check(furi_message_queue_get(event_queue, &event, FuriWaitForever) == FuriStatusOk);
|
||||
if(event.type == BlinkEventTypeInput) {
|
||||
if((event.input.type == InputTypeShort) && (event.input.key == InputKeyBack)) {
|
||||
break;
|
||||
|
@ -113,11 +113,11 @@ int32_t blink_test_app(void* p) {
|
|||
|
||||
notification_message(notifications, &blink_test_sequence_hw_blink_stop);
|
||||
|
||||
osTimerDelete(timer);
|
||||
furi_timer_free(timer);
|
||||
|
||||
gui_remove_view_port(gui, view_port);
|
||||
view_port_free(view_port);
|
||||
osMessageQueueDelete(event_queue);
|
||||
furi_message_queue_free(event_queue);
|
||||
|
||||
furi_record_close("notification");
|
||||
furi_record_close("gui");
|
||||
|
|
|
@ -9,7 +9,7 @@ typedef struct {
|
|||
|
||||
struct ViewDisplayTest {
|
||||
View* view;
|
||||
osTimerId_t timer;
|
||||
FuriTimer* timer;
|
||||
};
|
||||
|
||||
static void view_display_test_draw_callback_intro(Canvas* canvas, void* _model) {
|
||||
|
@ -138,12 +138,12 @@ static bool view_display_test_input_callback(InputEvent* event, void* context) {
|
|||
|
||||
static void view_display_test_enter(void* context) {
|
||||
ViewDisplayTest* instance = context;
|
||||
osTimerStart(instance->timer, osKernelGetTickFreq() / 32);
|
||||
furi_timer_start(instance->timer, furi_kernel_get_tick_frequency() / 32);
|
||||
}
|
||||
|
||||
static void view_display_test_exit(void* context) {
|
||||
ViewDisplayTest* instance = context;
|
||||
osTimerStop(instance->timer);
|
||||
furi_timer_stop(instance->timer);
|
||||
}
|
||||
|
||||
static void view_display_test_timer_callback(void* context) {
|
||||
|
@ -167,7 +167,7 @@ ViewDisplayTest* view_display_test_alloc() {
|
|||
view_set_exit_callback(instance->view, view_display_test_exit);
|
||||
|
||||
instance->timer =
|
||||
osTimerNew(view_display_test_timer_callback, osTimerPeriodic, instance, NULL);
|
||||
furi_timer_alloc(view_display_test_timer_callback, FuriTimerTypePeriodic, instance);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ ViewDisplayTest* view_display_test_alloc() {
|
|||
void view_display_test_free(ViewDisplayTest* instance) {
|
||||
furi_assert(instance);
|
||||
|
||||
osTimerDelete(instance->timer);
|
||||
furi_timer_free(instance->timer);
|
||||
view_free(instance->view);
|
||||
free(instance);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "../file_browser_app_i.h"
|
||||
#include "furi/check.h"
|
||||
#include "furi/log.h"
|
||||
#include <core/check.h>
|
||||
#include <core/log.h>
|
||||
#include "furi_hal.h"
|
||||
#include "m-string.h"
|
||||
|
||||
|
|
|
@ -55,13 +55,13 @@ static void keypad_test_render_callback(Canvas* canvas, void* ctx) {
|
|||
}
|
||||
|
||||
static void keypad_test_input_callback(InputEvent* input_event, void* ctx) {
|
||||
osMessageQueueId_t event_queue = ctx;
|
||||
osMessageQueuePut(event_queue, input_event, 0, osWaitForever);
|
||||
FuriMessageQueue* event_queue = ctx;
|
||||
furi_message_queue_put(event_queue, input_event, FuriWaitForever);
|
||||
}
|
||||
|
||||
int32_t keypad_test_app(void* p) {
|
||||
UNUSED(p);
|
||||
osMessageQueueId_t event_queue = osMessageQueueNew(32, sizeof(InputEvent), NULL);
|
||||
FuriMessageQueue* event_queue = furi_message_queue_alloc(32, sizeof(InputEvent));
|
||||
furi_check(event_queue);
|
||||
|
||||
KeypadTestState _state = {{false, false, false, false, false}, 0, 0, 0, 0, 0};
|
||||
|
@ -82,7 +82,7 @@ int32_t keypad_test_app(void* p) {
|
|||
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
|
||||
|
||||
InputEvent event;
|
||||
while(osMessageQueueGet(event_queue, &event, NULL, osWaitForever) == osOK) {
|
||||
while(furi_message_queue_get(event_queue, &event, FuriWaitForever) == FuriStatusOk) {
|
||||
KeypadTestState* state = (KeypadTestState*)acquire_mutex_block(&state_mutex);
|
||||
FURI_LOG_I(
|
||||
TAG,
|
||||
|
@ -146,7 +146,7 @@ int32_t keypad_test_app(void* p) {
|
|||
// remove & free all stuff created by app
|
||||
gui_remove_view_port(gui, view_port);
|
||||
view_port_free(view_port);
|
||||
osMessageQueueDelete(event_queue);
|
||||
furi_message_queue_free(event_queue);
|
||||
delete_mutex(&state_mutex);
|
||||
|
||||
furi_record_close("gui");
|
||||
|
|
|
@ -65,13 +65,13 @@ static void text_box_test_render_callback(Canvas* canvas, void* ctx) {
|
|||
}
|
||||
|
||||
static void text_box_test_input_callback(InputEvent* input_event, void* ctx) {
|
||||
osMessageQueueId_t event_queue = ctx;
|
||||
osMessageQueuePut(event_queue, input_event, 0, osWaitForever);
|
||||
FuriMessageQueue* event_queue = ctx;
|
||||
furi_message_queue_put(event_queue, input_event, FuriWaitForever);
|
||||
}
|
||||
|
||||
int32_t text_box_test_app(void* p) {
|
||||
UNUSED(p);
|
||||
osMessageQueueId_t event_queue = osMessageQueueNew(32, sizeof(InputEvent), NULL);
|
||||
FuriMessageQueue* event_queue = furi_message_queue_alloc(32, sizeof(InputEvent));
|
||||
furi_check(event_queue);
|
||||
|
||||
TextBoxTestState _state = {.idx = 0};
|
||||
|
@ -93,7 +93,7 @@ int32_t text_box_test_app(void* p) {
|
|||
|
||||
uint32_t test_renders_num = COUNT_OF(text_box_test_render);
|
||||
InputEvent event;
|
||||
while(osMessageQueueGet(event_queue, &event, NULL, osWaitForever) == osOK) {
|
||||
while(furi_message_queue_get(event_queue, &event, FuriWaitForever) == FuriStatusOk) {
|
||||
TextBoxTestState* state = acquire_mutex_block(&state_mutex);
|
||||
|
||||
if(event.type == InputTypeShort) {
|
||||
|
@ -118,7 +118,7 @@ int32_t text_box_test_app(void* p) {
|
|||
// remove & free all stuff created by app
|
||||
gui_remove_view_port(gui, view_port);
|
||||
view_port_free(view_port);
|
||||
osMessageQueueDelete(event_queue);
|
||||
furi_message_queue_free(event_queue);
|
||||
delete_mutex(&state_mutex);
|
||||
|
||||
furi_record_close("gui");
|
||||
|
|
|
@ -150,8 +150,8 @@ static int32_t uart_echo_worker(void* context) {
|
|||
|
||||
while(1) {
|
||||
uint32_t events =
|
||||
furi_thread_flags_wait(WORKER_EVENTS_MASK, osFlagsWaitAny, osWaitForever);
|
||||
furi_check((events & osFlagsError) == 0);
|
||||
furi_thread_flags_wait(WORKER_EVENTS_MASK, FuriFlagWaitAny, FuriWaitForever);
|
||||
furi_check((events & FuriFlagError) == 0);
|
||||
|
||||
if(events & WorkerEventStop) break;
|
||||
if(events & WorkerEventRx) {
|
||||
|
|
|
@ -29,17 +29,17 @@ static void usb_mouse_render_callback(Canvas* canvas, void* ctx) {
|
|||
}
|
||||
|
||||
static void usb_mouse_input_callback(InputEvent* input_event, void* ctx) {
|
||||
osMessageQueueId_t event_queue = ctx;
|
||||
FuriMessageQueue* event_queue = ctx;
|
||||
|
||||
UsbMouseEvent event;
|
||||
event.type = EventTypeInput;
|
||||
event.input = *input_event;
|
||||
osMessageQueuePut(event_queue, &event, 0, osWaitForever);
|
||||
furi_message_queue_put(event_queue, &event, FuriWaitForever);
|
||||
}
|
||||
|
||||
int32_t usb_mouse_app(void* p) {
|
||||
UNUSED(p);
|
||||
osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(UsbMouseEvent), NULL);
|
||||
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(UsbMouseEvent));
|
||||
furi_check(event_queue);
|
||||
ViewPort* view_port = view_port_alloc();
|
||||
|
||||
|
@ -56,9 +56,9 @@ int32_t usb_mouse_app(void* p) {
|
|||
|
||||
UsbMouseEvent event;
|
||||
while(1) {
|
||||
osStatus_t event_status = osMessageQueueGet(event_queue, &event, NULL, osWaitForever);
|
||||
FuriStatus event_status = furi_message_queue_get(event_queue, &event, FuriWaitForever);
|
||||
|
||||
if(event_status == osOK) {
|
||||
if(event_status == FuriStatusOk) {
|
||||
if(event.type == EventTypeInput) {
|
||||
if(event.input.type == InputTypeLong && event.input.key == InputKeyBack) {
|
||||
break;
|
||||
|
@ -118,7 +118,7 @@ int32_t usb_mouse_app(void* p) {
|
|||
// remove & free all stuff created by app
|
||||
gui_remove_view_port(gui, view_port);
|
||||
view_port_free(view_port);
|
||||
osMessageQueueDelete(event_queue);
|
||||
furi_message_queue_free(event_queue);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -18,13 +18,13 @@ void vibro_test_draw_callback(Canvas* canvas, void* ctx) {
|
|||
|
||||
void vibro_test_input_callback(InputEvent* input_event, void* ctx) {
|
||||
furi_assert(ctx);
|
||||
osMessageQueueId_t event_queue = ctx;
|
||||
osMessageQueuePut(event_queue, input_event, 0, osWaitForever);
|
||||
FuriMessageQueue* event_queue = ctx;
|
||||
furi_message_queue_put(event_queue, input_event, FuriWaitForever);
|
||||
}
|
||||
|
||||
int32_t vibro_test_app(void* p) {
|
||||
UNUSED(p);
|
||||
osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL);
|
||||
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
|
||||
|
||||
// Configure view port
|
||||
ViewPort* view_port = view_port_alloc();
|
||||
|
@ -39,7 +39,7 @@ int32_t vibro_test_app(void* p) {
|
|||
|
||||
InputEvent event;
|
||||
|
||||
while(osMessageQueueGet(event_queue, &event, NULL, osWaitForever) == osOK) {
|
||||
while(furi_message_queue_get(event_queue, &event, FuriWaitForever) == FuriStatusOk) {
|
||||
if(event.type == InputTypeShort && event.key == InputKeyBack) {
|
||||
notification_message(notification, &sequence_reset_vibro);
|
||||
notification_message(notification, &sequence_reset_green);
|
||||
|
@ -58,7 +58,7 @@ int32_t vibro_test_app(void* p) {
|
|||
|
||||
gui_remove_view_port(gui, view_port);
|
||||
view_port_free(view_port);
|
||||
osMessageQueueDelete(event_queue);
|
||||
furi_message_queue_free(event_queue);
|
||||
|
||||
furi_record_close("notification");
|
||||
furi_record_close("gui");
|
||||
|
|
|
@ -44,7 +44,7 @@ struct AnimationManager {
|
|||
FuriPubSubSubscription* pubsub_subscription_dolphin;
|
||||
BubbleAnimationView* animation_view;
|
||||
OneShotView* one_shot_view;
|
||||
osTimerId_t idle_animation_timer;
|
||||
FuriTimer* idle_animation_timer;
|
||||
StorageAnimation* current_animation;
|
||||
AnimationManagerInteractCallback interact_callback;
|
||||
AnimationManagerSetNewIdleAnimationCallback new_idle_callback;
|
||||
|
@ -198,7 +198,7 @@ static void animation_manager_start_new_idle(AnimationManager* animation_manager
|
|||
const BubbleAnimation* bubble_animation =
|
||||
animation_storage_get_bubble_animation(animation_manager->current_animation);
|
||||
animation_manager->state = AnimationManagerStateIdle;
|
||||
osTimerStart(animation_manager->idle_animation_timer, bubble_animation->duration * 1000);
|
||||
furi_timer_start(animation_manager->idle_animation_timer, bubble_animation->duration * 1000);
|
||||
}
|
||||
|
||||
static bool animation_manager_check_blocking(AnimationManager* animation_manager) {
|
||||
|
@ -246,7 +246,7 @@ static bool animation_manager_check_blocking(AnimationManager* animation_manager
|
|||
}
|
||||
|
||||
if(blocking_animation) {
|
||||
osTimerStop(animation_manager->idle_animation_timer);
|
||||
furi_timer_stop(animation_manager->idle_animation_timer);
|
||||
animation_manager_replace_current_animation(animation_manager, blocking_animation);
|
||||
/* no timer starting because this is blocking animation */
|
||||
animation_manager->state = AnimationManagerStateBlocked;
|
||||
|
@ -283,7 +283,7 @@ AnimationManager* animation_manager_alloc(void) {
|
|||
string_init(animation_manager->freezed_animation_name);
|
||||
|
||||
animation_manager->idle_animation_timer =
|
||||
osTimerNew(animation_manager_timer_callback, osTimerOnce, animation_manager, NULL);
|
||||
furi_timer_alloc(animation_manager_timer_callback, FuriTimerTypeOnce, animation_manager);
|
||||
bubble_animation_view_set_interact_callback(
|
||||
animation_manager->animation_view, animation_manager_interact_callback, animation_manager);
|
||||
|
||||
|
@ -322,7 +322,7 @@ void animation_manager_free(AnimationManager* animation_manager) {
|
|||
View* animation_view = bubble_animation_get_view(animation_manager->animation_view);
|
||||
view_stack_remove_view(animation_manager->view_stack, animation_view);
|
||||
bubble_animation_view_free(animation_manager->animation_view);
|
||||
osTimerDelete(animation_manager->idle_animation_timer);
|
||||
furi_timer_free(animation_manager->idle_animation_timer);
|
||||
}
|
||||
|
||||
View* animation_manager_get_animation_view(AnimationManager* animation_manager) {
|
||||
|
@ -449,7 +449,7 @@ void animation_manager_unload_and_stall_animation(AnimationManager* animation_ma
|
|||
if(animation_manager->freezed_animation_time_left < 0) {
|
||||
animation_manager->freezed_animation_time_left = 0;
|
||||
}
|
||||
osTimerStop(animation_manager->idle_animation_timer);
|
||||
furi_timer_stop(animation_manager->idle_animation_timer);
|
||||
} else {
|
||||
furi_assert(0);
|
||||
}
|
||||
|
@ -504,13 +504,13 @@ void animation_manager_load_and_continue_animation(AnimationManager* animation_m
|
|||
animation_manager->state = AnimationManagerStateIdle;
|
||||
|
||||
if(animation_manager->freezed_animation_time_left) {
|
||||
osTimerStart(
|
||||
furi_timer_start(
|
||||
animation_manager->idle_animation_timer,
|
||||
animation_manager->freezed_animation_time_left);
|
||||
} else {
|
||||
const BubbleAnimation* animation = animation_storage_get_bubble_animation(
|
||||
animation_manager->current_animation);
|
||||
osTimerStart(
|
||||
furi_timer_start(
|
||||
animation_manager->idle_animation_timer, animation->duration * 1000);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <stdint.h>
|
||||
#include <flipper_format/flipper_format.h>
|
||||
#include <furi.h>
|
||||
#include <furi/dangerous_defines.h>
|
||||
#include <core/dangerous_defines.h>
|
||||
#include <storage/storage.h>
|
||||
#include <gui/icon_i.h>
|
||||
#include <m-string.h>
|
||||
|
|
|
@ -11,9 +11,7 @@
|
|||
#include <gui/icon_i.h>
|
||||
#include <input/input.h>
|
||||
#include <stdint.h>
|
||||
#include <FreeRTOS.h>
|
||||
#include <timers.h>
|
||||
#include <furi/dangerous_defines.h>
|
||||
#include <core/dangerous_defines.h>
|
||||
|
||||
#define ACTIVE_SHIFT 2
|
||||
|
||||
|
@ -31,7 +29,7 @@ typedef struct {
|
|||
|
||||
struct BubbleAnimationView {
|
||||
View* view;
|
||||
osTimerId_t timer;
|
||||
FuriTimer* timer;
|
||||
BubbleAnimationInteractCallback interact_callback;
|
||||
void* interact_callback_context;
|
||||
};
|
||||
|
@ -192,7 +190,7 @@ static void bubble_animation_activate_right_now(BubbleAnimationView* view) {
|
|||
view_commit_model(view->view, true);
|
||||
|
||||
if(frame_rate) {
|
||||
osTimerStart(view->timer, 1000 / frame_rate);
|
||||
furi_timer_start(view->timer, 1000 / frame_rate);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -294,21 +292,21 @@ static void bubble_animation_enter(void* context) {
|
|||
view_commit_model(view->view, false);
|
||||
|
||||
if(frame_rate) {
|
||||
osTimerStart(view->timer, 1000 / frame_rate);
|
||||
furi_timer_start(view->timer, 1000 / frame_rate);
|
||||
}
|
||||
}
|
||||
|
||||
static void bubble_animation_exit(void* context) {
|
||||
furi_assert(context);
|
||||
BubbleAnimationView* view = context;
|
||||
osTimerStop(view->timer);
|
||||
furi_timer_stop(view->timer);
|
||||
}
|
||||
|
||||
BubbleAnimationView* bubble_animation_view_alloc(void) {
|
||||
BubbleAnimationView* view = malloc(sizeof(BubbleAnimationView));
|
||||
view->view = view_alloc();
|
||||
view->interact_callback = NULL;
|
||||
view->timer = osTimerNew(bubble_animation_timer_callback, osTimerPeriodic, view, NULL);
|
||||
view->timer = furi_timer_alloc(bubble_animation_timer_callback, FuriTimerTypePeriodic, view);
|
||||
|
||||
view_allocate_model(view->view, ViewModelTypeLocking, sizeof(BubbleAnimationViewModel));
|
||||
view_set_context(view->view, view);
|
||||
|
@ -369,7 +367,7 @@ void bubble_animation_view_set_animation(
|
|||
model->active_cycle = 0;
|
||||
view_commit_model(view->view, true);
|
||||
|
||||
osTimerStart(view->timer, 1000 / new_animation->icon_animation.frame_rate);
|
||||
furi_timer_start(view->timer, 1000 / new_animation->icon_animation.frame_rate);
|
||||
}
|
||||
|
||||
void bubble_animation_freeze(BubbleAnimationView* view) {
|
||||
|
@ -381,7 +379,7 @@ void bubble_animation_freeze(BubbleAnimationView* view) {
|
|||
model->freeze_frame = bubble_animation_clone_first_frame(&model->current->icon_animation);
|
||||
model->current = NULL;
|
||||
view_commit_model(view->view, false);
|
||||
osTimerStop(view->timer);
|
||||
furi_timer_stop(view->timer);
|
||||
}
|
||||
|
||||
void bubble_animation_unfreeze(BubbleAnimationView* view) {
|
||||
|
@ -395,7 +393,7 @@ void bubble_animation_unfreeze(BubbleAnimationView* view) {
|
|||
frame_rate = model->current->icon_animation.frame_rate;
|
||||
view_commit_model(view->view, true);
|
||||
|
||||
osTimerStart(view->timer, 1000 / frame_rate);
|
||||
furi_timer_start(view->timer, 1000 / frame_rate);
|
||||
bubble_animation_activate(view, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -93,12 +93,12 @@ static void desktop_auto_lock_timer_callback(void* context) {
|
|||
}
|
||||
|
||||
static void desktop_start_auto_lock_timer(Desktop* desktop) {
|
||||
osTimerStart(
|
||||
desktop->auto_lock_timer, furi_hal_ms_to_ticks(desktop->settings.auto_lock_delay_ms));
|
||||
furi_timer_start(
|
||||
desktop->auto_lock_timer, furi_ms_to_ticks(desktop->settings.auto_lock_delay_ms));
|
||||
}
|
||||
|
||||
static void desktop_stop_auto_lock_timer(Desktop* desktop) {
|
||||
osTimerStop(desktop->auto_lock_timer);
|
||||
furi_timer_stop(desktop->auto_lock_timer);
|
||||
}
|
||||
|
||||
static void desktop_auto_lock_arm(Desktop* desktop) {
|
||||
|
@ -232,7 +232,7 @@ Desktop* desktop_alloc() {
|
|||
desktop->input_events_subscription = NULL;
|
||||
|
||||
desktop->auto_lock_timer =
|
||||
osTimerNew(desktop_auto_lock_timer_callback, osTimerOnce, desktop, NULL);
|
||||
furi_timer_alloc(desktop_auto_lock_timer_callback, FuriTimerTypeOnce, desktop);
|
||||
|
||||
return desktop;
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ void desktop_free(Desktop* desktop) {
|
|||
|
||||
furi_record_close("menu");
|
||||
|
||||
osTimerDelete(desktop->auto_lock_timer);
|
||||
furi_timer_free(desktop->auto_lock_timer);
|
||||
|
||||
free(desktop);
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ struct Desktop {
|
|||
FuriPubSubSubscription* app_start_stop_subscription;
|
||||
FuriPubSub* input_events_pubsub;
|
||||
FuriPubSubSubscription* input_events_subscription;
|
||||
osTimerId_t auto_lock_timer;
|
||||
FuriTimer* auto_lock_timer;
|
||||
};
|
||||
|
||||
Desktop* desktop_alloc();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <stdint.h>
|
||||
#include <furi/check.h>
|
||||
#include <core/check.h>
|
||||
#include <gui/scene_manager.h>
|
||||
#include "../../helpers/pin_lock.h"
|
||||
#include "../desktop_settings_app.h"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <stdint.h>
|
||||
#include <furi/check.h>
|
||||
#include <core/check.h>
|
||||
#include <gui/scene_manager.h>
|
||||
#include <gui/modules/popup.h>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <stdint.h>
|
||||
#include <furi/check.h>
|
||||
#include <core/check.h>
|
||||
#include <gui/scene_manager.h>
|
||||
|
||||
#include "desktop/desktop_settings/desktop_settings.h"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <stdint.h>
|
||||
#include <furi/check.h>
|
||||
#include <core/check.h>
|
||||
#include <gui/scene_manager.h>
|
||||
|
||||
#include "../desktop_settings_app.h"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <storage/storage.h>
|
||||
#include <gui/icon.h>
|
||||
#include <gui/icon_i.h>
|
||||
#include <furi/dangerous_defines.h>
|
||||
#include <core/dangerous_defines.h>
|
||||
|
||||
#define SLIDESHOW_MAGIC 0x72676468
|
||||
#define SLIDESHOW_MAX_SUPPORTED_VERSION 1
|
||||
|
|
|
@ -150,7 +150,7 @@ void desktop_scene_pin_input_on_exit(void* context) {
|
|||
desktop->scene_manager, DesktopScenePinInput);
|
||||
xTimerStop(state->timer, portMAX_DELAY);
|
||||
while(xTimerIsTimerActive(state->timer)) {
|
||||
furi_hal_delay_ms(1);
|
||||
furi_delay_tick(1);
|
||||
}
|
||||
xTimerDelete(state->timer, portMAX_DELAY);
|
||||
free(state);
|
||||
|
|
|
@ -206,7 +206,7 @@ DesktopViewLocked* desktop_view_locked_alloc() {
|
|||
|
||||
void desktop_view_locked_free(DesktopViewLocked* locked_view) {
|
||||
furi_assert(locked_view);
|
||||
osTimerDelete(locked_view->timer);
|
||||
furi_timer_free(locked_view->timer);
|
||||
view_free(locked_view->view);
|
||||
free(locked_view);
|
||||
}
|
||||
|
|
|
@ -99,6 +99,6 @@ DesktopMainView* desktop_main_alloc() {
|
|||
void desktop_main_free(DesktopMainView* main_view) {
|
||||
furi_assert(main_view);
|
||||
view_free(main_view->view);
|
||||
osTimerDelete(main_view->poweroff_timer);
|
||||
furi_timer_free(main_view->poweroff_timer);
|
||||
free(main_view);
|
||||
}
|
||||
|
|
|
@ -214,7 +214,7 @@ void desktop_view_pin_input_free(DesktopViewPinInput* pin_input) {
|
|||
|
||||
xTimerStop(pin_input->timer, portMAX_DELAY);
|
||||
while(xTimerIsTimerActive(pin_input->timer)) {
|
||||
furi_hal_delay_ms(1);
|
||||
furi_delay_tick(1);
|
||||
}
|
||||
xTimerDelete(pin_input->timer, portMAX_DELAY);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
static DialogsApp* dialogs_app_alloc() {
|
||||
DialogsApp* app = malloc(sizeof(DialogsApp));
|
||||
app->message_queue = osMessageQueueNew(8, sizeof(DialogsAppMessage), NULL);
|
||||
app->message_queue = furi_message_queue_alloc(8, sizeof(DialogsAppMessage));
|
||||
|
||||
return app;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ int32_t dialogs_srv(void* p) {
|
|||
|
||||
DialogsAppMessage message;
|
||||
while(1) {
|
||||
if(osMessageQueueGet(app->message_queue, &message, NULL, osWaitForever) == osOK) {
|
||||
if(furi_message_queue_get(app->message_queue, &message, FuriWaitForever) == FuriStatusOk) {
|
||||
dialogs_app_process_message(app, &message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,8 @@ bool dialog_file_browser_show(
|
|||
.return_data = &return_data,
|
||||
};
|
||||
|
||||
furi_check(osMessageQueuePut(context->message_queue, &message, 0, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
furi_message_queue_put(context->message_queue, &message, FuriWaitForever) == FuriStatusOk);
|
||||
API_LOCK_WAIT_UNTIL_UNLOCK_AND_FREE(lock);
|
||||
|
||||
return return_data.bool_value;
|
||||
|
@ -60,7 +61,8 @@ DialogMessageButton dialog_message_show(DialogsApp* context, const DialogMessage
|
|||
.return_data = &return_data,
|
||||
};
|
||||
|
||||
furi_check(osMessageQueuePut(context->message_queue, &message, 0, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
furi_message_queue_put(context->message_queue, &message, FuriWaitForever) == FuriStatusOk);
|
||||
API_LOCK_WAIT_UNTIL_UNLOCK_AND_FREE(lock);
|
||||
|
||||
return return_data.dialog_value;
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
typedef osEventFlagsId_t FuriApiLock;
|
||||
typedef FuriEventFlag* FuriApiLock;
|
||||
|
||||
#define API_LOCK_EVENT (1U << 0)
|
||||
|
||||
#define API_LOCK_INIT_LOCKED() osEventFlagsNew(NULL);
|
||||
#define API_LOCK_INIT_LOCKED() furi_event_flag_alloc();
|
||||
|
||||
#define API_LOCK_WAIT_UNTIL_UNLOCK(_lock) \
|
||||
osEventFlagsWait(_lock, API_LOCK_EVENT, osFlagsWaitAny, osWaitForever);
|
||||
furi_event_flag_wait(_lock, API_LOCK_EVENT, FuriFlagWaitAny, FuriWaitForever);
|
||||
|
||||
#define API_LOCK_FREE(_lock) osEventFlagsDelete(_lock);
|
||||
#define API_LOCK_FREE(_lock) furi_event_flag_free(_lock);
|
||||
|
||||
#define API_LOCK_UNLOCK(_lock) osEventFlagsSet(_lock, API_LOCK_EVENT);
|
||||
#define API_LOCK_UNLOCK(_lock) furi_event_flag_set(_lock, API_LOCK_EVENT);
|
||||
|
||||
#define API_LOCK_WAIT_UNTIL_UNLOCK_AND_FREE(_lock) \
|
||||
API_LOCK_WAIT_UNTIL_UNLOCK(_lock); \
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
struct DialogsApp {
|
||||
osMessageQueueId_t message_queue;
|
||||
FuriMessageQueue* message_queue;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -96,7 +96,7 @@ void view_holder_start(ViewHolder* view_holder) {
|
|||
}
|
||||
|
||||
void view_holder_stop(ViewHolder* view_holder) {
|
||||
while(view_holder->ongoing_input) osDelay(1);
|
||||
while(view_holder->ongoing_input) furi_delay_tick(1);
|
||||
view_port_enabled_set(view_holder->view_port, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ Dolphin* dolphin_alloc() {
|
|||
Dolphin* dolphin = malloc(sizeof(Dolphin));
|
||||
|
||||
dolphin->state = dolphin_state_alloc();
|
||||
dolphin->event_queue = osMessageQueueNew(8, sizeof(DolphinEvent), NULL);
|
||||
dolphin->event_queue = furi_message_queue_alloc(8, sizeof(DolphinEvent));
|
||||
dolphin->pubsub = furi_pubsub_alloc();
|
||||
dolphin->butthurt_timer = xTimerCreate(
|
||||
NULL, HOURS_IN_TICKS(2 * 24), pdTRUE, dolphin, dolphin_butthurt_timer_callback);
|
||||
|
@ -93,7 +93,7 @@ void dolphin_free(Dolphin* dolphin) {
|
|||
furi_assert(dolphin);
|
||||
|
||||
dolphin_state_free(dolphin->state);
|
||||
osMessageQueueDelete(dolphin->event_queue);
|
||||
furi_message_queue_free(dolphin->event_queue);
|
||||
|
||||
free(dolphin);
|
||||
}
|
||||
|
@ -102,25 +102,28 @@ void dolphin_event_send_async(Dolphin* dolphin, DolphinEvent* event) {
|
|||
furi_assert(dolphin);
|
||||
furi_assert(event);
|
||||
event->flag = NULL;
|
||||
furi_check(osMessageQueuePut(dolphin->event_queue, event, 0, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
furi_message_queue_put(dolphin->event_queue, event, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void dolphin_event_send_wait(Dolphin* dolphin, DolphinEvent* event) {
|
||||
furi_assert(dolphin);
|
||||
furi_assert(event);
|
||||
event->flag = osEventFlagsNew(NULL);
|
||||
event->flag = furi_event_flag_alloc();
|
||||
furi_check(event->flag);
|
||||
furi_check(osMessageQueuePut(dolphin->event_queue, event, 0, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
osEventFlagsWait(event->flag, DOLPHIN_LOCK_EVENT_FLAG, osFlagsWaitAny, osWaitForever) ==
|
||||
furi_message_queue_put(dolphin->event_queue, event, FuriWaitForever) == FuriStatusOk);
|
||||
furi_check(
|
||||
furi_event_flag_wait(
|
||||
event->flag, DOLPHIN_LOCK_EVENT_FLAG, FuriFlagWaitAny, FuriWaitForever) ==
|
||||
DOLPHIN_LOCK_EVENT_FLAG);
|
||||
furi_check(osEventFlagsDelete(event->flag) == osOK);
|
||||
furi_event_flag_free(event->flag);
|
||||
}
|
||||
|
||||
void dolphin_event_release(Dolphin* dolphin, DolphinEvent* event) {
|
||||
UNUSED(dolphin);
|
||||
if(event->flag) {
|
||||
osEventFlagsSet(event->flag, DOLPHIN_LOCK_EVENT_FLAG);
|
||||
furi_event_flag_set(event->flag, DOLPHIN_LOCK_EVENT_FLAG);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,7 +164,8 @@ int32_t dolphin_srv(void* p) {
|
|||
|
||||
DolphinEvent event;
|
||||
while(1) {
|
||||
if(osMessageQueueGet(dolphin->event_queue, &event, NULL, HOURS_IN_TICKS(1)) == osOK) {
|
||||
if(furi_message_queue_get(dolphin->event_queue, &event, HOURS_IN_TICKS(1)) ==
|
||||
FuriStatusOk) {
|
||||
if(event.type == DolphinEventTypeDeed) {
|
||||
dolphin_state_on_deed(dolphin->state, event.deed);
|
||||
DolphinPubsubEvent event = DolphinPubsubEventUpdate;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "furi/pubsub.h"
|
||||
#include <core/pubsub.h>
|
||||
#include "gui/view.h"
|
||||
#include "helpers/dolphin_deed.h"
|
||||
#include <stdbool.h>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "furi/pubsub.h"
|
||||
#include <core/pubsub.h>
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
|
||||
|
@ -17,7 +17,7 @@ typedef enum {
|
|||
|
||||
typedef struct {
|
||||
DolphinEventType type;
|
||||
osEventFlagsId_t flag;
|
||||
FuriEventFlag* flag;
|
||||
union {
|
||||
DolphinDeed deed;
|
||||
DolphinStats* stats;
|
||||
|
@ -28,7 +28,7 @@ struct Dolphin {
|
|||
// State
|
||||
DolphinState* state;
|
||||
// Queue
|
||||
osMessageQueueId_t event_queue;
|
||||
FuriMessageQueue* event_queue;
|
||||
FuriPubSub* pubsub;
|
||||
TimerHandle_t butthurt_timer;
|
||||
TimerHandle_t flush_timer;
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
#include "assets_icons.h"
|
||||
#include "cmsis_os2.h"
|
||||
#include "dolphin/helpers/dolphin_state.h"
|
||||
#include "furi/check.h"
|
||||
#include "furi/record.h"
|
||||
#include <core/check.h>
|
||||
#include <core/record.h>
|
||||
#include <furi.h>
|
||||
#include <gui/gui.h>
|
||||
#include <furi_hal_version.h>
|
||||
|
@ -28,10 +27,10 @@ static const Icon* const portrait_bad[BUTTHURT_MAX] = {
|
|||
static const Icon* const* portraits[MOODS_TOTAL] = {portrait_happy, portrait_ok, portrait_bad};
|
||||
|
||||
static void input_callback(InputEvent* input, void* ctx) {
|
||||
osSemaphoreId_t semaphore = ctx;
|
||||
FuriSemaphore* semaphore = ctx;
|
||||
|
||||
if((input->type == InputTypeShort) && (input->key == InputKeyBack)) {
|
||||
osSemaphoreRelease(semaphore);
|
||||
furi_semaphore_release(semaphore);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,7 +90,7 @@ static void render_callback(Canvas* canvas, void* ctx) {
|
|||
|
||||
int32_t passport_app(void* p) {
|
||||
UNUSED(p);
|
||||
osSemaphoreId_t semaphore = osSemaphoreNew(1, 0, NULL);
|
||||
FuriSemaphore* semaphore = furi_semaphore_alloc(1, 0);
|
||||
furi_assert(semaphore);
|
||||
|
||||
ViewPort* view_port = view_port_alloc();
|
||||
|
@ -105,12 +104,12 @@ int32_t passport_app(void* p) {
|
|||
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
|
||||
view_port_update(view_port);
|
||||
|
||||
furi_check(osSemaphoreAcquire(semaphore, osWaitForever) == osOK);
|
||||
furi_check(furi_semaphore_acquire(semaphore, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
gui_remove_view_port(gui, view_port);
|
||||
view_port_free(view_port);
|
||||
furi_record_close("gui");
|
||||
osSemaphoreDelete(semaphore);
|
||||
furi_semaphore_free(semaphore);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -45,9 +45,9 @@ struct UsbUartBridge {
|
|||
|
||||
StreamBufferHandle_t rx_stream;
|
||||
|
||||
osMutexId_t usb_mutex;
|
||||
FuriMutex* usb_mutex;
|
||||
|
||||
osSemaphoreId_t tx_sem;
|
||||
FuriSemaphore* tx_sem;
|
||||
|
||||
UsbUartState st;
|
||||
|
||||
|
@ -158,8 +158,8 @@ static int32_t usb_uart_worker(void* context) {
|
|||
|
||||
usb_uart->rx_stream = xStreamBufferCreate(USB_UART_RX_BUF_SIZE, 1);
|
||||
|
||||
usb_uart->tx_sem = osSemaphoreNew(1, 1, NULL);
|
||||
usb_uart->usb_mutex = osMutexNew(NULL);
|
||||
usb_uart->tx_sem = furi_semaphore_alloc(1, 1);
|
||||
usb_uart->usb_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
|
||||
usb_uart->tx_thread = furi_thread_alloc();
|
||||
furi_thread_set_name(usb_uart->tx_thread, "UsbUartTxWorker");
|
||||
|
@ -185,18 +185,19 @@ static int32_t usb_uart_worker(void* context) {
|
|||
|
||||
while(1) {
|
||||
uint32_t events =
|
||||
furi_thread_flags_wait(WORKER_ALL_RX_EVENTS, osFlagsWaitAny, osWaitForever);
|
||||
furi_check((events & osFlagsError) == 0);
|
||||
furi_thread_flags_wait(WORKER_ALL_RX_EVENTS, FuriFlagWaitAny, FuriWaitForever);
|
||||
furi_check((events & FuriFlagError) == 0);
|
||||
if(events & WorkerEvtStop) break;
|
||||
if(events & WorkerEvtRxDone) {
|
||||
size_t len =
|
||||
xStreamBufferReceive(usb_uart->rx_stream, usb_uart->rx_buf, USB_CDC_PKT_LEN, 0);
|
||||
if(len > 0) {
|
||||
if(osSemaphoreAcquire(usb_uart->tx_sem, 100) == osOK) {
|
||||
if(furi_semaphore_acquire(usb_uart->tx_sem, 100) == FuriStatusOk) {
|
||||
usb_uart->st.rx_cnt += len;
|
||||
furi_check(osMutexAcquire(usb_uart->usb_mutex, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
furi_mutex_acquire(usb_uart->usb_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
furi_hal_cdc_send(usb_uart->cfg.vcp_ch, usb_uart->rx_buf, len);
|
||||
furi_check(osMutexRelease(usb_uart->usb_mutex) == osOK);
|
||||
furi_check(furi_mutex_release(usb_uart->usb_mutex) == FuriStatusOk);
|
||||
} else {
|
||||
xStreamBufferReset(usb_uart->rx_stream);
|
||||
}
|
||||
|
@ -270,8 +271,8 @@ static int32_t usb_uart_worker(void* context) {
|
|||
furi_thread_free(usb_uart->tx_thread);
|
||||
|
||||
vStreamBufferDelete(usb_uart->rx_stream);
|
||||
osMutexDelete(usb_uart->usb_mutex);
|
||||
osSemaphoreDelete(usb_uart->tx_sem);
|
||||
furi_mutex_free(usb_uart->usb_mutex);
|
||||
furi_semaphore_free(usb_uart->tx_sem);
|
||||
|
||||
furi_hal_usb_unlock();
|
||||
furi_check(furi_hal_usb_set_config(&usb_cdc_single, NULL) == true);
|
||||
|
@ -288,13 +289,13 @@ static int32_t usb_uart_tx_thread(void* context) {
|
|||
uint8_t data[USB_CDC_PKT_LEN];
|
||||
while(1) {
|
||||
uint32_t events =
|
||||
furi_thread_flags_wait(WORKER_ALL_TX_EVENTS, osFlagsWaitAny, osWaitForever);
|
||||
furi_check((events & osFlagsError) == 0);
|
||||
furi_thread_flags_wait(WORKER_ALL_TX_EVENTS, FuriFlagWaitAny, FuriWaitForever);
|
||||
furi_check((events & FuriFlagError) == 0);
|
||||
if(events & WorkerEvtTxStop) break;
|
||||
if(events & WorkerEvtCdcRx) {
|
||||
furi_check(osMutexAcquire(usb_uart->usb_mutex, osWaitForever) == osOK);
|
||||
furi_check(furi_mutex_acquire(usb_uart->usb_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
size_t len = furi_hal_cdc_receive(usb_uart->cfg.vcp_ch, data, USB_CDC_PKT_LEN);
|
||||
furi_check(osMutexRelease(usb_uart->usb_mutex) == osOK);
|
||||
furi_check(furi_mutex_release(usb_uart->usb_mutex) == FuriStatusOk);
|
||||
|
||||
if(len > 0) {
|
||||
usb_uart->st.tx_cnt += len;
|
||||
|
@ -309,7 +310,7 @@ static int32_t usb_uart_tx_thread(void* context) {
|
|||
|
||||
static void vcp_on_cdc_tx_complete(void* context) {
|
||||
UsbUartBridge* usb_uart = (UsbUartBridge*)context;
|
||||
osSemaphoreRelease(usb_uart->tx_sem);
|
||||
furi_semaphore_release(usb_uart->tx_sem);
|
||||
}
|
||||
|
||||
static void vcp_on_cdc_rx(void* context) {
|
||||
|
|
|
@ -28,7 +28,7 @@ void gui_input_events_callback(const void* value, void* ctx) {
|
|||
|
||||
Gui* gui = ctx;
|
||||
|
||||
osMessageQueuePut(gui->input_queue, value, 0, osWaitForever);
|
||||
furi_message_queue_put(gui->input_queue, value, FuriWaitForever);
|
||||
furi_thread_flags_set(gui->thread_id, GUI_THREAD_FLAG_INPUT);
|
||||
}
|
||||
|
||||
|
@ -308,12 +308,12 @@ void gui_input(Gui* gui, InputEvent* input_event) {
|
|||
|
||||
void gui_lock(Gui* gui) {
|
||||
furi_assert(gui);
|
||||
furi_check(osMutexAcquire(gui->mutex, osWaitForever) == osOK);
|
||||
furi_check(furi_mutex_acquire(gui->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void gui_unlock(Gui* gui) {
|
||||
furi_assert(gui);
|
||||
furi_check(osMutexRelease(gui->mutex) == osOK);
|
||||
furi_check(furi_mutex_release(gui->mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void gui_add_view_port(Gui* gui, ViewPort* view_port, GuiLayer layer) {
|
||||
|
@ -473,7 +473,7 @@ Gui* gui_alloc() {
|
|||
// Thread ID
|
||||
gui->thread_id = furi_thread_get_current_id();
|
||||
// Allocate mutex
|
||||
gui->mutex = osMutexNew(NULL);
|
||||
gui->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
furi_check(gui->mutex);
|
||||
// Layers
|
||||
for(size_t i = 0; i < GuiLayerMAX; i++) {
|
||||
|
@ -484,7 +484,7 @@ Gui* gui_alloc() {
|
|||
CanvasCallbackPairArray_init(gui->canvas_callback_pair);
|
||||
|
||||
// Input
|
||||
gui->input_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL);
|
||||
gui->input_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
|
||||
gui->input_events = furi_record_open("input_events");
|
||||
|
||||
furi_check(gui->input_events);
|
||||
|
@ -501,12 +501,12 @@ int32_t gui_srv(void* p) {
|
|||
|
||||
while(1) {
|
||||
uint32_t flags =
|
||||
furi_thread_flags_wait(GUI_THREAD_FLAG_ALL, osFlagsWaitAny, osWaitForever);
|
||||
furi_thread_flags_wait(GUI_THREAD_FLAG_ALL, FuriFlagWaitAny, FuriWaitForever);
|
||||
// Process and dispatch input
|
||||
if(flags & GUI_THREAD_FLAG_INPUT) {
|
||||
// Process till queue become empty
|
||||
InputEvent input_event;
|
||||
while(osMessageQueueGet(gui->input_queue, &input_event, NULL, 0) == osOK) {
|
||||
while(furi_message_queue_get(gui->input_queue, &input_event, 0) == FuriStatusOk) {
|
||||
gui_input(gui, &input_event);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ ALGO_DEF(CanvasCallbackPairArray, CanvasCallbackPairArray_t);
|
|||
struct Gui {
|
||||
// Thread and lock
|
||||
FuriThreadId thread_id;
|
||||
osMutexId_t mutex;
|
||||
FuriMutex* mutex;
|
||||
|
||||
// Layers and Canvas
|
||||
bool lockdown;
|
||||
|
@ -67,7 +67,7 @@ struct Gui {
|
|||
CanvasCallbackPairArray_t canvas_callback_pair;
|
||||
|
||||
// Input
|
||||
osMessageQueueId_t input_queue;
|
||||
FuriMessageQueue* input_queue;
|
||||
FuriPubSub* input_events;
|
||||
uint8_t ongoing_input;
|
||||
ViewPort* ongoing_input_view_port;
|
||||
|
|
|
@ -7,15 +7,16 @@ IconAnimation* icon_animation_alloc(const Icon* icon) {
|
|||
furi_assert(icon);
|
||||
IconAnimation* instance = malloc(sizeof(IconAnimation));
|
||||
instance->icon = icon;
|
||||
instance->timer = osTimerNew(icon_animation_timer_callback, osTimerPeriodic, instance, NULL);
|
||||
instance->timer =
|
||||
furi_timer_alloc(icon_animation_timer_callback, FuriTimerTypePeriodic, instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
void icon_animation_free(IconAnimation* instance) {
|
||||
furi_assert(instance);
|
||||
icon_animation_stop(instance);
|
||||
while(xTimerIsTimerActive(instance->timer) == pdTRUE) osDelay(1);
|
||||
furi_check(osTimerDelete(instance->timer) == osOK);
|
||||
while(xTimerIsTimerActive(instance->timer) == pdTRUE) furi_delay_tick(1);
|
||||
furi_timer_free(instance->timer);
|
||||
free(instance);
|
||||
}
|
||||
|
||||
|
@ -68,7 +69,7 @@ void icon_animation_start(IconAnimation* instance) {
|
|||
furi_check(
|
||||
xTimerChangePeriod(
|
||||
instance->timer,
|
||||
(osKernelGetTickFreq() / instance->icon->frame_rate),
|
||||
(furi_kernel_get_tick_frequency() / instance->icon->frame_rate),
|
||||
portMAX_DELAY) == pdPASS);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ struct IconAnimation {
|
|||
const Icon* icon;
|
||||
uint8_t frame;
|
||||
bool animating;
|
||||
osTimerId_t timer;
|
||||
FuriTimer* timer;
|
||||
IconAnimationCallback callback;
|
||||
void* callback_context;
|
||||
};
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
#include "file_browser.h"
|
||||
#include "assets_icons.h"
|
||||
#include "cmsis_os2.h"
|
||||
#include "file_browser_worker.h"
|
||||
#include "furi/check.h"
|
||||
#include "furi/common_defines.h"
|
||||
#include "furi/log.h"
|
||||
#include <core/check.h>
|
||||
#include <core/common_defines.h>
|
||||
#include <core/log.h>
|
||||
#include "furi_hal_resources.h"
|
||||
#include "m-string.h"
|
||||
#include <m-array.h>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "file_browser_worker.h"
|
||||
#include "furi/check.h"
|
||||
#include "furi/common_defines.h"
|
||||
#include <core/check.h>
|
||||
#include <core/common_defines.h>
|
||||
#include "m-string.h"
|
||||
#include "storage/filesystem_api_defines.h"
|
||||
#include <m-array.h>
|
||||
|
@ -262,8 +262,9 @@ static int32_t browser_worker(void* context) {
|
|||
furi_thread_flags_set(furi_thread_get_id(browser->thread), WorkerEvtConfigChange);
|
||||
|
||||
while(1) {
|
||||
uint32_t flags = furi_thread_flags_wait(WORKER_FLAGS_ALL, osFlagsWaitAny, osWaitForever);
|
||||
furi_assert((flags & osFlagsError) == 0);
|
||||
uint32_t flags =
|
||||
furi_thread_flags_wait(WORKER_FLAGS_ALL, FuriFlagWaitAny, FuriWaitForever);
|
||||
furi_assert((flags & FuriFlagError) == 0);
|
||||
|
||||
if(flags & WorkerEvtConfigChange) {
|
||||
// If start path is a path to the file - try finding index of this file in a folder
|
||||
|
|
|
@ -7,7 +7,7 @@ struct Popup {
|
|||
void* context;
|
||||
PopupCallback callback;
|
||||
|
||||
osTimerId_t timer;
|
||||
FuriTimer* timer;
|
||||
uint32_t timer_period_in_ms;
|
||||
bool timer_enabled;
|
||||
};
|
||||
|
@ -93,10 +93,11 @@ static bool popup_view_input_callback(InputEvent* event, void* context) {
|
|||
void popup_start_timer(void* context) {
|
||||
Popup* popup = context;
|
||||
if(popup->timer_enabled) {
|
||||
uint32_t timer_period = popup->timer_period_in_ms / (1000.0f / osKernelGetTickFreq());
|
||||
uint32_t timer_period =
|
||||
popup->timer_period_in_ms / (1000.0f / furi_kernel_get_tick_frequency());
|
||||
if(timer_period == 0) timer_period = 1;
|
||||
|
||||
if(osTimerStart(popup->timer, timer_period) != osOK) {
|
||||
if(furi_timer_start(popup->timer, timer_period) != FuriStatusOk) {
|
||||
furi_assert(0);
|
||||
};
|
||||
}
|
||||
|
@ -104,13 +105,13 @@ void popup_start_timer(void* context) {
|
|||
|
||||
void popup_stop_timer(void* context) {
|
||||
Popup* popup = context;
|
||||
osTimerStop(popup->timer);
|
||||
furi_timer_stop(popup->timer);
|
||||
}
|
||||
|
||||
Popup* popup_alloc() {
|
||||
Popup* popup = malloc(sizeof(Popup));
|
||||
popup->view = view_alloc();
|
||||
popup->timer = osTimerNew(popup_timer_callback, osTimerOnce, popup, NULL);
|
||||
popup->timer = furi_timer_alloc(popup_timer_callback, FuriTimerTypeOnce, popup);
|
||||
furi_assert(popup->timer);
|
||||
popup->timer_period_in_ms = 1000;
|
||||
popup->timer_enabled = false;
|
||||
|
@ -146,7 +147,7 @@ Popup* popup_alloc() {
|
|||
|
||||
void popup_free(Popup* popup) {
|
||||
furi_assert(popup);
|
||||
osTimerDelete(popup->timer);
|
||||
furi_timer_free(popup->timer);
|
||||
view_free(popup->view);
|
||||
free(popup);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
struct TextInput {
|
||||
View* view;
|
||||
osTimerId_t timer;
|
||||
FuriTimer* timer;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
@ -310,7 +310,7 @@ static void text_input_handle_ok(TextInput* text_input, TextInputModel* model, b
|
|||
(!model->validator_callback(
|
||||
model->text_buffer, model->validator_text, model->validator_callback_context))) {
|
||||
model->valadator_message_visible = true;
|
||||
osTimerStart(text_input->timer, osKernelGetTickFreq() * 4);
|
||||
furi_timer_start(text_input->timer, furi_kernel_get_tick_frequency() * 4);
|
||||
} else if(model->callback != 0 && text_length > 0) {
|
||||
model->callback(model->callback_context);
|
||||
}
|
||||
|
@ -438,7 +438,7 @@ TextInput* text_input_alloc() {
|
|||
view_set_draw_callback(text_input->view, text_input_view_draw_callback);
|
||||
view_set_input_callback(text_input->view, text_input_view_input_callback);
|
||||
|
||||
text_input->timer = osTimerNew(text_input_timer_callback, osTimerOnce, text_input, NULL);
|
||||
text_input->timer = furi_timer_alloc(text_input_timer_callback, FuriTimerTypeOnce, text_input);
|
||||
|
||||
with_view_model(
|
||||
text_input->view, (TextInputModel * model) {
|
||||
|
@ -460,11 +460,11 @@ void text_input_free(TextInput* text_input) {
|
|||
});
|
||||
|
||||
// Send stop command
|
||||
osTimerStop(text_input->timer);
|
||||
furi_timer_stop(text_input->timer);
|
||||
// Wait till timer stop
|
||||
while(osTimerIsRunning(text_input->timer)) osDelay(1);
|
||||
while(furi_timer_is_running(text_input->timer)) furi_delay_tick(1);
|
||||
// Release allocated memory
|
||||
osTimerDelete(text_input->timer);
|
||||
furi_timer_free(text_input->timer);
|
||||
|
||||
view_free(text_input->view);
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ void view_allocate_model(View* view, ViewModelType type, size_t size) {
|
|||
view->model = malloc(size);
|
||||
} else if(view->model_type == ViewModelTypeLocking) {
|
||||
ViewModelLocking* model = malloc(sizeof(ViewModelLocking));
|
||||
model->mutex = osMutexNew(NULL);
|
||||
model->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
furi_check(model->mutex);
|
||||
model->data = malloc(size);
|
||||
view->model = model;
|
||||
|
@ -98,7 +98,7 @@ void view_free_model(View* view) {
|
|||
free(view->model);
|
||||
} else if(view->model_type == ViewModelTypeLocking) {
|
||||
ViewModelLocking* model = view->model;
|
||||
furi_check(osMutexDelete(model->mutex) == osOK);
|
||||
furi_mutex_free(model->mutex);
|
||||
free(model->data);
|
||||
free(model);
|
||||
view->model = NULL;
|
||||
|
@ -111,7 +111,7 @@ void* view_get_model(View* view) {
|
|||
furi_assert(view);
|
||||
if(view->model_type == ViewModelTypeLocking) {
|
||||
ViewModelLocking* model = (ViewModelLocking*)(view->model);
|
||||
furi_check(osMutexAcquire(model->mutex, osWaitForever) == osOK);
|
||||
furi_check(furi_mutex_acquire(model->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
return model->data;
|
||||
}
|
||||
return view->model;
|
||||
|
@ -138,7 +138,7 @@ void view_unlock_model(View* view) {
|
|||
furi_assert(view);
|
||||
if(view->model_type == ViewModelTypeLocking) {
|
||||
ViewModelLocking* model = (ViewModelLocking*)(view->model);
|
||||
furi_check(osMutexRelease(model->mutex) == osOK);
|
||||
furi_check(furi_mutex_release(model->mutex) == FuriStatusOk);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ void view_dispatcher_free(ViewDispatcher* view_dispatcher) {
|
|||
view_port_free(view_dispatcher->view_port);
|
||||
// Free internal queue
|
||||
if(view_dispatcher->queue) {
|
||||
osMessageQueueDelete(view_dispatcher->queue);
|
||||
furi_message_queue_free(view_dispatcher->queue);
|
||||
}
|
||||
// Free dispatcher
|
||||
free(view_dispatcher);
|
||||
|
@ -39,7 +39,7 @@ void view_dispatcher_free(ViewDispatcher* view_dispatcher) {
|
|||
void view_dispatcher_enable_queue(ViewDispatcher* view_dispatcher) {
|
||||
furi_assert(view_dispatcher);
|
||||
furi_assert(view_dispatcher->queue == NULL);
|
||||
view_dispatcher->queue = osMessageQueueNew(16, sizeof(ViewDispatcherMessage), NULL);
|
||||
view_dispatcher->queue = furi_message_queue_alloc(16, sizeof(ViewDispatcherMessage));
|
||||
}
|
||||
|
||||
void view_dispatcher_set_event_callback_context(ViewDispatcher* view_dispatcher, void* context) {
|
||||
|
@ -77,11 +77,11 @@ void view_dispatcher_run(ViewDispatcher* view_dispatcher) {
|
|||
furi_assert(view_dispatcher);
|
||||
furi_assert(view_dispatcher->queue);
|
||||
|
||||
uint32_t tick_period = view_dispatcher->tick_period == 0 ? osWaitForever :
|
||||
uint32_t tick_period = view_dispatcher->tick_period == 0 ? FuriWaitForever :
|
||||
view_dispatcher->tick_period;
|
||||
ViewDispatcherMessage message;
|
||||
while(1) {
|
||||
if(osMessageQueueGet(view_dispatcher->queue, &message, NULL, tick_period) != osOK) {
|
||||
if(furi_message_queue_get(view_dispatcher->queue, &message, tick_period) != FuriStatusOk) {
|
||||
view_dispatcher_handle_tick_event(view_dispatcher);
|
||||
continue;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ void view_dispatcher_run(ViewDispatcher* view_dispatcher) {
|
|||
|
||||
// Wait till all input events delivered
|
||||
while(view_dispatcher->ongoing_input) {
|
||||
osMessageQueueGet(view_dispatcher->queue, &message, NULL, osWaitForever);
|
||||
furi_message_queue_get(view_dispatcher->queue, &message, FuriWaitForever);
|
||||
if(message.type == ViewDispatcherMessageTypeInput) {
|
||||
uint8_t key_bit = (1 << message.input.key);
|
||||
if(message.input.type == InputTypePress) {
|
||||
|
@ -113,7 +113,8 @@ void view_dispatcher_stop(ViewDispatcher* view_dispatcher) {
|
|||
furi_assert(view_dispatcher->queue);
|
||||
ViewDispatcherMessage message;
|
||||
message.type = ViewDispatcherMessageTypeStop;
|
||||
furi_check(osMessageQueuePut(view_dispatcher->queue, &message, 0, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
furi_message_queue_put(view_dispatcher->queue, &message, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void view_dispatcher_add_view(ViewDispatcher* view_dispatcher, uint32_t view_id, View* view) {
|
||||
|
@ -224,7 +225,9 @@ void view_dispatcher_input_callback(InputEvent* event, void* context) {
|
|||
ViewDispatcherMessage message;
|
||||
message.type = ViewDispatcherMessageTypeInput;
|
||||
message.input = *event;
|
||||
furi_check(osMessageQueuePut(view_dispatcher->queue, &message, 0, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
furi_message_queue_put(view_dispatcher->queue, &message, FuriWaitForever) ==
|
||||
FuriStatusOk);
|
||||
} else {
|
||||
view_dispatcher_handle_input(view_dispatcher, event);
|
||||
}
|
||||
|
@ -314,7 +317,8 @@ void view_dispatcher_send_custom_event(ViewDispatcher* view_dispatcher, uint32_t
|
|||
message.type = ViewDispatcherMessageTypeCustomEvent;
|
||||
message.custom_event = event;
|
||||
|
||||
furi_check(osMessageQueuePut(view_dispatcher->queue, &message, 0, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
furi_message_queue_put(view_dispatcher->queue, &message, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void view_dispatcher_set_current_view(ViewDispatcher* view_dispatcher, View* view) {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
DICT_DEF2(ViewDict, uint32_t, M_DEFAULT_OPLIST, View*, M_PTR_OPLIST)
|
||||
|
||||
struct ViewDispatcher {
|
||||
osMessageQueueId_t queue;
|
||||
FuriMessageQueue* queue;
|
||||
Gui* gui;
|
||||
ViewPort* view_port;
|
||||
ViewDict_t views;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
typedef struct {
|
||||
void* data;
|
||||
osMutexId_t mutex;
|
||||
FuriMutex* mutex;
|
||||
} ViewModelLocking;
|
||||
|
||||
struct View {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "gui/view.h"
|
||||
#include "furi/memmgr.h"
|
||||
#include <core/memmgr.h>
|
||||
#include "view_stack.h"
|
||||
#include "view_i.h"
|
||||
|
||||
|
|
|
@ -67,14 +67,14 @@ void ibutton_cli_print_key_data(iButtonKey* key) {
|
|||
|
||||
static void ibutton_cli_worker_read_cb(void* context) {
|
||||
furi_assert(context);
|
||||
osEventFlagsId_t event = context;
|
||||
osEventFlagsSet(event, EVENT_FLAG_IBUTTON_COMPLETE);
|
||||
FuriEventFlag* event = context;
|
||||
furi_event_flag_set(event, EVENT_FLAG_IBUTTON_COMPLETE);
|
||||
}
|
||||
|
||||
void ibutton_cli_read(Cli* cli) {
|
||||
iButtonKey* key = ibutton_key_alloc();
|
||||
iButtonWorker* worker = ibutton_worker_alloc();
|
||||
osEventFlagsId_t event = osEventFlagsNew(NULL);
|
||||
FuriEventFlag* event = furi_event_flag_alloc();
|
||||
|
||||
ibutton_worker_start_thread(worker);
|
||||
ibutton_worker_read_set_callback(worker, ibutton_cli_worker_read_cb, event);
|
||||
|
@ -82,7 +82,8 @@ void ibutton_cli_read(Cli* cli) {
|
|||
printf("Reading iButton...\r\nPress Ctrl+C to abort\r\n");
|
||||
ibutton_worker_read_start(worker, key);
|
||||
while(true) {
|
||||
uint32_t flags = osEventFlagsWait(event, EVENT_FLAG_IBUTTON_COMPLETE, osFlagsWaitAny, 100);
|
||||
uint32_t flags =
|
||||
furi_event_flag_wait(event, EVENT_FLAG_IBUTTON_COMPLETE, FuriFlagWaitAny, 100);
|
||||
|
||||
if(flags & EVENT_FLAG_IBUTTON_COMPLETE) {
|
||||
ibutton_cli_print_key_data(key);
|
||||
|
@ -107,11 +108,11 @@ void ibutton_cli_read(Cli* cli) {
|
|||
ibutton_worker_free(worker);
|
||||
ibutton_key_free(key);
|
||||
|
||||
osEventFlagsDelete(event);
|
||||
furi_event_flag_free(event);
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
osEventFlagsId_t event;
|
||||
FuriEventFlag* event;
|
||||
iButtonWorkerWriteResult result;
|
||||
} iButtonWriteContext;
|
||||
|
||||
|
@ -119,7 +120,7 @@ static void ibutton_cli_worker_write_cb(void* context, iButtonWorkerWriteResult
|
|||
furi_assert(context);
|
||||
iButtonWriteContext* write_context = (iButtonWriteContext*)context;
|
||||
write_context->result = result;
|
||||
osEventFlagsSet(write_context->event, EVENT_FLAG_IBUTTON_COMPLETE);
|
||||
furi_event_flag_set(write_context->event, EVENT_FLAG_IBUTTON_COMPLETE);
|
||||
}
|
||||
|
||||
void ibutton_cli_write(Cli* cli, string_t args) {
|
||||
|
@ -130,7 +131,7 @@ void ibutton_cli_write(Cli* cli, string_t args) {
|
|||
uint8_t key_data[IBUTTON_KEY_DATA_SIZE];
|
||||
string_t data;
|
||||
|
||||
write_context.event = osEventFlagsNew(NULL);
|
||||
write_context.event = furi_event_flag_alloc();
|
||||
|
||||
string_init(data);
|
||||
ibutton_worker_start_thread(worker);
|
||||
|
@ -166,8 +167,8 @@ void ibutton_cli_write(Cli* cli, string_t args) {
|
|||
|
||||
ibutton_worker_write_start(worker, key);
|
||||
while(true) {
|
||||
uint32_t flags = osEventFlagsWait(
|
||||
write_context.event, EVENT_FLAG_IBUTTON_COMPLETE, osFlagsWaitAny, 100);
|
||||
uint32_t flags = furi_event_flag_wait(
|
||||
write_context.event, EVENT_FLAG_IBUTTON_COMPLETE, FuriFlagWaitAny, 100);
|
||||
|
||||
if(flags & EVENT_FLAG_IBUTTON_COMPLETE) {
|
||||
if(write_context.result == iButtonWorkerWriteSameKey ||
|
||||
|
@ -190,7 +191,7 @@ void ibutton_cli_write(Cli* cli, string_t args) {
|
|||
ibutton_worker_free(worker);
|
||||
ibutton_key_free(key);
|
||||
|
||||
osEventFlagsDelete(write_context.event);
|
||||
furi_event_flag_free(write_context.event);
|
||||
};
|
||||
|
||||
void ibutton_cli_emulate(Cli* cli, string_t args) {
|
||||
|
@ -228,7 +229,7 @@ void ibutton_cli_emulate(Cli* cli, string_t args) {
|
|||
|
||||
ibutton_worker_emulate_start(worker, key);
|
||||
while(!cli_cmd_interrupt_received(cli)) {
|
||||
furi_hal_delay_ms(100);
|
||||
furi_delay_ms(100);
|
||||
};
|
||||
ibutton_worker_stop(worker);
|
||||
} while(false);
|
||||
|
@ -291,7 +292,7 @@ static void onewire_cli_search(Cli* cli) {
|
|||
}
|
||||
printf("\r\n");
|
||||
}
|
||||
furi_hal_delay_ms(100);
|
||||
furi_delay_ms(100);
|
||||
}
|
||||
|
||||
furi_hal_power_disable_otg();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "../ibutton_i.h"
|
||||
#include "furi/log.h"
|
||||
#include <core/log.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
#include <toolbox/path.h>
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ static void infrared_cli_start_ir_rx(Cli* cli, string_t args) {
|
|||
|
||||
printf("Receiving INFRARED...\r\nPress Ctrl+C to abort\r\n");
|
||||
while(!cli_cmd_interrupt_received(cli)) {
|
||||
furi_hal_delay_ms(50);
|
||||
furi_delay_ms(50);
|
||||
}
|
||||
|
||||
infrared_worker_rx_stop(worker);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <m-array.h>
|
||||
#include <toolbox/path.h>
|
||||
#include <storage/storage.h>
|
||||
#include <furi/common_defines.h>
|
||||
#include <core/common_defines.h>
|
||||
|
||||
#define TAG "InfraredRemote"
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <furi/check.h>
|
||||
#include <core/check.h>
|
||||
#include <infrared_worker.h>
|
||||
#include <infrared_transmit.h>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "furi/check.h"
|
||||
#include <core/check.h>
|
||||
#include "furi_hal_resources.h"
|
||||
#include "assets_icons.h"
|
||||
#include "gui/canvas.h"
|
||||
|
|
|
@ -4,18 +4,18 @@
|
|||
|
||||
static Input* input = NULL;
|
||||
|
||||
inline static void input_timer_start(osTimerId_t timer_id, uint32_t ticks) {
|
||||
inline static void input_timer_start(FuriTimer* timer_id, uint32_t ticks) {
|
||||
TimerHandle_t hTimer = (TimerHandle_t)timer_id;
|
||||
furi_check(xTimerChangePeriod(hTimer, ticks, portMAX_DELAY) == pdPASS);
|
||||
}
|
||||
|
||||
inline static void input_timer_stop(osTimerId_t timer_id) {
|
||||
inline static void input_timer_stop(FuriTimer* timer_id) {
|
||||
TimerHandle_t hTimer = (TimerHandle_t)timer_id;
|
||||
furi_check(xTimerStop(hTimer, portMAX_DELAY) == pdPASS);
|
||||
// xTimerStop is not actually stopping timer,
|
||||
// Instead it places stop event into timer queue
|
||||
// This code ensures that timer is stopped
|
||||
while(xTimerIsTimerActive(hTimer) == pdTRUE) osDelay(1);
|
||||
while(xTimerIsTimerActive(hTimer) == pdTRUE) furi_delay_tick(1);
|
||||
}
|
||||
|
||||
void input_press_timer_callback(void* arg) {
|
||||
|
@ -84,8 +84,8 @@ int32_t input_srv() {
|
|||
input->pin_states[i].pin = &input_pins[i];
|
||||
input->pin_states[i].state = GPIO_Read(input->pin_states[i]);
|
||||
input->pin_states[i].debounce = INPUT_DEBOUNCE_TICKS_HALF;
|
||||
input->pin_states[i].press_timer =
|
||||
osTimerNew(input_press_timer_callback, osTimerPeriodic, &input->pin_states[i], NULL);
|
||||
input->pin_states[i].press_timer = furi_timer_alloc(
|
||||
input_press_timer_callback, FuriTimerTypePeriodic, &input->pin_states[i]);
|
||||
input->pin_states[i].press_counter = 0;
|
||||
}
|
||||
|
||||
|
@ -127,9 +127,9 @@ int32_t input_srv() {
|
|||
}
|
||||
|
||||
if(is_changing) {
|
||||
osDelay(1);
|
||||
furi_delay_tick(1);
|
||||
} else {
|
||||
furi_thread_flags_wait(INPUT_THREAD_FLAG_ISR, osFlagsWaitAny, osWaitForever);
|
||||
furi_thread_flags_wait(INPUT_THREAD_FLAG_ISR, FuriFlagWaitAny, FuriWaitForever);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,20 +15,20 @@ static void input_cli_usage() {
|
|||
static void input_cli_dump_events_callback(const void* value, void* ctx) {
|
||||
furi_assert(value);
|
||||
furi_assert(ctx);
|
||||
osMessageQueueId_t input_queue = ctx;
|
||||
osMessageQueuePut(input_queue, value, 0, osWaitForever);
|
||||
FuriMessageQueue* input_queue = ctx;
|
||||
furi_message_queue_put(input_queue, value, FuriWaitForever);
|
||||
}
|
||||
|
||||
static void input_cli_dump(Cli* cli, string_t args, Input* input) {
|
||||
UNUSED(args);
|
||||
osMessageQueueId_t input_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL);
|
||||
FuriMessageQueue* input_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
|
||||
FuriPubSubSubscription* input_subscription =
|
||||
furi_pubsub_subscribe(input->event_pubsub, input_cli_dump_events_callback, input_queue);
|
||||
|
||||
InputEvent input_event;
|
||||
printf("Press CTRL+C to stop\r\n");
|
||||
while(!cli_cmd_interrupt_received(cli)) {
|
||||
if(osMessageQueueGet(input_queue, &input_event, NULL, 100) == osOK) {
|
||||
if(furi_message_queue_get(input_queue, &input_event, 100) == FuriStatusOk) {
|
||||
printf(
|
||||
"key: %s type: %s\r\n",
|
||||
input_get_key_name(input_event.key),
|
||||
|
@ -37,7 +37,7 @@ static void input_cli_dump(Cli* cli, string_t args, Input* input) {
|
|||
}
|
||||
|
||||
furi_pubsub_unsubscribe(input->event_pubsub, input_subscription);
|
||||
osMessageQueueDelete(input_queue);
|
||||
furi_message_queue_free(input_queue);
|
||||
}
|
||||
|
||||
static void input_cli_send_print_usage() {
|
||||
|
|
|
@ -25,7 +25,7 @@ typedef struct {
|
|||
// State
|
||||
volatile bool state;
|
||||
volatile uint8_t debounce;
|
||||
volatile osTimerId_t press_timer;
|
||||
FuriTimer* press_timer;
|
||||
volatile uint8_t press_counter;
|
||||
volatile uint32_t counter;
|
||||
} InputPinState;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "rfid_key.h"
|
||||
#include <furi/check.h>
|
||||
#include <core/check.h>
|
||||
#include <string.h>
|
||||
|
||||
RfidKey::RfidKey() {
|
||||
|
|
|
@ -39,12 +39,12 @@ void RfidReader::decode(bool polarity) {
|
|||
}
|
||||
|
||||
bool RfidReader::switch_timer_elapsed() {
|
||||
const uint32_t seconds_to_switch = osKernelGetTickFreq() * 2.0f;
|
||||
return (osKernelGetTickCount() - switch_os_tick_last) > seconds_to_switch;
|
||||
const uint32_t seconds_to_switch = furi_kernel_get_tick_frequency() * 2.0f;
|
||||
return (furi_get_tick() - switch_os_tick_last) > seconds_to_switch;
|
||||
}
|
||||
|
||||
void RfidReader::switch_timer_reset() {
|
||||
switch_os_tick_last = osKernelGetTickCount();
|
||||
switch_os_tick_last = furi_get_tick();
|
||||
}
|
||||
|
||||
void RfidReader::switch_mode() {
|
||||
|
|
|
@ -49,15 +49,15 @@ void RfidWriter::stop() {
|
|||
|
||||
void RfidWriter::write_gap(uint32_t gap_time) {
|
||||
furi_hal_rfid_tim_read_stop();
|
||||
furi_hal_delay_us(gap_time * 8);
|
||||
furi_delay_us(gap_time * 8);
|
||||
furi_hal_rfid_tim_read_start();
|
||||
}
|
||||
|
||||
void RfidWriter::write_bit(bool value) {
|
||||
if(value) {
|
||||
furi_hal_delay_us(T55xxTiming::data_1 * 8);
|
||||
furi_delay_us(T55xxTiming::data_1 * 8);
|
||||
} else {
|
||||
furi_hal_delay_us(T55xxTiming::data_0 * 8);
|
||||
furi_delay_us(T55xxTiming::data_0 * 8);
|
||||
}
|
||||
write_gap(T55xxTiming::write_gap);
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ void RfidWriter::write_byte(uint8_t value) {
|
|||
}
|
||||
|
||||
void RfidWriter::write_block(uint8_t page, uint8_t block, bool lock_bit, uint32_t data) {
|
||||
furi_hal_delay_us(T55xxTiming::wait_time * 8);
|
||||
furi_delay_us(T55xxTiming::wait_time * 8);
|
||||
|
||||
// start gap
|
||||
write_gap(T55xxTiming::start_gap);
|
||||
|
@ -102,9 +102,9 @@ void RfidWriter::write_block(uint8_t page, uint8_t block, bool lock_bit, uint32_
|
|||
write_bit((block >> 1) & 1);
|
||||
write_bit((block >> 0) & 1);
|
||||
|
||||
furi_hal_delay_us(T55xxTiming::program * 8);
|
||||
furi_delay_us(T55xxTiming::program * 8);
|
||||
|
||||
furi_hal_delay_us(T55xxTiming::wait_time * 8);
|
||||
furi_delay_us(T55xxTiming::wait_time * 8);
|
||||
write_reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "lfrfid_app.h"
|
||||
#include "assets_icons.h"
|
||||
#include "furi/common_defines.h"
|
||||
#include <core/common_defines.h>
|
||||
#include "m-string.h"
|
||||
#include "scene/lfrfid_app_scene_start.h"
|
||||
#include "scene/lfrfid_app_scene_read.h"
|
||||
|
|
|
@ -94,7 +94,7 @@ static void lfrfid_cli_read(Cli* cli, string_t args) {
|
|||
printf("\r\n");
|
||||
break;
|
||||
}
|
||||
furi_hal_delay_ms(100);
|
||||
furi_delay_ms(100);
|
||||
}
|
||||
|
||||
printf("Reading stopped\r\n");
|
||||
|
@ -144,7 +144,7 @@ static void lfrfid_cli_emulate(Cli* cli, string_t args) {
|
|||
|
||||
printf("Emulating RFID...\r\nPress Ctrl+C to abort\r\n");
|
||||
while(!cli_cmd_interrupt_received(cli)) {
|
||||
furi_hal_delay_ms(100);
|
||||
furi_delay_ms(100);
|
||||
}
|
||||
printf("Emulation stopped\r\n");
|
||||
emulator.stop();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "lfrfid_app_scene_emulate.h"
|
||||
#include "furi/common_defines.h"
|
||||
#include <core/common_defines.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
static const NotificationSequence sequence_blink_start_magenta = {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "lfrfid_app_scene_rpc.h"
|
||||
#include "furi/common_defines.h"
|
||||
#include <core/common_defines.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
void LfRfidAppSceneRpc::on_enter(LfRfidApp* app, bool /* need_restore */) {
|
||||
|
|
|
@ -471,7 +471,7 @@ int32_t loader_srv(void* p) {
|
|||
|
||||
while(1) {
|
||||
uint32_t flags =
|
||||
furi_thread_flags_wait(LOADER_THREAD_FLAG_ALL, osFlagsWaitAny, osWaitForever);
|
||||
furi_thread_flags_wait(LOADER_THREAD_FLAG_ALL, FuriFlagWaitAny, FuriWaitForever);
|
||||
if(flags & LOADER_THREAD_FLAG_SHOW_MENU) {
|
||||
menu_set_selected_item(loader_instance->primary_menu, 0);
|
||||
view_dispatcher_switch_to_view(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <furi/pubsub.h>
|
||||
#include <core/pubsub.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct Loader Loader;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
#include <furi/pubsub.h>
|
||||
#include <core/pubsub.h>
|
||||
#include <cli/cli.h>
|
||||
#include <lib/toolbox/args.h>
|
||||
|
||||
|
|
|
@ -27,9 +27,9 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
MusicPlayerModel* model;
|
||||
osMutexId_t* model_mutex;
|
||||
FuriMutex** model_mutex;
|
||||
|
||||
osMessageQueueId_t input_queue;
|
||||
FuriMessageQueue* input_queue;
|
||||
|
||||
ViewPort* view_port;
|
||||
Gui* gui;
|
||||
|
@ -126,7 +126,7 @@ static bool is_black_note(uint8_t semitone, uint8_t id) {
|
|||
|
||||
static void render_callback(Canvas* canvas, void* ctx) {
|
||||
MusicPlayer* music_player = ctx;
|
||||
furi_check(osMutexAcquire(music_player->model_mutex, osWaitForever) == osOK);
|
||||
furi_check(furi_mutex_acquire(music_player->model_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
canvas_clear(canvas);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
|
@ -208,13 +208,13 @@ static void render_callback(Canvas* canvas, void* ctx) {
|
|||
canvas_draw_line(canvas, x_pos, 64 - 16 * i, x_pos + 48, 64 - 16 * i);
|
||||
}
|
||||
|
||||
osMutexRelease(music_player->model_mutex);
|
||||
furi_mutex_release(music_player->model_mutex);
|
||||
}
|
||||
|
||||
static void input_callback(InputEvent* input_event, void* ctx) {
|
||||
MusicPlayer* music_player = ctx;
|
||||
if(input_event->type == InputTypeShort) {
|
||||
osMessageQueuePut(music_player->input_queue, input_event, 0, 0);
|
||||
furi_message_queue_put(music_player->input_queue, input_event, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -225,7 +225,7 @@ static void music_player_worker_callback(
|
|||
float position,
|
||||
void* context) {
|
||||
MusicPlayer* music_player = context;
|
||||
furi_check(osMutexAcquire(music_player->model_mutex, osWaitForever) == osOK);
|
||||
furi_check(furi_mutex_acquire(music_player->model_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
for(size_t i = 0; i < MUSIC_PLAYER_SEMITONE_HISTORY_SIZE - 1; i++) {
|
||||
size_t r = MUSIC_PLAYER_SEMITONE_HISTORY_SIZE - 1 - i;
|
||||
|
@ -243,7 +243,7 @@ static void music_player_worker_callback(
|
|||
music_player->model->semitone_history[0] = semitone;
|
||||
music_player->model->duration_history[0] = duration;
|
||||
|
||||
osMutexRelease(music_player->model_mutex);
|
||||
furi_mutex_release(music_player->model_mutex);
|
||||
view_port_update(music_player->view_port);
|
||||
}
|
||||
|
||||
|
@ -255,9 +255,9 @@ MusicPlayer* music_player_alloc() {
|
|||
memset(instance->model->semitone_history, 0xff, MUSIC_PLAYER_SEMITONE_HISTORY_SIZE);
|
||||
instance->model->volume = 3;
|
||||
|
||||
instance->model_mutex = osMutexNew(NULL);
|
||||
instance->model_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
|
||||
instance->input_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL);
|
||||
instance->input_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
|
||||
|
||||
instance->worker = music_player_worker_alloc();
|
||||
music_player_worker_set_volume(
|
||||
|
@ -282,9 +282,9 @@ void music_player_free(MusicPlayer* instance) {
|
|||
|
||||
music_player_worker_free(instance->worker);
|
||||
|
||||
osMessageQueueDelete(instance->input_queue);
|
||||
furi_message_queue_free(instance->input_queue);
|
||||
|
||||
osMutexDelete(instance->model_mutex);
|
||||
furi_mutex_free(instance->model_mutex);
|
||||
|
||||
free(instance->model);
|
||||
free(instance);
|
||||
|
@ -327,11 +327,13 @@ int32_t music_player_app(void* p) {
|
|||
music_player_worker_start(music_player->worker);
|
||||
|
||||
InputEvent input;
|
||||
while(osMessageQueueGet(music_player->input_queue, &input, NULL, osWaitForever) == osOK) {
|
||||
furi_check(osMutexAcquire(music_player->model_mutex, osWaitForever) == osOK);
|
||||
while(furi_message_queue_get(music_player->input_queue, &input, FuriWaitForever) ==
|
||||
FuriStatusOk) {
|
||||
furi_check(
|
||||
furi_mutex_acquire(music_player->model_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
if(input.key == InputKeyBack) {
|
||||
osMutexRelease(music_player->model_mutex);
|
||||
furi_mutex_release(music_player->model_mutex);
|
||||
break;
|
||||
} else if(input.key == InputKeyUp) {
|
||||
if(music_player->model->volume < COUNT_OF(MUSIC_PLAYER_VOLUMES) - 1)
|
||||
|
@ -344,7 +346,7 @@ int32_t music_player_app(void* p) {
|
|||
music_player->worker, MUSIC_PLAYER_VOLUMES[music_player->model->volume]);
|
||||
}
|
||||
|
||||
osMutexRelease(music_player->model_mutex);
|
||||
furi_mutex_release(music_player->model_mutex);
|
||||
view_port_update(music_player->view_port);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ static void music_player_cli(Cli* cli, string_t args, void* context) {
|
|||
music_player_worker_set_volume(music_player_worker, 1.0f);
|
||||
music_player_worker_start(music_player_worker);
|
||||
while(!cli_cmd_interrupt_received(cli)) {
|
||||
osDelay(50);
|
||||
furi_delay_ms(50);
|
||||
}
|
||||
music_player_worker_stop(music_player_worker);
|
||||
} while(0);
|
||||
|
|
|
@ -51,20 +51,20 @@ static int32_t music_player_worker_thread_callback(void* context) {
|
|||
while(instance->should_work) {
|
||||
if(NoteBlockArray_end_p(it)) {
|
||||
NoteBlockArray_it(it, instance->notes);
|
||||
osDelay(10);
|
||||
furi_delay_ms(10);
|
||||
} else {
|
||||
NoteBlock* note_block = NoteBlockArray_ref(it);
|
||||
|
||||
float note_from_a4 = (float)note_block->semitone - NOTE_C4_SEMITONE;
|
||||
float frequency = NOTE_C4 * powf(TWO_POW_TWELTH_ROOT, note_from_a4);
|
||||
float duration =
|
||||
60.0 * osKernelGetTickFreq() * 4 / instance->bpm / note_block->duration;
|
||||
60.0 * furi_kernel_get_tick_frequency() * 4 / instance->bpm / note_block->duration;
|
||||
uint32_t dots = note_block->dots;
|
||||
while(dots > 0) {
|
||||
duration += duration / 2;
|
||||
dots--;
|
||||
}
|
||||
uint32_t next_tick = furi_hal_get_tick() + duration;
|
||||
uint32_t next_tick = furi_get_tick() + duration;
|
||||
float volume = instance->volume;
|
||||
|
||||
if(instance->callback) {
|
||||
|
@ -78,10 +78,10 @@ static int32_t music_player_worker_thread_callback(void* context) {
|
|||
|
||||
furi_hal_speaker_stop();
|
||||
furi_hal_speaker_start(frequency, volume);
|
||||
while(instance->should_work && furi_hal_get_tick() < next_tick) {
|
||||
while(instance->should_work && furi_get_tick() < next_tick) {
|
||||
volume *= 0.9945679;
|
||||
furi_hal_speaker_set_volume(volume);
|
||||
furi_hal_delay_ms(2);
|
||||
furi_delay_ms(2);
|
||||
}
|
||||
NoteBlockArray_next(it);
|
||||
}
|
||||
|
|
|
@ -77,8 +77,8 @@ static void
|
|||
.event = event,
|
||||
.len = len << 8 | len >> 8,
|
||||
};
|
||||
xStreamBufferSend(instance->stream, &pkt_hdr, sizeof(pkt_hdr), osWaitForever);
|
||||
xStreamBufferSend(instance->stream, data, len, osWaitForever);
|
||||
xStreamBufferSend(instance->stream, &pkt_hdr, sizeof(pkt_hdr), FuriWaitForever);
|
||||
xStreamBufferSend(instance->stream, data, len, FuriWaitForever);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -40,7 +40,7 @@ static void nfc_cli_detect(Cli* cli, string_t args) {
|
|||
break;
|
||||
}
|
||||
furi_hal_nfc_sleep();
|
||||
osDelay(50);
|
||||
furi_delay_ms(50);
|
||||
}
|
||||
furi_hal_nfc_sleep();
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ static void nfc_cli_emulate(Cli* cli, string_t args) {
|
|||
printf("Reader detected\r\n");
|
||||
furi_hal_nfc_sleep();
|
||||
}
|
||||
osDelay(50);
|
||||
furi_delay_ms(50);
|
||||
}
|
||||
furi_hal_nfc_sleep();
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ static void nfc_cli_field(Cli* cli, string_t args) {
|
|||
printf("Press Ctrl+C to abort\r\n");
|
||||
|
||||
while(!cli_cmd_interrupt_received(cli)) {
|
||||
osDelay(50);
|
||||
furi_delay_ms(50);
|
||||
}
|
||||
|
||||
furi_hal_nfc_field_off();
|
||||
|
|
|
@ -23,7 +23,7 @@ NfcWorker* nfc_worker_alloc() {
|
|||
|
||||
// Initialize rfal
|
||||
while(furi_hal_nfc_is_busy()) {
|
||||
osDelay(10);
|
||||
furi_delay_ms(10);
|
||||
}
|
||||
nfc_worker_change_state(nfc_worker, NfcWorkerStateReady);
|
||||
|
||||
|
@ -59,7 +59,7 @@ void nfc_worker_start(
|
|||
furi_assert(nfc_worker);
|
||||
furi_assert(dev_data);
|
||||
while(furi_hal_nfc_is_busy()) {
|
||||
osDelay(10);
|
||||
furi_delay_ms(10);
|
||||
}
|
||||
|
||||
nfc_worker->callback = callback;
|
||||
|
@ -148,7 +148,7 @@ void nfc_worker_detect(NfcWorker* nfc_worker) {
|
|||
break;
|
||||
}
|
||||
furi_hal_nfc_sleep();
|
||||
osDelay(100);
|
||||
furi_delay_ms(100);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ void nfc_worker_read_emv_app(NfcWorker* nfc_worker) {
|
|||
FURI_LOG_D(TAG, "Can't find any cards");
|
||||
}
|
||||
furi_hal_nfc_sleep();
|
||||
osDelay(20);
|
||||
furi_delay_ms(20);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -252,7 +252,7 @@ void nfc_worker_read_emv(NfcWorker* nfc_worker) {
|
|||
FURI_LOG_D(TAG, "Can't find any cards");
|
||||
}
|
||||
furi_hal_nfc_sleep();
|
||||
osDelay(20);
|
||||
furi_delay_ms(20);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -277,7 +277,7 @@ void nfc_worker_emulate_apdu(NfcWorker* nfc_worker) {
|
|||
FURI_LOG_D(TAG, "Can't find reader");
|
||||
}
|
||||
furi_hal_nfc_sleep();
|
||||
osDelay(20);
|
||||
furi_delay_ms(20);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -312,7 +312,7 @@ void nfc_worker_read_mifare_ultralight(NfcWorker* nfc_worker) {
|
|||
FURI_LOG_D(TAG, "Can't find any tags");
|
||||
}
|
||||
furi_hal_nfc_sleep();
|
||||
osDelay(100);
|
||||
furi_delay_ms(100);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -434,7 +434,7 @@ void nfc_worker_mifare_classic_dict_attack(NfcWorker* nfc_worker) {
|
|||
}
|
||||
}
|
||||
if(nfc_worker->state != NfcWorkerStateReadMifareClassic) break;
|
||||
osDelay(1);
|
||||
furi_delay_tick(1);
|
||||
}
|
||||
if(nfc_worker->state != NfcWorkerStateReadMifareClassic) break;
|
||||
if(sector_key_found) {
|
||||
|
@ -529,14 +529,14 @@ void nfc_worker_read_mifare_desfire(NfcWorker* nfc_worker) {
|
|||
while(nfc_worker->state == NfcWorkerStateReadMifareDesfire) {
|
||||
furi_hal_nfc_sleep();
|
||||
if(!furi_hal_nfc_detect(nfc_data, 300)) {
|
||||
osDelay(100);
|
||||
furi_delay_ms(100);
|
||||
continue;
|
||||
}
|
||||
memset(data, 0, sizeof(MifareDesfireData));
|
||||
if(nfc_data->type != FuriHalNfcTypeA ||
|
||||
!mf_df_check_card_type(nfc_data->atqa[0], nfc_data->atqa[1], nfc_data->sak)) {
|
||||
FURI_LOG_D(TAG, "Tag is not DESFire");
|
||||
osDelay(100);
|
||||
furi_delay_ms(100);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "../nfc_i.h"
|
||||
#include "furi/common_defines.h"
|
||||
#include <core/common_defines.h>
|
||||
|
||||
void nfc_scene_emulate_apdu_sequence_on_enter(void* context) {
|
||||
Nfc* nfc = context;
|
||||
|
|
|
@ -30,10 +30,12 @@ uint8_t notification_settings_get_rgb_led_brightness(NotificationApp* app, uint8
|
|||
uint32_t notification_settings_display_off_delay_ticks(NotificationApp* app);
|
||||
|
||||
void notification_message_save_settings(NotificationApp* app) {
|
||||
NotificationAppMessage m = {.type = SaveSettingsMessage, .back_event = osEventFlagsNew(NULL)};
|
||||
furi_check(osMessageQueuePut(app->queue, &m, 0, osWaitForever) == osOK);
|
||||
osEventFlagsWait(m.back_event, NOTIFICATION_EVENT_COMPLETE, osFlagsWaitAny, osWaitForever);
|
||||
osEventFlagsDelete(m.back_event);
|
||||
NotificationAppMessage m = {
|
||||
.type = SaveSettingsMessage, .back_event = furi_event_flag_alloc()};
|
||||
furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
|
||||
furi_event_flag_wait(
|
||||
m.back_event, NOTIFICATION_EVENT_COMPLETE, FuriFlagWaitAny, FuriWaitForever);
|
||||
furi_event_flag_free(m.back_event);
|
||||
};
|
||||
|
||||
// internal layer
|
||||
|
@ -112,7 +114,7 @@ void notification_reset_notification_layer(NotificationApp* app, uint8_t reset_m
|
|||
notification_sound_off();
|
||||
}
|
||||
if(reset_mask & reset_display_mask) {
|
||||
osTimerStart(app->display_timer, notification_settings_display_off_delay_ticks(app));
|
||||
furi_timer_start(app->display_timer, notification_settings_display_off_delay_ticks(app));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,7 +135,9 @@ uint8_t notification_settings_get_rgb_led_brightness(NotificationApp* app, uint8
|
|||
}
|
||||
|
||||
uint32_t notification_settings_display_off_delay_ticks(NotificationApp* app) {
|
||||
return ((float)(app->settings.display_off_delay_ms) / (1000.0f / osKernelGetTickFreq()));
|
||||
return (
|
||||
(float)(app->settings.display_off_delay_ms) /
|
||||
(1000.0f / furi_kernel_get_tick_frequency()));
|
||||
}
|
||||
|
||||
// generics
|
||||
|
@ -189,8 +193,8 @@ void notification_process_notification_message(
|
|||
notification_message->data.led.value * display_brightness_setting);
|
||||
} else {
|
||||
notification_reset_notification_led_layer(&app->display);
|
||||
if(osTimerIsRunning(app->display_timer)) {
|
||||
osTimerStop(app->display_timer);
|
||||
if(furi_timer_is_running(app->display_timer)) {
|
||||
furi_timer_stop(app->display_timer);
|
||||
}
|
||||
}
|
||||
reset_mask |= reset_display_mask;
|
||||
|
@ -280,7 +284,7 @@ void notification_process_notification_message(
|
|||
if(led_active) {
|
||||
if(notification_is_any_led_layer_internal_and_not_empty(app)) {
|
||||
notification_apply_notification_leds(app, led_off_values);
|
||||
furi_hal_delay_ms(minimal_delay);
|
||||
furi_delay_ms(minimal_delay);
|
||||
}
|
||||
|
||||
led_active = false;
|
||||
|
@ -291,7 +295,7 @@ void notification_process_notification_message(
|
|||
reset_mask |= reset_blue_mask;
|
||||
}
|
||||
|
||||
furi_hal_delay_ms(notification_message->data.delay.length);
|
||||
furi_delay_ms(notification_message->data.delay.length);
|
||||
break;
|
||||
case NotificationMessageTypeDoNotReset:
|
||||
reset_notifications = false;
|
||||
|
@ -334,7 +338,7 @@ void notification_process_notification_message(
|
|||
|
||||
if((need_minimal_delay) && (reset_notifications)) {
|
||||
notification_apply_notification_leds(app, led_off_values);
|
||||
furi_hal_delay_ms(minimal_delay);
|
||||
furi_delay_ms(minimal_delay);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -416,9 +420,9 @@ static bool notification_load_settings(NotificationApp* app) {
|
|||
FURI_LOG_E(
|
||||
TAG, "version(%d != %d) mismatch", settings.version, NOTIFICATION_SETTINGS_VERSION);
|
||||
} else {
|
||||
osKernelLock();
|
||||
furi_kernel_lock();
|
||||
memcpy(&app->settings, &settings, settings_size);
|
||||
osKernelUnlock();
|
||||
furi_kernel_unlock();
|
||||
}
|
||||
} else {
|
||||
FURI_LOG_E(TAG, "load failed, %s", storage_file_get_error_desc(file));
|
||||
|
@ -438,9 +442,9 @@ static bool notification_save_settings(NotificationApp* app) {
|
|||
|
||||
FURI_LOG_I(TAG, "saving settings to \"%s\"", NOTIFICATION_SETTINGS_PATH);
|
||||
|
||||
osKernelLock();
|
||||
furi_kernel_lock();
|
||||
memcpy(&settings, &app->settings, settings_size);
|
||||
osKernelUnlock();
|
||||
furi_kernel_unlock();
|
||||
|
||||
bool fs_result =
|
||||
storage_file_open(file, NOTIFICATION_SETTINGS_PATH, FSAM_WRITE, FSOM_CREATE_ALWAYS);
|
||||
|
@ -476,8 +480,8 @@ static void input_event_callback(const void* value, void* context) {
|
|||
// App alloc
|
||||
static NotificationApp* notification_app_alloc() {
|
||||
NotificationApp* app = malloc(sizeof(NotificationApp));
|
||||
app->queue = osMessageQueueNew(8, sizeof(NotificationAppMessage), NULL);
|
||||
app->display_timer = osTimerNew(notification_display_timer, osTimerOnce, app, NULL);
|
||||
app->queue = furi_message_queue_alloc(8, sizeof(NotificationAppMessage));
|
||||
app->display_timer = furi_timer_alloc(notification_display_timer, FuriTimerTypeOnce, app);
|
||||
|
||||
app->settings.speaker_volume = 1.0f;
|
||||
app->settings.display_brightness = 1.0f;
|
||||
|
@ -535,7 +539,7 @@ int32_t notification_srv(void* p) {
|
|||
|
||||
NotificationAppMessage message;
|
||||
while(1) {
|
||||
furi_check(osMessageQueueGet(app->queue, &message, NULL, osWaitForever) == osOK);
|
||||
furi_check(furi_message_queue_get(app->queue, &message, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
switch(message.type) {
|
||||
case NotificationLayerMessage:
|
||||
|
@ -550,7 +554,7 @@ int32_t notification_srv(void* p) {
|
|||
}
|
||||
|
||||
if(message.back_event != NULL) {
|
||||
osEventFlagsSet(message.back_event, NOTIFICATION_EVENT_COMPLETE);
|
||||
furi_event_flag_set(message.back_event, NOTIFICATION_EVENT_COMPLETE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ typedef enum {
|
|||
typedef struct {
|
||||
const NotificationSequence* sequence;
|
||||
NotificationAppMessageType type;
|
||||
osEventFlagsId_t back_event;
|
||||
FuriEventFlag* back_event;
|
||||
} NotificationAppMessage;
|
||||
|
||||
typedef enum {
|
||||
|
@ -44,9 +44,9 @@ typedef struct {
|
|||
} NotificationSettings;
|
||||
|
||||
struct NotificationApp {
|
||||
osMessageQueueId_t queue;
|
||||
FuriMessageQueue* queue;
|
||||
FuriPubSub* event_record;
|
||||
osTimerId_t display_timer;
|
||||
FuriTimer* display_timer;
|
||||
|
||||
NotificationLedLayer display;
|
||||
NotificationLedLayer led[NOTIFICATION_LED_COUNT];
|
||||
|
|
|
@ -7,31 +7,33 @@
|
|||
void notification_message(NotificationApp* app, const NotificationSequence* sequence) {
|
||||
NotificationAppMessage m = {
|
||||
.type = NotificationLayerMessage, .sequence = sequence, .back_event = NULL};
|
||||
furi_check(osMessageQueuePut(app->queue, &m, 0, osWaitForever) == osOK);
|
||||
furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
|
||||
};
|
||||
|
||||
void notification_internal_message(NotificationApp* app, const NotificationSequence* sequence) {
|
||||
NotificationAppMessage m = {
|
||||
.type = InternalLayerMessage, .sequence = sequence, .back_event = NULL};
|
||||
furi_check(osMessageQueuePut(app->queue, &m, 0, osWaitForever) == osOK);
|
||||
furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
|
||||
};
|
||||
|
||||
void notification_message_block(NotificationApp* app, const NotificationSequence* sequence) {
|
||||
NotificationAppMessage m = {
|
||||
.type = NotificationLayerMessage,
|
||||
.sequence = sequence,
|
||||
.back_event = osEventFlagsNew(NULL)};
|
||||
furi_check(osMessageQueuePut(app->queue, &m, 0, osWaitForever) == osOK);
|
||||
osEventFlagsWait(m.back_event, NOTIFICATION_EVENT_COMPLETE, osFlagsWaitAny, osWaitForever);
|
||||
osEventFlagsDelete(m.back_event);
|
||||
.back_event = furi_event_flag_alloc()};
|
||||
furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
|
||||
furi_event_flag_wait(
|
||||
m.back_event, NOTIFICATION_EVENT_COMPLETE, FuriFlagWaitAny, FuriWaitForever);
|
||||
furi_event_flag_free(m.back_event);
|
||||
};
|
||||
|
||||
void notification_internal_message_block(
|
||||
NotificationApp* app,
|
||||
const NotificationSequence* sequence) {
|
||||
NotificationAppMessage m = {
|
||||
.type = InternalLayerMessage, .sequence = sequence, .back_event = osEventFlagsNew(NULL)};
|
||||
furi_check(osMessageQueuePut(app->queue, &m, 0, osWaitForever) == osOK);
|
||||
osEventFlagsWait(m.back_event, NOTIFICATION_EVENT_COMPLETE, osFlagsWaitAny, osWaitForever);
|
||||
osEventFlagsDelete(m.back_event);
|
||||
.type = InternalLayerMessage, .sequence = sequence, .back_event = furi_event_flag_alloc()};
|
||||
furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
|
||||
furi_event_flag_wait(
|
||||
m.back_event, NOTIFICATION_EVENT_COMPLETE, FuriFlagWaitAny, FuriWaitForever);
|
||||
furi_event_flag_free(m.back_event);
|
||||
};
|
||||
|
|
|
@ -305,6 +305,6 @@ void picopass_worker_detect(PicopassWorker* picopass_worker) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
osDelay(100);
|
||||
furi_delay_ms(100);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ void power_cli_off(Cli* cli, string_t args) {
|
|||
UNUSED(args);
|
||||
Power* power = furi_record_open("power");
|
||||
printf("It's now safe to disconnect USB from your flipper\r\n");
|
||||
osDelay(666);
|
||||
furi_delay_ms(666);
|
||||
power_off(power);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ Power* power_alloc() {
|
|||
power->state = PowerStateNotCharging;
|
||||
power->battery_low = false;
|
||||
power->power_off_timeout = POWER_OFF_TIMEOUT;
|
||||
power->api_mtx = osMutexNew(NULL);
|
||||
power->api_mtx = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
|
||||
// Gui
|
||||
power->view_dispatcher = view_dispatcher_alloc();
|
||||
|
@ -83,7 +83,7 @@ void power_free(Power* power) {
|
|||
view_port_free(power->battery_view_port);
|
||||
|
||||
// State
|
||||
osMutexDelete(power->api_mtx);
|
||||
furi_mutex_free(power->api_mtx);
|
||||
|
||||
// FuriPubSub
|
||||
furi_pubsub_free(power->event_pubsub);
|
||||
|
@ -138,10 +138,10 @@ static bool power_update_info(Power* power) {
|
|||
info.temperature_charger = furi_hal_power_get_battery_temperature(FuriHalPowerICCharger);
|
||||
info.temperature_gauge = furi_hal_power_get_battery_temperature(FuriHalPowerICFuelGauge);
|
||||
|
||||
osMutexAcquire(power->api_mtx, osWaitForever);
|
||||
furi_mutex_acquire(power->api_mtx, FuriWaitForever);
|
||||
bool need_refresh = power->info.charge != info.charge;
|
||||
power->info = info;
|
||||
osMutexRelease(power->api_mtx);
|
||||
furi_mutex_release(power->api_mtx);
|
||||
|
||||
return need_refresh;
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ int32_t power_srv(void* p) {
|
|||
furi_hal_power_check_otg_status();
|
||||
}
|
||||
|
||||
osDelay(1000);
|
||||
furi_delay_ms(1000);
|
||||
}
|
||||
|
||||
power_free(power);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <furi/pubsub.h>
|
||||
#include <core/pubsub.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct Power Power;
|
||||
|
|
|
@ -9,7 +9,7 @@ void power_off(Power* power) {
|
|||
// Notify user if USB is plugged
|
||||
view_dispatcher_send_to_front(power->view_dispatcher);
|
||||
view_dispatcher_switch_to_view(power->view_dispatcher, PowerViewPopup);
|
||||
osDelay(10);
|
||||
furi_delay_ms(10);
|
||||
furi_halt("Disconnect USB for safe shutdown");
|
||||
}
|
||||
|
||||
|
@ -28,9 +28,9 @@ void power_get_info(Power* power, PowerInfo* info) {
|
|||
furi_assert(power);
|
||||
furi_assert(info);
|
||||
|
||||
osMutexAcquire(power->api_mtx, osWaitForever);
|
||||
furi_mutex_acquire(power->api_mtx, FuriWaitForever);
|
||||
memcpy(info, &power->info, sizeof(power->info));
|
||||
osMutexRelease(power->api_mtx);
|
||||
furi_mutex_release(power->api_mtx);
|
||||
}
|
||||
|
||||
FuriPubSub* power_get_pubsub(Power* power) {
|
||||
|
@ -41,15 +41,15 @@ FuriPubSub* power_get_pubsub(Power* power) {
|
|||
bool power_is_battery_healthy(Power* power) {
|
||||
furi_assert(power);
|
||||
bool is_healthy = false;
|
||||
osMutexAcquire(power->api_mtx, osWaitForever);
|
||||
furi_mutex_acquire(power->api_mtx, FuriWaitForever);
|
||||
is_healthy = power->info.health > POWER_BATTERY_HEALTHY_LEVEL;
|
||||
osMutexRelease(power->api_mtx);
|
||||
furi_mutex_release(power->api_mtx);
|
||||
return is_healthy;
|
||||
}
|
||||
|
||||
void power_enable_low_battery_level_notification(Power* power, bool enable) {
|
||||
furi_assert(power);
|
||||
osMutexAcquire(power->api_mtx, osWaitForever);
|
||||
furi_mutex_acquire(power->api_mtx, FuriWaitForever);
|
||||
power->show_low_bat_level_message = enable;
|
||||
osMutexRelease(power->api_mtx);
|
||||
furi_mutex_release(power->api_mtx);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ struct Power {
|
|||
uint8_t battery_level;
|
||||
uint8_t power_off_timeout;
|
||||
|
||||
osMutexId_t api_mtx;
|
||||
FuriMutex* api_mtx;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
|
|
|
@ -68,7 +68,7 @@ struct RpcSession {
|
|||
void** system_contexts;
|
||||
bool decode_error;
|
||||
|
||||
osMutexId_t callbacks_mutex;
|
||||
FuriMutex* callbacks_mutex;
|
||||
RpcSendBytesCallback send_bytes_callback;
|
||||
RpcBufferIsEmptyCallback buffer_is_empty_callback;
|
||||
RpcSessionClosedCallback closed_callback;
|
||||
|
@ -77,7 +77,7 @@ struct RpcSession {
|
|||
};
|
||||
|
||||
struct Rpc {
|
||||
osMutexId_t busy_mutex;
|
||||
FuriMutex* busy_mutex;
|
||||
};
|
||||
|
||||
static bool content_callback(pb_istream_t* stream, const pb_field_t* field, void** arg);
|
||||
|
@ -89,13 +89,13 @@ static void rpc_close_session_process(const PB_Main* request, void* context) {
|
|||
furi_assert(session);
|
||||
|
||||
rpc_send_and_release_empty(session, request->command_id, PB_CommandStatus_OK);
|
||||
osMutexAcquire(session->callbacks_mutex, osWaitForever);
|
||||
furi_mutex_acquire(session->callbacks_mutex, FuriWaitForever);
|
||||
if(session->closed_callback) {
|
||||
session->closed_callback(session->context);
|
||||
} else {
|
||||
FURI_LOG_W(TAG, "Session stop isn't processed by transport layer");
|
||||
}
|
||||
osMutexRelease(session->callbacks_mutex);
|
||||
furi_mutex_release(session->callbacks_mutex);
|
||||
}
|
||||
|
||||
static size_t rpc_sprintf_msg_file(
|
||||
|
@ -359,25 +359,25 @@ void rpc_print_message(const PB_Main* message) {
|
|||
void rpc_session_set_context(RpcSession* session, void* context) {
|
||||
furi_assert(session);
|
||||
|
||||
osMutexAcquire(session->callbacks_mutex, osWaitForever);
|
||||
furi_mutex_acquire(session->callbacks_mutex, FuriWaitForever);
|
||||
session->context = context;
|
||||
osMutexRelease(session->callbacks_mutex);
|
||||
furi_mutex_release(session->callbacks_mutex);
|
||||
}
|
||||
|
||||
void rpc_session_set_close_callback(RpcSession* session, RpcSessionClosedCallback callback) {
|
||||
furi_assert(session);
|
||||
|
||||
osMutexAcquire(session->callbacks_mutex, osWaitForever);
|
||||
furi_mutex_acquire(session->callbacks_mutex, FuriWaitForever);
|
||||
session->closed_callback = callback;
|
||||
osMutexRelease(session->callbacks_mutex);
|
||||
furi_mutex_release(session->callbacks_mutex);
|
||||
}
|
||||
|
||||
void rpc_session_set_send_bytes_callback(RpcSession* session, RpcSendBytesCallback callback) {
|
||||
furi_assert(session);
|
||||
|
||||
osMutexAcquire(session->callbacks_mutex, osWaitForever);
|
||||
furi_mutex_acquire(session->callbacks_mutex, FuriWaitForever);
|
||||
session->send_bytes_callback = callback;
|
||||
osMutexRelease(session->callbacks_mutex);
|
||||
furi_mutex_release(session->callbacks_mutex);
|
||||
}
|
||||
|
||||
void rpc_session_set_buffer_is_empty_callback(
|
||||
|
@ -385,9 +385,9 @@ void rpc_session_set_buffer_is_empty_callback(
|
|||
RpcBufferIsEmptyCallback callback) {
|
||||
furi_assert(session);
|
||||
|
||||
osMutexAcquire(session->callbacks_mutex, osWaitForever);
|
||||
furi_mutex_acquire(session->callbacks_mutex, FuriWaitForever);
|
||||
session->buffer_is_empty_callback = callback;
|
||||
osMutexRelease(session->callbacks_mutex);
|
||||
furi_mutex_release(session->callbacks_mutex);
|
||||
}
|
||||
|
||||
void rpc_session_set_terminated_callback(
|
||||
|
@ -395,9 +395,9 @@ void rpc_session_set_terminated_callback(
|
|||
RpcSessionTerminatedCallback callback) {
|
||||
furi_assert(session);
|
||||
|
||||
osMutexAcquire(session->callbacks_mutex, osWaitForever);
|
||||
furi_mutex_acquire(session->callbacks_mutex, FuriWaitForever);
|
||||
session->terminated_callback = callback;
|
||||
osMutexRelease(session->callbacks_mutex);
|
||||
furi_mutex_release(session->callbacks_mutex);
|
||||
}
|
||||
|
||||
/* Doesn't forbid using rpc_feed_bytes() after session close - it's safe.
|
||||
|
@ -444,7 +444,7 @@ bool rpc_pb_stream_read(pb_istream_t* istream, pb_byte_t* buf, size_t count) {
|
|||
if(count == bytes_received) {
|
||||
break;
|
||||
} else {
|
||||
flags = furi_thread_flags_wait(RPC_ALL_EVENTS, osFlagsWaitAny, osWaitForever);
|
||||
flags = furi_thread_flags_wait(RPC_ALL_EVENTS, FuriFlagWaitAny, FuriWaitForever);
|
||||
if(flags & RpcEvtDisconnect) {
|
||||
if(xStreamBufferIsEmpty(session->stream)) {
|
||||
session->terminate = true;
|
||||
|
@ -508,9 +508,9 @@ static int32_t rpc_session_worker(void* context) {
|
|||
RpcHandlerDict_get(session->handlers, session->decoded_message->which_content);
|
||||
|
||||
if(handler && handler->message_handler) {
|
||||
furi_check(osMutexAcquire(rpc->busy_mutex, osWaitForever) == osOK);
|
||||
furi_check(furi_mutex_acquire(rpc->busy_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
handler->message_handler(session->decoded_message, handler->context);
|
||||
furi_check(osMutexRelease(rpc->busy_mutex) == osOK);
|
||||
furi_check(furi_mutex_release(rpc->busy_mutex) == FuriStatusOk);
|
||||
} else if(session->decoded_message->which_content == 0) {
|
||||
/* Receiving zeroes means message is 0-length, which
|
||||
* is valid for proto3: all fields are filled with default values.
|
||||
|
@ -551,11 +551,11 @@ static int32_t rpc_session_worker(void* context) {
|
|||
FURI_LOG_E(TAG, "Decode failed, error: \'%.128s\'", PB_GET_ERROR(&istream));
|
||||
session->decode_error = true;
|
||||
rpc_send_and_release_empty(session, 0, PB_CommandStatus_ERROR_DECODE);
|
||||
osMutexAcquire(session->callbacks_mutex, osWaitForever);
|
||||
furi_mutex_acquire(session->callbacks_mutex, FuriWaitForever);
|
||||
if(session->closed_callback) {
|
||||
session->closed_callback(session->context);
|
||||
}
|
||||
osMutexRelease(session->callbacks_mutex);
|
||||
furi_mutex_release(session->callbacks_mutex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -586,13 +586,13 @@ static void rpc_session_free_callback(FuriThreadState thread_state, void* contex
|
|||
RpcHandlerDict_clear(session->handlers);
|
||||
vStreamBufferDelete(session->stream);
|
||||
|
||||
osMutexAcquire(session->callbacks_mutex, osWaitForever);
|
||||
furi_mutex_acquire(session->callbacks_mutex, FuriWaitForever);
|
||||
if(session->terminated_callback) {
|
||||
session->terminated_callback(session->context);
|
||||
}
|
||||
osMutexRelease(session->callbacks_mutex);
|
||||
furi_mutex_release(session->callbacks_mutex);
|
||||
|
||||
osMutexDelete(session->callbacks_mutex);
|
||||
furi_mutex_free(session->callbacks_mutex);
|
||||
furi_thread_free(session->thread);
|
||||
free(session);
|
||||
}
|
||||
|
@ -602,7 +602,7 @@ RpcSession* rpc_session_open(Rpc* rpc) {
|
|||
furi_assert(rpc);
|
||||
|
||||
RpcSession* session = malloc(sizeof(RpcSession));
|
||||
session->callbacks_mutex = osMutexNew(NULL);
|
||||
session->callbacks_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
session->stream = xStreamBufferCreate(RPC_BUFFER_SIZE, 1);
|
||||
session->rpc = rpc;
|
||||
session->terminate = false;
|
||||
|
@ -653,7 +653,7 @@ int32_t rpc_srv(void* p) {
|
|||
UNUSED(p);
|
||||
Rpc* rpc = malloc(sizeof(Rpc));
|
||||
|
||||
rpc->busy_mutex = osMutexNew(NULL);
|
||||
rpc->busy_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
|
||||
Cli* cli = furi_record_open("cli");
|
||||
cli_add_command(
|
||||
|
@ -693,11 +693,11 @@ void rpc_send(RpcSession* session, PB_Main* message) {
|
|||
rpc_print_data("OUTPUT", buffer, ostream.bytes_written);
|
||||
#endif
|
||||
|
||||
osMutexAcquire(session->callbacks_mutex, osWaitForever);
|
||||
furi_mutex_acquire(session->callbacks_mutex, FuriWaitForever);
|
||||
if(session->send_bytes_callback) {
|
||||
session->send_bytes_callback(session->context, buffer, ostream.bytes_written);
|
||||
}
|
||||
osMutexRelease(session->callbacks_mutex);
|
||||
furi_mutex_release(session->callbacks_mutex);
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include "cmsis_os2.h"
|
||||
#include "flipper.pb.h"
|
||||
#include "furi/record.h"
|
||||
#include <core/record.h>
|
||||
#include "rpc_i.h"
|
||||
#include <furi.h>
|
||||
#include <loader/loader.h>
|
||||
|
@ -13,7 +12,7 @@ struct RpcAppSystem {
|
|||
RpcSession* session;
|
||||
RpcAppSystemCallback app_callback;
|
||||
void* app_context;
|
||||
osTimerId_t timer;
|
||||
FuriTimer* timer;
|
||||
};
|
||||
|
||||
static void rpc_system_app_timer_callback(void* context) {
|
||||
|
@ -111,7 +110,7 @@ static void rpc_system_app_exit(const PB_Main* request, void* context) {
|
|||
if(rpc_app->app_callback) {
|
||||
if(rpc_app->app_callback(RpcAppEventAppExit, NULL, rpc_app->app_context)) {
|
||||
status = PB_CommandStatus_OK;
|
||||
osTimerStop(rpc_app->timer);
|
||||
furi_timer_stop(rpc_app->timer);
|
||||
} else {
|
||||
status = PB_CommandStatus_ERROR_APP_CMD_ERROR;
|
||||
}
|
||||
|
@ -160,7 +159,7 @@ static void rpc_system_app_button_press(const PB_Main* request, void* context) {
|
|||
const char* args = request->content.app_button_press_request.args;
|
||||
if(rpc_app->app_callback(RpcAppEventButtonPress, args, rpc_app->app_context)) {
|
||||
status = PB_CommandStatus_OK;
|
||||
osTimerStart(rpc_app->timer, APP_BUTTON_TIMEOUT);
|
||||
furi_timer_start(rpc_app->timer, APP_BUTTON_TIMEOUT);
|
||||
} else {
|
||||
status = PB_CommandStatus_ERROR_APP_CMD_ERROR;
|
||||
}
|
||||
|
@ -184,7 +183,7 @@ static void rpc_system_app_button_release(const PB_Main* request, void* context)
|
|||
if(rpc_app->app_callback) {
|
||||
if(rpc_app->app_callback(RpcAppEventButtonRelease, NULL, rpc_app->app_context)) {
|
||||
status = PB_CommandStatus_OK;
|
||||
osTimerStop(rpc_app->timer);
|
||||
furi_timer_stop(rpc_app->timer);
|
||||
} else {
|
||||
status = PB_CommandStatus_ERROR_APP_CMD_ERROR;
|
||||
}
|
||||
|
@ -208,7 +207,7 @@ void* rpc_system_app_alloc(RpcSession* session) {
|
|||
RpcAppSystem* rpc_app = malloc(sizeof(RpcAppSystem));
|
||||
rpc_app->session = session;
|
||||
|
||||
rpc_app->timer = osTimerNew(rpc_system_app_timer_callback, osTimerOnce, rpc_app, NULL);
|
||||
rpc_app->timer = furi_timer_alloc(rpc_system_app_timer_callback, FuriTimerTypeOnce, rpc_app);
|
||||
|
||||
RpcHandler rpc_handler = {
|
||||
.message_handler = NULL,
|
||||
|
@ -242,7 +241,7 @@ void rpc_system_app_free(void* context) {
|
|||
RpcSession* session = rpc_app->session;
|
||||
furi_assert(session);
|
||||
|
||||
osTimerDelete(rpc_app->timer);
|
||||
furi_timer_free(rpc_app->timer);
|
||||
|
||||
if(rpc_app->app_callback) {
|
||||
rpc_app->app_callback(RpcAppEventSessionClose, NULL, rpc_app->app_context);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
typedef struct {
|
||||
Cli* cli;
|
||||
bool session_close_request;
|
||||
osSemaphoreId_t terminate_semaphore;
|
||||
FuriSemaphore* terminate_semaphore;
|
||||
} CliRpc;
|
||||
|
||||
#define CLI_READ_BUFFER_SIZE 64
|
||||
|
@ -34,7 +34,7 @@ static void rpc_session_terminated_callback(void* context) {
|
|||
furi_check(context);
|
||||
CliRpc* cli_rpc = context;
|
||||
|
||||
osSemaphoreRelease(cli_rpc->terminate_semaphore);
|
||||
furi_semaphore_release(cli_rpc->terminate_semaphore);
|
||||
}
|
||||
|
||||
void rpc_cli_command_start_session(Cli* cli, string_t args, void* context) {
|
||||
|
@ -53,7 +53,7 @@ void rpc_cli_command_start_session(Cli* cli, string_t args, void* context) {
|
|||
}
|
||||
|
||||
CliRpc cli_rpc = {.cli = cli, .session_close_request = false};
|
||||
cli_rpc.terminate_semaphore = osSemaphoreNew(1, 0, NULL);
|
||||
cli_rpc.terminate_semaphore = furi_semaphore_alloc(1, 0);
|
||||
rpc_session_set_context(rpc_session, &cli_rpc);
|
||||
rpc_session_set_send_bytes_callback(rpc_session, rpc_send_bytes_callback);
|
||||
rpc_session_set_close_callback(rpc_session, rpc_session_close_callback);
|
||||
|
@ -77,9 +77,10 @@ void rpc_cli_command_start_session(Cli* cli, string_t args, void* context) {
|
|||
|
||||
rpc_session_close(rpc_session);
|
||||
|
||||
furi_check(osSemaphoreAcquire(cli_rpc.terminate_semaphore, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
furi_semaphore_acquire(cli_rpc.terminate_semaphore, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
osSemaphoreDelete(cli_rpc.terminate_semaphore);
|
||||
furi_semaphore_free(cli_rpc.terminate_semaphore);
|
||||
|
||||
free(buffer);
|
||||
furi_hal_usb_unlock();
|
||||
|
|
|
@ -50,7 +50,7 @@ static int32_t rpc_system_gui_screen_stream_frame_transmit_thread(void* context)
|
|||
|
||||
while(true) {
|
||||
uint32_t flags =
|
||||
furi_thread_flags_wait(RpcGuiWorkerFlagAny, osFlagsWaitAny, osWaitForever);
|
||||
furi_thread_flags_wait(RpcGuiWorkerFlagAny, FuriFlagWaitAny, FuriWaitForever);
|
||||
if(flags & RpcGuiWorkerFlagTransmit) {
|
||||
rpc_send(rpc_gui->session, rpc_gui->transmit_frame);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "flipper.pb.h"
|
||||
#include "furi/common_defines.h"
|
||||
#include "furi/memmgr.h"
|
||||
#include "furi/record.h"
|
||||
#include <core/common_defines.h>
|
||||
#include <core/memmgr.h>
|
||||
#include <core/record.h>
|
||||
#include "pb_decode.h"
|
||||
#include "rpc/rpc.h"
|
||||
#include "rpc_i.h"
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue