mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Merge branch 'dev' into datetime-module
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,v,86.1,,
|
||||
Version,+,87.0,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
|
||||
Header,+,applications/services/cli/cli.h,,
|
||||
@@ -174,6 +174,7 @@ Header,+,lib/toolbox/protocols/protocol_dict.h,,
|
||||
Header,+,lib/toolbox/pulse_protocols/pulse_glue.h,,
|
||||
Header,+,lib/toolbox/saved_struct.h,,
|
||||
Header,+,lib/toolbox/simple_array.h,,
|
||||
Header,+,lib/toolbox/str_buffer.h,,
|
||||
Header,+,lib/toolbox/stream/buffered_file_stream.h,,
|
||||
Header,+,lib/toolbox/stream/file_stream.h,,
|
||||
Header,+,lib/toolbox/stream/stream.h,,
|
||||
@@ -704,6 +705,7 @@ Function,+,bt_forget_bonded_devices,void,Bt*
|
||||
Function,+,bt_keys_storage_alloc,BtKeysStorage*,const char*
|
||||
Function,+,bt_keys_storage_delete,_Bool,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_free,void,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_get_root_keys,const GapRootSecurityKeys*,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_is_changed,_Bool,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_load,_Bool,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_set_default_path,void,Bt*
|
||||
@@ -1179,7 +1181,7 @@ Function,+,furi_hal_adc_convert_vref,float,"FuriHalAdcHandle*, uint16_t"
|
||||
Function,+,furi_hal_adc_init,void,
|
||||
Function,+,furi_hal_adc_read,uint16_t,"FuriHalAdcHandle*, FuriHalAdcChannel"
|
||||
Function,+,furi_hal_adc_release,void,FuriHalAdcHandle*
|
||||
Function,+,furi_hal_bt_change_app,FuriHalBleProfileBase*,"const FuriHalBleProfileTemplate*, FuriHalBleProfileParams, GapEventCallback, void*"
|
||||
Function,+,furi_hal_bt_change_app,FuriHalBleProfileBase*,"const FuriHalBleProfileTemplate*, FuriHalBleProfileParams, const GapRootSecurityKeys*, GapEventCallback, void*"
|
||||
Function,+,furi_hal_bt_check_profile_type,_Bool,"FuriHalBleProfileBase*, const FuriHalBleProfileTemplate*"
|
||||
Function,+,furi_hal_bt_clear_white_list,_Bool,
|
||||
Function,+,furi_hal_bt_dump_state,void,FuriString*
|
||||
@@ -1206,7 +1208,7 @@ Function,+,furi_hal_bt_nvm_sram_sem_release,void,
|
||||
Function,+,furi_hal_bt_reinit,void,
|
||||
Function,+,furi_hal_bt_set_key_storage_change_callback,void,"BleGlueKeyStorageChangedCallback, void*"
|
||||
Function,+,furi_hal_bt_start_advertising,void,
|
||||
Function,+,furi_hal_bt_start_app,FuriHalBleProfileBase*,"const FuriHalBleProfileTemplate*, FuriHalBleProfileParams, GapEventCallback, void*"
|
||||
Function,+,furi_hal_bt_start_app,FuriHalBleProfileBase*,"const FuriHalBleProfileTemplate*, FuriHalBleProfileParams, const GapRootSecurityKeys*, GapEventCallback, void*"
|
||||
Function,+,furi_hal_bt_start_packet_rx,void,"uint8_t, uint8_t"
|
||||
Function,+,furi_hal_bt_start_packet_tx,void,"uint8_t, uint8_t, uint8_t"
|
||||
Function,+,furi_hal_bt_start_radio_stack,_Bool,
|
||||
@@ -1746,7 +1748,7 @@ Function,-,gap_extra_beacon_set_data,_Bool,"const uint8_t*, uint8_t"
|
||||
Function,-,gap_extra_beacon_start,_Bool,
|
||||
Function,-,gap_extra_beacon_stop,_Bool,
|
||||
Function,-,gap_get_state,GapState,
|
||||
Function,-,gap_init,_Bool,"GapConfig*, GapEventCallback, void*"
|
||||
Function,-,gap_init,_Bool,"GapConfig*, const GapRootSecurityKeys*, GapEventCallback, void*"
|
||||
Function,-,gap_start_advertising,void,
|
||||
Function,-,gap_stop_advertising,void,
|
||||
Function,-,gap_thread_stop,void,
|
||||
@@ -2637,6 +2639,8 @@ Function,+,storage_simply_remove,_Bool,"Storage*, const char*"
|
||||
Function,+,storage_simply_remove_recursive,_Bool,"Storage*, const char*"
|
||||
Function,-,stpcpy,char*,"char*, const char*"
|
||||
Function,-,stpncpy,char*,"char*, const char*, size_t"
|
||||
Function,+,str_buffer_clear_all_clones,void,StrBuffer*
|
||||
Function,+,str_buffer_make_owned_clone,const char*,"StrBuffer*, const char*"
|
||||
Function,+,strcasecmp,int,"const char*, const char*"
|
||||
Function,-,strcasecmp_l,int,"const char*, const char*, locale_t"
|
||||
Function,+,strcasestr,char*,"const char*, const char*"
|
||||
|
||||
|
@@ -246,6 +246,7 @@ Header,+,lib/toolbox/protocols/protocol_dict.h,,
|
||||
Header,+,lib/toolbox/pulse_protocols/pulse_glue.h,,
|
||||
Header,+,lib/toolbox/saved_struct.h,,
|
||||
Header,+,lib/toolbox/simple_array.h,,
|
||||
Header,+,lib/toolbox/str_buffer.h,,
|
||||
Header,+,lib/toolbox/stream/buffered_file_stream.h,,
|
||||
Header,+,lib/toolbox/stream/file_stream.h,,
|
||||
Header,+,lib/toolbox/stream/stream.h,,
|
||||
@@ -781,6 +782,7 @@ Function,+,bt_forget_bonded_devices,void,Bt*
|
||||
Function,+,bt_keys_storage_alloc,BtKeysStorage*,const char*
|
||||
Function,+,bt_keys_storage_delete,_Bool,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_free,void,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_get_root_keys,const GapRootSecurityKeys*,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_is_changed,_Bool,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_load,_Bool,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_set_default_path,void,Bt*
|
||||
@@ -1291,7 +1293,7 @@ Function,+,furi_hal_adc_convert_vref,float,"FuriHalAdcHandle*, uint16_t"
|
||||
Function,+,furi_hal_adc_init,void,
|
||||
Function,+,furi_hal_adc_read,uint16_t,"FuriHalAdcHandle*, FuriHalAdcChannel"
|
||||
Function,+,furi_hal_adc_release,void,FuriHalAdcHandle*
|
||||
Function,+,furi_hal_bt_change_app,FuriHalBleProfileBase*,"const FuriHalBleProfileTemplate*, FuriHalBleProfileParams, GapEventCallback, void*"
|
||||
Function,+,furi_hal_bt_change_app,FuriHalBleProfileBase*,"const FuriHalBleProfileTemplate*, FuriHalBleProfileParams, const GapRootSecurityKeys*, GapEventCallback, void*"
|
||||
Function,+,furi_hal_bt_check_profile_type,_Bool,"FuriHalBleProfileBase*, const FuriHalBleProfileTemplate*"
|
||||
Function,+,furi_hal_bt_clear_white_list,_Bool,
|
||||
Function,+,furi_hal_bt_dump_state,void,FuriString*
|
||||
@@ -1318,7 +1320,7 @@ Function,+,furi_hal_bt_nvm_sram_sem_release,void,
|
||||
Function,+,furi_hal_bt_reinit,void,
|
||||
Function,+,furi_hal_bt_set_key_storage_change_callback,void,"BleGlueKeyStorageChangedCallback, void*"
|
||||
Function,+,furi_hal_bt_start_advertising,void,
|
||||
Function,+,furi_hal_bt_start_app,FuriHalBleProfileBase*,"const FuriHalBleProfileTemplate*, FuriHalBleProfileParams, GapEventCallback, void*"
|
||||
Function,+,furi_hal_bt_start_app,FuriHalBleProfileBase*,"const FuriHalBleProfileTemplate*, FuriHalBleProfileParams, const GapRootSecurityKeys*, GapEventCallback, void*"
|
||||
Function,+,furi_hal_bt_start_packet_rx,void,"uint8_t, uint8_t"
|
||||
Function,+,furi_hal_bt_start_packet_tx,void,"uint8_t, uint8_t, uint8_t"
|
||||
Function,+,furi_hal_bt_start_radio_stack,_Bool,
|
||||
@@ -1967,7 +1969,7 @@ Function,-,gap_extra_beacon_set_data,_Bool,"const uint8_t*, uint8_t"
|
||||
Function,-,gap_extra_beacon_start,_Bool,
|
||||
Function,-,gap_extra_beacon_stop,_Bool,
|
||||
Function,-,gap_get_state,GapState,
|
||||
Function,-,gap_init,_Bool,"GapConfig*, GapEventCallback, void*"
|
||||
Function,-,gap_init,_Bool,"GapConfig*, const GapRootSecurityKeys*, GapEventCallback, void*"
|
||||
Function,-,gap_start_advertising,void,
|
||||
Function,-,gap_stop_advertising,void,
|
||||
Function,-,gap_thread_stop,void,
|
||||
@@ -2865,6 +2867,8 @@ Function,+,nfc_device_set_data,void,"NfcDevice*, NfcProtocol, const NfcDeviceDat
|
||||
Function,+,nfc_device_set_loading_callback,void,"NfcDevice*, NfcLoadingCallback, void*"
|
||||
Function,+,nfc_device_set_uid,_Bool,"NfcDevice*, const uint8_t*, size_t"
|
||||
Function,+,nfc_felica_listener_set_sensf_res_data,NfcError,"Nfc*, const uint8_t*, const uint8_t, const uint8_t*, const uint8_t, const uint16_t"
|
||||
Function,+,nfc_felica_listener_timer_anticol_start,void,"Nfc*, uint8_t"
|
||||
Function,+,nfc_felica_listener_timer_anticol_stop,void,Nfc*
|
||||
Function,+,nfc_free,void,Nfc*
|
||||
Function,+,nfc_iso14443a_listener_set_col_res_data,NfcError,"Nfc*, uint8_t*, uint8_t, uint8_t*, uint8_t"
|
||||
Function,+,nfc_iso14443a_listener_tx_custom_parity,NfcError,"Nfc*, const BitBuffer*"
|
||||
@@ -3325,6 +3329,8 @@ Function,+,storage_simply_remove,_Bool,"Storage*, const char*"
|
||||
Function,+,storage_simply_remove_recursive,_Bool,"Storage*, const char*"
|
||||
Function,-,stpcpy,char*,"char*, const char*"
|
||||
Function,-,stpncpy,char*,"char*, const char*, size_t"
|
||||
Function,+,str_buffer_clear_all_clones,void,StrBuffer*
|
||||
Function,+,str_buffer_make_owned_clone,const char*,"StrBuffer*, const char*"
|
||||
Function,+,strcasecmp,int,"const char*, const char*"
|
||||
Function,-,strcasecmp_l,int,"const char*, const char*, locale_t"
|
||||
Function,+,strcasestr,char*,"const char*, const char*"
|
||||
|
||||
|
@@ -51,13 +51,6 @@ typedef enum {
|
||||
GapCommandKillThread,
|
||||
} GapCommand;
|
||||
|
||||
// Identity root key
|
||||
static const uint8_t gap_irk[16] =
|
||||
{0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0};
|
||||
// Encryption root key
|
||||
static const uint8_t gap_erk[16] =
|
||||
{0xfe, 0xdc, 0xba, 0x09, 0x87, 0x65, 0x43, 0x21, 0xfe, 0xdc, 0xba, 0x09, 0x87, 0x65, 0x43, 0x21};
|
||||
|
||||
static Gap* gap = NULL;
|
||||
|
||||
static void gap_advertise_start(GapState new_state);
|
||||
@@ -333,7 +326,9 @@ static void set_manufacturer_data(uint8_t* mfg_data, uint8_t mfg_data_len) {
|
||||
gap->service.mfg_data_len += mfg_data_len;
|
||||
}
|
||||
|
||||
static void gap_init_svc(Gap* gap) {
|
||||
static void gap_init_svc(Gap* gap, const GapRootSecurityKeys* root_keys) {
|
||||
furi_check(root_keys);
|
||||
|
||||
tBleStatus status;
|
||||
uint32_t srd_bd_addr[2];
|
||||
|
||||
@@ -351,9 +346,9 @@ static void gap_init_svc(Gap* gap) {
|
||||
aci_hal_write_config_data(
|
||||
CONFIG_DATA_RANDOM_ADDRESS_OFFSET, CONFIG_DATA_RANDOM_ADDRESS_LEN, (uint8_t*)srd_bd_addr);
|
||||
// Set Identity root key used to derive LTK and CSRK
|
||||
aci_hal_write_config_data(CONFIG_DATA_IR_OFFSET, CONFIG_DATA_IR_LEN, (uint8_t*)gap_irk);
|
||||
aci_hal_write_config_data(CONFIG_DATA_IR_OFFSET, CONFIG_DATA_IR_LEN, root_keys->irk);
|
||||
// Set Encryption root key used to derive LTK and CSRK
|
||||
aci_hal_write_config_data(CONFIG_DATA_ER_OFFSET, CONFIG_DATA_ER_LEN, (uint8_t*)gap_erk);
|
||||
aci_hal_write_config_data(CONFIG_DATA_ER_OFFSET, CONFIG_DATA_ER_LEN, root_keys->erk);
|
||||
// Set TX Power to 0 dBm
|
||||
aci_hal_set_tx_power_level(1, 0x19);
|
||||
// Initialize GATT interface
|
||||
@@ -535,7 +530,11 @@ static void gap_advetise_timer_callback(void* context) {
|
||||
furi_check(furi_message_queue_put(gap->command_queue, &command, 0) == FuriStatusOk);
|
||||
}
|
||||
|
||||
bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context) {
|
||||
bool gap_init(
|
||||
GapConfig* config,
|
||||
const GapRootSecurityKeys* root_keys,
|
||||
GapEventCallback on_event_cb,
|
||||
void* context) {
|
||||
if(!ble_glue_is_radio_stack_ready()) {
|
||||
return false;
|
||||
}
|
||||
@@ -548,7 +547,7 @@ bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context) {
|
||||
gap->advertise_timer = furi_timer_alloc(gap_advetise_timer_callback, FuriTimerTypeOnce, NULL);
|
||||
// Initialization of GATT & GAP layer
|
||||
gap->service.adv_name = config->adv_name;
|
||||
gap_init_svc(gap);
|
||||
gap_init_svc(gap, root_keys);
|
||||
ble_event_dispatcher_init();
|
||||
// Initialization of the GAP state
|
||||
gap->state_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
@@ -573,14 +572,13 @@ bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context) {
|
||||
set_manufacturer_data(gap->config->mfg_data, gap->config->mfg_data_len);
|
||||
}
|
||||
|
||||
gap->service.adv_svc_uuid_len = 1;
|
||||
if(gap->config->adv_service.UUID_Type == UUID_TYPE_16) {
|
||||
uint8_t adv_service_uid[2];
|
||||
gap->service.adv_svc_uuid_len = 1;
|
||||
adv_service_uid[0] = gap->config->adv_service.Service_UUID_16 & 0xff;
|
||||
adv_service_uid[1] = gap->config->adv_service.Service_UUID_16 >> 8;
|
||||
set_advertisment_service_uid(adv_service_uid, sizeof(adv_service_uid));
|
||||
} else if(gap->config->adv_service.UUID_Type == UUID_TYPE_128) {
|
||||
gap->service.adv_svc_uuid_len = 1;
|
||||
set_advertisment_service_uid(
|
||||
gap->config->adv_service.Service_UUID_128,
|
||||
sizeof(gap->config->adv_service.Service_UUID_128));
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <furi_hal_version.h>
|
||||
|
||||
#define GAP_MAC_ADDR_SIZE (6)
|
||||
#define GAP_KEY_SIZE (0x10)
|
||||
|
||||
/*
|
||||
* GAP helpers - background thread that handles BLE GAP events and advertising.
|
||||
@@ -83,7 +84,18 @@ typedef struct {
|
||||
GapConnectionParamsRequest conn_param;
|
||||
} GapConfig;
|
||||
|
||||
bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context);
|
||||
typedef struct {
|
||||
// Encryption Root key. Must be unique per-device (or app)
|
||||
uint8_t erk[GAP_KEY_SIZE];
|
||||
// Identity Root key. Used for resolving RPAs, if configured
|
||||
uint8_t irk[GAP_KEY_SIZE];
|
||||
} GapRootSecurityKeys;
|
||||
|
||||
bool gap_init(
|
||||
GapConfig* config,
|
||||
const GapRootSecurityKeys* root_keys,
|
||||
GapEventCallback on_event_cb,
|
||||
void* context);
|
||||
|
||||
void gap_start_advertising(void);
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@ static FuriHalBt furi_hal_bt = {
|
||||
.stack = FuriHalBtStackUnknown,
|
||||
};
|
||||
|
||||
static FuriHalBleProfileBase* current_profile = NULL;
|
||||
static GapConfig current_config = {0};
|
||||
|
||||
void furi_hal_bt_init(void) {
|
||||
FURI_LOG_I(TAG, "Start BT initialization");
|
||||
furi_hal_bus_enable(FuriHalBusHSEM);
|
||||
@@ -149,9 +152,6 @@ bool furi_hal_bt_is_testing_supported(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static FuriHalBleProfileBase* current_profile = NULL;
|
||||
static GapConfig current_config = {0};
|
||||
|
||||
bool furi_hal_bt_check_profile_type(
|
||||
FuriHalBleProfileBase* profile,
|
||||
const FuriHalBleProfileTemplate* profile_template) {
|
||||
@@ -165,10 +165,12 @@ bool furi_hal_bt_check_profile_type(
|
||||
FuriHalBleProfileBase* furi_hal_bt_start_app(
|
||||
const FuriHalBleProfileTemplate* profile_template,
|
||||
FuriHalBleProfileParams params,
|
||||
const GapRootSecurityKeys* root_keys,
|
||||
GapEventCallback event_cb,
|
||||
void* context) {
|
||||
furi_check(event_cb);
|
||||
furi_check(profile_template);
|
||||
furi_check(root_keys);
|
||||
furi_check(current_profile == NULL);
|
||||
|
||||
do {
|
||||
@@ -183,7 +185,7 @@ FuriHalBleProfileBase* furi_hal_bt_start_app(
|
||||
|
||||
profile_template->get_gap_config(¤t_config, params);
|
||||
|
||||
if(!gap_init(¤t_config, event_cb, context)) {
|
||||
if(!gap_init(¤t_config, root_keys, event_cb, context)) {
|
||||
gap_thread_stop();
|
||||
FURI_LOG_E(TAG, "Failed to init GAP");
|
||||
break;
|
||||
@@ -239,12 +241,11 @@ void furi_hal_bt_reinit(void) {
|
||||
FuriHalBleProfileBase* furi_hal_bt_change_app(
|
||||
const FuriHalBleProfileTemplate* profile_template,
|
||||
FuriHalBleProfileParams profile_params,
|
||||
const GapRootSecurityKeys* root_keys,
|
||||
GapEventCallback event_cb,
|
||||
void* context) {
|
||||
furi_check(event_cb);
|
||||
|
||||
furi_hal_bt_reinit();
|
||||
return furi_hal_bt_start_app(profile_template, profile_params, event_cb, context);
|
||||
return furi_hal_bt_start_app(profile_template, profile_params, root_keys, event_cb, context);
|
||||
}
|
||||
|
||||
bool furi_hal_bt_is_active(void) {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "furi_hal_nfc_i.h"
|
||||
#include "furi_hal_nfc_tech_i.h"
|
||||
|
||||
// Prevent FDT timer from starting
|
||||
#define FURI_HAL_NFC_FELICA_LISTENER_FDT_COMP_FC (INT32_MAX)
|
||||
#define FURI_HAL_NFC_FELICA_LISTENER_FDT_COMP_FC (0)
|
||||
|
||||
#define FURI_HAL_FELICA_COMMUNICATION_PERFORMANCE (0x0083U)
|
||||
#define FURI_HAL_FELICA_RESPONSE_CODE (0x01)
|
||||
|
||||
@@ -817,6 +817,21 @@ static void furi_hal_serial_async_rx_configure(
|
||||
FuriHalSerialHandle* handle,
|
||||
FuriHalSerialAsyncRxCallback callback,
|
||||
void* context) {
|
||||
// Disable RXFNE interrupts before unsetting the user callback that reads data
|
||||
// Otherwise interrupt runs without reading data and without clearing RXFNE flag
|
||||
// This would cause a system hang as the same interrupt runs in loop forever
|
||||
if(!callback) {
|
||||
if(handle->id == FuriHalSerialIdUsart) {
|
||||
LL_USART_DisableIT_RXNE_RXFNE(USART1);
|
||||
furi_hal_interrupt_set_isr(FuriHalInterruptIdUart1, NULL, NULL);
|
||||
furi_hal_serial_usart_deinit_dma_rx();
|
||||
} else if(handle->id == FuriHalSerialIdLpuart) {
|
||||
LL_LPUART_DisableIT_RXNE_RXFNE(LPUART1);
|
||||
furi_hal_interrupt_set_isr(FuriHalInterruptIdLpUart1, NULL, NULL);
|
||||
furi_hal_serial_lpuart_deinit_dma_rx();
|
||||
}
|
||||
}
|
||||
|
||||
// Handle must be configured before enabling RX interrupt
|
||||
// as it might be triggered right away on a misconfigured handle
|
||||
furi_hal_serial[handle->id].rx_byte_callback = callback;
|
||||
@@ -824,27 +839,17 @@ static void furi_hal_serial_async_rx_configure(
|
||||
furi_hal_serial[handle->id].rx_dma_callback = NULL;
|
||||
furi_hal_serial[handle->id].context = context;
|
||||
|
||||
if(handle->id == FuriHalSerialIdUsart) {
|
||||
if(callback) {
|
||||
if(callback) {
|
||||
if(handle->id == FuriHalSerialIdUsart) {
|
||||
furi_hal_serial_usart_deinit_dma_rx();
|
||||
furi_hal_interrupt_set_isr(
|
||||
FuriHalInterruptIdUart1, furi_hal_serial_usart_irq_callback, NULL);
|
||||
LL_USART_EnableIT_RXNE_RXFNE(USART1);
|
||||
} else {
|
||||
furi_hal_interrupt_set_isr(FuriHalInterruptIdUart1, NULL, NULL);
|
||||
furi_hal_serial_usart_deinit_dma_rx();
|
||||
LL_USART_DisableIT_RXNE_RXFNE(USART1);
|
||||
}
|
||||
} else if(handle->id == FuriHalSerialIdLpuart) {
|
||||
if(callback) {
|
||||
} else if(handle->id == FuriHalSerialIdLpuart) {
|
||||
furi_hal_serial_lpuart_deinit_dma_rx();
|
||||
furi_hal_interrupt_set_isr(
|
||||
FuriHalInterruptIdLpUart1, furi_hal_serial_lpuart_irq_callback, NULL);
|
||||
LL_LPUART_EnableIT_RXNE_RXFNE(LPUART1);
|
||||
} else {
|
||||
furi_hal_interrupt_set_isr(FuriHalInterruptIdLpUart1, NULL, NULL);
|
||||
furi_hal_serial_lpuart_deinit_dma_rx();
|
||||
LL_LPUART_DisableIT_RXNE_RXFNE(LPUART1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -944,33 +949,39 @@ static void furi_hal_serial_dma_configure(
|
||||
FuriHalSerialHandle* handle,
|
||||
FuriHalSerialDmaRxCallback callback,
|
||||
void* context) {
|
||||
furi_check(handle);
|
||||
|
||||
if(handle->id == FuriHalSerialIdUsart) {
|
||||
if(callback) {
|
||||
furi_hal_serial_usart_init_dma_rx();
|
||||
furi_hal_interrupt_set_isr(
|
||||
FuriHalInterruptIdUart1, furi_hal_serial_usart_irq_callback, NULL);
|
||||
} else {
|
||||
// Disable RXFNE interrupts before unsetting the user callback that reads data
|
||||
// Otherwise interrupt runs without reading data and without clearing RXFNE flag
|
||||
// This would cause a system hang as the same interrupt runs in loop forever
|
||||
if(!callback) {
|
||||
if(handle->id == FuriHalSerialIdUsart) {
|
||||
LL_USART_DisableIT_RXNE_RXFNE(USART1);
|
||||
furi_hal_interrupt_set_isr(FuriHalInterruptIdUart1, NULL, NULL);
|
||||
furi_hal_serial_usart_deinit_dma_rx();
|
||||
}
|
||||
} else if(handle->id == FuriHalSerialIdLpuart) {
|
||||
if(callback) {
|
||||
furi_hal_serial_lpuart_init_dma_rx();
|
||||
furi_hal_interrupt_set_isr(
|
||||
FuriHalInterruptIdLpUart1, furi_hal_serial_lpuart_irq_callback, NULL);
|
||||
} else {
|
||||
} else if(handle->id == FuriHalSerialIdLpuart) {
|
||||
LL_LPUART_DisableIT_RXNE_RXFNE(LPUART1);
|
||||
furi_hal_interrupt_set_isr(FuriHalInterruptIdLpUart1, NULL, NULL);
|
||||
furi_hal_serial_lpuart_deinit_dma_rx();
|
||||
}
|
||||
}
|
||||
|
||||
// Handle must be configured before enabling RX interrupt
|
||||
// as it might be triggered right away on a misconfigured handle
|
||||
furi_hal_serial[handle->id].rx_byte_callback = NULL;
|
||||
furi_hal_serial[handle->id].handle = handle;
|
||||
furi_hal_serial[handle->id].rx_dma_callback = callback;
|
||||
furi_hal_serial[handle->id].context = context;
|
||||
|
||||
if(callback) {
|
||||
if(handle->id == FuriHalSerialIdUsart) {
|
||||
furi_hal_serial_usart_init_dma_rx();
|
||||
furi_hal_interrupt_set_isr(
|
||||
FuriHalInterruptIdUart1, furi_hal_serial_usart_irq_callback, NULL);
|
||||
} else if(handle->id == FuriHalSerialIdLpuart) {
|
||||
furi_hal_serial_lpuart_init_dma_rx();
|
||||
furi_hal_interrupt_set_isr(
|
||||
FuriHalInterruptIdLpUart1, furi_hal_serial_lpuart_irq_callback, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_serial_dma_rx_start(
|
||||
|
||||
@@ -68,7 +68,7 @@ void SystemInit(void) {
|
||||
RCC->PLLSAI1CFGR = 0x22041000U;
|
||||
#endif
|
||||
// Reset HSEBYP bit
|
||||
RCC->CR &= 0xFFFBFFFFU;
|
||||
RCC->CR &= 0xFFFBFFFFU; //-V784
|
||||
// Disable all RCC related interrupts
|
||||
RCC->CIER = 0x00000000;
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ bool furi_hal_bt_check_profile_type(
|
||||
*
|
||||
* @param profile_template FuriHalBleProfileTemplate instance
|
||||
* @param params Parameters to pass to the profile. Can be NULL
|
||||
* @param root_keys pointer to root keys
|
||||
* @param event_cb GapEventCallback instance
|
||||
* @param context pointer to context
|
||||
*
|
||||
@@ -85,6 +86,7 @@ bool furi_hal_bt_check_profile_type(
|
||||
FURI_WARN_UNUSED FuriHalBleProfileBase* furi_hal_bt_start_app(
|
||||
const FuriHalBleProfileTemplate* profile_template,
|
||||
FuriHalBleProfileParams params,
|
||||
const GapRootSecurityKeys* root_keys,
|
||||
GapEventCallback event_cb,
|
||||
void* context);
|
||||
|
||||
@@ -100,6 +102,7 @@ void furi_hal_bt_reinit(void);
|
||||
* @param profile_template FuriHalBleProfileTemplate instance
|
||||
* @param profile_params Parameters to pass to the profile. Can be NULL
|
||||
* @param event_cb GapEventCallback instance
|
||||
* @param root_keys pointer to root keys
|
||||
* @param context pointer to context
|
||||
*
|
||||
* @return instance of profile, NULL on failure
|
||||
@@ -107,6 +110,7 @@ void furi_hal_bt_reinit(void);
|
||||
FURI_WARN_UNUSED FuriHalBleProfileBase* furi_hal_bt_change_app(
|
||||
const FuriHalBleProfileTemplate* profile_template,
|
||||
FuriHalBleProfileParams profile_params,
|
||||
const GapRootSecurityKeys* root_keys,
|
||||
GapEventCallback event_cb,
|
||||
void* context);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user