Merge remote-tracking branch 'upstream/dev' into nfcf

This commit is contained in:
nullableVoidPtr
2023-05-07 21:25:03 +08:00
168 changed files with 3731 additions and 2119 deletions

View File

@@ -1,5 +1,5 @@
entry,status,name,type,params
Version,+,23.1,,
Version,+,26.1,,
Header,+,applications/services/bt/bt_service/bt.h,,
Header,+,applications/services/cli/cli.h,,
Header,+,applications/services/cli/cli_vcp.h,,
@@ -47,6 +47,7 @@ Header,+,firmware/targets/f7/furi_hal/furi_hal_idle_timer.h,,
Header,+,firmware/targets/f7/furi_hal/furi_hal_interrupt.h,,
Header,+,firmware/targets/f7/furi_hal/furi_hal_nfc.h,,
Header,+,firmware/targets/f7/furi_hal/furi_hal_os.h,,
Header,-,firmware/targets/f7/furi_hal/furi_hal_power_calibration.h,,
Header,+,firmware/targets/f7/furi_hal/furi_hal_pwm.h,,
Header,+,firmware/targets/f7/furi_hal/furi_hal_resources.h,,
Header,+,firmware/targets/f7/furi_hal/furi_hal_rfid.h,,
@@ -117,6 +118,7 @@ Header,+,lib/flipper_application/plugins/composite_resolver.h,,
Header,+,lib/flipper_application/plugins/plugin_manager.h,,
Header,+,lib/flipper_format/flipper_format.h,,
Header,+,lib/flipper_format/flipper_format_i.h,,
Header,+,lib/flipper_format/flipper_format_stream.h,,
Header,+,lib/ibutton/ibutton_key.h,,
Header,+,lib/ibutton/ibutton_protocols.h,,
Header,+,lib/ibutton/ibutton_worker.h,,
@@ -231,8 +233,8 @@ Function,-,LL_EXTI_StructInit,void,LL_EXTI_InitTypeDef*
Function,-,LL_GPIO_DeInit,ErrorStatus,GPIO_TypeDef*
Function,+,LL_GPIO_Init,ErrorStatus,"GPIO_TypeDef*, LL_GPIO_InitTypeDef*"
Function,-,LL_GPIO_StructInit,void,LL_GPIO_InitTypeDef*
Function,-,LL_I2C_DeInit,ErrorStatus,const I2C_TypeDef*
Function,+,LL_I2C_Init,ErrorStatus,"I2C_TypeDef*, const LL_I2C_InitTypeDef*"
Function,-,LL_I2C_DeInit,ErrorStatus,I2C_TypeDef*
Function,+,LL_I2C_Init,ErrorStatus,"I2C_TypeDef*, LL_I2C_InitTypeDef*"
Function,-,LL_I2C_StructInit,void,LL_I2C_InitTypeDef*
Function,-,LL_Init1msTick,void,uint32_t
Function,+,LL_LPTIM_DeInit,ErrorStatus,LPTIM_TypeDef*
@@ -935,6 +937,11 @@ Function,+,flipper_format_read_uint32,_Bool,"FlipperFormat*, const char*, uint32
Function,+,flipper_format_rewind,_Bool,FlipperFormat*
Function,+,flipper_format_seek_to_end,_Bool,FlipperFormat*
Function,+,flipper_format_set_strict_mode,void,"FlipperFormat*, _Bool"
Function,+,flipper_format_stream_delete_key_and_write,_Bool,"Stream*, FlipperStreamWriteData*, _Bool"
Function,+,flipper_format_stream_get_value_count,_Bool,"Stream*, const char*, uint32_t*, _Bool"
Function,+,flipper_format_stream_read_value_line,_Bool,"Stream*, const char*, FlipperStreamValue, void*, size_t, _Bool"
Function,+,flipper_format_stream_write_comment_cstr,_Bool,"Stream*, const char*"
Function,+,flipper_format_stream_write_value_line,_Bool,"Stream*, FlipperStreamWriteData*"
Function,+,flipper_format_string_alloc,FlipperFormat*,
Function,+,flipper_format_update_bool,_Bool,"FlipperFormat*, const char*, const _Bool*, const uint16_t"
Function,+,flipper_format_update_float,_Bool,"FlipperFormat*, const char*, const float*, const uint16_t"
@@ -1084,6 +1091,8 @@ Function,+,furi_hal_console_puts,void,const char*
Function,+,furi_hal_console_set_tx_callback,void,"FuriHalConsoleTxCallback, void*"
Function,+,furi_hal_console_tx,void,"const uint8_t*, size_t"
Function,+,furi_hal_console_tx_with_new_line,void,"const uint8_t*, size_t"
Function,+,furi_hal_cortex_comp_enable,void,"FuriHalCortexComp, FuriHalCortexCompFunction, uint32_t, uint32_t, FuriHalCortexCompSize"
Function,+,furi_hal_cortex_comp_reset,void,FuriHalCortexComp
Function,+,furi_hal_cortex_delay_us,void,uint32_t
Function,-,furi_hal_cortex_init_early,void,
Function,+,furi_hal_cortex_instructions_per_microsecond,uint32_t,
@@ -1165,6 +1174,7 @@ Function,+,furi_hal_ibutton_pin_configure,void,
Function,+,furi_hal_ibutton_pin_reset,void,
Function,+,furi_hal_ibutton_pin_write,void,const _Bool
Function,+,furi_hal_info_get,void,"PropertyValueCallback, char, void*"
Function,+,furi_hal_info_get_api_version,void,"uint16_t*, uint16_t*"
Function,+,furi_hal_infrared_async_rx_set_capture_isr_callback,void,"FuriHalInfraredRxCaptureCallback, void*"
Function,+,furi_hal_infrared_async_rx_set_timeout,void,uint32_t
Function,+,furi_hal_infrared_async_rx_set_timeout_isr_callback,void,"FuriHalInfraredRxTimeoutCallback, void*"
@@ -1572,7 +1582,7 @@ Function,+,furi_thread_set_priority,void,"FuriThread*, FuriThreadPriority"
Function,+,furi_thread_set_stack_size,void,"FuriThread*, size_t"
Function,+,furi_thread_set_state_callback,void,"FuriThread*, FuriThreadStateCallback"
Function,+,furi_thread_set_state_context,void,"FuriThread*, void*"
Function,+,furi_thread_set_stdout_callback,_Bool,FuriThreadStdoutWriteCallback
Function,+,furi_thread_set_stdout_callback,void,FuriThreadStdoutWriteCallback
Function,+,furi_thread_start,void,FuriThread*
Function,+,furi_thread_stdout_flush,int32_t,
Function,+,furi_thread_stdout_write,size_t,"const char*, size_t"
@@ -1581,6 +1591,7 @@ Function,+,furi_thread_yield,void,
Function,+,furi_timer_alloc,FuriTimer*,"FuriTimerCallback, FuriTimerType, void*"
Function,+,furi_timer_free,void,FuriTimer*
Function,+,furi_timer_is_running,uint32_t,FuriTimer*
Function,+,furi_timer_pending_callback,void,"FuriTimerPendigCallback, void*, uint32_t"
Function,+,furi_timer_start,FuriStatus,"FuriTimer*, uint32_t"
Function,+,furi_timer_stop,FuriStatus,FuriTimer*
Function,-,fwrite,size_t,"const void*, size_t, size_t, FILE*"
@@ -1805,12 +1816,11 @@ Function,-,llround,long long int,double
Function,-,llroundf,long long int,float
Function,-,llroundl,long long int,long double
Function,+,loader_get_pubsub,FuriPubSub*,Loader*
Function,+,loader_is_locked,_Bool,const Loader*
Function,+,loader_is_locked,_Bool,Loader*
Function,+,loader_lock,_Bool,Loader*
Function,+,loader_show_menu,void,
Function,+,loader_show_menu,void,Loader*
Function,+,loader_start,LoaderStatus,"Loader*, const char*, const char*"
Function,+,loader_unlock,void,Loader*
Function,+,loader_update_menu,void,
Function,+,loading_alloc,Loading*,
Function,+,loading_free,void,Loading*
Function,+,loading_get_view,View*,Loading*
1 entry status name type params
2 Version + 23.1 26.1
3 Header + applications/services/bt/bt_service/bt.h
4 Header + applications/services/cli/cli.h
5 Header + applications/services/cli/cli_vcp.h
47 Header + firmware/targets/f7/furi_hal/furi_hal_interrupt.h
48 Header + firmware/targets/f7/furi_hal/furi_hal_nfc.h
49 Header + firmware/targets/f7/furi_hal/furi_hal_os.h
50 Header - firmware/targets/f7/furi_hal/furi_hal_power_calibration.h
51 Header + firmware/targets/f7/furi_hal/furi_hal_pwm.h
52 Header + firmware/targets/f7/furi_hal/furi_hal_resources.h
53 Header + firmware/targets/f7/furi_hal/furi_hal_rfid.h
118 Header + lib/flipper_application/plugins/plugin_manager.h
119 Header + lib/flipper_format/flipper_format.h
120 Header + lib/flipper_format/flipper_format_i.h
121 Header + lib/flipper_format/flipper_format_stream.h
122 Header + lib/ibutton/ibutton_key.h
123 Header + lib/ibutton/ibutton_protocols.h
124 Header + lib/ibutton/ibutton_worker.h
233 Function - LL_GPIO_DeInit ErrorStatus GPIO_TypeDef*
234 Function + LL_GPIO_Init ErrorStatus GPIO_TypeDef*, LL_GPIO_InitTypeDef*
235 Function - LL_GPIO_StructInit void LL_GPIO_InitTypeDef*
236 Function - LL_I2C_DeInit ErrorStatus const I2C_TypeDef* I2C_TypeDef*
237 Function + LL_I2C_Init ErrorStatus I2C_TypeDef*, const LL_I2C_InitTypeDef* I2C_TypeDef*, LL_I2C_InitTypeDef*
238 Function - LL_I2C_StructInit void LL_I2C_InitTypeDef*
239 Function - LL_Init1msTick void uint32_t
240 Function + LL_LPTIM_DeInit ErrorStatus LPTIM_TypeDef*
937 Function + flipper_format_rewind _Bool FlipperFormat*
938 Function + flipper_format_seek_to_end _Bool FlipperFormat*
939 Function + flipper_format_set_strict_mode void FlipperFormat*, _Bool
940 Function + flipper_format_stream_delete_key_and_write _Bool Stream*, FlipperStreamWriteData*, _Bool
941 Function + flipper_format_stream_get_value_count _Bool Stream*, const char*, uint32_t*, _Bool
942 Function + flipper_format_stream_read_value_line _Bool Stream*, const char*, FlipperStreamValue, void*, size_t, _Bool
943 Function + flipper_format_stream_write_comment_cstr _Bool Stream*, const char*
944 Function + flipper_format_stream_write_value_line _Bool Stream*, FlipperStreamWriteData*
945 Function + flipper_format_string_alloc FlipperFormat*
946 Function + flipper_format_update_bool _Bool FlipperFormat*, const char*, const _Bool*, const uint16_t
947 Function + flipper_format_update_float _Bool FlipperFormat*, const char*, const float*, const uint16_t
1091 Function + furi_hal_console_set_tx_callback void FuriHalConsoleTxCallback, void*
1092 Function + furi_hal_console_tx void const uint8_t*, size_t
1093 Function + furi_hal_console_tx_with_new_line void const uint8_t*, size_t
1094 Function + furi_hal_cortex_comp_enable void FuriHalCortexComp, FuriHalCortexCompFunction, uint32_t, uint32_t, FuriHalCortexCompSize
1095 Function + furi_hal_cortex_comp_reset void FuriHalCortexComp
1096 Function + furi_hal_cortex_delay_us void uint32_t
1097 Function - furi_hal_cortex_init_early void
1098 Function + furi_hal_cortex_instructions_per_microsecond uint32_t
1174 Function + furi_hal_ibutton_pin_reset void
1175 Function + furi_hal_ibutton_pin_write void const _Bool
1176 Function + furi_hal_info_get void PropertyValueCallback, char, void*
1177 Function + furi_hal_info_get_api_version void uint16_t*, uint16_t*
1178 Function + furi_hal_infrared_async_rx_set_capture_isr_callback void FuriHalInfraredRxCaptureCallback, void*
1179 Function + furi_hal_infrared_async_rx_set_timeout void uint32_t
1180 Function + furi_hal_infrared_async_rx_set_timeout_isr_callback void FuriHalInfraredRxTimeoutCallback, void*
1582 Function + furi_thread_set_stack_size void FuriThread*, size_t
1583 Function + furi_thread_set_state_callback void FuriThread*, FuriThreadStateCallback
1584 Function + furi_thread_set_state_context void FuriThread*, void*
1585 Function + furi_thread_set_stdout_callback _Bool void FuriThreadStdoutWriteCallback
1586 Function + furi_thread_start void FuriThread*
1587 Function + furi_thread_stdout_flush int32_t
1588 Function + furi_thread_stdout_write size_t const char*, size_t
1591 Function + furi_timer_alloc FuriTimer* FuriTimerCallback, FuriTimerType, void*
1592 Function + furi_timer_free void FuriTimer*
1593 Function + furi_timer_is_running uint32_t FuriTimer*
1594 Function + furi_timer_pending_callback void FuriTimerPendigCallback, void*, uint32_t
1595 Function + furi_timer_start FuriStatus FuriTimer*, uint32_t
1596 Function + furi_timer_stop FuriStatus FuriTimer*
1597 Function - fwrite size_t const void*, size_t, size_t, FILE*
1816 Function - llroundf long long int float
1817 Function - llroundl long long int long double
1818 Function + loader_get_pubsub FuriPubSub* Loader*
1819 Function + loader_is_locked _Bool const Loader* Loader*
1820 Function + loader_lock _Bool Loader*
1821 Function + loader_show_menu void Loader*
1822 Function + loader_start LoaderStatus Loader*, const char*, const char*
1823 Function + loader_unlock void Loader*
Function + loader_update_menu void
1824 Function + loading_alloc Loading*
1825 Function + loading_free void Loading*
1826 Function + loading_get_view View* Loading*

View File

@@ -18,8 +18,8 @@ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static TL_CmdPacket_t ble_app_cmd_buffer;
PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint32_t ble_app_nvm[BLE_NVM_SRAM_SIZE];
_Static_assert(
sizeof(SHCI_C2_Ble_Init_Cmd_Packet_t) == 58,
"Ble stack config structure size mismatch (check new config options - last updated for v.1.16.0)");
sizeof(SHCI_C2_Ble_Init_Cmd_Packet_t) == 57,
"Ble stack config structure size mismatch (check new config options - last updated for v.1.15.0)");
typedef struct {
FuriMutex* hci_mtx;
@@ -88,7 +88,7 @@ bool ble_app_init() {
.min_tx_power = 0,
.max_tx_power = 0,
.rx_model_config = 1,
/* New stack (13.3->16.0)*/
/* New stack (13.3->15.0) */
.max_adv_set_nbr = 1, // Only used if SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV is set
.max_adv_data_len = 31, // Only used if SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV is set
.tx_path_compens = 0, // RF TX Path Compensation, * 0.1 dB

View File

@@ -84,9 +84,7 @@ void furi_hal_bt_init() {
}
// Explicitly tell that we are in charge of CLK48 domain
if(!LL_HSEM_IsSemaphoreLocked(HSEM, CFG_HW_CLK48_CONFIG_SEMID)) {
furi_check(LL_HSEM_1StepLock(HSEM, CFG_HW_CLK48_CONFIG_SEMID) == 0);
}
furi_check(LL_HSEM_1StepLock(HSEM, CFG_HW_CLK48_CONFIG_SEMID) == 0);
// Start Core2
ble_glue_init();
@@ -129,9 +127,7 @@ bool furi_hal_bt_start_radio_stack() {
furi_mutex_acquire(furi_hal_bt_core2_mtx, FuriWaitForever);
// Explicitly tell that we are in charge of CLK48 domain
if(!LL_HSEM_IsSemaphoreLocked(HSEM, CFG_HW_CLK48_CONFIG_SEMID)) {
furi_check(LL_HSEM_1StepLock(HSEM, CFG_HW_CLK48_CONFIG_SEMID) == 0);
}
furi_check(LL_HSEM_1StepLock(HSEM, CFG_HW_CLK48_CONFIG_SEMID) == 0);
do {
// Wait until C2 is started or timeout

View File

@@ -144,6 +144,7 @@ void furi_hal_clock_init() {
LL_RCC_SetRNGClockSource(LL_RCC_RNG_CLKSOURCE_CLK48);
LL_RCC_SetUSBClockSource(LL_RCC_USB_CLKSOURCE_PLLSAI1);
LL_RCC_SetCLK48ClockSource(LL_RCC_CLK48_CLKSOURCE_PLLSAI1);
LL_RCC_HSI_EnableInStopMode(); // Ensure that MR is capable of work in STOP0
LL_RCC_SetSMPSClockSource(LL_RCC_SMPS_CLKSOURCE_HSE);
LL_RCC_SetSMPSPrescaler(LL_RCC_SMPS_DIV_1);
LL_RCC_SetRFWKPClockSource(LL_RCC_RFWKP_CLKSOURCE_LSE);
@@ -207,13 +208,17 @@ void furi_hal_clock_switch_to_hsi() {
while(!LL_RCC_HSI_IsReady())
;
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI);
LL_RCC_SetSMPSClockSource(LL_RCC_SMPS_CLKSOURCE_HSI);
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI);
while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSI)
;
LL_FLASH_SetLatency(LL_FLASH_LATENCY_1);
LL_C2_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
LL_FLASH_SetLatency(LL_FLASH_LATENCY_0);
while(LL_FLASH_GetLatency() != LL_FLASH_LATENCY_0)
;
}
void furi_hal_clock_switch_to_pll() {
@@ -228,7 +233,11 @@ void furi_hal_clock_switch_to_pll() {
while(!LL_RCC_PLLSAI1_IsReady())
;
LL_C2_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_2);
LL_FLASH_SetLatency(LL_FLASH_LATENCY_3);
while(LL_FLASH_GetLatency() != LL_FLASH_LATENCY_3)
;
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL);
LL_RCC_SetSMPSClockSource(LL_RCC_SMPS_CLKSOURCE_HSE);

View File

@@ -1,11 +1,12 @@
#include <furi_hal_cortex.h>
#include <furi.h>
#include <stm32wbxx.h>
#define FURI_HAL_CORTEX_INSTRUCTIONS_PER_MICROSECOND (SystemCoreClock / 1000000)
void furi_hal_cortex_init_early() {
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
CoreDebug->DEMCR |= (CoreDebug_DEMCR_TRCENA_Msk | CoreDebug_DEMCR_MON_EN_Msk);
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
DWT->CYCCNT = 0U;
@@ -38,4 +39,71 @@ bool furi_hal_cortex_timer_is_expired(FuriHalCortexTimer cortex_timer) {
void furi_hal_cortex_timer_wait(FuriHalCortexTimer cortex_timer) {
while(!furi_hal_cortex_timer_is_expired(cortex_timer))
;
}
}
// Duck ST
#undef COMP0
#undef COMP1
#undef COMP2
#undef COMP3
void furi_hal_cortex_comp_enable(
FuriHalCortexComp comp,
FuriHalCortexCompFunction function,
uint32_t value,
uint32_t mask,
FuriHalCortexCompSize size) {
uint32_t function_reg = (uint32_t)function | ((uint32_t)size << 10);
switch(comp) {
case FuriHalCortexComp0:
(DWT->COMP0) = value;
(DWT->MASK0) = mask;
(DWT->FUNCTION0) = function_reg;
break;
case FuriHalCortexComp1:
(DWT->COMP1) = value;
(DWT->MASK1) = mask;
(DWT->FUNCTION1) = function_reg;
break;
case FuriHalCortexComp2:
(DWT->COMP2) = value;
(DWT->MASK2) = mask;
(DWT->FUNCTION2) = function_reg;
break;
case FuriHalCortexComp3:
(DWT->COMP3) = value;
(DWT->MASK3) = mask;
(DWT->FUNCTION3) = function_reg;
break;
default:
furi_crash("Invalid parameter");
}
}
void furi_hal_cortex_comp_reset(FuriHalCortexComp comp) {
switch(comp) {
case FuriHalCortexComp0:
(DWT->COMP0) = 0;
(DWT->MASK0) = 0;
(DWT->FUNCTION0) = 0;
break;
case FuriHalCortexComp1:
(DWT->COMP1) = 0;
(DWT->MASK1) = 0;
(DWT->FUNCTION1) = 0;
break;
case FuriHalCortexComp2:
(DWT->COMP2) = 0;
(DWT->MASK2) = 0;
(DWT->FUNCTION2) = 0;
break;
case FuriHalCortexComp3:
(DWT->COMP3) = 0;
(DWT->MASK3) = 0;
(DWT->FUNCTION3) = 0;
break;
default:
furi_crash("Invalid parameter");
}
}

View File

@@ -1,6 +1,7 @@
#include <furi_hal_flash.h>
#include <furi_hal_bt.h>
#include <furi_hal_power.h>
#include <furi_hal_cortex.h>
#include <furi.h>
#include <ble/ble.h>
#include <interface/patterns/ble_thread/shci/shci.h>
@@ -26,6 +27,16 @@
#define FURI_HAL_FLASH_OPT_KEY2 0x4C5D6E7F
#define FURI_HAL_FLASH_OB_TOTAL_WORDS (0x80 / (sizeof(uint32_t) * 2))
/* lib/STM32CubeWB/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_RfWithFlash/Core/Src/flash_driver.c
* ProcessSingleFlashOperation, quote:
> In most BLE application, the flash should not be blocked by the CPU2 longer than FLASH_TIMEOUT_VALUE (1000ms)
> However, it could be that for some marginal application, this time is longer.
> ... there is no other way than waiting the operation to be completed.
> If for any reason this test is never passed, this means there is a failure in the system and there is no other
> way to recover than applying a device reset.
*/
#define FURI_HAL_FLASH_C2_LOCK_TIMEOUT_MS 3000u /* 3 seconds */
#define IS_ADDR_ALIGNED_64BITS(__VALUE__) (((__VALUE__)&0x7U) == (0x00UL))
#define IS_FLASH_PROGRAM_ADDRESS(__VALUE__) \
(((__VALUE__) >= FLASH_BASE) && ((__VALUE__) <= (FLASH_BASE + FLASH_SIZE - 8UL)) && \
@@ -131,9 +142,11 @@ static void furi_hal_flash_begin_with_core2(bool erase_flag) {
for(volatile uint32_t i = 0; i < 35; i++)
;
FuriHalCortexTimer timer = furi_hal_cortex_timer_get(FURI_HAL_FLASH_C2_LOCK_TIMEOUT_MS * 1000);
while(true) {
/* Wait till flash controller become usable */
while(LL_FLASH_IsActiveFlag_OperationSuspended()) {
furi_check(!furi_hal_cortex_timer_is_expired(timer));
furi_thread_yield();
};
@@ -143,6 +156,7 @@ static void furi_hal_flash_begin_with_core2(bool erase_flag) {
/* Actually we already have mutex for it, but specification is specification */
if(LL_HSEM_IsSemaphoreLocked(HSEM, CFG_HW_BLOCK_FLASH_REQ_BY_CPU1_SEMID)) {
taskEXIT_CRITICAL();
furi_check(!furi_hal_cortex_timer_is_expired(timer));
furi_thread_yield();
continue;
}
@@ -150,6 +164,7 @@ static void furi_hal_flash_begin_with_core2(bool erase_flag) {
/* Take sempahopre and prevent core2 from anything funky */
if(LL_HSEM_1StepLock(HSEM, CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID) != 0) {
taskEXIT_CRITICAL();
furi_check(!furi_hal_cortex_timer_is_expired(timer));
furi_thread_yield();
continue;
}
@@ -231,17 +246,13 @@ static void furi_hal_flush_cache(void) {
bool furi_hal_flash_wait_last_operation(uint32_t timeout) {
uint32_t error = 0;
uint32_t countdown = 0;
/* Wait for the FLASH operation to complete by polling on BUSY flag to be reset.
Even if the FLASH operation fails, the BUSY flag will be reset and an error
flag will be set */
countdown = timeout;
FuriHalCortexTimer timer = furi_hal_cortex_timer_get(timeout * 1000);
while(READ_BIT(FLASH->SR, FLASH_SR_BSY)) {
if(LL_SYSTICK_IsActiveCounterFlag()) {
countdown--;
}
if(countdown == 0) {
if(furi_hal_cortex_timer_is_expired(timer)) {
return false;
}
}
@@ -264,12 +275,9 @@ bool furi_hal_flash_wait_last_operation(uint32_t timeout) {
CLEAR_BIT(FLASH->SR, error);
/* Wait for control register to be written */
countdown = timeout;
timer = furi_hal_cortex_timer_get(timeout * 1000);
while(READ_BIT(FLASH->SR, FLASH_SR_CFGBSY)) {
if(LL_SYSTICK_IsActiveCounterFlag()) {
countdown--;
}
if(countdown == 0) {
if(furi_hal_cortex_timer_is_expired(timer)) {
return false;
}
}

View File

@@ -8,6 +8,11 @@
#include <furi.h>
#include <protobuf_version.h>
FURI_WEAK void furi_hal_info_get_api_version(uint16_t* major, uint16_t* minor) {
*major = 0;
*minor = 0;
}
void furi_hal_info_get(PropertyValueCallback out, char sep, void* context) {
FuriString* key = furi_string_alloc();
FuriString* value = furi_string_alloc();
@@ -18,10 +23,10 @@ void furi_hal_info_get(PropertyValueCallback out, char sep, void* context) {
// Device Info version
if(sep == '.') {
property_value_out(&property_context, NULL, 2, "format", "major", "3");
property_value_out(&property_context, NULL, 2, "format", "minor", "0");
property_value_out(&property_context, NULL, 2, "format", "minor", "1");
} else {
property_value_out(&property_context, NULL, 3, "device", "info", "major", "2");
property_value_out(&property_context, NULL, 3, "device", "info", "minor", "0");
property_value_out(&property_context, NULL, 3, "device", "info", "minor", "1");
}
// Model name
@@ -161,6 +166,13 @@ void furi_hal_info_get(PropertyValueCallback out, char sep, void* context) {
version_get_builddate(firmware_version));
property_value_out(
&property_context, "%d", 2, "firmware", "target", version_get_target(firmware_version));
uint16_t api_version_major, api_version_minor;
furi_hal_info_get_api_version(&api_version_major, &api_version_minor);
property_value_out(
&property_context, "%d", 3, "firmware", "api", "major", api_version_major);
property_value_out(
&property_context, "%d", 3, "firmware", "api", "minor", api_version_minor);
}
if(furi_hal_bt_is_alive()) {

View File

@@ -29,10 +29,6 @@
#define FURI_HAL_POWER_DEBUG_STOP_GPIO (&gpio_ext_pc3)
#endif
#ifndef FURI_HAL_POWER_DEBUG_ABNORMAL_GPIO
#define FURI_HAL_POWER_DEBUG_ABNORMAL_GPIO (&gpio_ext_pb3)
#endif
#ifndef FURI_HAL_POWER_STOP_MODE
#define FURI_HAL_POWER_STOP_MODE (LL_PWR_MODE_STOP2)
#endif
@@ -50,56 +46,19 @@ static volatile FuriHalPower furi_hal_power = {
.suppress_charge = 0,
};
const ParamCEDV cedv = {
.cedv_conf.gauge_conf =
{
.CCT = 1,
.CSYNC = 0,
.EDV_CMP = 0,
.SC = 1,
.FIXED_EDV0 = 1,
.FCC_LIM = 1,
.FC_FOR_VDQ = 1,
.IGNORE_SD = 1,
.SME0 = 0,
},
.full_charge_cap = 2101,
.design_cap = 2101,
.EDV0 = 3300,
.EDV1 = 3321,
.EDV2 = 3355,
.EMF = 3679,
.C0 = 430,
.C1 = 0,
.R1 = 408,
.R0 = 334,
.T0 = 4626,
.TC = 11,
.DOD0 = 4044,
.DOD10 = 3905,
.DOD20 = 3807,
.DOD30 = 3718,
.DOD40 = 3642,
.DOD50 = 3585,
.DOD60 = 3546,
.DOD70 = 3514,
.DOD80 = 3477,
.DOD90 = 3411,
.DOD100 = 3299,
};
#include <furi_hal_power_calibration.h>
void furi_hal_power_init() {
#ifdef FURI_HAL_POWER_DEBUG
furi_hal_gpio_init_simple(FURI_HAL_POWER_DEBUG_WFI_GPIO, GpioModeOutputPushPull);
furi_hal_gpio_init_simple(FURI_HAL_POWER_DEBUG_STOP_GPIO, GpioModeOutputPushPull);
furi_hal_gpio_init_simple(FURI_HAL_POWER_DEBUG_ABNORMAL_GPIO, GpioModeOutputPushPull);
furi_hal_gpio_write(FURI_HAL_POWER_DEBUG_WFI_GPIO, 0);
furi_hal_gpio_write(FURI_HAL_POWER_DEBUG_STOP_GPIO, 0);
furi_hal_gpio_write(FURI_HAL_POWER_DEBUG_ABNORMAL_GPIO, 0);
#endif
LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1);
LL_PWR_SMPS_SetMode(LL_PWR_SMPS_STEP_DOWN);
LL_PWR_SetPowerMode(FURI_HAL_POWER_STOP_MODE);
LL_C2_PWR_SetPowerMode(FURI_HAL_POWER_STOP_MODE);
@@ -158,9 +117,7 @@ bool furi_hal_power_sleep_available() {
static inline bool furi_hal_power_deep_sleep_available() {
return furi_hal_bt_is_alive() && !furi_hal_rtc_is_flag_set(FuriHalRtcFlagLegacySleep) &&
!furi_hal_debug_is_gdb_session_active() && !LL_PWR_IsActiveFlag_CRPE() &&
!LL_PWR_IsActiveFlag_CRP() && !LL_PWR_IsActiveFlag_BLEA() &&
!LL_PWR_IsActiveFlag_BLEWU();
!furi_hal_debug_is_gdb_session_active();
}
static inline void furi_hal_power_light_sleep() {
@@ -211,16 +168,7 @@ static inline void furi_hal_power_deep_sleep() {
__force_stores();
#endif
bool should_abort_sleep = LL_PWR_IsActiveFlag_CRPE() || LL_PWR_IsActiveFlag_CRP() ||
LL_PWR_IsActiveFlag_BLEA() || LL_PWR_IsActiveFlag_BLEWU();
if(should_abort_sleep) {
#ifdef FURI_HAL_POWER_DEBUG
furi_hal_gpio_write(FURI_HAL_POWER_DEBUG_ABNORMAL_GPIO, 1);
#endif
} else {
__WFI();
}
__WFI();
LL_LPM_EnableSleep();

View File

@@ -0,0 +1,37 @@
const ParamCEDV cedv = {
.cedv_conf.gauge_conf =
{
.CCT = 1,
.CSYNC = 0,
.EDV_CMP = 0,
.SC = 1,
.FIXED_EDV0 = 1,
.FCC_LIM = 1,
.FC_FOR_VDQ = 1,
.IGNORE_SD = 1,
.SME0 = 0,
},
.full_charge_cap = 2101,
.design_cap = 2101,
.EDV0 = 3300,
.EDV1 = 3321,
.EDV2 = 3355,
.EMF = 3679,
.C0 = 430,
.C1 = 0,
.R1 = 408,
.R0 = 334,
.T0 = 4626,
.TC = 11,
.DOD0 = 4044,
.DOD10 = 3905,
.DOD20 = 3807,
.DOD30 = 3718,
.DOD40 = 3642,
.DOD50 = 3585,
.DOD60 = 3546,
.DOD70 = 3514,
.DOD80 = 3477,
.DOD90 = 3411,
.DOD100 = 3299,
};