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:
@@ -16,10 +16,10 @@ Cli* cli_alloc() {
|
||||
|
||||
cli->session = NULL;
|
||||
|
||||
cli->mutex = osMutexNew(NULL);
|
||||
cli->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
furi_check(cli->mutex);
|
||||
|
||||
cli->idle_sem = osSemaphoreNew(1, 0, NULL);
|
||||
cli->idle_sem = furi_semaphore_alloc(1, 0);
|
||||
|
||||
return cli;
|
||||
}
|
||||
@@ -35,7 +35,7 @@ char cli_getc(Cli* cli) {
|
||||
furi_assert(cli);
|
||||
char c = 0;
|
||||
if(cli->session != NULL) {
|
||||
if(cli->session->rx((uint8_t*)&c, 1, osWaitForever) == 0) {
|
||||
if(cli->session->rx((uint8_t*)&c, 1, FuriWaitForever) == 0) {
|
||||
cli_reset(cli);
|
||||
}
|
||||
} else {
|
||||
@@ -54,7 +54,7 @@ void cli_write(Cli* cli, const uint8_t* buffer, size_t size) {
|
||||
size_t cli_read(Cli* cli, uint8_t* buffer, size_t size) {
|
||||
furi_assert(cli);
|
||||
if(cli->session != NULL) {
|
||||
return cli->session->rx(buffer, size, osWaitForever);
|
||||
return cli->session->rx(buffer, size, FuriWaitForever);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@@ -228,17 +228,17 @@ static void cli_handle_enter(Cli* cli) {
|
||||
}
|
||||
|
||||
// Search for command
|
||||
furi_check(osMutexAcquire(cli->mutex, osWaitForever) == osOK);
|
||||
furi_check(furi_mutex_acquire(cli->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
CliCommand* cli_command_ptr = CliCommandTree_get(cli->commands, command);
|
||||
|
||||
if(cli_command_ptr) {
|
||||
CliCommand cli_command;
|
||||
memcpy(&cli_command, cli_command_ptr, sizeof(CliCommand));
|
||||
furi_check(osMutexRelease(cli->mutex) == osOK);
|
||||
furi_check(furi_mutex_release(cli->mutex) == FuriStatusOk);
|
||||
cli_nl(cli);
|
||||
cli_execute_command(cli, &cli_command, args);
|
||||
} else {
|
||||
furi_check(osMutexRelease(cli->mutex) == osOK);
|
||||
furi_check(furi_mutex_release(cli->mutex) == FuriStatusOk);
|
||||
cli_nl(cli);
|
||||
printf(
|
||||
"`%s` command not found, use `help` or `?` to list all available commands",
|
||||
@@ -339,7 +339,7 @@ void cli_process_input(Cli* cli) {
|
||||
if(in_chr == CliSymbolAsciiTab) {
|
||||
cli_handle_autocomplete(cli);
|
||||
} else if(in_chr == CliSymbolAsciiSOH) {
|
||||
osDelay(33); // We are too fast, Minicom is not ready yet
|
||||
furi_delay_ms(33); // We are too fast, Minicom is not ready yet
|
||||
cli_motd();
|
||||
cli_prompt(cli);
|
||||
} else if(in_chr == CliSymbolAsciiETX) {
|
||||
@@ -406,9 +406,9 @@ void cli_add_command(
|
||||
c.context = context;
|
||||
c.flags = flags;
|
||||
|
||||
furi_check(osMutexAcquire(cli->mutex, osWaitForever) == osOK);
|
||||
furi_check(furi_mutex_acquire(cli->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
CliCommandTree_set_at(cli->commands, name_str, c);
|
||||
furi_check(osMutexRelease(cli->mutex) == osOK);
|
||||
furi_check(furi_mutex_release(cli->mutex) == FuriStatusOk);
|
||||
|
||||
string_clear(name_str);
|
||||
}
|
||||
@@ -423,9 +423,9 @@ void cli_delete_command(Cli* cli, const char* name) {
|
||||
name_replace = string_replace_str(name_str, " ", "_");
|
||||
} while(name_replace != STRING_FAILURE);
|
||||
|
||||
furi_check(osMutexAcquire(cli->mutex, osWaitForever) == osOK);
|
||||
furi_check(furi_mutex_acquire(cli->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
CliCommandTree_erase(cli->commands, name_str);
|
||||
furi_check(osMutexRelease(cli->mutex) == osOK);
|
||||
furi_check(furi_mutex_release(cli->mutex) == FuriStatusOk);
|
||||
|
||||
string_clear(name_str);
|
||||
}
|
||||
@@ -433,7 +433,7 @@ void cli_delete_command(Cli* cli, const char* name) {
|
||||
void cli_session_open(Cli* cli, void* session) {
|
||||
furi_assert(cli);
|
||||
|
||||
furi_check(osMutexAcquire(cli->mutex, osWaitForever) == osOK);
|
||||
furi_check(furi_mutex_acquire(cli->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
cli->session = session;
|
||||
if(cli->session != NULL) {
|
||||
cli->session->init();
|
||||
@@ -441,20 +441,20 @@ void cli_session_open(Cli* cli, void* session) {
|
||||
} else {
|
||||
furi_stdglue_set_thread_stdout_callback(NULL);
|
||||
}
|
||||
osSemaphoreRelease(cli->idle_sem);
|
||||
furi_check(osMutexRelease(cli->mutex) == osOK);
|
||||
furi_semaphore_release(cli->idle_sem);
|
||||
furi_check(furi_mutex_release(cli->mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void cli_session_close(Cli* cli) {
|
||||
furi_assert(cli);
|
||||
|
||||
furi_check(osMutexAcquire(cli->mutex, osWaitForever) == osOK);
|
||||
furi_check(furi_mutex_acquire(cli->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
if(cli->session != NULL) {
|
||||
cli->session->deinit();
|
||||
}
|
||||
cli->session = NULL;
|
||||
furi_stdglue_set_thread_stdout_callback(NULL);
|
||||
furi_check(osMutexRelease(cli->mutex) == osOK);
|
||||
furi_check(furi_mutex_release(cli->mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
int32_t cli_srv(void* p) {
|
||||
@@ -482,7 +482,7 @@ int32_t cli_srv(void* p) {
|
||||
if(cli->session != NULL) {
|
||||
cli_process_input(cli);
|
||||
} else {
|
||||
furi_check(osSemaphoreAcquire(cli->idle_sem, osWaitForever) == osOK);
|
||||
furi_check(furi_semaphore_acquire(cli->idle_sem, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -41,8 +41,8 @@ BPTREE_DEF2(
|
||||
|
||||
struct Cli {
|
||||
CliCommandTree_t commands;
|
||||
osMutexId_t mutex;
|
||||
osSemaphoreId_t idle_sem;
|
||||
FuriMutex* mutex;
|
||||
FuriSemaphore* idle_sem;
|
||||
string_t last_line;
|
||||
string_t line;
|
||||
CliSession* session;
|
||||
|
@@ -103,8 +103,8 @@ static int32_t vcp_worker(void* context) {
|
||||
|
||||
while(1) {
|
||||
uint32_t flags =
|
||||
furi_thread_flags_wait(VCP_THREAD_FLAG_ALL, osFlagsWaitAny, osWaitForever);
|
||||
furi_assert((flags & osFlagsError) == 0);
|
||||
furi_thread_flags_wait(VCP_THREAD_FLAG_ALL, FuriFlagWaitAny, FuriWaitForever);
|
||||
furi_assert((flags & FuriFlagError) == 0);
|
||||
|
||||
// VCP session opened
|
||||
if(flags & VcpEvtConnect) {
|
||||
@@ -113,7 +113,7 @@ static int32_t vcp_worker(void* context) {
|
||||
#endif
|
||||
if(vcp->connected == false) {
|
||||
vcp->connected = true;
|
||||
xStreamBufferSend(vcp->rx_stream, &ascii_soh, 1, osWaitForever);
|
||||
xStreamBufferSend(vcp->rx_stream, &ascii_soh, 1, FuriWaitForever);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ static int32_t vcp_worker(void* context) {
|
||||
if(vcp->connected == true) {
|
||||
vcp->connected = false;
|
||||
xStreamBufferReceive(vcp->tx_stream, vcp->data_buffer, USB_CDC_PKT_LEN, 0);
|
||||
xStreamBufferSend(vcp->rx_stream, &ascii_eot, 1, osWaitForever);
|
||||
xStreamBufferSend(vcp->rx_stream, &ascii_eot, 1, FuriWaitForever);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ static int32_t vcp_worker(void* context) {
|
||||
#endif
|
||||
if(len > 0) {
|
||||
furi_check(
|
||||
xStreamBufferSend(vcp->rx_stream, vcp->data_buffer, len, osWaitForever) ==
|
||||
xStreamBufferSend(vcp->rx_stream, vcp->data_buffer, len, FuriWaitForever) ==
|
||||
(size_t)len);
|
||||
}
|
||||
} else {
|
||||
@@ -203,7 +203,7 @@ static int32_t vcp_worker(void* context) {
|
||||
furi_hal_usb_set_config(vcp->usb_if_prev, NULL);
|
||||
}
|
||||
xStreamBufferReceive(vcp->tx_stream, vcp->data_buffer, USB_CDC_PKT_LEN, 0);
|
||||
xStreamBufferSend(vcp->rx_stream, &ascii_eot, 1, osWaitForever);
|
||||
xStreamBufferSend(vcp->rx_stream, &ascii_eot, 1, FuriWaitForever);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -262,7 +262,7 @@ static void cli_vcp_tx(const uint8_t* buffer, size_t size) {
|
||||
size_t batch_size = size;
|
||||
if(batch_size > USB_CDC_PKT_LEN) batch_size = USB_CDC_PKT_LEN;
|
||||
|
||||
xStreamBufferSend(vcp->tx_stream, buffer, batch_size, osWaitForever);
|
||||
xStreamBufferSend(vcp->tx_stream, buffer, batch_size, FuriWaitForever);
|
||||
furi_thread_flags_set(furi_thread_get_id(vcp->thread), VcpEvtStreamTx);
|
||||
#ifdef CLI_VCP_DEBUG
|
||||
FURI_LOG_D(TAG, "tx %u", batch_size);
|
||||
@@ -304,7 +304,7 @@ static void vcp_on_cdc_control_line(void* context, uint8_t state) {
|
||||
static void vcp_on_cdc_rx(void* context) {
|
||||
UNUSED(context);
|
||||
uint32_t ret = furi_thread_flags_set(furi_thread_get_id(vcp->thread), VcpEvtRx);
|
||||
furi_check((ret & osFlagsError) == 0);
|
||||
furi_check((ret & FuriFlagError) == 0);
|
||||
}
|
||||
|
||||
static void vcp_on_cdc_tx_complete(void* context) {
|
||||
|
Reference in New Issue
Block a user