mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 14:18:35 -07:00
Merge branch 'gsurkov/3764_expansion_control' of https://github.com/flipperdevices/flipperzero-firmware into xfw-dev
This commit is contained in:
@@ -60,7 +60,7 @@ static void expansion_detect_callback(void* context) {
|
||||
|
||||
ExpansionMessage message = {
|
||||
.type = ExpansionMessageTypeModuleConnected,
|
||||
.api_lock = NULL, // Not locking the API here
|
||||
.api_lock = NULL, // Not locking the API here to avoid a deadlock
|
||||
};
|
||||
|
||||
// Not waiting for available queue space, discarding message if there is none
|
||||
@@ -74,7 +74,7 @@ static void expansion_worker_callback(void* context) {
|
||||
|
||||
ExpansionMessage message = {
|
||||
.type = ExpansionMessageTypeModuleDisconnected,
|
||||
.api_lock = NULL, // Not locking the API here
|
||||
.api_lock = NULL, // Not locking the API here to avoid a deadlock
|
||||
};
|
||||
|
||||
const FuriStatus status = furi_message_queue_put(instance->queue, &message, FuriWaitForever);
|
||||
|
||||
@@ -317,18 +317,6 @@ static inline void expansion_worker_state_machine(ExpansionWorker* instance) {
|
||||
}
|
||||
}
|
||||
|
||||
static void expansion_worker_pending_callback(void* context, uint32_t arg) {
|
||||
furi_assert(context);
|
||||
UNUSED(arg);
|
||||
|
||||
ExpansionWorker* instance = context;
|
||||
furi_thread_join(instance->thread);
|
||||
|
||||
if(instance->callback != NULL) {
|
||||
instance->callback(instance->cb_context);
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t expansion_worker(void* context) {
|
||||
furi_assert(context);
|
||||
ExpansionWorker* instance = context;
|
||||
@@ -361,9 +349,9 @@ static int32_t expansion_worker(void* context) {
|
||||
furi_hal_serial_control_release(instance->serial_handle);
|
||||
furi_hal_power_insomnia_exit();
|
||||
|
||||
// Do not invoke pending callback on user-requested exit
|
||||
if(instance->exit_reason != ExpansionWorkerExitReasonUser) {
|
||||
furi_timer_pending_callback(expansion_worker_pending_callback, instance, 0);
|
||||
// Do not invoke worker callback on user-requested exit
|
||||
if((instance->exit_reason != ExpansionWorkerExitReasonUser) && (instance->callback != NULL)) {
|
||||
instance->callback(instance->cb_context);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -385,6 +373,7 @@ ExpansionWorker* expansion_worker_alloc(FuriHalSerialId serial_id) {
|
||||
|
||||
void expansion_worker_free(ExpansionWorker* instance) {
|
||||
furi_stream_buffer_free(instance->rx_buf);
|
||||
furi_thread_join(instance->thread);
|
||||
furi_thread_free(instance->thread);
|
||||
free(instance);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user