|
@@ -51,7 +51,6 @@ struct InfraredWorkerSignal {
|
|
|
struct InfraredWorker {
|
|
struct InfraredWorker {
|
|
|
FuriThread* thread;
|
|
FuriThread* thread;
|
|
|
StreamBufferHandle_t stream;
|
|
StreamBufferHandle_t stream;
|
|
|
- osEventFlagsId_t events;
|
|
|
|
|
|
|
|
|
|
InfraredWorkerSignal signal;
|
|
InfraredWorkerSignal signal;
|
|
|
InfraredWorkerState state;
|
|
InfraredWorkerState state;
|
|
@@ -93,7 +92,8 @@ static void infrared_worker_furi_hal_message_sent_isr_callback(void* context);
|
|
|
|
|
|
|
|
static void infrared_worker_rx_timeout_callback(void* context) {
|
|
static void infrared_worker_rx_timeout_callback(void* context) {
|
|
|
InfraredWorker* instance = context;
|
|
InfraredWorker* instance = context;
|
|
|
- uint32_t flags_set = osEventFlagsSet(instance->events, INFRARED_WORKER_RX_TIMEOUT_RECEIVED);
|
|
|
|
|
|
|
+ uint32_t flags_set = osThreadFlagsSet(
|
|
|
|
|
+ furi_thread_get_thread_id(instance->thread), INFRARED_WORKER_RX_TIMEOUT_RECEIVED);
|
|
|
furi_check(flags_set & INFRARED_WORKER_RX_TIMEOUT_RECEIVED);
|
|
furi_check(flags_set & INFRARED_WORKER_RX_TIMEOUT_RECEIVED);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -110,7 +110,7 @@ static void infrared_worker_rx_callback(void* context, bool level, uint32_t dura
|
|
|
INFRARED_WORKER_OVERRUN;
|
|
INFRARED_WORKER_OVERRUN;
|
|
|
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
|
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
|
|
|
|
|
|
|
- uint32_t flags_set = osEventFlagsSet(instance->events, events);
|
|
|
|
|
|
|
+ uint32_t flags_set = osThreadFlagsSet(furi_thread_get_thread_id(instance->thread), events);
|
|
|
furi_check(flags_set & events);
|
|
furi_check(flags_set & events);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -152,7 +152,8 @@ static void
|
|
|
instance->signal.timings[instance->signal.timings_cnt] = duration;
|
|
instance->signal.timings[instance->signal.timings_cnt] = duration;
|
|
|
++instance->signal.timings_cnt;
|
|
++instance->signal.timings_cnt;
|
|
|
} else {
|
|
} else {
|
|
|
- uint32_t flags_set = osEventFlagsSet(instance->events, INFRARED_WORKER_OVERRUN);
|
|
|
|
|
|
|
+ uint32_t flags_set = osThreadFlagsSet(
|
|
|
|
|
+ furi_thread_get_thread_id(instance->thread), INFRARED_WORKER_OVERRUN);
|
|
|
furi_check(flags_set & INFRARED_WORKER_OVERRUN);
|
|
furi_check(flags_set & INFRARED_WORKER_OVERRUN);
|
|
|
instance->rx.overrun = true;
|
|
instance->rx.overrun = true;
|
|
|
}
|
|
}
|
|
@@ -166,8 +167,7 @@ static int32_t infrared_worker_rx_thread(void* thread_context) {
|
|
|
TickType_t last_blink_time = 0;
|
|
TickType_t last_blink_time = 0;
|
|
|
|
|
|
|
|
while(1) {
|
|
while(1) {
|
|
|
- events =
|
|
|
|
|
- osEventFlagsWait(instance->events, INFRARED_WORKER_ALL_RX_EVENTS, 0, osWaitForever);
|
|
|
|
|
|
|
+ events = osThreadFlagsWait(INFRARED_WORKER_ALL_RX_EVENTS, 0, osWaitForever);
|
|
|
furi_check(events & INFRARED_WORKER_ALL_RX_EVENTS); /* at least one caught */
|
|
furi_check(events & INFRARED_WORKER_ALL_RX_EVENTS); /* at least one caught */
|
|
|
|
|
|
|
|
if(events & INFRARED_WORKER_RX_RECEIVED) {
|
|
if(events & INFRARED_WORKER_RX_RECEIVED) {
|
|
@@ -238,7 +238,6 @@ InfraredWorker* infrared_worker_alloc() {
|
|
|
instance->blink_enable = false;
|
|
instance->blink_enable = false;
|
|
|
instance->notification = furi_record_open("notification");
|
|
instance->notification = furi_record_open("notification");
|
|
|
instance->state = InfraredWorkerStateIdle;
|
|
instance->state = InfraredWorkerStateIdle;
|
|
|
- instance->events = osEventFlagsNew(NULL);
|
|
|
|
|
|
|
|
|
|
return instance;
|
|
return instance;
|
|
|
}
|
|
}
|
|
@@ -252,7 +251,6 @@ void infrared_worker_free(InfraredWorker* instance) {
|
|
|
infrared_free_encoder(instance->infrared_encoder);
|
|
infrared_free_encoder(instance->infrared_encoder);
|
|
|
vStreamBufferDelete(instance->stream);
|
|
vStreamBufferDelete(instance->stream);
|
|
|
furi_thread_free(instance->thread);
|
|
furi_thread_free(instance->thread);
|
|
|
- osEventFlagsDelete(instance->events);
|
|
|
|
|
|
|
|
|
|
free(instance);
|
|
free(instance);
|
|
|
}
|
|
}
|
|
@@ -263,7 +261,6 @@ void infrared_worker_rx_start(InfraredWorker* instance) {
|
|
|
|
|
|
|
|
xStreamBufferSetTriggerLevel(instance->stream, sizeof(LevelDuration));
|
|
xStreamBufferSetTriggerLevel(instance->stream, sizeof(LevelDuration));
|
|
|
|
|
|
|
|
- osEventFlagsClear(instance->events, INFRARED_WORKER_ALL_EVENTS);
|
|
|
|
|
furi_thread_set_callback(instance->thread, infrared_worker_rx_thread);
|
|
furi_thread_set_callback(instance->thread, infrared_worker_rx_thread);
|
|
|
furi_thread_start(instance->thread);
|
|
furi_thread_start(instance->thread);
|
|
|
|
|
|
|
@@ -285,7 +282,7 @@ void infrared_worker_rx_stop(InfraredWorker* instance) {
|
|
|
furi_hal_infrared_async_rx_set_capture_isr_callback(NULL, NULL);
|
|
furi_hal_infrared_async_rx_set_capture_isr_callback(NULL, NULL);
|
|
|
furi_hal_infrared_async_rx_stop();
|
|
furi_hal_infrared_async_rx_stop();
|
|
|
|
|
|
|
|
- osEventFlagsSet(instance->events, INFRARED_WORKER_EXIT);
|
|
|
|
|
|
|
+ osThreadFlagsSet(furi_thread_get_thread_id(instance->thread), INFRARED_WORKER_EXIT);
|
|
|
furi_thread_join(instance->thread);
|
|
furi_thread_join(instance->thread);
|
|
|
|
|
|
|
|
BaseType_t xReturn = xStreamBufferReset(instance->stream);
|
|
BaseType_t xReturn = xStreamBufferReset(instance->stream);
|
|
@@ -330,7 +327,6 @@ void infrared_worker_tx_start(InfraredWorker* instance) {
|
|
|
// size have to be greater than api hal infrared async tx buffer size
|
|
// size have to be greater than api hal infrared async tx buffer size
|
|
|
xStreamBufferSetTriggerLevel(instance->stream, sizeof(InfraredWorkerTiming));
|
|
xStreamBufferSetTriggerLevel(instance->stream, sizeof(InfraredWorkerTiming));
|
|
|
|
|
|
|
|
- osEventFlagsClear(instance->events, INFRARED_WORKER_ALL_EVENTS);
|
|
|
|
|
furi_thread_set_callback(instance->thread, infrared_worker_tx_thread);
|
|
furi_thread_set_callback(instance->thread, infrared_worker_tx_thread);
|
|
|
|
|
|
|
|
instance->tx.steady_signal_sent = false;
|
|
instance->tx.steady_signal_sent = false;
|
|
@@ -346,7 +342,8 @@ void infrared_worker_tx_start(InfraredWorker* instance) {
|
|
|
|
|
|
|
|
static void infrared_worker_furi_hal_message_sent_isr_callback(void* context) {
|
|
static void infrared_worker_furi_hal_message_sent_isr_callback(void* context) {
|
|
|
InfraredWorker* instance = context;
|
|
InfraredWorker* instance = context;
|
|
|
- uint32_t flags_set = osEventFlagsSet(instance->events, INFRARED_WORKER_TX_MESSAGE_SENT);
|
|
|
|
|
|
|
+ uint32_t flags_set = osThreadFlagsSet(
|
|
|
|
|
+ furi_thread_get_thread_id(instance->thread), INFRARED_WORKER_TX_MESSAGE_SENT);
|
|
|
furi_check(flags_set & INFRARED_WORKER_TX_MESSAGE_SENT);
|
|
furi_check(flags_set & INFRARED_WORKER_TX_MESSAGE_SENT);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -372,7 +369,8 @@ static FuriHalInfraredTxGetDataState
|
|
|
state = FuriHalInfraredTxGetDataStateDone;
|
|
state = FuriHalInfraredTxGetDataStateDone;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- uint32_t flags_set = osEventFlagsSet(instance->events, INFRARED_WORKER_TX_FILL_BUFFER);
|
|
|
|
|
|
|
+ uint32_t flags_set = osThreadFlagsSet(
|
|
|
|
|
+ furi_thread_get_thread_id(instance->thread), INFRARED_WORKER_TX_FILL_BUFFER);
|
|
|
furi_check(flags_set & INFRARED_WORKER_TX_FILL_BUFFER);
|
|
furi_check(flags_set & INFRARED_WORKER_TX_FILL_BUFFER);
|
|
|
|
|
|
|
|
return state;
|
|
return state;
|
|
@@ -500,7 +498,7 @@ static int32_t infrared_worker_tx_thread(void* thread_context) {
|
|
|
furi_hal_infrared_async_tx_wait_termination();
|
|
furi_hal_infrared_async_tx_wait_termination();
|
|
|
instance->state = InfraredWorkerStateStartTx;
|
|
instance->state = InfraredWorkerStateStartTx;
|
|
|
|
|
|
|
|
- events = osEventFlagsGet(instance->events);
|
|
|
|
|
|
|
+ events = osThreadFlagsGet();
|
|
|
if(events & INFRARED_WORKER_EXIT) {
|
|
if(events & INFRARED_WORKER_EXIT) {
|
|
|
exit = true;
|
|
exit = true;
|
|
|
break;
|
|
break;
|
|
@@ -508,8 +506,7 @@ static int32_t infrared_worker_tx_thread(void* thread_context) {
|
|
|
|
|
|
|
|
break;
|
|
break;
|
|
|
case InfraredWorkerStateRunTx:
|
|
case InfraredWorkerStateRunTx:
|
|
|
- events = osEventFlagsWait(
|
|
|
|
|
- instance->events, INFRARED_WORKER_ALL_TX_EVENTS, 0, osWaitForever);
|
|
|
|
|
|
|
+ events = osThreadFlagsWait(INFRARED_WORKER_ALL_TX_EVENTS, 0, osWaitForever);
|
|
|
furi_check(events & INFRARED_WORKER_ALL_TX_EVENTS); /* at least one caught */
|
|
furi_check(events & INFRARED_WORKER_ALL_TX_EVENTS); /* at least one caught */
|
|
|
|
|
|
|
|
if(events & INFRARED_WORKER_EXIT) {
|
|
if(events & INFRARED_WORKER_EXIT) {
|
|
@@ -561,7 +558,7 @@ void infrared_worker_tx_stop(InfraredWorker* instance) {
|
|
|
furi_assert(instance);
|
|
furi_assert(instance);
|
|
|
furi_assert(instance->state != InfraredWorkerStateRunRx);
|
|
furi_assert(instance->state != InfraredWorkerStateRunRx);
|
|
|
|
|
|
|
|
- osEventFlagsSet(instance->events, INFRARED_WORKER_EXIT);
|
|
|
|
|
|
|
+ osThreadFlagsSet(furi_thread_get_thread_id(instance->thread), INFRARED_WORKER_EXIT);
|
|
|
furi_thread_join(instance->thread);
|
|
furi_thread_join(instance->thread);
|
|
|
furi_hal_infrared_async_tx_set_data_isr_callback(NULL, NULL);
|
|
furi_hal_infrared_async_tx_set_data_isr_callback(NULL, NULL);
|
|
|
furi_hal_infrared_async_tx_set_signal_sent_isr_callback(NULL, NULL);
|
|
furi_hal_infrared_async_tx_set_signal_sent_isr_callback(NULL, NULL);
|