mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-23 04:53:08 +00:00
Do not use a timer callback
This commit is contained in:
parent
4c2e997997
commit
73deff8863
2 changed files with 6 additions and 17 deletions
|
@ -57,7 +57,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
|
||||
|
@ -71,7 +71,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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue