mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-26 14:51:52 +03:00
Do not use a timer callback
This commit is contained in:
parent
4c2e997997
commit
73deff8863
@ -57,7 +57,7 @@ static void expansion_detect_callback(void* context) {
|
|||||||
|
|
||||||
ExpansionMessage message = {
|
ExpansionMessage message = {
|
||||||
.type = ExpansionMessageTypeModuleConnected,
|
.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
|
// Not waiting for available queue space, discarding message if there is none
|
||||||
@ -71,7 +71,7 @@ static void expansion_worker_callback(void* context) {
|
|||||||
|
|
||||||
ExpansionMessage message = {
|
ExpansionMessage message = {
|
||||||
.type = ExpansionMessageTypeModuleDisconnected,
|
.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);
|
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) {
|
static int32_t expansion_worker(void* context) {
|
||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
ExpansionWorker* instance = 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_serial_control_release(instance->serial_handle);
|
||||||
furi_hal_power_insomnia_exit();
|
furi_hal_power_insomnia_exit();
|
||||||
|
|
||||||
// Do not invoke pending callback on user-requested exit
|
// Do not invoke worker callback on user-requested exit
|
||||||
if(instance->exit_reason != ExpansionWorkerExitReasonUser) {
|
if((instance->exit_reason != ExpansionWorkerExitReasonUser) && (instance->callback != NULL)) {
|
||||||
furi_timer_pending_callback(expansion_worker_pending_callback, instance, 0);
|
instance->callback(instance->cb_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -385,6 +373,7 @@ ExpansionWorker* expansion_worker_alloc(FuriHalSerialId serial_id) {
|
|||||||
|
|
||||||
void expansion_worker_free(ExpansionWorker* instance) {
|
void expansion_worker_free(ExpansionWorker* instance) {
|
||||||
furi_stream_buffer_free(instance->rx_buf);
|
furi_stream_buffer_free(instance->rx_buf);
|
||||||
|
furi_thread_join(instance->thread);
|
||||||
furi_thread_free(instance->thread);
|
furi_thread_free(instance->thread);
|
||||||
free(instance);
|
free(instance);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user