Furi: core refactoring and CMSIS removal part 2 (#1410)
* Furi: rename and move core * Furi: drop CMSIS_OS header and unused api, partially refactor and cleanup the rest * Furi: CMSIS_OS drop and refactoring. * Furi: refactoring, remove cmsis legacy * Furi: fix incorrect assert on queue deallocation, cleanup timer * Furi: improve delay api, get rid of floats * hal: dropped furi_hal_crc * Furi: move DWT based delay to cortex HAL * Furi: update core documentation Co-authored-by: hedger <hedger@nanode.su>
This commit is contained in:
@@ -10,7 +10,7 @@ struct SubGhzChatWorker {
|
||||
|
||||
volatile bool worker_running;
|
||||
volatile bool worker_stoping;
|
||||
osMessageQueueId_t event_queue;
|
||||
FuriMessageQueue* event_queue;
|
||||
uint32_t last_time_rx_data;
|
||||
|
||||
Cli* cli;
|
||||
@@ -27,12 +27,12 @@ static int32_t subghz_chat_worker_thread(void* context) {
|
||||
char c;
|
||||
SubGhzChatEvent event;
|
||||
event.event = SubGhzChatEventUserEntrance;
|
||||
osMessageQueuePut(instance->event_queue, &event, 0, 0);
|
||||
furi_message_queue_put(instance->event_queue, &event, 0);
|
||||
while(instance->worker_running) {
|
||||
if(cli_read_timeout(instance->cli, (uint8_t*)&c, 1, 1000) == 1) {
|
||||
event.event = SubGhzChatEventInputData;
|
||||
event.c = c;
|
||||
osMessageQueuePut(instance->event_queue, &event, 0, osWaitForever);
|
||||
furi_message_queue_put(instance->event_queue, &event, FuriWaitForever);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,14 +44,14 @@ static void subghz_chat_worker_update_rx_event_chat(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzChatWorker* instance = context;
|
||||
SubGhzChatEvent event;
|
||||
if((furi_hal_get_tick() - instance->last_time_rx_data) >
|
||||
if((furi_get_tick() - instance->last_time_rx_data) >
|
||||
SUBGHZ_CHAT_WORKER_TIMEOUT_BETWEEN_MESSAGES) {
|
||||
event.event = SubGhzChatEventNewMessage;
|
||||
osMessageQueuePut(instance->event_queue, &event, 0, osWaitForever);
|
||||
furi_message_queue_put(instance->event_queue, &event, FuriWaitForever);
|
||||
}
|
||||
instance->last_time_rx_data = furi_hal_get_tick();
|
||||
instance->last_time_rx_data = furi_get_tick();
|
||||
event.event = SubGhzChatEventRXData;
|
||||
osMessageQueuePut(instance->event_queue, &event, 0, osWaitForever);
|
||||
furi_message_queue_put(instance->event_queue, &event, FuriWaitForever);
|
||||
}
|
||||
|
||||
SubGhzChatWorker* subghz_chat_worker_alloc(Cli* cli) {
|
||||
@@ -65,14 +65,14 @@ SubGhzChatWorker* subghz_chat_worker_alloc(Cli* cli) {
|
||||
furi_thread_set_context(instance->thread, instance);
|
||||
furi_thread_set_callback(instance->thread, subghz_chat_worker_thread);
|
||||
instance->subghz_txrx = subghz_tx_rx_worker_alloc();
|
||||
instance->event_queue = osMessageQueueNew(80, sizeof(SubGhzChatEvent), NULL);
|
||||
instance->event_queue = furi_message_queue_alloc(80, sizeof(SubGhzChatEvent));
|
||||
return instance;
|
||||
}
|
||||
|
||||
void subghz_chat_worker_free(SubGhzChatWorker* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(!instance->worker_running);
|
||||
osMessageQueueDelete(instance->event_queue);
|
||||
furi_message_queue_free(instance->event_queue);
|
||||
subghz_tx_rx_worker_free(instance->subghz_txrx);
|
||||
furi_thread_free(instance->thread);
|
||||
|
||||
@@ -85,7 +85,7 @@ bool subghz_chat_worker_start(SubGhzChatWorker* instance, uint32_t frequency) {
|
||||
bool res = false;
|
||||
|
||||
if(subghz_tx_rx_worker_start(instance->subghz_txrx, frequency)) {
|
||||
osMessageQueueReset(instance->event_queue);
|
||||
furi_message_queue_reset(instance->event_queue);
|
||||
subghz_tx_rx_worker_set_callback_have_read(
|
||||
instance->subghz_txrx, subghz_chat_worker_update_rx_event_chat, instance);
|
||||
|
||||
@@ -119,7 +119,7 @@ bool subghz_chat_worker_is_running(SubGhzChatWorker* instance) {
|
||||
SubGhzChatEvent subghz_chat_worker_get_event_chat(SubGhzChatWorker* instance) {
|
||||
furi_assert(instance);
|
||||
SubGhzChatEvent event;
|
||||
if(osMessageQueueGet(instance->event_queue, &event, NULL, osWaitForever) == osOK) {
|
||||
if(furi_message_queue_get(instance->event_queue, &event, FuriWaitForever) == FuriStatusOk) {
|
||||
return event;
|
||||
} else {
|
||||
event.event = SubGhzChatEventNoEvent;
|
||||
@@ -129,7 +129,7 @@ SubGhzChatEvent subghz_chat_worker_get_event_chat(SubGhzChatWorker* instance) {
|
||||
|
||||
void subghz_chat_worker_put_event_chat(SubGhzChatWorker* instance, SubGhzChatEvent* event) {
|
||||
furi_assert(instance);
|
||||
osMessageQueuePut(instance->event_queue, event, 0, osWaitForever);
|
||||
furi_message_queue_put(instance->event_queue, event, FuriWaitForever);
|
||||
}
|
||||
|
||||
size_t subghz_chat_worker_available(SubGhzChatWorker* instance) {
|
||||
|
@@ -100,7 +100,7 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
|
||||
furi_hal_subghz_set_path(FuriHalSubGhzPathIsolate);
|
||||
|
||||
while(instance->worker_running) {
|
||||
osDelay(10);
|
||||
furi_delay_ms(10);
|
||||
|
||||
float rssi_min = 26.0f;
|
||||
float rssi_avg = 0;
|
||||
@@ -129,8 +129,7 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
|
||||
cc1101_switch_to_rx(&furi_hal_spi_bus_handle_subghz);
|
||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||
|
||||
// delay will be in range between 1 and 2ms
|
||||
osDelay(3);
|
||||
furi_delay_ms(2);
|
||||
|
||||
rssi = furi_hal_subghz_get_rssi();
|
||||
|
||||
@@ -175,8 +174,7 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
|
||||
cc1101_switch_to_rx(&furi_hal_spi_bus_handle_subghz);
|
||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||
|
||||
// delay will be in range between 1 and 2ms
|
||||
osDelay(3);
|
||||
furi_delay_ms(2);
|
||||
|
||||
rssi = furi_hal_subghz_get_rssi();
|
||||
|
||||
|
@@ -51,7 +51,7 @@ void subghz_cli_command_tx_carrier(Cli* cli, string_t args, void* context) {
|
||||
printf("Transmitting at frequency %lu Hz\r\n", frequency);
|
||||
printf("Press CTRL+C to stop\r\n");
|
||||
while(!cli_cmd_interrupt_received(cli)) {
|
||||
osDelay(250);
|
||||
furi_delay_ms(250);
|
||||
}
|
||||
} else {
|
||||
printf("This frequency can only be used for RX in your region\r\n");
|
||||
@@ -93,7 +93,7 @@ void subghz_cli_command_rx_carrier(Cli* cli, string_t args, void* context) {
|
||||
furi_hal_subghz_rx();
|
||||
|
||||
while(!cli_cmd_interrupt_received(cli)) {
|
||||
osDelay(250);
|
||||
furi_delay_ms(250);
|
||||
printf("RSSI: %03.1fdbm\r", (double)furi_hal_subghz_get_rssi());
|
||||
fflush(stdout);
|
||||
}
|
||||
@@ -172,7 +172,7 @@ void subghz_cli_command_tx(Cli* cli, string_t args, void* context) {
|
||||
while(!(furi_hal_subghz_is_async_tx_complete() || cli_cmd_interrupt_received(cli))) {
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
osDelay(333);
|
||||
furi_delay_ms(333);
|
||||
}
|
||||
furi_hal_subghz_stop_async_tx();
|
||||
furi_hal_subghz_sleep();
|
||||
@@ -377,7 +377,7 @@ void subghz_cli_command_decode_raw(Cli* cli, string_t args, void* context) {
|
||||
SubGhzFileEncoderWorker* file_worker_encoder = subghz_file_encoder_worker_alloc();
|
||||
if(subghz_file_encoder_worker_start(file_worker_encoder, string_get_cstr(file_name))) {
|
||||
//the worker needs a file in order to open and read part of the file
|
||||
osDelay(100);
|
||||
furi_delay_ms(100);
|
||||
}
|
||||
|
||||
printf(
|
||||
@@ -386,7 +386,7 @@ void subghz_cli_command_decode_raw(Cli* cli, string_t args, void* context) {
|
||||
|
||||
LevelDuration level_duration;
|
||||
while(!cli_cmd_interrupt_received(cli)) {
|
||||
furi_hal_delay_us(500); //you need to have time to read from the file from the SD card
|
||||
furi_delay_us(500); //you need to have time to read from the file from the SD card
|
||||
level_duration = subghz_file_encoder_worker_get_level_duration(file_worker_encoder);
|
||||
if(!level_duration_is_reset(level_duration)) {
|
||||
bool level = level_duration_get_level(level_duration);
|
||||
@@ -616,7 +616,7 @@ static void subghz_cli_command_chat(Cli* cli, string_t args) {
|
||||
subghz_chat,
|
||||
(uint8_t*)string_get_cstr(input),
|
||||
strlen(string_get_cstr(input)))) {
|
||||
furi_hal_delay_ms(10);
|
||||
furi_delay_ms(10);
|
||||
}
|
||||
|
||||
string_printf(input, "%s", string_get_cstr(name));
|
||||
@@ -668,7 +668,7 @@ static void subghz_cli_command_chat(Cli* cli, string_t args) {
|
||||
subghz_chat,
|
||||
(uint8_t*)string_get_cstr(sysmsg),
|
||||
strlen(string_get_cstr(sysmsg)));
|
||||
furi_hal_delay_ms(10);
|
||||
furi_delay_ms(10);
|
||||
exit = true;
|
||||
break;
|
||||
default:
|
||||
|
@@ -140,13 +140,13 @@ bool subghz_history_add_to_history(
|
||||
SubGhzProtocolDecoderBase* decoder_base = context;
|
||||
if((instance->code_last_hash_data ==
|
||||
subghz_protocol_decoder_base_get_hash_data(decoder_base)) &&
|
||||
((furi_hal_get_tick() - instance->last_update_timestamp) < 500)) {
|
||||
instance->last_update_timestamp = furi_hal_get_tick();
|
||||
((furi_get_tick() - instance->last_update_timestamp) < 500)) {
|
||||
instance->last_update_timestamp = furi_get_tick();
|
||||
return false;
|
||||
}
|
||||
|
||||
instance->code_last_hash_data = subghz_protocol_decoder_base_get_hash_data(decoder_base);
|
||||
instance->last_update_timestamp = furi_hal_get_tick();
|
||||
instance->last_update_timestamp = furi_get_tick();
|
||||
|
||||
string_t text;
|
||||
string_init(text);
|
||||
|
@@ -45,7 +45,7 @@ typedef enum {
|
||||
struct SubGhzViewReceiver {
|
||||
SubGhzLock lock;
|
||||
uint8_t lock_count;
|
||||
osTimerId_t timer;
|
||||
FuriTimer* timer;
|
||||
View* view;
|
||||
SubGhzViewReceiverCallback callback;
|
||||
void* context;
|
||||
@@ -72,7 +72,7 @@ void subghz_view_receiver_set_lock(SubGhzViewReceiver* subghz_receiver, SubGhzLo
|
||||
model->bar_show = SubGhzViewReceiverBarShowLock;
|
||||
return true;
|
||||
});
|
||||
osTimerStart(subghz_receiver->timer, pdMS_TO_TICKS(1000));
|
||||
furi_timer_start(subghz_receiver->timer, pdMS_TO_TICKS(1000));
|
||||
} else {
|
||||
with_view_model(
|
||||
subghz_receiver->view, (SubGhzViewReceiverModel * model) {
|
||||
@@ -266,7 +266,7 @@ bool subghz_view_receiver_input(InputEvent* event, void* context) {
|
||||
return true;
|
||||
});
|
||||
if(subghz_receiver->lock_count == 0) {
|
||||
osTimerStart(subghz_receiver->timer, pdMS_TO_TICKS(1000));
|
||||
furi_timer_start(subghz_receiver->timer, pdMS_TO_TICKS(1000));
|
||||
}
|
||||
if(event->key == InputKeyBack && event->type == InputTypeShort) {
|
||||
subghz_receiver->lock_count++;
|
||||
@@ -280,7 +280,7 @@ bool subghz_view_receiver_input(InputEvent* event, void* context) {
|
||||
return true;
|
||||
});
|
||||
//subghz_receiver->lock = SubGhzLockOff;
|
||||
osTimerStart(subghz_receiver->timer, pdMS_TO_TICKS(650));
|
||||
furi_timer_start(subghz_receiver->timer, pdMS_TO_TICKS(650));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -345,7 +345,7 @@ void subghz_view_receiver_exit(void* context) {
|
||||
model->history_item = 0;
|
||||
return false;
|
||||
});
|
||||
osTimerStop(subghz_receiver->timer);
|
||||
furi_timer_stop(subghz_receiver->timer);
|
||||
}
|
||||
|
||||
SubGhzViewReceiver* subghz_view_receiver_alloc() {
|
||||
@@ -375,7 +375,7 @@ SubGhzViewReceiver* subghz_view_receiver_alloc() {
|
||||
return true;
|
||||
});
|
||||
subghz_receiver->timer =
|
||||
osTimerNew(subghz_view_receiver_timer_callback, osTimerOnce, subghz_receiver, NULL);
|
||||
furi_timer_alloc(subghz_view_receiver_timer_callback, FuriTimerTypeOnce, subghz_receiver);
|
||||
return subghz_receiver;
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ void subghz_view_receiver_free(SubGhzViewReceiver* subghz_receiver) {
|
||||
free(model->history);
|
||||
return false;
|
||||
});
|
||||
osTimerDelete(subghz_receiver->timer);
|
||||
furi_timer_free(subghz_receiver->timer);
|
||||
view_free(subghz_receiver->view);
|
||||
free(subghz_receiver);
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@
|
||||
|
||||
struct SubGhzTestCarrier {
|
||||
View* view;
|
||||
osTimerId_t timer;
|
||||
FuriTimer* timer;
|
||||
SubGhzTestCarrierCallback callback;
|
||||
void* context;
|
||||
};
|
||||
@@ -154,14 +154,14 @@ void subghz_test_carrier_enter(void* context) {
|
||||
|
||||
furi_hal_subghz_rx();
|
||||
|
||||
osTimerStart(subghz_test_carrier->timer, osKernelGetTickFreq() / 4);
|
||||
furi_timer_start(subghz_test_carrier->timer, furi_kernel_get_tick_frequency() / 4);
|
||||
}
|
||||
|
||||
void subghz_test_carrier_exit(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzTestCarrier* subghz_test_carrier = context;
|
||||
|
||||
osTimerStop(subghz_test_carrier->timer);
|
||||
furi_timer_stop(subghz_test_carrier->timer);
|
||||
|
||||
// Reinitialize IC to default state
|
||||
furi_hal_subghz_sleep();
|
||||
@@ -194,15 +194,15 @@ SubGhzTestCarrier* subghz_test_carrier_alloc() {
|
||||
view_set_enter_callback(subghz_test_carrier->view, subghz_test_carrier_enter);
|
||||
view_set_exit_callback(subghz_test_carrier->view, subghz_test_carrier_exit);
|
||||
|
||||
subghz_test_carrier->timer = osTimerNew(
|
||||
subghz_test_carrier_rssi_timer_callback, osTimerPeriodic, subghz_test_carrier, NULL);
|
||||
subghz_test_carrier->timer = furi_timer_alloc(
|
||||
subghz_test_carrier_rssi_timer_callback, FuriTimerTypePeriodic, subghz_test_carrier);
|
||||
|
||||
return subghz_test_carrier;
|
||||
}
|
||||
|
||||
void subghz_test_carrier_free(SubGhzTestCarrier* subghz_test_carrier) {
|
||||
furi_assert(subghz_test_carrier);
|
||||
osTimerDelete(subghz_test_carrier->timer);
|
||||
furi_timer_free(subghz_test_carrier->timer);
|
||||
view_free(subghz_test_carrier->view);
|
||||
free(subghz_test_carrier);
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@
|
||||
|
||||
struct SubGhzTestPacket {
|
||||
View* view;
|
||||
osTimerId_t timer;
|
||||
FuriTimer* timer;
|
||||
|
||||
SubGhzDecoderPrinceton* decoder;
|
||||
SubGhzEncoderPrinceton* encoder;
|
||||
@@ -141,7 +141,7 @@ static bool subghz_test_packet_input(InputEvent* event, void* context) {
|
||||
if(model->status == SubGhzTestPacketModelStatusRx) {
|
||||
furi_hal_subghz_stop_async_rx();
|
||||
} else if(model->status == SubGhzTestPacketModelStatusTx) {
|
||||
subghz_encoder_princeton_for_testing_stop(instance->encoder, furi_hal_get_tick());
|
||||
subghz_encoder_princeton_for_testing_stop(instance->encoder, furi_get_tick());
|
||||
furi_hal_subghz_stop_async_tx();
|
||||
}
|
||||
|
||||
@@ -206,14 +206,14 @@ void subghz_test_packet_enter(void* context) {
|
||||
|
||||
furi_hal_subghz_start_async_rx(subghz_test_packet_rx_callback, instance);
|
||||
|
||||
osTimerStart(instance->timer, osKernelGetTickFreq() / 4);
|
||||
furi_timer_start(instance->timer, furi_kernel_get_tick_frequency() / 4);
|
||||
}
|
||||
|
||||
void subghz_test_packet_exit(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzTestPacket* instance = context;
|
||||
|
||||
osTimerStop(instance->timer);
|
||||
furi_timer_stop(instance->timer);
|
||||
|
||||
// Reinitialize IC to default state
|
||||
with_view_model(
|
||||
@@ -221,7 +221,7 @@ void subghz_test_packet_exit(void* context) {
|
||||
if(model->status == SubGhzTestPacketModelStatusRx) {
|
||||
furi_hal_subghz_stop_async_rx();
|
||||
} else if(model->status == SubGhzTestPacketModelStatusTx) {
|
||||
subghz_encoder_princeton_for_testing_stop(instance->encoder, furi_hal_get_tick());
|
||||
subghz_encoder_princeton_for_testing_stop(instance->encoder, furi_get_tick());
|
||||
furi_hal_subghz_stop_async_tx();
|
||||
}
|
||||
return true;
|
||||
@@ -242,7 +242,7 @@ SubGhzTestPacket* subghz_test_packet_alloc() {
|
||||
view_set_exit_callback(instance->view, subghz_test_packet_exit);
|
||||
|
||||
instance->timer =
|
||||
osTimerNew(subghz_test_packet_rssi_timer_callback, osTimerPeriodic, instance, NULL);
|
||||
furi_timer_alloc(subghz_test_packet_rssi_timer_callback, FuriTimerTypePeriodic, instance);
|
||||
|
||||
instance->decoder = subghz_decoder_princeton_for_testing_alloc();
|
||||
subghz_decoder_princeton_for_testing_set_callback(
|
||||
@@ -258,7 +258,7 @@ void subghz_test_packet_free(SubGhzTestPacket* instance) {
|
||||
subghz_decoder_princeton_for_testing_free(instance->decoder);
|
||||
subghz_encoder_princeton_for_testing_free(instance->encoder);
|
||||
|
||||
osTimerDelete(instance->timer);
|
||||
furi_timer_free(instance->timer);
|
||||
view_free(instance->view);
|
||||
free(instance);
|
||||
}
|
||||
|
@@ -119,7 +119,7 @@ bool subghz_test_static_input(InputEvent* event, void* context) {
|
||||
if(instance->satus_tx == SubGhzTestStaticStatusTX) {
|
||||
FURI_LOG_I(TAG, "TX Stop");
|
||||
subghz_encoder_princeton_for_testing_stop(
|
||||
instance->encoder, furi_hal_get_tick());
|
||||
instance->encoder, furi_get_tick());
|
||||
subghz_encoder_princeton_for_testing_print_log(instance->encoder);
|
||||
furi_hal_subghz_stop_async_tx();
|
||||
notification_message(notification, &sequence_reset_red);
|
||||
|
Reference in New Issue
Block a user