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:
@@ -4,18 +4,18 @@
|
||||
|
||||
static Input* input = NULL;
|
||||
|
||||
inline static void input_timer_start(osTimerId_t timer_id, uint32_t ticks) {
|
||||
inline static void input_timer_start(FuriTimer* timer_id, uint32_t ticks) {
|
||||
TimerHandle_t hTimer = (TimerHandle_t)timer_id;
|
||||
furi_check(xTimerChangePeriod(hTimer, ticks, portMAX_DELAY) == pdPASS);
|
||||
}
|
||||
|
||||
inline static void input_timer_stop(osTimerId_t timer_id) {
|
||||
inline static void input_timer_stop(FuriTimer* timer_id) {
|
||||
TimerHandle_t hTimer = (TimerHandle_t)timer_id;
|
||||
furi_check(xTimerStop(hTimer, portMAX_DELAY) == pdPASS);
|
||||
// xTimerStop is not actually stopping timer,
|
||||
// Instead it places stop event into timer queue
|
||||
// This code ensures that timer is stopped
|
||||
while(xTimerIsTimerActive(hTimer) == pdTRUE) osDelay(1);
|
||||
while(xTimerIsTimerActive(hTimer) == pdTRUE) furi_delay_tick(1);
|
||||
}
|
||||
|
||||
void input_press_timer_callback(void* arg) {
|
||||
@@ -84,8 +84,8 @@ int32_t input_srv() {
|
||||
input->pin_states[i].pin = &input_pins[i];
|
||||
input->pin_states[i].state = GPIO_Read(input->pin_states[i]);
|
||||
input->pin_states[i].debounce = INPUT_DEBOUNCE_TICKS_HALF;
|
||||
input->pin_states[i].press_timer =
|
||||
osTimerNew(input_press_timer_callback, osTimerPeriodic, &input->pin_states[i], NULL);
|
||||
input->pin_states[i].press_timer = furi_timer_alloc(
|
||||
input_press_timer_callback, FuriTimerTypePeriodic, &input->pin_states[i]);
|
||||
input->pin_states[i].press_counter = 0;
|
||||
}
|
||||
|
||||
@@ -127,9 +127,9 @@ int32_t input_srv() {
|
||||
}
|
||||
|
||||
if(is_changing) {
|
||||
osDelay(1);
|
||||
furi_delay_tick(1);
|
||||
} else {
|
||||
furi_thread_flags_wait(INPUT_THREAD_FLAG_ISR, osFlagsWaitAny, osWaitForever);
|
||||
furi_thread_flags_wait(INPUT_THREAD_FLAG_ISR, FuriFlagWaitAny, FuriWaitForever);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -15,20 +15,20 @@ static void input_cli_usage() {
|
||||
static void input_cli_dump_events_callback(const void* value, void* ctx) {
|
||||
furi_assert(value);
|
||||
furi_assert(ctx);
|
||||
osMessageQueueId_t input_queue = ctx;
|
||||
osMessageQueuePut(input_queue, value, 0, osWaitForever);
|
||||
FuriMessageQueue* input_queue = ctx;
|
||||
furi_message_queue_put(input_queue, value, FuriWaitForever);
|
||||
}
|
||||
|
||||
static void input_cli_dump(Cli* cli, string_t args, Input* input) {
|
||||
UNUSED(args);
|
||||
osMessageQueueId_t input_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL);
|
||||
FuriMessageQueue* input_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
|
||||
FuriPubSubSubscription* input_subscription =
|
||||
furi_pubsub_subscribe(input->event_pubsub, input_cli_dump_events_callback, input_queue);
|
||||
|
||||
InputEvent input_event;
|
||||
printf("Press CTRL+C to stop\r\n");
|
||||
while(!cli_cmd_interrupt_received(cli)) {
|
||||
if(osMessageQueueGet(input_queue, &input_event, NULL, 100) == osOK) {
|
||||
if(furi_message_queue_get(input_queue, &input_event, 100) == FuriStatusOk) {
|
||||
printf(
|
||||
"key: %s type: %s\r\n",
|
||||
input_get_key_name(input_event.key),
|
||||
@@ -37,7 +37,7 @@ static void input_cli_dump(Cli* cli, string_t args, Input* input) {
|
||||
}
|
||||
|
||||
furi_pubsub_unsubscribe(input->event_pubsub, input_subscription);
|
||||
osMessageQueueDelete(input_queue);
|
||||
furi_message_queue_free(input_queue);
|
||||
}
|
||||
|
||||
static void input_cli_send_print_usage() {
|
||||
|
@@ -25,7 +25,7 @@ typedef struct {
|
||||
// State
|
||||
volatile bool state;
|
||||
volatile uint8_t debounce;
|
||||
volatile osTimerId_t press_timer;
|
||||
FuriTimer* press_timer;
|
||||
volatile uint8_t press_counter;
|
||||
volatile uint32_t counter;
|
||||
} InputPinState;
|
||||
|
Reference in New Issue
Block a user