99
1010NfcWorker * nfc_worker_alloc () {
1111 NfcWorker * nfc_worker = malloc (sizeof (NfcWorker ));
12+
1213 // Worker thread attributes
13- nfc_worker -> thread_attr .name = "NfcWorker" ;
14- nfc_worker -> thread_attr .stack_size = 8192 ;
14+ nfc_worker -> thread = furi_thread_alloc ();
15+ furi_thread_set_name (nfc_worker -> thread , "NfcWorker" );
16+ furi_thread_set_stack_size (nfc_worker -> thread , 8192 );
17+ furi_thread_set_callback (nfc_worker -> thread , nfc_worker_task );
18+ furi_thread_set_context (nfc_worker -> thread , nfc_worker );
19+
1520 nfc_worker -> callback = NULL ;
1621 nfc_worker -> context = NULL ;
22+
1723 // Initialize rfal
1824 while (furi_hal_nfc_is_busy ()) {
1925 osDelay (10 );
@@ -25,6 +31,7 @@ NfcWorker* nfc_worker_alloc() {
2531
2632void nfc_worker_free (NfcWorker * nfc_worker ) {
2733 furi_assert (nfc_worker );
34+ furi_thread_free (nfc_worker -> thread );
2835 free (nfc_worker );
2936}
3037
@@ -48,7 +55,7 @@ void nfc_worker_start(
4855 nfc_worker -> context = context ;
4956 nfc_worker -> dev_data = dev_data ;
5057 nfc_worker_change_state (nfc_worker , state );
51- nfc_worker -> thread = osThreadNew ( nfc_worker_task , nfc_worker , & nfc_worker -> thread_attr );
58+ furi_thread_start ( nfc_worker -> thread );
5259}
5360
5461void nfc_worker_stop (NfcWorker * nfc_worker ) {
@@ -58,6 +65,7 @@ void nfc_worker_stop(NfcWorker* nfc_worker) {
5865 }
5966 furi_hal_nfc_stop ();
6067 nfc_worker_change_state (nfc_worker , NfcWorkerStateStop );
68+ furi_thread_join (nfc_worker -> thread );
6169}
6270
6371void nfc_worker_change_state (NfcWorker * nfc_worker , NfcWorkerState state ) {
@@ -66,7 +74,7 @@ void nfc_worker_change_state(NfcWorker* nfc_worker, NfcWorkerState state) {
6674
6775/***************************** NFC Worker Thread *******************************/
6876
69- void nfc_worker_task (void * context ) {
77+ int32_t nfc_worker_task (void * context ) {
7078 NfcWorker * nfc_worker = context ;
7179
7280 furi_hal_power_insomnia_enter ();
@@ -92,7 +100,8 @@ void nfc_worker_task(void* context) {
92100 furi_hal_nfc_deactivate ();
93101 nfc_worker_change_state (nfc_worker , NfcWorkerStateReady );
94102 furi_hal_power_insomnia_exit ();
95- osThreadExit ();
103+
104+ return 0 ;
96105}
97106
98107void nfc_worker_detect (NfcWorker * nfc_worker ) {
0 commit comments