[FL-1009, FL-1118] Better initialization sequence and V8 hardware support (#406)
* Interrupt manager: add memory barriers. * ISRs: remove TIM17 dead code. * API HAL Delay: rename initialization routine and move to API-HAL * Main: move FURI initialization to the start. * API HAL GPIO: drop CC1101 shenanigans, COMP inversion for new boards. * IButton: migrate Cyfral and Metakom to RFID comp routine, make it compatible with new boards. * RFID: Better keyboard handling and shutdown routines
This commit is contained in:
@@ -137,17 +137,12 @@ void KeyReader::stop_comaparator(void) {
|
||||
}
|
||||
|
||||
void KeyReader::comparator_trigger_callback(void* hcomp, void* comp_ctx) {
|
||||
COMP_HandleTypeDef* _hcomp = static_cast<COMP_HandleTypeDef*>(hcomp);
|
||||
KeyReader* _this = static_cast<KeyReader*>(comp_ctx);
|
||||
|
||||
if(hcomp == &hcomp1) {
|
||||
_this->cyfral_decoder.process_front(
|
||||
(HAL_COMP_GetOutputLevel(_hcomp) == COMP_OUTPUT_LEVEL_HIGH),
|
||||
DWT->CYCCNT - last_dwt_value);
|
||||
_this->cyfral_decoder.process_front(get_rfid_in_level(), DWT->CYCCNT - last_dwt_value);
|
||||
|
||||
_this->metakom_decoder.process_front(
|
||||
(HAL_COMP_GetOutputLevel(_hcomp) == COMP_OUTPUT_LEVEL_HIGH),
|
||||
DWT->CYCCNT - last_dwt_value);
|
||||
_this->metakom_decoder.process_front(get_rfid_in_level(), DWT->CYCCNT - last_dwt_value);
|
||||
|
||||
last_dwt_value = DWT->CYCCNT;
|
||||
}
|
||||
|
@@ -51,10 +51,12 @@ static void render_callback(Canvas* canvas, void* ctx) {
|
||||
static void input_callback(InputEvent* input_event, void* ctx) {
|
||||
osMessageQueueId_t event_queue = ctx;
|
||||
|
||||
if(input_event->type != InputTypeShort) return;
|
||||
|
||||
AppEvent event;
|
||||
event.type = EventTypeKey;
|
||||
event.value.input = *input_event;
|
||||
osMessageQueuePut(event_queue, &event, 0, 0);
|
||||
osMessageQueuePut(event_queue, &event, 1, osWaitForever);
|
||||
}
|
||||
|
||||
extern TIM_HandleTypeDef TIM_C;
|
||||
@@ -244,7 +246,7 @@ static void extract_data(uint8_t* buf, uint8_t* customer, uint32_t* em_data) {
|
||||
}
|
||||
|
||||
int32_t lf_rfid_workaround(void* p) {
|
||||
osMessageQueueId_t event_queue = osMessageQueueNew(2, sizeof(AppEvent), NULL);
|
||||
osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(AppEvent), NULL);
|
||||
|
||||
// create pin
|
||||
GpioPin pull_pin = {.pin = RFID_PULL_Pin, .port = RFID_PULL_GPIO_Port};
|
||||
@@ -337,41 +339,27 @@ int32_t lf_rfid_workaround(void* p) {
|
||||
if(event_status == osOK) {
|
||||
if(event.type == EventTypeKey) {
|
||||
// press events
|
||||
if(event.value.input.type == InputTypePress &&
|
||||
event.value.input.key == InputKeyBack) {
|
||||
hal_pwmn_stop(&TIM_C, TIM_CHANNEL_1); // TODO: move to furiac_onexit
|
||||
api_interrupt_remove(
|
||||
comparator_trigger_callback, InterruptTypeComparatorTrigger);
|
||||
gpio_init(pull_pin_record, GpioModeInput);
|
||||
gpio_init((GpioPin*)&ibutton_gpio, GpioModeInput);
|
||||
|
||||
// TODO remove all view_ports create by app
|
||||
view_port_enabled_set(view_port, false);
|
||||
return 255;
|
||||
if(event.value.input.key == InputKeyBack) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(event.value.input.type == InputTypePress &&
|
||||
event.value.input.key == InputKeyUp) {
|
||||
if(event.value.input.key == InputKeyUp) {
|
||||
state->dirty_freq = true;
|
||||
state->freq_khz += 10;
|
||||
}
|
||||
|
||||
if(event.value.input.type == InputTypePress &&
|
||||
event.value.input.key == InputKeyDown) {
|
||||
if(event.value.input.key == InputKeyDown) {
|
||||
state->dirty_freq = true;
|
||||
state->freq_khz -= 10;
|
||||
}
|
||||
|
||||
if(event.value.input.type == InputTypePress &&
|
||||
event.value.input.key == InputKeyLeft) {
|
||||
if(event.value.input.key == InputKeyLeft) {
|
||||
}
|
||||
|
||||
if(event.value.input.type == InputTypePress &&
|
||||
event.value.input.key == InputKeyRight) {
|
||||
if(event.value.input.key == InputKeyRight) {
|
||||
}
|
||||
|
||||
if(event.value.input.type == InputTypePress &&
|
||||
event.value.input.key == InputKeyOk) {
|
||||
if(event.value.input.key == InputKeyOk) {
|
||||
state->dirty = true;
|
||||
state->on = !state->on;
|
||||
}
|
||||
@@ -412,5 +400,22 @@ int32_t lf_rfid_workaround(void* p) {
|
||||
}
|
||||
}
|
||||
|
||||
hal_pwmn_stop(&TIM_C, TIM_CHANNEL_1); // TODO: move to furiac_onexit
|
||||
api_interrupt_remove(comparator_trigger_callback, InterruptTypeComparatorTrigger);
|
||||
|
||||
gpio_init(pull_pin_record, GpioModeInput);
|
||||
gpio_init((GpioPin*)&ibutton_gpio, GpioModeInput);
|
||||
|
||||
// TODO remove all view_ports create by app
|
||||
view_port_enabled_set(view_port, false);
|
||||
gui_remove_view_port(gui, view_port);
|
||||
view_port_free(view_port);
|
||||
|
||||
HAL_COMP_Stop(&hcomp1);
|
||||
|
||||
vStreamBufferDelete(comp_ctx.stream_buffer);
|
||||
|
||||
osMessageQueueDelete(event_queue);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user