Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
Fix crashes on thread waking.
Browse files Browse the repository at this point in the history
  • Loading branch information
kareltucek committed Dec 5, 2024
1 parent 01bc033 commit 1f69adc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions device/src/state_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include "peripherals/merge_sensor.h"
#include "power_mode.h"

#define WAKE(TID) if (TID != 0) { k_wakeup(TID); }

#define STATE_SYNC_SEND_DELAY 2

#define THREAD_STACK_SIZE 2000
Expand Down Expand Up @@ -141,14 +143,14 @@ static void invalidateProperty(state_sync_prop_id_t propId) {
bool isRightLeftLink = (stateSyncProps[propId].direction &
(SyncDirection_RightToLeft | SyncDirection_LeftToRight));
if (isRightLeftLink && isRightLeftDevice) {
k_wakeup(stateSyncThreadLeftId);
WAKE(stateSyncThreadLeftId);
}
bool isRightDongleDevice =
(DEVICE_ID == DeviceId_Uhk80_Right || DEVICE_ID == DeviceId_Uhk_Dongle);
bool isRightDongleLink = (stateSyncProps[propId].direction &
(SyncDirection_DongleToRight | SyncDirection_RightToDongle));
if (isRightDongleLink && isRightDongleDevice) {
k_wakeup(stateSyncThreadDongleId);
WAKE(stateSyncThreadDongleId);
}
}

Expand Down Expand Up @@ -633,7 +635,7 @@ void StateSync_UpdateLayer(layer_id_t layerId, bool fullUpdate) {
stateSyncProps[propId].dirtyState = fullUpdate ? DirtyState_NeedsUpdate : DirtyState_NeedsClearing;
stateSyncProps[propId].defaultDirty = stateSyncProps[propId].dirtyState;

k_wakeup(stateSyncThreadLeftId);
WAKE(stateSyncThreadLeftId);
}

void StateSync_Init() {
Expand Down

0 comments on commit 1f69adc

Please sign in to comment.