mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Api Symbols: replace asserts with checks (#3507)
* Api Symbols: replace asserts with checks * Api Symbols: replace asserts with checks part 2 * Update no args function signatures with void, to help compiler to track incorrect usage * More unavoidable void * Update PVS config and code to make it happy * Format sources * nfc: fix checks * dead code cleanup & include fixes Co-authored-by: gornekich <n.gorbadey@gmail.com> Co-authored-by: hedger <hedger@users.noreply.github.com> Co-authored-by: hedger <hedger@nanode.su>
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
#define TAG "FuriHal"
|
||||
|
||||
void furi_hal_init_early() {
|
||||
void furi_hal_init_early(void) {
|
||||
furi_hal_cortex_init_early();
|
||||
furi_hal_clock_init_early();
|
||||
furi_hal_bus_init_early();
|
||||
@@ -19,7 +19,7 @@ void furi_hal_init_early() {
|
||||
furi_hal_rtc_init_early();
|
||||
}
|
||||
|
||||
void furi_hal_deinit_early() {
|
||||
void furi_hal_deinit_early(void) {
|
||||
furi_hal_rtc_deinit_early();
|
||||
furi_hal_i2c_deinit_early();
|
||||
furi_hal_spi_config_deinit_early();
|
||||
@@ -29,7 +29,7 @@ void furi_hal_deinit_early() {
|
||||
furi_hal_clock_deinit_early();
|
||||
}
|
||||
|
||||
void furi_hal_init() {
|
||||
void furi_hal_init(void) {
|
||||
furi_hal_mpu_init();
|
||||
furi_hal_clock_init();
|
||||
furi_hal_random_init();
|
||||
|
||||
@@ -37,7 +37,7 @@ static FuriHalBt furi_hal_bt = {
|
||||
.stack = FuriHalBtStackUnknown,
|
||||
};
|
||||
|
||||
void furi_hal_bt_init() {
|
||||
void furi_hal_bt_init(void) {
|
||||
FURI_LOG_I(TAG, "Start BT initialization");
|
||||
furi_hal_bus_enable(FuriHalBusHSEM);
|
||||
furi_hal_bus_enable(FuriHalBusIPCC);
|
||||
@@ -47,7 +47,7 @@ void furi_hal_bt_init() {
|
||||
|
||||
if(!furi_hal_bt.core2_mtx) {
|
||||
furi_hal_bt.core2_mtx = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
furi_assert(furi_hal_bt.core2_mtx);
|
||||
furi_check(furi_hal_bt.core2_mtx);
|
||||
}
|
||||
|
||||
// Explicitly tell that we are in charge of CLK48 domain
|
||||
@@ -57,13 +57,13 @@ void furi_hal_bt_init() {
|
||||
ble_glue_init();
|
||||
}
|
||||
|
||||
void furi_hal_bt_lock_core2() {
|
||||
furi_assert(furi_hal_bt.core2_mtx);
|
||||
void furi_hal_bt_lock_core2(void) {
|
||||
furi_check(furi_hal_bt.core2_mtx);
|
||||
furi_check(furi_mutex_acquire(furi_hal_bt.core2_mtx, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void furi_hal_bt_unlock_core2() {
|
||||
furi_assert(furi_hal_bt.core2_mtx);
|
||||
void furi_hal_bt_unlock_core2(void) {
|
||||
furi_check(furi_hal_bt.core2_mtx);
|
||||
furi_check(furi_mutex_release(furi_hal_bt.core2_mtx) == FuriStatusOk);
|
||||
}
|
||||
|
||||
@@ -87,9 +87,9 @@ static bool furi_hal_bt_radio_stack_is_supported(const BleGlueC2Info* info) {
|
||||
return supported;
|
||||
}
|
||||
|
||||
bool furi_hal_bt_start_radio_stack() {
|
||||
bool furi_hal_bt_start_radio_stack(void) {
|
||||
bool res = false;
|
||||
furi_assert(furi_hal_bt.core2_mtx);
|
||||
furi_check(furi_hal_bt.core2_mtx);
|
||||
|
||||
furi_mutex_acquire(furi_hal_bt.core2_mtx, FuriWaitForever);
|
||||
|
||||
@@ -130,11 +130,11 @@ bool furi_hal_bt_start_radio_stack() {
|
||||
return res;
|
||||
}
|
||||
|
||||
FuriHalBtStack furi_hal_bt_get_radio_stack() {
|
||||
FuriHalBtStack furi_hal_bt_get_radio_stack(void) {
|
||||
return furi_hal_bt.stack;
|
||||
}
|
||||
|
||||
bool furi_hal_bt_is_gatt_gap_supported() {
|
||||
bool furi_hal_bt_is_gatt_gap_supported(void) {
|
||||
if(furi_hal_bt.stack == FuriHalBtStackLight || furi_hal_bt.stack == FuriHalBtStackFull) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -142,7 +142,7 @@ bool furi_hal_bt_is_gatt_gap_supported() {
|
||||
}
|
||||
}
|
||||
|
||||
bool furi_hal_bt_is_testing_supported() {
|
||||
bool furi_hal_bt_is_testing_supported(void) {
|
||||
if(furi_hal_bt.stack == FuriHalBtStackFull) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -168,7 +168,7 @@ FuriHalBleProfileBase* furi_hal_bt_start_app(
|
||||
FuriHalBleProfileParams params,
|
||||
GapEventCallback event_cb,
|
||||
void* context) {
|
||||
furi_assert(event_cb);
|
||||
furi_check(event_cb);
|
||||
furi_check(profile_template);
|
||||
furi_check(current_profile == NULL);
|
||||
|
||||
@@ -198,7 +198,7 @@ FuriHalBleProfileBase* furi_hal_bt_start_app(
|
||||
return current_profile;
|
||||
}
|
||||
|
||||
void furi_hal_bt_reinit() {
|
||||
void furi_hal_bt_reinit(void) {
|
||||
furi_hal_power_insomnia_enter();
|
||||
FURI_LOG_I(TAG, "Disconnect and stop advertising");
|
||||
furi_hal_bt_stop_advertising();
|
||||
@@ -239,23 +239,23 @@ FuriHalBleProfileBase* furi_hal_bt_change_app(
|
||||
FuriHalBleProfileParams profile_params,
|
||||
GapEventCallback event_cb,
|
||||
void* context) {
|
||||
furi_assert(event_cb);
|
||||
furi_check(event_cb);
|
||||
|
||||
furi_hal_bt_reinit();
|
||||
return furi_hal_bt_start_app(profile_template, profile_params, event_cb, context);
|
||||
}
|
||||
|
||||
bool furi_hal_bt_is_active() {
|
||||
bool furi_hal_bt_is_active(void) {
|
||||
return gap_get_state() > GapStateIdle;
|
||||
}
|
||||
|
||||
void furi_hal_bt_start_advertising() {
|
||||
void furi_hal_bt_start_advertising(void) {
|
||||
if(gap_get_state() == GapStateIdle) {
|
||||
gap_start_advertising();
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_bt_stop_advertising() {
|
||||
void furi_hal_bt_stop_advertising(void) {
|
||||
if(furi_hal_bt_is_active()) {
|
||||
gap_stop_advertising();
|
||||
while(furi_hal_bt_is_active()) {
|
||||
@@ -279,21 +279,21 @@ void furi_hal_bt_get_key_storage_buff(uint8_t** key_buff_addr, uint16_t* key_buf
|
||||
void furi_hal_bt_set_key_storage_change_callback(
|
||||
BleGlueKeyStorageChangedCallback callback,
|
||||
void* context) {
|
||||
furi_assert(callback);
|
||||
furi_check(callback);
|
||||
ble_glue_set_key_storage_changed_callback(callback, context);
|
||||
}
|
||||
|
||||
void furi_hal_bt_nvm_sram_sem_acquire() {
|
||||
void furi_hal_bt_nvm_sram_sem_acquire(void) {
|
||||
while(LL_HSEM_1StepLock(HSEM, CFG_HW_BLE_NVM_SRAM_SEMID)) {
|
||||
furi_thread_yield();
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_bt_nvm_sram_sem_release() {
|
||||
void furi_hal_bt_nvm_sram_sem_release(void) {
|
||||
LL_HSEM_ReleaseLock(HSEM, CFG_HW_BLE_NVM_SRAM_SEMID, 0);
|
||||
}
|
||||
|
||||
bool furi_hal_bt_clear_white_list() {
|
||||
bool furi_hal_bt_clear_white_list(void) {
|
||||
furi_hal_bt_nvm_sram_sem_acquire();
|
||||
tBleStatus status = aci_gap_clear_security_db();
|
||||
if(status) {
|
||||
@@ -304,6 +304,8 @@ bool furi_hal_bt_clear_white_list() {
|
||||
}
|
||||
|
||||
void furi_hal_bt_dump_state(FuriString* buffer) {
|
||||
furi_check(buffer);
|
||||
|
||||
if(furi_hal_bt_is_alive()) {
|
||||
uint8_t HCI_Version;
|
||||
uint16_t HCI_Revision;
|
||||
@@ -328,7 +330,7 @@ void furi_hal_bt_dump_state(FuriString* buffer) {
|
||||
}
|
||||
}
|
||||
|
||||
bool furi_hal_bt_is_alive() {
|
||||
bool furi_hal_bt_is_alive(void) {
|
||||
return ble_glue_is_alive();
|
||||
}
|
||||
|
||||
@@ -337,7 +339,7 @@ void furi_hal_bt_start_tone_tx(uint8_t channel, uint8_t power) {
|
||||
aci_hal_tone_start(channel, 0);
|
||||
}
|
||||
|
||||
void furi_hal_bt_stop_tone_tx() {
|
||||
void furi_hal_bt_stop_tone_tx(void) {
|
||||
aci_hal_tone_stop();
|
||||
}
|
||||
|
||||
@@ -349,7 +351,7 @@ void furi_hal_bt_start_packet_rx(uint8_t channel, uint8_t datarate) {
|
||||
hci_le_enhanced_receiver_test(channel, datarate, 0);
|
||||
}
|
||||
|
||||
uint16_t furi_hal_bt_stop_packet_test() {
|
||||
uint16_t furi_hal_bt_stop_packet_test(void) {
|
||||
uint16_t num_of_packets = 0;
|
||||
hci_le_test_end(&num_of_packets);
|
||||
return num_of_packets;
|
||||
@@ -359,7 +361,7 @@ void furi_hal_bt_start_rx(uint8_t channel) {
|
||||
aci_hal_rx_start(channel);
|
||||
}
|
||||
|
||||
float furi_hal_bt_get_rssi() {
|
||||
float furi_hal_bt_get_rssi(void) {
|
||||
float val;
|
||||
uint8_t rssi_raw[3];
|
||||
|
||||
@@ -383,13 +385,13 @@ float furi_hal_bt_get_rssi() {
|
||||
return val;
|
||||
}
|
||||
|
||||
uint32_t furi_hal_bt_get_transmitted_packets() {
|
||||
uint32_t furi_hal_bt_get_transmitted_packets(void) {
|
||||
uint32_t packets = 0;
|
||||
aci_hal_le_tx_test_packet_number(&packets);
|
||||
return packets;
|
||||
}
|
||||
|
||||
void furi_hal_bt_stop_rx() {
|
||||
void furi_hal_bt_stop_rx(void) {
|
||||
aci_hal_rx_stop();
|
||||
}
|
||||
|
||||
@@ -420,18 +422,18 @@ bool furi_hal_bt_extra_beacon_set_config(const GapExtraBeaconConfig* config) {
|
||||
return gap_extra_beacon_set_config(config);
|
||||
}
|
||||
|
||||
const GapExtraBeaconConfig* furi_hal_bt_extra_beacon_get_config() {
|
||||
const GapExtraBeaconConfig* furi_hal_bt_extra_beacon_get_config(void) {
|
||||
return gap_extra_beacon_get_config();
|
||||
}
|
||||
|
||||
bool furi_hal_bt_extra_beacon_start() {
|
||||
bool furi_hal_bt_extra_beacon_start(void) {
|
||||
return gap_extra_beacon_start();
|
||||
}
|
||||
|
||||
bool furi_hal_bt_extra_beacon_stop() {
|
||||
bool furi_hal_bt_extra_beacon_stop(void) {
|
||||
return gap_extra_beacon_stop();
|
||||
}
|
||||
|
||||
bool furi_hal_bt_extra_beacon_is_active() {
|
||||
bool furi_hal_bt_extra_beacon_is_active(void) {
|
||||
return gap_extra_beacon_get_state() == GapExtraBeaconStateStarted;
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ static const uint32_t furi_hal_bus[] = {
|
||||
[FuriHalBusRF] = LL_APB3_GRP1_PERIPH_RF,
|
||||
};
|
||||
|
||||
void furi_hal_bus_init_early() {
|
||||
void furi_hal_bus_init_early(void) {
|
||||
FURI_CRITICAL_ENTER();
|
||||
|
||||
// FURI_HAL_BUS_PERIPH_DISABLE(AHB1, FURI_HAL_BUS_AHB1_GRP1, 1);
|
||||
@@ -158,7 +158,7 @@ void furi_hal_bus_init_early() {
|
||||
FURI_CRITICAL_EXIT();
|
||||
}
|
||||
|
||||
void furi_hal_bus_deinit_early() {
|
||||
void furi_hal_bus_deinit_early(void) {
|
||||
FURI_CRITICAL_ENTER();
|
||||
|
||||
// FURI_HAL_BUS_PERIPH_ENABLE(AHB1, FURI_HAL_BUS_AHB1_GRP1, 1);
|
||||
|
||||
@@ -68,10 +68,10 @@ typedef enum {
|
||||
} FuriHalBus;
|
||||
|
||||
/** Early initialization */
|
||||
void furi_hal_bus_init_early();
|
||||
void furi_hal_bus_init_early(void);
|
||||
|
||||
/** Early de-initialization */
|
||||
void furi_hal_bus_deinit_early();
|
||||
void furi_hal_bus_deinit_early(void);
|
||||
|
||||
/**
|
||||
* Enable a peripheral by turning the clocking on and deasserting the reset.
|
||||
|
||||
@@ -22,15 +22,15 @@
|
||||
#define HS_CLOCK_IS_READY() (LL_RCC_HSE_IsReady() && LL_RCC_HSI_IsReady())
|
||||
#define LS_CLOCK_IS_READY() (LL_RCC_LSE_IsReady() && LL_RCC_LSI1_IsReady())
|
||||
|
||||
void furi_hal_clock_init_early() {
|
||||
void furi_hal_clock_init_early(void) {
|
||||
LL_SetSystemCoreClock(CPU_CLOCK_EARLY_HZ);
|
||||
LL_Init1msTick(SystemCoreClock);
|
||||
}
|
||||
|
||||
void furi_hal_clock_deinit_early() {
|
||||
void furi_hal_clock_deinit_early(void) {
|
||||
}
|
||||
|
||||
void furi_hal_clock_init() {
|
||||
void furi_hal_clock_init(void) {
|
||||
/* HSE and HSI configuration and activation */
|
||||
LL_RCC_HSE_SetCapacitorTuning(0x26);
|
||||
LL_RCC_HSE_Enable();
|
||||
@@ -125,7 +125,7 @@ void furi_hal_clock_init() {
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
void furi_hal_clock_switch_hse2hsi() {
|
||||
void furi_hal_clock_switch_hse2hsi(void) {
|
||||
LL_RCC_HSI_Enable();
|
||||
|
||||
while(!LL_RCC_HSI_IsReady())
|
||||
@@ -142,7 +142,7 @@ void furi_hal_clock_switch_hse2hsi() {
|
||||
;
|
||||
}
|
||||
|
||||
void furi_hal_clock_switch_hsi2hse() {
|
||||
void furi_hal_clock_switch_hsi2hse(void) {
|
||||
#ifdef FURI_HAL_CLOCK_TRACK_STARTUP
|
||||
uint32_t clock_start_time = DWT->CYCCNT;
|
||||
#endif
|
||||
@@ -168,7 +168,7 @@ void furi_hal_clock_switch_hsi2hse() {
|
||||
#endif
|
||||
}
|
||||
|
||||
bool furi_hal_clock_switch_hse2pll() {
|
||||
bool furi_hal_clock_switch_hse2pll(void) {
|
||||
furi_assert(LL_RCC_GetSysClkSource() == LL_RCC_SYS_CLKSOURCE_STATUS_HSE);
|
||||
|
||||
LL_RCC_PLL_Enable();
|
||||
@@ -191,7 +191,7 @@ bool furi_hal_clock_switch_hse2pll() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool furi_hal_clock_switch_pll2hse() {
|
||||
bool furi_hal_clock_switch_pll2hse(void) {
|
||||
furi_assert(LL_RCC_GetSysClkSource() == LL_RCC_SYS_CLKSOURCE_STATUS_PLL);
|
||||
|
||||
LL_RCC_HSE_Enable();
|
||||
@@ -210,11 +210,11 @@ bool furi_hal_clock_switch_pll2hse() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void furi_hal_clock_suspend_tick() {
|
||||
void furi_hal_clock_suspend_tick(void) {
|
||||
CLEAR_BIT(SysTick->CTRL, SysTick_CTRL_ENABLE_Msk);
|
||||
}
|
||||
|
||||
void furi_hal_clock_resume_tick() {
|
||||
void furi_hal_clock_resume_tick(void) {
|
||||
SET_BIT(SysTick->CTRL, SysTick_CTRL_ENABLE_Msk);
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ void furi_hal_clock_mco_enable(FuriHalClockMcoSourceId source, FuriHalClockMcoDi
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_clock_mco_disable() {
|
||||
void furi_hal_clock_mco_disable(void) {
|
||||
LL_RCC_ConfigMCO(LL_RCC_MCO1SOURCE_NOCLOCK, FuriHalClockMcoDiv1);
|
||||
LL_RCC_MSI_Disable();
|
||||
while(LL_RCC_MSI_IsReady() != 0)
|
||||
|
||||
@@ -33,37 +33,37 @@ typedef enum {
|
||||
} FuriHalClockMcoDivisorId;
|
||||
|
||||
/** Early initialization */
|
||||
void furi_hal_clock_init_early();
|
||||
void furi_hal_clock_init_early(void);
|
||||
|
||||
/** Early deinitialization */
|
||||
void furi_hal_clock_deinit_early();
|
||||
void furi_hal_clock_deinit_early(void);
|
||||
|
||||
/** Initialize clocks */
|
||||
void furi_hal_clock_init();
|
||||
void furi_hal_clock_init(void);
|
||||
|
||||
/** Switch clock from HSE to HSI */
|
||||
void furi_hal_clock_switch_hse2hsi();
|
||||
void furi_hal_clock_switch_hse2hsi(void);
|
||||
|
||||
/** Switch clock from HSI to HSE */
|
||||
void furi_hal_clock_switch_hsi2hse();
|
||||
void furi_hal_clock_switch_hsi2hse(void);
|
||||
|
||||
/** Switch clock from HSE to PLL
|
||||
*
|
||||
* @return true if changed, false if failed or not possible at this moment
|
||||
*/
|
||||
bool furi_hal_clock_switch_hse2pll();
|
||||
bool furi_hal_clock_switch_hse2pll(void);
|
||||
|
||||
/** Switch clock from PLL to HSE
|
||||
*
|
||||
* @return true if changed, false if failed or not possible at this moment
|
||||
*/
|
||||
bool furi_hal_clock_switch_pll2hse();
|
||||
bool furi_hal_clock_switch_pll2hse(void);
|
||||
|
||||
/** Stop SysTick counter without resetting */
|
||||
void furi_hal_clock_suspend_tick();
|
||||
void furi_hal_clock_suspend_tick(void);
|
||||
|
||||
/** Continue SysTick counter operation */
|
||||
void furi_hal_clock_resume_tick();
|
||||
void furi_hal_clock_resume_tick(void);
|
||||
|
||||
/** Enable clock output on MCO pin
|
||||
*
|
||||
@@ -73,7 +73,7 @@ void furi_hal_clock_resume_tick();
|
||||
void furi_hal_clock_mco_enable(FuriHalClockMcoSourceId source, FuriHalClockMcoDivisorId div);
|
||||
|
||||
/** Disable clock output on MCO pin */
|
||||
void furi_hal_clock_mco_disable();
|
||||
void furi_hal_clock_mco_disable(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#define FURI_HAL_CORTEX_INSTRUCTIONS_PER_MICROSECOND (SystemCoreClock / 1000000)
|
||||
|
||||
void furi_hal_cortex_init_early() {
|
||||
void furi_hal_cortex_init_early(void) {
|
||||
CoreDebug->DEMCR |= (CoreDebug_DEMCR_TRCENA_Msk | CoreDebug_DEMCR_MON_EN_Msk);
|
||||
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
|
||||
DWT->CYCCNT = 0U;
|
||||
@@ -24,7 +24,7 @@ void furi_hal_cortex_delay_us(uint32_t microseconds) {
|
||||
};
|
||||
}
|
||||
|
||||
uint32_t furi_hal_cortex_instructions_per_microsecond() {
|
||||
uint32_t furi_hal_cortex_instructions_per_microsecond(void) {
|
||||
return FURI_HAL_CORTEX_INSTRUCTIONS_PER_MICROSECOND;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ static const uint8_t enclave_signature_expected[ENCLAVE_FACTORY_KEY_SLOTS][ENCLA
|
||||
{0xc9, 0xf7, 0x03, 0xf1, 0x6c, 0x65, 0xad, 0x49, 0x74, 0xbe, 0x00, 0x54, 0xfd, 0xa6, 0x9c, 0x32},
|
||||
};
|
||||
|
||||
void furi_hal_crypto_init() {
|
||||
void furi_hal_crypto_init(void) {
|
||||
furi_hal_crypto_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
@@ -129,8 +129,8 @@ bool furi_hal_crypto_enclave_ensure_key(uint8_t key_slot) {
|
||||
}
|
||||
|
||||
bool furi_hal_crypto_enclave_verify(uint8_t* keys_nb, uint8_t* valid_keys_nb) {
|
||||
furi_assert(keys_nb);
|
||||
furi_assert(valid_keys_nb);
|
||||
furi_check(keys_nb);
|
||||
furi_check(valid_keys_nb);
|
||||
uint8_t keys = 0;
|
||||
uint8_t keys_valid = 0;
|
||||
uint8_t buffer[ENCLAVE_SIGNATURE_SIZE];
|
||||
@@ -155,8 +155,8 @@ bool furi_hal_crypto_enclave_verify(uint8_t* keys_nb, uint8_t* valid_keys_nb) {
|
||||
}
|
||||
|
||||
bool furi_hal_crypto_enclave_store_key(FuriHalCryptoKey* key, uint8_t* slot) {
|
||||
furi_assert(key);
|
||||
furi_assert(slot);
|
||||
furi_check(key);
|
||||
furi_check(slot);
|
||||
|
||||
furi_check(furi_mutex_acquire(furi_hal_crypto_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
@@ -256,8 +256,8 @@ static bool crypto_process_block(uint32_t* in, uint32_t* out, uint8_t blk_len) {
|
||||
}
|
||||
|
||||
bool furi_hal_crypto_enclave_load_key(uint8_t slot, const uint8_t* iv) {
|
||||
furi_assert(slot > 0 && slot <= 100);
|
||||
furi_assert(furi_hal_crypto_mutex);
|
||||
furi_check(slot > 0 && slot <= 100);
|
||||
furi_check(furi_hal_crypto_mutex);
|
||||
furi_check(furi_mutex_acquire(furi_hal_crypto_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
furi_hal_bus_enable(FuriHalBusAES1);
|
||||
@@ -286,16 +286,16 @@ bool furi_hal_crypto_enclave_unload_key(uint8_t slot) {
|
||||
CLEAR_BIT(AES1->CR, AES_CR_EN);
|
||||
|
||||
SHCI_CmdStatus_t shci_state = SHCI_C2_FUS_UnloadUsrKey(slot);
|
||||
furi_assert(shci_state == SHCI_Success);
|
||||
|
||||
furi_hal_bus_disable(FuriHalBusAES1);
|
||||
|
||||
furi_check(furi_mutex_release(furi_hal_crypto_mutex) == FuriStatusOk);
|
||||
|
||||
return (shci_state == SHCI_Success);
|
||||
}
|
||||
|
||||
bool furi_hal_crypto_load_key(const uint8_t* key, const uint8_t* iv) {
|
||||
furi_assert(furi_hal_crypto_mutex);
|
||||
furi_check(furi_hal_crypto_mutex);
|
||||
furi_check(furi_mutex_acquire(furi_hal_crypto_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
furi_hal_bus_enable(FuriHalBusAES1);
|
||||
@@ -400,7 +400,7 @@ static void crypto_key_init_bswap(uint32_t* key, uint32_t* iv, uint32_t chaining
|
||||
|
||||
static bool
|
||||
furi_hal_crypto_load_key_bswap(const uint8_t* key, const uint8_t* iv, uint32_t chaining_mode) {
|
||||
furi_assert(furi_hal_crypto_mutex);
|
||||
furi_check(furi_hal_crypto_mutex);
|
||||
furi_check(furi_mutex_acquire(furi_hal_crypto_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
furi_hal_bus_enable(FuriHalBusAES1);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
volatile bool furi_hal_debug_gdb_session_active = false;
|
||||
|
||||
void furi_hal_debug_enable() {
|
||||
void furi_hal_debug_enable(void) {
|
||||
// Low power mode debug
|
||||
LL_DBGMCU_EnableDBGSleepMode();
|
||||
LL_DBGMCU_EnableDBGStopMode();
|
||||
@@ -25,7 +25,7 @@ void furi_hal_debug_enable() {
|
||||
&gpio_swclk, GpioModeAltFunctionPushPull, GpioPullDown, GpioSpeedLow, GpioAltFn0JTCK_SWCLK);
|
||||
}
|
||||
|
||||
void furi_hal_debug_disable() {
|
||||
void furi_hal_debug_disable(void) {
|
||||
// Low power mode debug
|
||||
LL_DBGMCU_DisableDBGSleepMode();
|
||||
LL_DBGMCU_DisableDBGStopMode();
|
||||
@@ -36,6 +36,6 @@ void furi_hal_debug_disable() {
|
||||
furi_hal_gpio_init_simple(&gpio_swclk, GpioModeAnalog);
|
||||
}
|
||||
|
||||
bool furi_hal_debug_is_gdb_session_active() {
|
||||
bool furi_hal_debug_is_gdb_session_active(void) {
|
||||
return furi_hal_debug_gdb_session_active;
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
#include <furi_hal_dma.h>
|
||||
#include <furi_hal_bus.h>
|
||||
|
||||
void furi_hal_dma_init_early() {
|
||||
void furi_hal_dma_init_early(void) {
|
||||
furi_hal_bus_enable(FuriHalBusDMA1);
|
||||
furi_hal_bus_enable(FuriHalBusDMA2);
|
||||
furi_hal_bus_enable(FuriHalBusDMAMUX1);
|
||||
}
|
||||
|
||||
void furi_hal_dma_deinit_early() {
|
||||
void furi_hal_dma_deinit_early(void) {
|
||||
furi_hal_bus_disable(FuriHalBusDMA1);
|
||||
furi_hal_bus_disable(FuriHalBusDMA2);
|
||||
furi_hal_bus_disable(FuriHalBusDMAMUX1);
|
||||
|
||||
@@ -5,10 +5,10 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** Early initialization */
|
||||
void furi_hal_dma_init_early();
|
||||
void furi_hal_dma_init_early(void);
|
||||
|
||||
/** Early de-initialization */
|
||||
void furi_hal_dma_deinit_early();
|
||||
void furi_hal_dma_deinit_early(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -51,37 +51,37 @@
|
||||
/* Free flash space borders, exported by linker */
|
||||
extern const void __free_flash_start__;
|
||||
|
||||
size_t furi_hal_flash_get_base() {
|
||||
size_t furi_hal_flash_get_base(void) {
|
||||
return FLASH_BASE;
|
||||
}
|
||||
|
||||
size_t furi_hal_flash_get_read_block_size() {
|
||||
size_t furi_hal_flash_get_read_block_size(void) {
|
||||
return FURI_HAL_FLASH_READ_BLOCK;
|
||||
}
|
||||
|
||||
size_t furi_hal_flash_get_write_block_size() {
|
||||
size_t furi_hal_flash_get_write_block_size(void) {
|
||||
return FURI_HAL_FLASH_WRITE_BLOCK;
|
||||
}
|
||||
|
||||
size_t furi_hal_flash_get_page_size() {
|
||||
size_t furi_hal_flash_get_page_size(void) {
|
||||
return FURI_HAL_FLASH_PAGE_SIZE;
|
||||
}
|
||||
|
||||
size_t furi_hal_flash_get_cycles_count() {
|
||||
size_t furi_hal_flash_get_cycles_count(void) {
|
||||
return FURI_HAL_FLASH_CYCLES_COUNT;
|
||||
}
|
||||
|
||||
const void* furi_hal_flash_get_free_start_address() {
|
||||
const void* furi_hal_flash_get_free_start_address(void) {
|
||||
return &__free_flash_start__;
|
||||
}
|
||||
|
||||
const void* furi_hal_flash_get_free_end_address() {
|
||||
const void* furi_hal_flash_get_free_end_address(void) {
|
||||
uint32_t sfr_reg_val = READ_REG(FLASH->SFR);
|
||||
uint32_t sfsa = (READ_BIT(sfr_reg_val, FLASH_SFR_SFSA) >> FLASH_SFR_SFSA_Pos);
|
||||
return (const void*)((sfsa * FURI_HAL_FLASH_PAGE_SIZE) + FLASH_BASE);
|
||||
}
|
||||
|
||||
size_t furi_hal_flash_get_free_page_start_address() {
|
||||
size_t furi_hal_flash_get_free_page_start_address(void) {
|
||||
size_t start = (size_t)furi_hal_flash_get_free_start_address();
|
||||
size_t page_start = start - start % FURI_HAL_FLASH_PAGE_SIZE;
|
||||
if(page_start != start) {
|
||||
@@ -90,13 +90,13 @@ size_t furi_hal_flash_get_free_page_start_address() {
|
||||
return page_start;
|
||||
}
|
||||
|
||||
size_t furi_hal_flash_get_free_page_count() {
|
||||
size_t furi_hal_flash_get_free_page_count(void) {
|
||||
size_t end = (size_t)furi_hal_flash_get_free_end_address();
|
||||
size_t page_start = (size_t)furi_hal_flash_get_free_page_start_address();
|
||||
return (end - page_start) / FURI_HAL_FLASH_PAGE_SIZE;
|
||||
}
|
||||
|
||||
void furi_hal_flash_init() {
|
||||
void furi_hal_flash_init(void) {
|
||||
/* Errata 2.2.9, Flash OPTVERR flag is always set after system reset */
|
||||
// WRITE_REG(FLASH->SR, FLASH_SR_OPTVERR);
|
||||
/* Actually, reset all error flags on start */
|
||||
@@ -106,7 +106,7 @@ void furi_hal_flash_init() {
|
||||
}
|
||||
}
|
||||
|
||||
static void furi_hal_flash_unlock() {
|
||||
static void furi_hal_flash_unlock(void) {
|
||||
/* verify Flash is locked */
|
||||
furi_check(READ_BIT(FLASH->CR, FLASH_CR_LOCK) != 0U);
|
||||
|
||||
@@ -450,7 +450,7 @@ uint32_t furi_hal_flash_ob_get_word(size_t word_idx, bool complementary) {
|
||||
return ob_data[raw_word_idx];
|
||||
}
|
||||
|
||||
void furi_hal_flash_ob_unlock() {
|
||||
void furi_hal_flash_ob_unlock(void) {
|
||||
furi_check(READ_BIT(FLASH->CR, FLASH_CR_OPTLOCK) != 0U);
|
||||
furi_hal_flash_begin(true);
|
||||
WRITE_REG(FLASH->OPTKEYR, FURI_HAL_FLASH_OPT_KEY1);
|
||||
@@ -460,7 +460,7 @@ void furi_hal_flash_ob_unlock() {
|
||||
furi_check(READ_BIT(FLASH->CR, FLASH_CR_OPTLOCK) == 0U);
|
||||
}
|
||||
|
||||
void furi_hal_flash_ob_lock() {
|
||||
void furi_hal_flash_ob_lock(void) {
|
||||
furi_check(READ_BIT(FLASH->CR, FLASH_CR_OPTLOCK) == 0U);
|
||||
SET_BIT(FLASH->CR, FLASH_CR_OPTLOCK);
|
||||
furi_hal_flash_end(true);
|
||||
@@ -511,7 +511,7 @@ static const FuriHalFlashObMapping furi_hal_flash_ob_reg_map[FURI_HAL_FLASH_OB_T
|
||||
};
|
||||
#undef OB_REG_DEF
|
||||
|
||||
void furi_hal_flash_ob_apply() {
|
||||
void furi_hal_flash_ob_apply(void) {
|
||||
furi_hal_flash_ob_unlock();
|
||||
/* OBL_LAUNCH: When set to 1, this bit forces the option byte reloading.
|
||||
* It cannot be written if OPTLOCK is set */
|
||||
@@ -558,6 +558,6 @@ bool furi_hal_flash_ob_set_word(size_t word_idx, const uint32_t value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const FuriHalFlashRawOptionByteData* furi_hal_flash_ob_get_raw_ptr() {
|
||||
const FuriHalFlashRawOptionByteData* furi_hal_flash_ob_get_raw_ptr(void) {
|
||||
return (const FuriHalFlashRawOptionByteData*)OPTION_BYTE_BASE;
|
||||
}
|
||||
|
||||
@@ -29,61 +29,61 @@ _Static_assert(
|
||||
|
||||
/** Init flash, applying necessary workarounds
|
||||
*/
|
||||
void furi_hal_flash_init();
|
||||
void furi_hal_flash_init(void);
|
||||
|
||||
/** Get flash base address
|
||||
*
|
||||
* @return pointer to flash base
|
||||
*/
|
||||
size_t furi_hal_flash_get_base();
|
||||
size_t furi_hal_flash_get_base(void);
|
||||
|
||||
/** Get flash read block size
|
||||
*
|
||||
* @return size in bytes
|
||||
*/
|
||||
size_t furi_hal_flash_get_read_block_size();
|
||||
size_t furi_hal_flash_get_read_block_size(void);
|
||||
|
||||
/** Get flash write block size
|
||||
*
|
||||
* @return size in bytes
|
||||
*/
|
||||
size_t furi_hal_flash_get_write_block_size();
|
||||
size_t furi_hal_flash_get_write_block_size(void);
|
||||
|
||||
/** Get flash page size
|
||||
*
|
||||
* @return size in bytes
|
||||
*/
|
||||
size_t furi_hal_flash_get_page_size();
|
||||
size_t furi_hal_flash_get_page_size(void);
|
||||
|
||||
/** Get expected flash cycles count
|
||||
*
|
||||
* @return count of erase-write operations
|
||||
*/
|
||||
size_t furi_hal_flash_get_cycles_count();
|
||||
size_t furi_hal_flash_get_cycles_count(void);
|
||||
|
||||
/** Get free flash start address
|
||||
*
|
||||
* @return pointer to free region start
|
||||
*/
|
||||
const void* furi_hal_flash_get_free_start_address();
|
||||
const void* furi_hal_flash_get_free_start_address(void);
|
||||
|
||||
/** Get free flash end address
|
||||
*
|
||||
* @return pointer to free region end
|
||||
*/
|
||||
const void* furi_hal_flash_get_free_end_address();
|
||||
const void* furi_hal_flash_get_free_end_address(void);
|
||||
|
||||
/** Get first free page start address
|
||||
*
|
||||
* @return first free page memory address
|
||||
*/
|
||||
size_t furi_hal_flash_get_free_page_start_address();
|
||||
size_t furi_hal_flash_get_free_page_start_address(void);
|
||||
|
||||
/** Get free page count
|
||||
*
|
||||
* @return free page count
|
||||
*/
|
||||
size_t furi_hal_flash_get_free_page_count();
|
||||
size_t furi_hal_flash_get_free_page_count(void);
|
||||
|
||||
/** Erase Flash
|
||||
*
|
||||
@@ -133,13 +133,13 @@ bool furi_hal_flash_ob_set_word(size_t word_idx, const uint32_t value);
|
||||
* @warning Initializes system restart
|
||||
*
|
||||
*/
|
||||
void furi_hal_flash_ob_apply();
|
||||
void furi_hal_flash_ob_apply(void);
|
||||
|
||||
/** Get raw OB storage data
|
||||
*
|
||||
* @return pointer to read-only data of OB (raw + complementary values)
|
||||
*/
|
||||
const FuriHalFlashRawOptionByteData* furi_hal_flash_ob_get_raw_ptr();
|
||||
const FuriHalFlashRawOptionByteData* furi_hal_flash_ob_get_raw_ptr(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <stm32wbxx_ll_comp.h>
|
||||
#include <stm32wbxx_ll_pwr.h>
|
||||
|
||||
static uint32_t furi_hal_gpio_invalid_argument_crash() {
|
||||
static uint32_t furi_hal_gpio_invalid_argument_crash(void) {
|
||||
furi_crash("Invalid argument");
|
||||
return 0;
|
||||
}
|
||||
@@ -194,8 +194,8 @@ void furi_hal_gpio_init_ex(
|
||||
}
|
||||
|
||||
void furi_hal_gpio_add_int_callback(const GpioPin* gpio, GpioExtiCallback cb, void* ctx) {
|
||||
furi_assert(gpio);
|
||||
furi_assert(cb);
|
||||
furi_check(gpio);
|
||||
furi_check(cb);
|
||||
|
||||
FURI_CRITICAL_ENTER();
|
||||
|
||||
@@ -211,7 +211,7 @@ void furi_hal_gpio_add_int_callback(const GpioPin* gpio, GpioExtiCallback cb, vo
|
||||
}
|
||||
|
||||
void furi_hal_gpio_enable_int_callback(const GpioPin* gpio) {
|
||||
furi_assert(gpio);
|
||||
furi_check(gpio);
|
||||
|
||||
FURI_CRITICAL_ENTER();
|
||||
|
||||
@@ -222,7 +222,7 @@ void furi_hal_gpio_enable_int_callback(const GpioPin* gpio) {
|
||||
}
|
||||
|
||||
void furi_hal_gpio_disable_int_callback(const GpioPin* gpio) {
|
||||
furi_assert(gpio);
|
||||
furi_check(gpio);
|
||||
|
||||
FURI_CRITICAL_ENTER();
|
||||
|
||||
@@ -234,7 +234,7 @@ void furi_hal_gpio_disable_int_callback(const GpioPin* gpio) {
|
||||
}
|
||||
|
||||
void furi_hal_gpio_remove_int_callback(const GpioPin* gpio) {
|
||||
furi_assert(gpio);
|
||||
furi_check(gpio);
|
||||
|
||||
FURI_CRITICAL_ENTER();
|
||||
|
||||
|
||||
@@ -9,15 +9,15 @@
|
||||
|
||||
#define TAG "FuriHalI2c"
|
||||
|
||||
void furi_hal_i2c_init_early() {
|
||||
void furi_hal_i2c_init_early(void) {
|
||||
furi_hal_i2c_bus_power.callback(&furi_hal_i2c_bus_power, FuriHalI2cBusEventInit);
|
||||
}
|
||||
|
||||
void furi_hal_i2c_deinit_early() {
|
||||
void furi_hal_i2c_deinit_early(void) {
|
||||
furi_hal_i2c_bus_power.callback(&furi_hal_i2c_bus_power, FuriHalI2cBusEventDeinit);
|
||||
}
|
||||
|
||||
void furi_hal_i2c_init() {
|
||||
void furi_hal_i2c_init(void) {
|
||||
furi_hal_i2c_bus_external.callback(&furi_hal_i2c_bus_external, FuriHalI2cBusEventInit);
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
@@ -235,7 +235,7 @@ bool furi_hal_i2c_tx(
|
||||
const uint8_t* data,
|
||||
size_t size,
|
||||
uint32_t timeout) {
|
||||
furi_assert(timeout > 0);
|
||||
furi_check(timeout > 0);
|
||||
|
||||
return furi_hal_i2c_tx_ext(
|
||||
handle, address, false, data, size, FuriHalI2cBeginStart, FuriHalI2cEndStop, timeout);
|
||||
@@ -247,7 +247,7 @@ bool furi_hal_i2c_rx(
|
||||
uint8_t* data,
|
||||
size_t size,
|
||||
uint32_t timeout) {
|
||||
furi_assert(timeout > 0);
|
||||
furi_check(timeout > 0);
|
||||
|
||||
return furi_hal_i2c_rx_ext(
|
||||
handle, address, false, data, size, FuriHalI2cBeginStart, FuriHalI2cEndStop, timeout);
|
||||
@@ -284,7 +284,7 @@ bool furi_hal_i2c_trx(
|
||||
bool furi_hal_i2c_is_device_ready(FuriHalI2cBusHandle* handle, uint8_t i2c_addr, uint32_t timeout) {
|
||||
furi_check(handle);
|
||||
furi_check(handle->bus->current_handle == handle);
|
||||
furi_assert(timeout > 0);
|
||||
furi_check(timeout > 0);
|
||||
|
||||
bool ret = true;
|
||||
FuriHalCortexTimer timer = furi_hal_cortex_timer_get(timeout * 1000);
|
||||
@@ -393,7 +393,7 @@ bool furi_hal_i2c_write_mem(
|
||||
uint32_t timeout) {
|
||||
furi_check(handle);
|
||||
furi_check(handle->bus->current_handle == handle);
|
||||
furi_assert(timeout > 0);
|
||||
furi_check(timeout > 0);
|
||||
|
||||
return furi_hal_i2c_tx_ext(
|
||||
handle,
|
||||
|
||||
@@ -33,7 +33,7 @@ static void furi_hal_ibutton_emulate_isr(void* context) {
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_ibutton_init() {
|
||||
void furi_hal_ibutton_init(void) {
|
||||
furi_hal_ibutton = malloc(sizeof(FuriHalIbutton));
|
||||
furi_hal_ibutton->state = FuriHalIbuttonStateIdle;
|
||||
|
||||
@@ -44,8 +44,8 @@ void furi_hal_ibutton_emulate_start(
|
||||
uint32_t period,
|
||||
FuriHalIbuttonEmulateCallback callback,
|
||||
void* context) {
|
||||
furi_assert(furi_hal_ibutton);
|
||||
furi_assert(furi_hal_ibutton->state == FuriHalIbuttonStateIdle);
|
||||
furi_check(furi_hal_ibutton);
|
||||
furi_check(furi_hal_ibutton->state == FuriHalIbuttonStateIdle);
|
||||
|
||||
furi_hal_ibutton->state = FuriHalIbuttonStateRunning;
|
||||
furi_hal_ibutton->callback = callback;
|
||||
@@ -74,8 +74,8 @@ void furi_hal_ibutton_emulate_set_next(uint32_t period) {
|
||||
LL_TIM_SetAutoReload(FURI_HAL_IBUTTON_TIMER, period);
|
||||
}
|
||||
|
||||
void furi_hal_ibutton_emulate_stop() {
|
||||
furi_assert(furi_hal_ibutton);
|
||||
void furi_hal_ibutton_emulate_stop(void) {
|
||||
furi_check(furi_hal_ibutton);
|
||||
|
||||
if(furi_hal_ibutton->state == FuriHalIbuttonStateRunning) {
|
||||
furi_hal_ibutton->state = FuriHalIbuttonStateIdle;
|
||||
@@ -89,12 +89,12 @@ void furi_hal_ibutton_emulate_stop() {
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_ibutton_pin_configure() {
|
||||
void furi_hal_ibutton_pin_configure(void) {
|
||||
furi_hal_gpio_write(&gpio_ibutton, true);
|
||||
furi_hal_gpio_init(&gpio_ibutton, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow);
|
||||
}
|
||||
|
||||
void furi_hal_ibutton_pin_reset() {
|
||||
void furi_hal_ibutton_pin_reset(void) {
|
||||
furi_hal_gpio_write(&gpio_ibutton, true);
|
||||
furi_hal_gpio_init(&gpio_ibutton, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ extern "C" {
|
||||
typedef void (*FuriHalIbuttonEmulateCallback)(void* context);
|
||||
|
||||
/** Initialize */
|
||||
void furi_hal_ibutton_init();
|
||||
void furi_hal_ibutton_init(void);
|
||||
|
||||
/**
|
||||
* Start emulation timer
|
||||
@@ -37,17 +37,17 @@ void furi_hal_ibutton_emulate_set_next(uint32_t period);
|
||||
/**
|
||||
* Stop emulation timer
|
||||
*/
|
||||
void furi_hal_ibutton_emulate_stop();
|
||||
void furi_hal_ibutton_emulate_stop(void);
|
||||
|
||||
/**
|
||||
* Set the pin to normal mode (open collector), and sets it to float
|
||||
*/
|
||||
void furi_hal_ibutton_pin_configure();
|
||||
void furi_hal_ibutton_pin_configure(void);
|
||||
|
||||
/**
|
||||
* Sets the pin to analog mode, and sets it to float
|
||||
*/
|
||||
void furi_hal_ibutton_pin_reset();
|
||||
void furi_hal_ibutton_pin_reset(void);
|
||||
|
||||
/**
|
||||
* iButton write pin
|
||||
|
||||
@@ -102,7 +102,7 @@ static void furi_hal_infrared_tim_rx_isr(void* context) {
|
||||
/* Timeout */
|
||||
if(LL_TIM_IsActiveFlag_CC3(INFRARED_RX_TIMER)) {
|
||||
LL_TIM_ClearFlag_CC3(INFRARED_RX_TIMER);
|
||||
furi_assert(furi_hal_infrared_state == InfraredStateAsyncRx);
|
||||
furi_check(furi_hal_infrared_state == InfraredStateAsyncRx);
|
||||
|
||||
/* Timers CNT register starts to counting from 0 to ARR, but it is
|
||||
* reseted when Channel 1 catches interrupt. It is not reseted by
|
||||
@@ -119,7 +119,7 @@ static void furi_hal_infrared_tim_rx_isr(void* context) {
|
||||
/* Rising Edge */
|
||||
if(LL_TIM_IsActiveFlag_CC1(INFRARED_RX_TIMER)) {
|
||||
LL_TIM_ClearFlag_CC1(INFRARED_RX_TIMER);
|
||||
furi_assert(furi_hal_infrared_state == InfraredStateAsyncRx);
|
||||
furi_check(furi_hal_infrared_state == InfraredStateAsyncRx);
|
||||
|
||||
if(READ_BIT(INFRARED_RX_TIMER->CCMR1, TIM_CCMR1_CC1S)) {
|
||||
/* Low pin level is a Mark state of INFRARED signal. Invert level for further processing. */
|
||||
@@ -134,7 +134,7 @@ static void furi_hal_infrared_tim_rx_isr(void* context) {
|
||||
/* Falling Edge */
|
||||
if(LL_TIM_IsActiveFlag_CC2(INFRARED_RX_TIMER)) {
|
||||
LL_TIM_ClearFlag_CC2(INFRARED_RX_TIMER);
|
||||
furi_assert(furi_hal_infrared_state == InfraredStateAsyncRx);
|
||||
furi_check(furi_hal_infrared_state == InfraredStateAsyncRx);
|
||||
|
||||
if(READ_BIT(INFRARED_RX_TIMER->CCMR1, TIM_CCMR1_CC2S)) {
|
||||
/* High pin level is a Space state of INFRARED signal. Invert level for further processing. */
|
||||
@@ -149,7 +149,7 @@ static void furi_hal_infrared_tim_rx_isr(void* context) {
|
||||
}
|
||||
|
||||
void furi_hal_infrared_async_rx_start(void) {
|
||||
furi_assert(furi_hal_infrared_state == InfraredStateIdle);
|
||||
furi_check(furi_hal_infrared_state == InfraredStateIdle);
|
||||
|
||||
furi_hal_gpio_init_ex(
|
||||
&gpio_infrared_rx,
|
||||
@@ -198,7 +198,7 @@ void furi_hal_infrared_async_rx_start(void) {
|
||||
}
|
||||
|
||||
void furi_hal_infrared_async_rx_stop(void) {
|
||||
furi_assert(furi_hal_infrared_state == InfraredStateAsyncRx);
|
||||
furi_check(furi_hal_infrared_state == InfraredStateAsyncRx);
|
||||
|
||||
FURI_CRITICAL_ENTER();
|
||||
furi_hal_bus_disable(INFRARED_RX_TIMER_BUS);
|
||||
@@ -237,7 +237,7 @@ static void furi_hal_infrared_tx_dma_terminate(void) {
|
||||
LL_DMA_DisableIT_HT(INFRARED_DMA_CH2_DEF);
|
||||
LL_DMA_DisableIT_TC(INFRARED_DMA_CH2_DEF);
|
||||
|
||||
furi_assert(furi_hal_infrared_state == InfraredStateAsyncTxStopInProgress);
|
||||
furi_check(furi_hal_infrared_state == InfraredStateAsyncTxStopInProgress);
|
||||
|
||||
LL_DMA_DisableIT_TC(INFRARED_DMA_CH1_DEF);
|
||||
LL_DMA_DisableChannel(INFRARED_DMA_CH2_DEF);
|
||||
@@ -447,14 +447,14 @@ static void furi_hal_infrared_configure_tim_rcr_dma_tx(void) {
|
||||
}
|
||||
|
||||
static void furi_hal_infrared_tx_fill_buffer_last(uint8_t buf_num) {
|
||||
furi_assert(buf_num < 2);
|
||||
furi_assert(furi_hal_infrared_state != InfraredStateAsyncRx);
|
||||
furi_assert(furi_hal_infrared_state < InfraredStateMAX);
|
||||
furi_assert(infrared_tim_tx.data_callback);
|
||||
furi_check(buf_num < 2);
|
||||
furi_check(furi_hal_infrared_state != InfraredStateAsyncRx);
|
||||
furi_check(furi_hal_infrared_state < InfraredStateMAX);
|
||||
furi_check(infrared_tim_tx.data_callback);
|
||||
InfraredTxBuf* buffer = &infrared_tim_tx.buffer[buf_num];
|
||||
furi_assert(buffer->data != NULL);
|
||||
furi_check(buffer->data != NULL);
|
||||
(void)buffer->data;
|
||||
furi_assert(buffer->polarity != NULL);
|
||||
furi_check(buffer->polarity != NULL);
|
||||
(void)buffer->polarity;
|
||||
|
||||
infrared_tim_tx.buffer[buf_num].data[0] = 0; // 1 pulse
|
||||
@@ -467,13 +467,13 @@ static void furi_hal_infrared_tx_fill_buffer_last(uint8_t buf_num) {
|
||||
}
|
||||
|
||||
static void furi_hal_infrared_tx_fill_buffer(uint8_t buf_num, uint8_t polarity_shift) {
|
||||
furi_assert(buf_num < 2);
|
||||
furi_assert(furi_hal_infrared_state != InfraredStateAsyncRx);
|
||||
furi_assert(furi_hal_infrared_state < InfraredStateMAX);
|
||||
furi_assert(infrared_tim_tx.data_callback);
|
||||
furi_check(buf_num < 2);
|
||||
furi_check(furi_hal_infrared_state != InfraredStateAsyncRx);
|
||||
furi_check(furi_hal_infrared_state < InfraredStateMAX);
|
||||
furi_check(infrared_tim_tx.data_callback);
|
||||
InfraredTxBuf* buffer = &infrared_tim_tx.buffer[buf_num];
|
||||
furi_assert(buffer->data != NULL);
|
||||
furi_assert(buffer->polarity != NULL);
|
||||
furi_check(buffer->data != NULL);
|
||||
furi_check(buffer->polarity != NULL);
|
||||
|
||||
FuriHalInfraredTxGetDataState status = FuriHalInfraredTxGetDataStateOk;
|
||||
uint32_t duration = 0;
|
||||
@@ -539,10 +539,10 @@ static void furi_hal_infrared_tx_fill_buffer(uint8_t buf_num, uint8_t polarity_s
|
||||
}
|
||||
|
||||
static void furi_hal_infrared_tx_dma_set_polarity(uint8_t buf_num, uint8_t polarity_shift) {
|
||||
furi_assert(buf_num < 2);
|
||||
furi_assert(furi_hal_infrared_state < InfraredStateMAX);
|
||||
furi_check(buf_num < 2);
|
||||
furi_check(furi_hal_infrared_state < InfraredStateMAX);
|
||||
InfraredTxBuf* buffer = &infrared_tim_tx.buffer[buf_num];
|
||||
furi_assert(buffer->polarity != NULL);
|
||||
furi_check(buffer->polarity != NULL);
|
||||
|
||||
FURI_CRITICAL_ENTER();
|
||||
bool channel_enabled = LL_DMA_IsEnabledChannel(INFRARED_DMA_CH1_DEF);
|
||||
@@ -558,10 +558,10 @@ static void furi_hal_infrared_tx_dma_set_polarity(uint8_t buf_num, uint8_t polar
|
||||
}
|
||||
|
||||
static void furi_hal_infrared_tx_dma_set_buffer(uint8_t buf_num) {
|
||||
furi_assert(buf_num < 2);
|
||||
furi_assert(furi_hal_infrared_state < InfraredStateMAX);
|
||||
furi_check(buf_num < 2);
|
||||
furi_check(furi_hal_infrared_state < InfraredStateMAX);
|
||||
InfraredTxBuf* buffer = &infrared_tim_tx.buffer[buf_num];
|
||||
furi_assert(buffer->data != NULL);
|
||||
furi_check(buffer->data != NULL);
|
||||
|
||||
/* non-circular mode requires disabled channel before setup */
|
||||
FURI_CRITICAL_ENTER();
|
||||
@@ -578,7 +578,7 @@ static void furi_hal_infrared_tx_dma_set_buffer(uint8_t buf_num) {
|
||||
}
|
||||
|
||||
static void furi_hal_infrared_async_tx_free_resources(void) {
|
||||
furi_assert(
|
||||
furi_check(
|
||||
(furi_hal_infrared_state == InfraredStateIdle) ||
|
||||
(furi_hal_infrared_state == InfraredStateAsyncTxStopped));
|
||||
|
||||
@@ -606,11 +606,11 @@ void furi_hal_infrared_async_tx_start(uint32_t freq, float duty_cycle) {
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
furi_assert(furi_hal_infrared_state == InfraredStateIdle);
|
||||
furi_assert(infrared_tim_tx.buffer[0].data == NULL);
|
||||
furi_assert(infrared_tim_tx.buffer[1].data == NULL);
|
||||
furi_assert(infrared_tim_tx.buffer[0].polarity == NULL);
|
||||
furi_assert(infrared_tim_tx.buffer[1].polarity == NULL);
|
||||
furi_check(furi_hal_infrared_state == InfraredStateIdle);
|
||||
furi_check(infrared_tim_tx.buffer[0].data == NULL);
|
||||
furi_check(infrared_tim_tx.buffer[1].data == NULL);
|
||||
furi_check(infrared_tim_tx.buffer[0].polarity == NULL);
|
||||
furi_check(infrared_tim_tx.buffer[1].polarity == NULL);
|
||||
|
||||
size_t alloc_size_data = INFRARED_TIM_TX_DMA_BUFFER_SIZE * sizeof(uint16_t);
|
||||
infrared_tim_tx.buffer[0].data = malloc(alloc_size_data);
|
||||
@@ -655,8 +655,8 @@ void furi_hal_infrared_async_tx_start(uint32_t freq, float duty_cycle) {
|
||||
}
|
||||
|
||||
void furi_hal_infrared_async_tx_wait_termination(void) {
|
||||
furi_assert(furi_hal_infrared_state >= InfraredStateAsyncTx);
|
||||
furi_assert(furi_hal_infrared_state < InfraredStateMAX);
|
||||
furi_check(furi_hal_infrared_state >= InfraredStateAsyncTx);
|
||||
furi_check(furi_hal_infrared_state < InfraredStateMAX);
|
||||
|
||||
FuriStatus status;
|
||||
status = furi_semaphore_acquire(infrared_tim_tx.stop_semaphore, FuriWaitForever);
|
||||
@@ -666,8 +666,8 @@ void furi_hal_infrared_async_tx_wait_termination(void) {
|
||||
}
|
||||
|
||||
void furi_hal_infrared_async_tx_stop(void) {
|
||||
furi_assert(furi_hal_infrared_state >= InfraredStateAsyncTx);
|
||||
furi_assert(furi_hal_infrared_state < InfraredStateMAX);
|
||||
furi_check(furi_hal_infrared_state >= InfraredStateAsyncTx);
|
||||
furi_check(furi_hal_infrared_state < InfraredStateMAX);
|
||||
|
||||
FURI_CRITICAL_ENTER();
|
||||
if(furi_hal_infrared_state == InfraredStateAsyncTx)
|
||||
@@ -680,7 +680,7 @@ void furi_hal_infrared_async_tx_stop(void) {
|
||||
void furi_hal_infrared_async_tx_set_data_isr_callback(
|
||||
FuriHalInfraredTxGetDataISRCallback callback,
|
||||
void* context) {
|
||||
furi_assert(furi_hal_infrared_state == InfraredStateIdle);
|
||||
furi_check(furi_hal_infrared_state == InfraredStateIdle);
|
||||
infrared_tim_tx.data_callback = callback;
|
||||
infrared_tim_tx.data_context = context;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ __attribute__((always_inline)) static inline void
|
||||
NVIC_DisableIRQ(furi_hal_interrupt_irqn[index]);
|
||||
}
|
||||
|
||||
void furi_hal_interrupt_init() {
|
||||
void furi_hal_interrupt_init(void) {
|
||||
NVIC_SetPriority(
|
||||
TAMP_STAMP_LSECSS_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0));
|
||||
NVIC_EnableIRQ(TAMP_STAMP_LSECSS_IRQn);
|
||||
@@ -165,82 +165,82 @@ void furi_hal_interrupt_set_isr_ex(
|
||||
}
|
||||
|
||||
/* Timer 2 */
|
||||
void TIM2_IRQHandler() {
|
||||
void TIM2_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdTIM2);
|
||||
}
|
||||
|
||||
/* Timer 1 Update */
|
||||
void TIM1_UP_TIM16_IRQHandler() {
|
||||
void TIM1_UP_TIM16_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdTim1UpTim16);
|
||||
}
|
||||
|
||||
void TIM1_TRG_COM_TIM17_IRQHandler() {
|
||||
void TIM1_TRG_COM_TIM17_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdTim1TrgComTim17);
|
||||
}
|
||||
|
||||
void TIM1_CC_IRQHandler() {
|
||||
void TIM1_CC_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdTim1Cc);
|
||||
}
|
||||
|
||||
/* DMA 1 */
|
||||
void DMA1_Channel1_IRQHandler() {
|
||||
void DMA1_Channel1_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdDma1Ch1);
|
||||
}
|
||||
|
||||
void DMA1_Channel2_IRQHandler() {
|
||||
void DMA1_Channel2_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdDma1Ch2);
|
||||
}
|
||||
|
||||
void DMA1_Channel3_IRQHandler() {
|
||||
void DMA1_Channel3_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdDma1Ch3);
|
||||
}
|
||||
|
||||
void DMA1_Channel4_IRQHandler() {
|
||||
void DMA1_Channel4_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdDma1Ch4);
|
||||
}
|
||||
|
||||
void DMA1_Channel5_IRQHandler() {
|
||||
void DMA1_Channel5_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdDma1Ch5);
|
||||
}
|
||||
|
||||
void DMA1_Channel6_IRQHandler() {
|
||||
void DMA1_Channel6_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdDma1Ch6);
|
||||
}
|
||||
|
||||
void DMA1_Channel7_IRQHandler() {
|
||||
void DMA1_Channel7_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdDma1Ch7);
|
||||
}
|
||||
|
||||
/* DMA 2 */
|
||||
void DMA2_Channel1_IRQHandler() {
|
||||
void DMA2_Channel1_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdDma2Ch1);
|
||||
}
|
||||
|
||||
void DMA2_Channel2_IRQHandler() {
|
||||
void DMA2_Channel2_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdDma2Ch2);
|
||||
}
|
||||
|
||||
void DMA2_Channel3_IRQHandler() {
|
||||
void DMA2_Channel3_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdDma2Ch3);
|
||||
}
|
||||
|
||||
void DMA2_Channel4_IRQHandler() {
|
||||
void DMA2_Channel4_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdDma2Ch4);
|
||||
}
|
||||
|
||||
void DMA2_Channel5_IRQHandler() {
|
||||
void DMA2_Channel5_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdDma2Ch5);
|
||||
}
|
||||
|
||||
void DMA2_Channel6_IRQHandler() {
|
||||
void DMA2_Channel6_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdDma2Ch6);
|
||||
}
|
||||
|
||||
void DMA2_Channel7_IRQHandler() {
|
||||
void DMA2_Channel7_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdDma2Ch7);
|
||||
}
|
||||
|
||||
void HSEM_IRQHandler() {
|
||||
void HSEM_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdHsem);
|
||||
}
|
||||
|
||||
@@ -256,11 +256,11 @@ void TAMP_STAMP_LSECSS_IRQHandler(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void RCC_IRQHandler() {
|
||||
void RCC_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdRcc);
|
||||
}
|
||||
|
||||
void NMI_Handler() {
|
||||
void NMI_Handler(void) {
|
||||
if(LL_RCC_IsActiveFlag_HSECSS()) {
|
||||
LL_RCC_ClearFlag_HSECSS();
|
||||
FURI_LOG_E(TAG, "HSE CSS fired: resetting system");
|
||||
@@ -268,11 +268,11 @@ void NMI_Handler() {
|
||||
}
|
||||
}
|
||||
|
||||
void HardFault_Handler() {
|
||||
void HardFault_Handler(void) {
|
||||
furi_crash("HardFault");
|
||||
}
|
||||
|
||||
void MemManage_Handler() {
|
||||
void MemManage_Handler(void) {
|
||||
if(FURI_BIT(SCB->CFSR, SCB_CFSR_MMARVALID_Pos)) {
|
||||
uint32_t memfault_address = SCB->MMFAR;
|
||||
if(memfault_address < (1024 * 1024)) {
|
||||
@@ -290,15 +290,15 @@ void MemManage_Handler() {
|
||||
furi_crash("MemManage");
|
||||
}
|
||||
|
||||
void BusFault_Handler() {
|
||||
void BusFault_Handler(void) {
|
||||
furi_crash("BusFault");
|
||||
}
|
||||
|
||||
void UsageFault_Handler() {
|
||||
void UsageFault_Handler(void) {
|
||||
furi_crash("UsageFault");
|
||||
}
|
||||
|
||||
void DebugMon_Handler() {
|
||||
void DebugMon_Handler(void) {
|
||||
}
|
||||
|
||||
#include "usbd_core.h"
|
||||
@@ -308,36 +308,36 @@ extern usbd_device udev;
|
||||
extern void HW_IPCC_Tx_Handler();
|
||||
extern void HW_IPCC_Rx_Handler();
|
||||
|
||||
void SysTick_Handler() {
|
||||
void SysTick_Handler(void) {
|
||||
furi_hal_os_tick();
|
||||
}
|
||||
|
||||
void USB_LP_IRQHandler() {
|
||||
void USB_LP_IRQHandler(void) {
|
||||
#ifndef FURI_RAM_EXEC
|
||||
usbd_poll(&udev);
|
||||
#endif
|
||||
}
|
||||
|
||||
void USB_HP_IRQHandler() {
|
||||
void USB_HP_IRQHandler(void) {
|
||||
}
|
||||
|
||||
void IPCC_C1_TX_IRQHandler() {
|
||||
void IPCC_C1_TX_IRQHandler(void) {
|
||||
HW_IPCC_Tx_Handler();
|
||||
}
|
||||
|
||||
void IPCC_C1_RX_IRQHandler() {
|
||||
void IPCC_C1_RX_IRQHandler(void) {
|
||||
HW_IPCC_Rx_Handler();
|
||||
}
|
||||
|
||||
void FPU_IRQHandler() {
|
||||
void FPU_IRQHandler(void) {
|
||||
furi_crash("FpuFault");
|
||||
}
|
||||
|
||||
void LPTIM1_IRQHandler() {
|
||||
void LPTIM1_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdLpTim1);
|
||||
}
|
||||
|
||||
void LPTIM2_IRQHandler() {
|
||||
void LPTIM2_IRQHandler(void) {
|
||||
furi_hal_interrupt_call(FuriHalInterruptIdLpTim2);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ typedef enum {
|
||||
} FuriHalInterruptPriority;
|
||||
|
||||
/** Initialize interrupt subsystem */
|
||||
void furi_hal_interrupt_init();
|
||||
void furi_hal_interrupt_init(void);
|
||||
|
||||
/** Set ISR and enable interrupt with default priority
|
||||
*
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
#include <lp5562.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define LED_CURRENT_RED 50
|
||||
#define LED_CURRENT_GREEN 50
|
||||
#define LED_CURRENT_BLUE 50
|
||||
#define LED_CURRENT_WHITE 150
|
||||
#define LED_CURRENT_RED (50u)
|
||||
#define LED_CURRENT_GREEN (50u)
|
||||
#define LED_CURRENT_BLUE (50u)
|
||||
#define LED_CURRENT_WHITE (150u)
|
||||
|
||||
void furi_hal_light_init() {
|
||||
void furi_hal_light_init(void) {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
|
||||
lp5562_reset(&furi_hal_i2c_handle_power);
|
||||
@@ -64,7 +64,7 @@ void furi_hal_light_blink_start(Light light, uint8_t brightness, uint16_t on_tim
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
}
|
||||
|
||||
void furi_hal_light_blink_stop() {
|
||||
void furi_hal_light_blink_stop(void) {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
lp5562_set_channel_src(
|
||||
&furi_hal_i2c_handle_power,
|
||||
|
||||
@@ -25,7 +25,7 @@ extern const void __sram2a_start__;
|
||||
extern const void __sram2a_free__;
|
||||
extern const void __sram2b_start__;
|
||||
|
||||
void furi_hal_memory_init() {
|
||||
void furi_hal_memory_init(void) {
|
||||
if(furi_hal_rtc_get_boot_mode() != FuriHalRtcBootModeNormal) {
|
||||
return;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ void* furi_hal_memory_alloc(size_t size) {
|
||||
return allocated_memory;
|
||||
}
|
||||
|
||||
size_t furi_hal_memory_get_free() {
|
||||
size_t furi_hal_memory_get_free(void) {
|
||||
if(furi_hal_memory == NULL) return 0;
|
||||
|
||||
size_t free = 0;
|
||||
@@ -116,7 +116,7 @@ size_t furi_hal_memory_get_free() {
|
||||
return free;
|
||||
}
|
||||
|
||||
size_t furi_hal_memory_max_pool_block() {
|
||||
size_t furi_hal_memory_max_pool_block(void) {
|
||||
if(furi_hal_memory == NULL) return 0;
|
||||
|
||||
size_t max = 0;
|
||||
|
||||
@@ -7,18 +7,18 @@
|
||||
|
||||
#define FURI_HAL_MPU_STACK_PROTECT_REGION FuriHalMPURegionSize32B
|
||||
|
||||
void furi_hal_mpu_init() {
|
||||
void furi_hal_mpu_init(void) {
|
||||
furi_hal_mpu_enable();
|
||||
|
||||
// NULL pointer dereference protection
|
||||
furi_hal_mpu_protect_no_access(FuriHalMpuRegionNULL, 0x00, FuriHalMPURegionSize1MB);
|
||||
}
|
||||
|
||||
void furi_hal_mpu_enable() {
|
||||
void furi_hal_mpu_enable(void) {
|
||||
LL_MPU_Enable(LL_MPU_CTRL_PRIVILEGED_DEFAULT);
|
||||
}
|
||||
|
||||
void furi_hal_mpu_disable() {
|
||||
void furi_hal_mpu_disable(void) {
|
||||
LL_MPU_Disable();
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ static FuriHalNfcError furi_hal_nfc_turn_on_osc(FuriHalSpiBusHandle* handle) {
|
||||
return error;
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_is_hal_ready() {
|
||||
FuriHalNfcError furi_hal_nfc_is_hal_ready(void) {
|
||||
FuriHalNfcError error = FuriHalNfcErrorNone;
|
||||
|
||||
do {
|
||||
@@ -68,8 +68,8 @@ FuriHalNfcError furi_hal_nfc_is_hal_ready() {
|
||||
return error;
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_init() {
|
||||
furi_assert(furi_hal_nfc.mutex == NULL);
|
||||
FuriHalNfcError furi_hal_nfc_init(void) {
|
||||
furi_check(furi_hal_nfc.mutex == NULL);
|
||||
|
||||
furi_hal_nfc.mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
FuriHalNfcError error = FuriHalNfcErrorNone;
|
||||
@@ -252,11 +252,11 @@ FuriHalNfcError furi_hal_nfc_init() {
|
||||
return error;
|
||||
}
|
||||
|
||||
static bool furi_hal_nfc_is_mine() {
|
||||
static bool furi_hal_nfc_is_mine(void) {
|
||||
return (furi_mutex_get_owner(furi_hal_nfc.mutex) == furi_thread_get_current_id());
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_acquire() {
|
||||
FuriHalNfcError furi_hal_nfc_acquire(void) {
|
||||
furi_check(furi_hal_nfc.mutex);
|
||||
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_nfc);
|
||||
@@ -270,7 +270,7 @@ FuriHalNfcError furi_hal_nfc_acquire() {
|
||||
return error;
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_release() {
|
||||
FuriHalNfcError furi_hal_nfc_release(void) {
|
||||
furi_check(furi_hal_nfc.mutex);
|
||||
furi_check(furi_hal_nfc_is_mine());
|
||||
furi_check(furi_mutex_release(furi_hal_nfc.mutex) == FuriStatusOk);
|
||||
@@ -280,7 +280,7 @@ FuriHalNfcError furi_hal_nfc_release() {
|
||||
return FuriHalNfcErrorNone;
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_low_power_mode_start() {
|
||||
FuriHalNfcError furi_hal_nfc_low_power_mode_start(void) {
|
||||
FuriHalNfcError error = FuriHalNfcErrorNone;
|
||||
FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc;
|
||||
|
||||
@@ -298,7 +298,7 @@ FuriHalNfcError furi_hal_nfc_low_power_mode_start() {
|
||||
return error;
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_low_power_mode_stop() {
|
||||
FuriHalNfcError furi_hal_nfc_low_power_mode_stop(void) {
|
||||
FuriHalNfcError error = FuriHalNfcErrorNone;
|
||||
FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc;
|
||||
|
||||
@@ -346,8 +346,8 @@ static FuriHalNfcError furi_hal_nfc_listener_init_common(FuriHalSpiBusHandle* ha
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_set_mode(FuriHalNfcMode mode, FuriHalNfcTech tech) {
|
||||
furi_assert(mode < FuriHalNfcModeNum);
|
||||
furi_assert(tech < FuriHalNfcTechNum);
|
||||
furi_check(mode < FuriHalNfcModeNum);
|
||||
furi_check(tech < FuriHalNfcTechNum);
|
||||
|
||||
FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc;
|
||||
|
||||
@@ -373,7 +373,7 @@ FuriHalNfcError furi_hal_nfc_set_mode(FuriHalNfcMode mode, FuriHalNfcTech tech)
|
||||
return error;
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_reset_mode() {
|
||||
FuriHalNfcError furi_hal_nfc_reset_mode(void) {
|
||||
FuriHalNfcError error = FuriHalNfcErrorNone;
|
||||
FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc;
|
||||
|
||||
@@ -413,7 +413,7 @@ FuriHalNfcError furi_hal_nfc_reset_mode() {
|
||||
return error;
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_field_detect_start() {
|
||||
FuriHalNfcError furi_hal_nfc_field_detect_start(void) {
|
||||
FuriHalNfcError error = FuriHalNfcErrorNone;
|
||||
FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc;
|
||||
|
||||
@@ -427,7 +427,7 @@ FuriHalNfcError furi_hal_nfc_field_detect_start() {
|
||||
return error;
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_field_detect_stop() {
|
||||
FuriHalNfcError furi_hal_nfc_field_detect_stop(void) {
|
||||
FuriHalNfcError error = FuriHalNfcErrorNone;
|
||||
FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc;
|
||||
|
||||
@@ -439,7 +439,7 @@ FuriHalNfcError furi_hal_nfc_field_detect_stop() {
|
||||
return error;
|
||||
}
|
||||
|
||||
bool furi_hal_nfc_field_is_present() {
|
||||
bool furi_hal_nfc_field_is_present(void) {
|
||||
bool is_present = false;
|
||||
FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc;
|
||||
|
||||
@@ -454,7 +454,7 @@ bool furi_hal_nfc_field_is_present() {
|
||||
return is_present;
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_poller_field_on() {
|
||||
FuriHalNfcError furi_hal_nfc_poller_field_on(void) {
|
||||
FuriHalNfcError error = FuriHalNfcErrorNone;
|
||||
FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc;
|
||||
|
||||
@@ -479,7 +479,7 @@ FuriHalNfcError furi_hal_nfc_poller_tx_common(
|
||||
FuriHalSpiBusHandle* handle,
|
||||
const uint8_t* tx_data,
|
||||
size_t tx_bits) {
|
||||
furi_assert(tx_data);
|
||||
furi_check(tx_data);
|
||||
|
||||
FuriHalNfcError err = FuriHalNfcErrorNone;
|
||||
|
||||
@@ -521,40 +521,40 @@ FuriHalNfcError furi_hal_nfc_common_fifo_tx(
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_poller_tx(const uint8_t* tx_data, size_t tx_bits) {
|
||||
furi_assert(furi_hal_nfc.mode == FuriHalNfcModePoller);
|
||||
furi_assert(furi_hal_nfc.tech < FuriHalNfcTechNum);
|
||||
furi_check(furi_hal_nfc.mode == FuriHalNfcModePoller);
|
||||
furi_check(furi_hal_nfc.tech < FuriHalNfcTechNum);
|
||||
FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc;
|
||||
|
||||
return furi_hal_nfc_tech[furi_hal_nfc.tech]->poller.tx(handle, tx_data, tx_bits);
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_poller_rx(uint8_t* rx_data, size_t rx_data_size, size_t* rx_bits) {
|
||||
furi_assert(furi_hal_nfc.mode == FuriHalNfcModePoller);
|
||||
furi_assert(furi_hal_nfc.tech < FuriHalNfcTechNum);
|
||||
furi_check(furi_hal_nfc.mode == FuriHalNfcModePoller);
|
||||
furi_check(furi_hal_nfc.tech < FuriHalNfcTechNum);
|
||||
FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc;
|
||||
|
||||
return furi_hal_nfc_tech[furi_hal_nfc.tech]->poller.rx(handle, rx_data, rx_data_size, rx_bits);
|
||||
}
|
||||
|
||||
FuriHalNfcEvent furi_hal_nfc_poller_wait_event(uint32_t timeout_ms) {
|
||||
furi_assert(furi_hal_nfc.mode == FuriHalNfcModePoller);
|
||||
furi_assert(furi_hal_nfc.tech < FuriHalNfcTechNum);
|
||||
furi_check(furi_hal_nfc.mode == FuriHalNfcModePoller);
|
||||
furi_check(furi_hal_nfc.tech < FuriHalNfcTechNum);
|
||||
|
||||
return furi_hal_nfc_tech[furi_hal_nfc.tech]->poller.wait_event(timeout_ms);
|
||||
}
|
||||
|
||||
FuriHalNfcEvent furi_hal_nfc_listener_wait_event(uint32_t timeout_ms) {
|
||||
furi_assert(furi_hal_nfc.mode == FuriHalNfcModeListener);
|
||||
furi_assert(furi_hal_nfc.tech < FuriHalNfcTechNum);
|
||||
furi_check(furi_hal_nfc.mode == FuriHalNfcModeListener);
|
||||
furi_check(furi_hal_nfc.tech < FuriHalNfcTechNum);
|
||||
|
||||
return furi_hal_nfc_tech[furi_hal_nfc.tech]->listener.wait_event(timeout_ms);
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_listener_tx(const uint8_t* tx_data, size_t tx_bits) {
|
||||
furi_assert(tx_data);
|
||||
furi_check(tx_data);
|
||||
|
||||
furi_assert(furi_hal_nfc.mode == FuriHalNfcModeListener);
|
||||
furi_assert(furi_hal_nfc.tech < FuriHalNfcTechNum);
|
||||
furi_check(furi_hal_nfc.mode == FuriHalNfcModeListener);
|
||||
furi_check(furi_hal_nfc.tech < FuriHalNfcTechNum);
|
||||
|
||||
FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc;
|
||||
return furi_hal_nfc_tech[furi_hal_nfc.tech]->listener.tx(handle, tx_data, tx_bits);
|
||||
@@ -575,18 +575,18 @@ FuriHalNfcError furi_hal_nfc_common_fifo_rx(
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_listener_rx(uint8_t* rx_data, size_t rx_data_size, size_t* rx_bits) {
|
||||
furi_assert(rx_data);
|
||||
furi_assert(rx_bits);
|
||||
furi_check(rx_data);
|
||||
furi_check(rx_bits);
|
||||
|
||||
furi_assert(furi_hal_nfc.mode == FuriHalNfcModeListener);
|
||||
furi_assert(furi_hal_nfc.tech < FuriHalNfcTechNum);
|
||||
furi_check(furi_hal_nfc.mode == FuriHalNfcModeListener);
|
||||
furi_check(furi_hal_nfc.tech < FuriHalNfcTechNum);
|
||||
|
||||
FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc;
|
||||
return furi_hal_nfc_tech[furi_hal_nfc.tech]->listener.rx(
|
||||
handle, rx_data, rx_data_size, rx_bits);
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_trx_reset() {
|
||||
FuriHalNfcError furi_hal_nfc_trx_reset(void) {
|
||||
FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc;
|
||||
|
||||
st25r3916_direct_cmd(handle, ST25R3916_CMD_STOP);
|
||||
@@ -594,25 +594,25 @@ FuriHalNfcError furi_hal_nfc_trx_reset() {
|
||||
return FuriHalNfcErrorNone;
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_listener_sleep() {
|
||||
furi_assert(furi_hal_nfc.mode == FuriHalNfcModeListener);
|
||||
furi_assert(furi_hal_nfc.tech < FuriHalNfcTechNum);
|
||||
FuriHalNfcError furi_hal_nfc_listener_sleep(void) {
|
||||
furi_check(furi_hal_nfc.mode == FuriHalNfcModeListener);
|
||||
furi_check(furi_hal_nfc.tech < FuriHalNfcTechNum);
|
||||
|
||||
FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc;
|
||||
|
||||
return furi_hal_nfc_tech[furi_hal_nfc.tech]->listener.sleep(handle);
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_listener_idle() {
|
||||
furi_assert(furi_hal_nfc.mode == FuriHalNfcModeListener);
|
||||
furi_assert(furi_hal_nfc.tech < FuriHalNfcTechNum);
|
||||
FuriHalNfcError furi_hal_nfc_listener_idle(void) {
|
||||
furi_check(furi_hal_nfc.mode == FuriHalNfcModeListener);
|
||||
furi_check(furi_hal_nfc.tech < FuriHalNfcTechNum);
|
||||
|
||||
FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc;
|
||||
|
||||
return furi_hal_nfc_tech[furi_hal_nfc.tech]->listener.idle(handle);
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_listener_enable_rx() {
|
||||
FuriHalNfcError furi_hal_nfc_listener_enable_rx(void) {
|
||||
FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc;
|
||||
|
||||
st25r3916_direct_cmd(handle, ST25R3916_CMD_UNMASK_RECEIVE_DATA);
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
FuriHalNfcEventInternal* furi_hal_nfc_event = NULL;
|
||||
|
||||
void furi_hal_nfc_event_init() {
|
||||
void furi_hal_nfc_event_init(void) {
|
||||
furi_hal_nfc_event = malloc(sizeof(FuriHalNfcEventInternal));
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_event_start() {
|
||||
furi_assert(furi_hal_nfc_event);
|
||||
FuriHalNfcError furi_hal_nfc_event_start(void) {
|
||||
furi_check(furi_hal_nfc_event);
|
||||
|
||||
furi_hal_nfc_event->thread = furi_thread_get_current_id();
|
||||
furi_thread_flags_clear(FURI_HAL_NFC_EVENT_INTERNAL_ALL);
|
||||
@@ -15,8 +15,8 @@ FuriHalNfcError furi_hal_nfc_event_start() {
|
||||
return FuriHalNfcErrorNone;
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_event_stop() {
|
||||
furi_assert(furi_hal_nfc_event);
|
||||
FuriHalNfcError furi_hal_nfc_event_stop(void) {
|
||||
furi_check(furi_hal_nfc_event);
|
||||
|
||||
furi_hal_nfc_event->thread = NULL;
|
||||
|
||||
@@ -24,21 +24,21 @@ FuriHalNfcError furi_hal_nfc_event_stop() {
|
||||
}
|
||||
|
||||
void furi_hal_nfc_event_set(FuriHalNfcEventInternalType event) {
|
||||
furi_assert(furi_hal_nfc_event);
|
||||
furi_check(furi_hal_nfc_event);
|
||||
|
||||
if(furi_hal_nfc_event->thread) {
|
||||
furi_thread_flags_set(furi_hal_nfc_event->thread, event);
|
||||
}
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_abort() {
|
||||
FuriHalNfcError furi_hal_nfc_abort(void) {
|
||||
furi_hal_nfc_event_set(FuriHalNfcEventInternalTypeAbort);
|
||||
return FuriHalNfcErrorNone;
|
||||
}
|
||||
|
||||
FuriHalNfcEvent furi_hal_nfc_wait_event_common(uint32_t timeout_ms) {
|
||||
furi_assert(furi_hal_nfc_event);
|
||||
furi_assert(furi_hal_nfc_event->thread);
|
||||
furi_check(furi_hal_nfc_event);
|
||||
furi_check(furi_hal_nfc_event->thread);
|
||||
|
||||
FuriHalNfcEvent event = 0;
|
||||
uint32_t event_timeout = timeout_ms == FURI_HAL_NFC_EVENT_WAIT_FOREVER ? FuriWaitForever :
|
||||
@@ -101,8 +101,8 @@ bool furi_hal_nfc_event_wait_for_specific_irq(
|
||||
FuriHalSpiBusHandle* handle,
|
||||
uint32_t mask,
|
||||
uint32_t timeout_ms) {
|
||||
furi_assert(furi_hal_nfc_event);
|
||||
furi_assert(furi_hal_nfc_event->thread);
|
||||
furi_check(furi_hal_nfc_event);
|
||||
furi_check(furi_hal_nfc_event->thread);
|
||||
|
||||
bool irq_received = false;
|
||||
uint32_t event_flag =
|
||||
|
||||
@@ -163,6 +163,9 @@ FuriHalNfcError furi_hal_nfc_felica_listener_set_sensf_res_data(
|
||||
const uint8_t idm_len,
|
||||
const uint8_t* pmm,
|
||||
const uint8_t pmm_len) {
|
||||
furi_check(idm);
|
||||
furi_check(pmm);
|
||||
|
||||
FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc;
|
||||
// Write PT Memory
|
||||
uint8_t pt_memory[19] = {};
|
||||
|
||||
@@ -69,7 +69,7 @@ extern FuriHalNfc furi_hal_nfc;
|
||||
/**
|
||||
* @brief Initialise NFC HAL event system.
|
||||
*/
|
||||
void furi_hal_nfc_event_init();
|
||||
void furi_hal_nfc_event_init(void);
|
||||
|
||||
/**
|
||||
* @brief Forcibly emit (a) particular internal event(s).
|
||||
@@ -81,22 +81,22 @@ void furi_hal_nfc_event_set(FuriHalNfcEventInternalType event);
|
||||
/**
|
||||
* @brief Initialise GPIO to generate an interrupt from the NFC hardware.
|
||||
*/
|
||||
void furi_hal_nfc_init_gpio_isr();
|
||||
void furi_hal_nfc_init_gpio_isr(void);
|
||||
|
||||
/**
|
||||
* @brief Disable interrupts from the NFC hardware.
|
||||
*/
|
||||
void furi_hal_nfc_deinit_gpio_isr();
|
||||
void furi_hal_nfc_deinit_gpio_isr(void);
|
||||
|
||||
/**
|
||||
* @brief Initialise all NFC timers.
|
||||
*/
|
||||
void furi_hal_nfc_timers_init();
|
||||
void furi_hal_nfc_timers_init(void);
|
||||
|
||||
/**
|
||||
* @brief Disable all NFC timers.
|
||||
*/
|
||||
void furi_hal_nfc_timers_deinit();
|
||||
void furi_hal_nfc_timers_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Get the interrupt bitmask from the NFC hardware.
|
||||
|
||||
@@ -16,14 +16,14 @@ uint32_t furi_hal_nfc_get_irq(FuriHalSpiBusHandle* handle) {
|
||||
return irq;
|
||||
}
|
||||
|
||||
void furi_hal_nfc_init_gpio_isr() {
|
||||
void furi_hal_nfc_init_gpio_isr(void) {
|
||||
furi_hal_gpio_init(
|
||||
&gpio_nfc_irq_rfid_pull, GpioModeInterruptRise, GpioPullDown, GpioSpeedVeryHigh);
|
||||
furi_hal_gpio_add_int_callback(&gpio_nfc_irq_rfid_pull, furi_hal_nfc_int_callback, NULL);
|
||||
furi_hal_gpio_enable_int_callback(&gpio_nfc_irq_rfid_pull);
|
||||
}
|
||||
|
||||
void furi_hal_nfc_deinit_gpio_isr() {
|
||||
void furi_hal_nfc_deinit_gpio_isr(void) {
|
||||
furi_hal_gpio_remove_int_callback(&gpio_nfc_irq_rfid_pull);
|
||||
furi_hal_gpio_init(&gpio_nfc_irq_rfid_pull, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ FuriHalNfcError
|
||||
|
||||
FuriHalNfcError
|
||||
furi_hal_nfc_iso14443a_poller_tx_custom_parity(const uint8_t* tx_data, size_t tx_bits) {
|
||||
furi_assert(tx_data);
|
||||
furi_check(tx_data);
|
||||
|
||||
FuriHalNfcError err = FuriHalNfcErrorNone;
|
||||
FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc;
|
||||
@@ -215,10 +215,9 @@ FuriHalNfcError furi_hal_nfc_iso14443a_listener_set_col_res_data(
|
||||
uint8_t uid_len,
|
||||
uint8_t* atqa,
|
||||
uint8_t sak) {
|
||||
furi_assert(uid);
|
||||
furi_assert(atqa);
|
||||
UNUSED(uid_len);
|
||||
UNUSED(sak);
|
||||
furi_check(uid);
|
||||
furi_check(atqa);
|
||||
|
||||
FuriHalNfcError error = FuriHalNfcErrorNone;
|
||||
|
||||
FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc;
|
||||
@@ -280,10 +279,10 @@ FuriHalNfcError furi_hal_nfc_iso14443a_listener_tx_custom_parity(
|
||||
const uint8_t* tx_data,
|
||||
const uint8_t* tx_parity,
|
||||
size_t tx_bits) {
|
||||
furi_assert(tx_data);
|
||||
furi_assert(tx_parity);
|
||||
furi_check(tx_data);
|
||||
furi_check(tx_parity);
|
||||
|
||||
furi_assert(iso14443_3a_signal);
|
||||
furi_check(iso14443_3a_signal);
|
||||
|
||||
FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc;
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ typedef struct {
|
||||
static FuriHalNfcIso15693Listener* furi_hal_nfc_iso15693_listener = NULL;
|
||||
static FuriHalNfcIso15693Poller* furi_hal_nfc_iso15693_poller = NULL;
|
||||
|
||||
static FuriHalNfcIso15693Listener* furi_hal_nfc_iso15693_listener_alloc() {
|
||||
static FuriHalNfcIso15693Listener* furi_hal_nfc_iso15693_listener_alloc(void) {
|
||||
FuriHalNfcIso15693Listener* instance = malloc(sizeof(FuriHalNfcIso15693Listener));
|
||||
|
||||
instance->signal = iso15693_signal_alloc(&gpio_spi_r_mosi);
|
||||
@@ -54,7 +54,7 @@ static FuriHalNfcIso15693Listener* furi_hal_nfc_iso15693_listener_alloc() {
|
||||
}
|
||||
|
||||
static void furi_hal_nfc_iso15693_listener_free(FuriHalNfcIso15693Listener* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
iso15693_signal_free(instance->signal);
|
||||
iso15693_parser_free(instance->parser);
|
||||
@@ -62,14 +62,14 @@ static void furi_hal_nfc_iso15693_listener_free(FuriHalNfcIso15693Listener* inst
|
||||
free(instance);
|
||||
}
|
||||
|
||||
static FuriHalNfcIso15693Poller* furi_hal_nfc_iso15693_poller_alloc() {
|
||||
static FuriHalNfcIso15693Poller* furi_hal_nfc_iso15693_poller_alloc(void) {
|
||||
FuriHalNfcIso15693Poller* instance = malloc(sizeof(FuriHalNfcIso15693Poller));
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
static void furi_hal_nfc_iso15693_poller_free(FuriHalNfcIso15693Poller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
free(instance);
|
||||
}
|
||||
@@ -113,7 +113,7 @@ static FuriHalNfcError furi_hal_nfc_iso15693_common_init(FuriHalSpiBusHandle* ha
|
||||
}
|
||||
|
||||
static FuriHalNfcError furi_hal_nfc_iso15693_poller_init(FuriHalSpiBusHandle* handle) {
|
||||
furi_assert(furi_hal_nfc_iso15693_poller == NULL);
|
||||
furi_check(furi_hal_nfc_iso15693_poller == NULL);
|
||||
|
||||
furi_hal_nfc_iso15693_poller = furi_hal_nfc_iso15693_poller_alloc();
|
||||
|
||||
@@ -143,7 +143,7 @@ static FuriHalNfcError furi_hal_nfc_iso15693_poller_init(FuriHalSpiBusHandle* ha
|
||||
|
||||
static FuriHalNfcError furi_hal_nfc_iso15693_poller_deinit(FuriHalSpiBusHandle* handle) {
|
||||
UNUSED(handle);
|
||||
furi_assert(furi_hal_nfc_iso15693_poller);
|
||||
furi_check(furi_hal_nfc_iso15693_poller);
|
||||
|
||||
furi_hal_nfc_iso15693_poller_free(furi_hal_nfc_iso15693_poller);
|
||||
furi_hal_nfc_iso15693_poller = NULL;
|
||||
@@ -159,7 +159,7 @@ static void iso15693_3_poller_encode_frame(
|
||||
size_t* frame_buf_bits) {
|
||||
static const uint8_t bit_patterns_1_out_of_4[] = {0x02, 0x08, 0x20, 0x80};
|
||||
size_t frame_buf_size_calc = (tx_bits / 2) + 2;
|
||||
furi_assert(frame_buf_size >= frame_buf_size_calc);
|
||||
furi_check(frame_buf_size >= frame_buf_size_calc);
|
||||
|
||||
// Add SOF 1 out of 4
|
||||
frame_buf[0] = 0x21;
|
||||
@@ -300,7 +300,7 @@ static void furi_hal_nfc_iso15693_listener_transparent_mode_exit(FuriHalSpiBusHa
|
||||
}
|
||||
|
||||
static FuriHalNfcError furi_hal_nfc_iso15693_listener_init(FuriHalSpiBusHandle* handle) {
|
||||
furi_assert(furi_hal_nfc_iso15693_listener == NULL);
|
||||
furi_check(furi_hal_nfc_iso15693_listener == NULL);
|
||||
|
||||
furi_hal_nfc_iso15693_listener = furi_hal_nfc_iso15693_listener_alloc();
|
||||
|
||||
@@ -329,7 +329,7 @@ static FuriHalNfcError furi_hal_nfc_iso15693_listener_init(FuriHalSpiBusHandle*
|
||||
}
|
||||
|
||||
static FuriHalNfcError furi_hal_nfc_iso15693_listener_deinit(FuriHalSpiBusHandle* handle) {
|
||||
furi_assert(furi_hal_nfc_iso15693_listener);
|
||||
furi_check(furi_hal_nfc_iso15693_listener);
|
||||
|
||||
furi_hal_nfc_iso15693_listener_transparent_mode_exit(handle);
|
||||
|
||||
@@ -348,7 +348,7 @@ static FuriHalNfcError
|
||||
}
|
||||
|
||||
static void furi_hal_nfc_iso15693_parser_callback(Iso15693ParserEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
furi_check(context);
|
||||
|
||||
if(event == Iso15693ParserEventDataReceived) {
|
||||
FuriThreadId thread_id = context;
|
||||
@@ -391,7 +391,7 @@ static FuriHalNfcError furi_hal_nfc_iso15693_listener_tx(
|
||||
const uint8_t* tx_data,
|
||||
size_t tx_bits) {
|
||||
UNUSED(handle);
|
||||
furi_assert(furi_hal_nfc_iso15693_listener);
|
||||
furi_check(furi_hal_nfc_iso15693_listener);
|
||||
|
||||
FuriHalNfcError error = FuriHalNfcErrorNone;
|
||||
|
||||
@@ -400,7 +400,7 @@ static FuriHalNfcError furi_hal_nfc_iso15693_listener_tx(
|
||||
return error;
|
||||
}
|
||||
|
||||
FuriHalNfcError furi_hal_nfc_iso15693_listener_tx_sof() {
|
||||
FuriHalNfcError furi_hal_nfc_iso15693_listener_tx_sof(void) {
|
||||
iso15693_signal_tx_sof(furi_hal_nfc_iso15693_listener->signal, Iso15693SignalDataRateHi);
|
||||
|
||||
return FuriHalNfcErrorNone;
|
||||
@@ -411,7 +411,7 @@ static FuriHalNfcError furi_hal_nfc_iso15693_listener_rx(
|
||||
uint8_t* rx_data,
|
||||
size_t rx_data_size,
|
||||
size_t* rx_bits) {
|
||||
furi_assert(furi_hal_nfc_iso15693_listener);
|
||||
furi_check(furi_hal_nfc_iso15693_listener);
|
||||
UNUSED(handle);
|
||||
|
||||
if(rx_data_size <
|
||||
|
||||
@@ -192,13 +192,13 @@ static void furi_hal_nfc_timer_stop(FuriHalNfcTimer timer) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void furi_hal_nfc_timers_init() {
|
||||
void furi_hal_nfc_timers_init(void) {
|
||||
for(size_t i = 0; i < FuriHalNfcTimerCount; i++) {
|
||||
furi_hal_nfc_timer_init(i);
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_nfc_timers_deinit() {
|
||||
void furi_hal_nfc_timers_deinit(void) {
|
||||
for(size_t i = 0; i < FuriHalNfcTimerCount; i++) {
|
||||
furi_hal_nfc_timer_deinit(i);
|
||||
}
|
||||
@@ -208,7 +208,7 @@ void furi_hal_nfc_timer_fwt_start(uint32_t time_fc) {
|
||||
furi_hal_nfc_timer_start_fc(FuriHalNfcTimerFwt, time_fc);
|
||||
}
|
||||
|
||||
void furi_hal_nfc_timer_fwt_stop() {
|
||||
void furi_hal_nfc_timer_fwt_stop(void) {
|
||||
furi_hal_nfc_timer_stop(FuriHalNfcTimerFwt);
|
||||
}
|
||||
|
||||
@@ -220,10 +220,10 @@ void furi_hal_nfc_timer_block_tx_start_us(uint32_t time_us) {
|
||||
furi_hal_nfc_timer_start_us(FuriHalNfcTimerBlockTx, time_us);
|
||||
}
|
||||
|
||||
void furi_hal_nfc_timer_block_tx_stop() {
|
||||
void furi_hal_nfc_timer_block_tx_stop(void) {
|
||||
furi_hal_nfc_timer_stop(FuriHalNfcTimerBlockTx);
|
||||
}
|
||||
|
||||
bool furi_hal_nfc_timer_block_tx_is_running() {
|
||||
bool furi_hal_nfc_timer_block_tx_is_running(void) {
|
||||
return furi_hal_nfc_timer_is_running(FuriHalNfcTimerBlockTx);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#ifdef FURI_HAL_OS_DEBUG
|
||||
#include <stm32wbxx_ll_gpio.h>
|
||||
|
||||
void furi_hal_os_timer_callback() {
|
||||
void furi_hal_os_timer_callback(void) {
|
||||
furi_hal_gpio_write(
|
||||
FURI_HAL_OS_DEBUG_SECOND_GPIO, !furi_hal_gpio_read(FURI_HAL_OS_DEBUG_SECOND_GPIO));
|
||||
}
|
||||
@@ -55,7 +55,7 @@ extern void xPortSysTickHandler();
|
||||
|
||||
static volatile uint32_t furi_hal_os_skew;
|
||||
|
||||
void furi_hal_os_init() {
|
||||
void furi_hal_os_init(void) {
|
||||
furi_hal_idle_timer_init();
|
||||
|
||||
#ifdef FURI_HAL_OS_DEBUG
|
||||
@@ -72,7 +72,7 @@ void furi_hal_os_init() {
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
void furi_hal_os_tick() {
|
||||
void furi_hal_os_tick(void) {
|
||||
if(xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) {
|
||||
#ifdef FURI_HAL_OS_DEBUG
|
||||
furi_hal_gpio_write(
|
||||
@@ -84,7 +84,7 @@ void furi_hal_os_tick() {
|
||||
|
||||
#ifdef FURI_HAL_OS_DEBUG
|
||||
// Find out the IRQ number while debugging
|
||||
static void furi_hal_os_nvic_dbg_trap() {
|
||||
static void furi_hal_os_nvic_dbg_trap(void) {
|
||||
for(int32_t i = WWDG_IRQn; i <= DMAMUX1_OVR_IRQn; i++) {
|
||||
if(NVIC_GetPendingIRQ(i)) {
|
||||
(void)i;
|
||||
@@ -107,7 +107,7 @@ static void furi_hal_os_exti_dbg_trap(uint32_t exti, uint32_t val) {
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline bool furi_hal_os_is_pending_irq() {
|
||||
static inline bool furi_hal_os_is_pending_irq(void) {
|
||||
if(FURI_HAL_OS_NVIC_IS_PENDING()) {
|
||||
#ifdef FURI_HAL_OS_DEBUG
|
||||
furi_hal_os_nvic_dbg_trap();
|
||||
|
||||
@@ -9,11 +9,11 @@ extern "C" {
|
||||
/* Initialize OS helpers
|
||||
* Configure and start tick timer
|
||||
*/
|
||||
void furi_hal_os_init();
|
||||
void furi_hal_os_init(void);
|
||||
|
||||
/* Advance OS tick counter
|
||||
*/
|
||||
void furi_hal_os_tick();
|
||||
void furi_hal_os_tick(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ static volatile FuriHalPower furi_hal_power = {
|
||||
|
||||
extern const BQ27220DMData furi_hal_power_gauge_data_memory[];
|
||||
|
||||
void furi_hal_power_init() {
|
||||
void furi_hal_power_init(void) {
|
||||
#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);
|
||||
@@ -107,7 +107,7 @@ void furi_hal_power_init() {
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
bool furi_hal_power_gauge_is_ok() {
|
||||
bool furi_hal_power_gauge_is_ok(void) {
|
||||
bool ret = true;
|
||||
|
||||
BatteryStatus battery_status;
|
||||
@@ -129,7 +129,7 @@ bool furi_hal_power_gauge_is_ok() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool furi_hal_power_is_shutdown_requested() {
|
||||
bool furi_hal_power_is_shutdown_requested(void) {
|
||||
bool ret = false;
|
||||
|
||||
BatteryStatus battery_status;
|
||||
@@ -145,34 +145,34 @@ bool furi_hal_power_is_shutdown_requested() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint16_t furi_hal_power_insomnia_level() {
|
||||
uint16_t furi_hal_power_insomnia_level(void) {
|
||||
return furi_hal_power.insomnia;
|
||||
}
|
||||
|
||||
void furi_hal_power_insomnia_enter() {
|
||||
void furi_hal_power_insomnia_enter(void) {
|
||||
FURI_CRITICAL_ENTER();
|
||||
furi_assert(furi_hal_power.insomnia < UINT8_MAX);
|
||||
furi_check(furi_hal_power.insomnia < UINT8_MAX);
|
||||
furi_hal_power.insomnia++;
|
||||
FURI_CRITICAL_EXIT();
|
||||
}
|
||||
|
||||
void furi_hal_power_insomnia_exit() {
|
||||
void furi_hal_power_insomnia_exit(void) {
|
||||
FURI_CRITICAL_ENTER();
|
||||
furi_assert(furi_hal_power.insomnia > 0);
|
||||
furi_check(furi_hal_power.insomnia > 0);
|
||||
furi_hal_power.insomnia--;
|
||||
FURI_CRITICAL_EXIT();
|
||||
}
|
||||
|
||||
bool furi_hal_power_sleep_available() {
|
||||
bool furi_hal_power_sleep_available(void) {
|
||||
return furi_hal_power.insomnia == 0;
|
||||
}
|
||||
|
||||
static inline bool furi_hal_power_deep_sleep_available() {
|
||||
static inline bool furi_hal_power_deep_sleep_available(void) {
|
||||
return furi_hal_bt_is_alive() && !furi_hal_rtc_is_flag_set(FuriHalRtcFlagLegacySleep) &&
|
||||
!furi_hal_debug_is_gdb_session_active();
|
||||
}
|
||||
|
||||
static inline void furi_hal_power_light_sleep() {
|
||||
static inline void furi_hal_power_light_sleep(void) {
|
||||
#ifdef FURI_HAL_POWER_DEBUG
|
||||
furi_hal_gpio_write(FURI_HAL_POWER_DEBUG_WFI_GPIO, 1);
|
||||
#endif
|
||||
@@ -182,17 +182,17 @@ static inline void furi_hal_power_light_sleep() {
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void furi_hal_power_suspend_aux_periphs() {
|
||||
static inline void furi_hal_power_suspend_aux_periphs(void) {
|
||||
// Disable USART
|
||||
furi_hal_serial_control_suspend();
|
||||
}
|
||||
|
||||
static inline void furi_hal_power_resume_aux_periphs() {
|
||||
static inline void furi_hal_power_resume_aux_periphs(void) {
|
||||
// Re-enable USART
|
||||
furi_hal_serial_control_resume();
|
||||
}
|
||||
|
||||
static inline void furi_hal_power_deep_sleep() {
|
||||
static inline void furi_hal_power_deep_sleep(void) {
|
||||
furi_hal_power_suspend_aux_periphs();
|
||||
|
||||
if(!furi_hal_clock_switch_pll2hse()) {
|
||||
@@ -260,7 +260,7 @@ static inline void furi_hal_power_deep_sleep() {
|
||||
furi_hal_rtc_sync_shadow();
|
||||
}
|
||||
|
||||
void furi_hal_power_sleep() {
|
||||
void furi_hal_power_sleep(void) {
|
||||
if(furi_hal_power_deep_sleep_available()) {
|
||||
furi_hal_power_deep_sleep();
|
||||
} else {
|
||||
@@ -268,35 +268,35 @@ void furi_hal_power_sleep() {
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t furi_hal_power_get_pct() {
|
||||
uint8_t furi_hal_power_get_pct(void) {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
uint8_t ret = bq27220_get_state_of_charge(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint8_t furi_hal_power_get_bat_health_pct() {
|
||||
uint8_t furi_hal_power_get_bat_health_pct(void) {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
uint8_t ret = bq27220_get_state_of_health(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool furi_hal_power_is_charging() {
|
||||
bool furi_hal_power_is_charging(void) {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
bool ret = bq25896_is_charging(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool furi_hal_power_is_charging_done() {
|
||||
bool furi_hal_power_is_charging_done(void) {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
bool ret = bq25896_is_charging_done(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void furi_hal_power_shutdown() {
|
||||
void furi_hal_power_shutdown(void) {
|
||||
furi_hal_power_insomnia_enter();
|
||||
|
||||
furi_hal_bt_reinit();
|
||||
@@ -328,7 +328,7 @@ void furi_hal_power_shutdown() {
|
||||
furi_crash("Insomniac core2");
|
||||
}
|
||||
|
||||
void furi_hal_power_off() {
|
||||
void furi_hal_power_off(void) {
|
||||
// Crutch: shutting down with ext 3V3 off is causing LSE to stop
|
||||
furi_hal_power_enable_external_3_3v();
|
||||
furi_hal_vibro_on(true);
|
||||
@@ -340,11 +340,11 @@ void furi_hal_power_off() {
|
||||
furi_hal_vibro_on(false);
|
||||
}
|
||||
|
||||
void furi_hal_power_reset() {
|
||||
FURI_NORETURN void furi_hal_power_reset(void) {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
bool furi_hal_power_enable_otg() {
|
||||
bool furi_hal_power_enable_otg(void) {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
bq25896_set_boost_lim(&furi_hal_i2c_handle_power, BoostLim_2150);
|
||||
bq25896_enable_otg(&furi_hal_i2c_handle_power);
|
||||
@@ -355,20 +355,20 @@ bool furi_hal_power_enable_otg() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void furi_hal_power_disable_otg() {
|
||||
void furi_hal_power_disable_otg(void) {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
bq25896_disable_otg(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
}
|
||||
|
||||
bool furi_hal_power_is_otg_enabled() {
|
||||
bool furi_hal_power_is_otg_enabled(void) {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
bool ret = bq25896_is_otg_enabled(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
return ret;
|
||||
}
|
||||
|
||||
float furi_hal_power_get_battery_charge_voltage_limit() {
|
||||
float furi_hal_power_get_battery_charge_voltage_limit(void) {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
float ret = (float)bq25896_get_vreg_voltage(&furi_hal_i2c_handle_power) / 1000.0f;
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
@@ -382,35 +382,35 @@ void furi_hal_power_set_battery_charge_voltage_limit(float voltage) {
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
}
|
||||
|
||||
bool furi_hal_power_check_otg_fault() {
|
||||
bool furi_hal_power_check_otg_fault(void) {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
bool ret = bq25896_check_otg_fault(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void furi_hal_power_check_otg_status() {
|
||||
void furi_hal_power_check_otg_status(void) {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
if(bq25896_check_otg_fault(&furi_hal_i2c_handle_power))
|
||||
bq25896_disable_otg(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
}
|
||||
|
||||
uint32_t furi_hal_power_get_battery_remaining_capacity() {
|
||||
uint32_t furi_hal_power_get_battery_remaining_capacity(void) {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
uint32_t ret = bq27220_get_remaining_capacity(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t furi_hal_power_get_battery_full_capacity() {
|
||||
uint32_t furi_hal_power_get_battery_full_capacity(void) {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
uint32_t ret = bq27220_get_full_charge_capacity(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t furi_hal_power_get_battery_design_capacity() {
|
||||
uint32_t furi_hal_power_get_battery_design_capacity(void) {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
uint32_t ret = bq27220_get_design_capacity(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
@@ -425,6 +425,8 @@ float furi_hal_power_get_battery_voltage(FuriHalPowerIC ic) {
|
||||
ret = (float)bq25896_get_vbat_voltage(&furi_hal_i2c_handle_power) / 1000.0f;
|
||||
} else if(ic == FuriHalPowerICFuelGauge) {
|
||||
ret = (float)bq27220_get_voltage(&furi_hal_i2c_handle_power) / 1000.0f;
|
||||
} else {
|
||||
furi_crash();
|
||||
}
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
|
||||
@@ -439,6 +441,8 @@ float furi_hal_power_get_battery_current(FuriHalPowerIC ic) {
|
||||
ret = (float)bq25896_get_vbat_current(&furi_hal_i2c_handle_power) / 1000.0f;
|
||||
} else if(ic == FuriHalPowerICFuelGauge) {
|
||||
ret = (float)bq27220_get_current(&furi_hal_i2c_handle_power) / 1000.0f;
|
||||
} else {
|
||||
furi_crash();
|
||||
}
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
|
||||
@@ -466,22 +470,22 @@ float furi_hal_power_get_battery_temperature(FuriHalPowerIC ic) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
float furi_hal_power_get_usb_voltage() {
|
||||
float furi_hal_power_get_usb_voltage(void) {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
float ret = (float)bq25896_get_vbus_voltage(&furi_hal_i2c_handle_power) / 1000.0f;
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void furi_hal_power_enable_external_3_3v() {
|
||||
void furi_hal_power_enable_external_3_3v(void) {
|
||||
furi_hal_gpio_write(&gpio_periph_power, 1);
|
||||
}
|
||||
|
||||
void furi_hal_power_disable_external_3_3v() {
|
||||
void furi_hal_power_disable_external_3_3v(void) {
|
||||
furi_hal_gpio_write(&gpio_periph_power, 0);
|
||||
}
|
||||
|
||||
void furi_hal_power_suppress_charge_enter() {
|
||||
void furi_hal_power_suppress_charge_enter(void) {
|
||||
FURI_CRITICAL_ENTER();
|
||||
bool disable_charging = furi_hal_power.suppress_charge == 0;
|
||||
furi_hal_power.suppress_charge++;
|
||||
@@ -494,7 +498,7 @@ void furi_hal_power_suppress_charge_enter() {
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_power_suppress_charge_exit() {
|
||||
void furi_hal_power_suppress_charge_exit(void) {
|
||||
FURI_CRITICAL_ENTER();
|
||||
furi_hal_power.suppress_charge--;
|
||||
bool enable_charging = furi_hal_power.suppress_charge == 0;
|
||||
@@ -508,7 +512,7 @@ void furi_hal_power_suppress_charge_exit() {
|
||||
}
|
||||
|
||||
void furi_hal_power_info_get(PropertyValueCallback out, char sep, void* context) {
|
||||
furi_assert(out);
|
||||
furi_check(out);
|
||||
|
||||
FuriString* value = furi_string_alloc();
|
||||
FuriString* key = furi_string_alloc();
|
||||
@@ -581,7 +585,7 @@ void furi_hal_power_info_get(PropertyValueCallback out, char sep, void* context)
|
||||
}
|
||||
|
||||
void furi_hal_power_debug_get(PropertyValueCallback out, void* context) {
|
||||
furi_assert(out);
|
||||
furi_check(out);
|
||||
|
||||
FuriString* value = furi_string_alloc();
|
||||
FuriString* key = furi_string_alloc();
|
||||
|
||||
@@ -69,6 +69,8 @@ void furi_hal_pwm_start(FuriHalPwmOutputId channel, uint32_t freq, uint8_t duty)
|
||||
furi_hal_pwm_set_params(channel, freq, duty);
|
||||
|
||||
LL_LPTIM_StartCounter(LPTIM2, LL_LPTIM_OPERATING_MODE_CONTINUOUS);
|
||||
} else {
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +81,8 @@ void furi_hal_pwm_stop(FuriHalPwmOutputId channel) {
|
||||
} else if(channel == FuriHalPwmOutputIdLptim2PA4) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pa4, GpioModeAnalog);
|
||||
furi_hal_bus_disable(FuriHalBusLPTIM2);
|
||||
} else {
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +92,8 @@ bool furi_hal_pwm_is_running(FuriHalPwmOutputId channel) {
|
||||
} else if(channel == FuriHalPwmOutputIdLptim2PA4) {
|
||||
return furi_hal_bus_is_enabled(FuriHalBusLPTIM2);
|
||||
}
|
||||
return false;
|
||||
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
void furi_hal_pwm_set_params(FuriHalPwmOutputId channel, uint32_t freq, uint8_t duty) {
|
||||
@@ -134,5 +139,7 @@ void furi_hal_pwm_set_params(FuriHalPwmOutputId channel, uint32_t freq, uint8_t
|
||||
} else {
|
||||
LL_RCC_SetLPTIMClockSource(LL_RCC_LPTIM2_CLKSOURCE_PCLK1);
|
||||
}
|
||||
} else {
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#define TAG "FuriHalRandom"
|
||||
|
||||
static uint32_t furi_hal_random_read_rng() {
|
||||
static uint32_t furi_hal_random_read_rng(void) {
|
||||
while(LL_RNG_IsActiveFlag_CECS(RNG) && LL_RNG_IsActiveFlag_SECS(RNG) &&
|
||||
!LL_RNG_IsActiveFlag_DRDY(RNG)) {
|
||||
/* Error handling as described in RM0434, pg. 582-583 */
|
||||
@@ -33,12 +33,12 @@ static uint32_t furi_hal_random_read_rng() {
|
||||
return LL_RNG_ReadRandData32(RNG);
|
||||
}
|
||||
|
||||
void furi_hal_random_init() {
|
||||
void furi_hal_random_init(void) {
|
||||
furi_hal_bus_enable(FuriHalBusRNG);
|
||||
LL_RCC_SetRNGClockSource(LL_RCC_RNG_CLKSOURCE_CLK48);
|
||||
}
|
||||
|
||||
uint32_t furi_hal_random_get() {
|
||||
uint32_t furi_hal_random_get(void) {
|
||||
while(LL_HSEM_1StepLock(HSEM, CFG_HW_RNG_SEMID))
|
||||
;
|
||||
LL_RNG_Enable(RNG);
|
||||
@@ -53,6 +53,9 @@ uint32_t furi_hal_random_get() {
|
||||
}
|
||||
|
||||
void furi_hal_random_fill_buf(uint8_t* buf, uint32_t len) {
|
||||
furi_check(buf);
|
||||
furi_check(len);
|
||||
|
||||
while(LL_HSEM_1StepLock(HSEM, CFG_HW_RNG_SEMID))
|
||||
;
|
||||
LL_RNG_Enable(RNG);
|
||||
@@ -71,10 +74,10 @@ void srand(unsigned seed) {
|
||||
UNUSED(seed);
|
||||
}
|
||||
|
||||
int rand() {
|
||||
int rand(void) {
|
||||
return (furi_hal_random_get() & RAND_MAX);
|
||||
}
|
||||
|
||||
long random() {
|
||||
long random(void) {
|
||||
return (furi_hal_random_get() & RAND_MAX);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <furi_hal_region.h>
|
||||
#include <furi_hal_version.h>
|
||||
#include <furi.h>
|
||||
|
||||
const FuriHalRegion furi_hal_region_zero = {
|
||||
.country_code = "00",
|
||||
@@ -72,7 +73,7 @@ const FuriHalRegion furi_hal_region_jp = {
|
||||
|
||||
static const FuriHalRegion* furi_hal_region = NULL;
|
||||
|
||||
void furi_hal_region_init() {
|
||||
void furi_hal_region_init(void) {
|
||||
FuriHalVersionRegion region = furi_hal_version_get_hw_region();
|
||||
|
||||
if(region == FuriHalVersionRegionUnknown) {
|
||||
@@ -86,19 +87,21 @@ void furi_hal_region_init() {
|
||||
}
|
||||
}
|
||||
|
||||
const FuriHalRegion* furi_hal_region_get() {
|
||||
const FuriHalRegion* furi_hal_region_get(void) {
|
||||
return furi_hal_region;
|
||||
}
|
||||
|
||||
void furi_hal_region_set(FuriHalRegion* region) {
|
||||
furi_check(region);
|
||||
|
||||
furi_hal_region = region;
|
||||
}
|
||||
|
||||
bool furi_hal_region_is_provisioned() {
|
||||
bool furi_hal_region_is_provisioned(void) {
|
||||
return furi_hal_region != NULL;
|
||||
}
|
||||
|
||||
const char* furi_hal_region_get_name() {
|
||||
const char* furi_hal_region_get_name(void) {
|
||||
if(furi_hal_region) {
|
||||
return furi_hal_region->country_code;
|
||||
} else {
|
||||
|
||||
@@ -125,7 +125,7 @@ static void furi_hal_resources_init_gpio_pins(GpioMode mode) {
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_resources_init_early() {
|
||||
void furi_hal_resources_init_early(void) {
|
||||
furi_hal_bus_enable(FuriHalBusGPIOA);
|
||||
furi_hal_bus_enable(FuriHalBusGPIOB);
|
||||
furi_hal_bus_enable(FuriHalBusGPIOC);
|
||||
@@ -172,7 +172,7 @@ void furi_hal_resources_init_early() {
|
||||
furi_hal_resources_init_gpio_pins(GpioModeAnalog);
|
||||
}
|
||||
|
||||
void furi_hal_resources_deinit_early() {
|
||||
void furi_hal_resources_deinit_early(void) {
|
||||
furi_hal_resources_init_input_pins(GpioModeAnalog);
|
||||
furi_hal_bus_disable(FuriHalBusGPIOA);
|
||||
furi_hal_bus_disable(FuriHalBusGPIOB);
|
||||
@@ -182,7 +182,7 @@ void furi_hal_resources_deinit_early() {
|
||||
furi_hal_bus_disable(FuriHalBusGPIOH);
|
||||
}
|
||||
|
||||
void furi_hal_resources_init() {
|
||||
void furi_hal_resources_init(void) {
|
||||
// Button pins
|
||||
furi_hal_resources_init_input_pins(GpioModeInterruptRiseFall);
|
||||
|
||||
|
||||
@@ -214,11 +214,11 @@ extern const GpioPin gpio_usb_dp;
|
||||
#define NFC_IRQ_Pin RFID_PULL_Pin
|
||||
#define NFC_IRQ_GPIO_Port RFID_PULL_GPIO_Port
|
||||
|
||||
void furi_hal_resources_init_early();
|
||||
void furi_hal_resources_init_early(void);
|
||||
|
||||
void furi_hal_resources_deinit_early();
|
||||
void furi_hal_resources_deinit_early(void);
|
||||
|
||||
void furi_hal_resources_init();
|
||||
void furi_hal_resources_init(void);
|
||||
|
||||
/**
|
||||
* Get a corresponding external connector pin number for a gpio
|
||||
|
||||
@@ -67,8 +67,8 @@ FuriHalRfid* furi_hal_rfid = NULL;
|
||||
#define LFRFID_LL_EMULATE_TIM TIM2
|
||||
#define LFRFID_LL_EMULATE_CHANNEL LL_TIM_CHANNEL_CH3
|
||||
|
||||
void furi_hal_rfid_init() {
|
||||
furi_assert(furi_hal_rfid == NULL);
|
||||
void furi_hal_rfid_init(void) {
|
||||
furi_check(furi_hal_rfid == NULL);
|
||||
furi_hal_rfid = malloc(sizeof(FuriHalRfid));
|
||||
furi_hal_rfid->field.counter = 0;
|
||||
furi_hal_rfid->field.set_tim_counter_cnt = 0;
|
||||
@@ -95,7 +95,7 @@ void furi_hal_rfid_init() {
|
||||
NVIC_EnableIRQ(COMP_IRQn);
|
||||
}
|
||||
|
||||
void furi_hal_rfid_pins_reset() {
|
||||
void furi_hal_rfid_pins_reset(void) {
|
||||
// ibutton bus disable
|
||||
furi_hal_ibutton_pin_reset();
|
||||
|
||||
@@ -112,7 +112,7 @@ void furi_hal_rfid_pins_reset() {
|
||||
furi_hal_gpio_init(&gpio_rfid_data_in, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
}
|
||||
|
||||
static void furi_hal_rfid_pins_emulate() {
|
||||
static void furi_hal_rfid_pins_emulate(void) {
|
||||
// ibutton low
|
||||
furi_hal_ibutton_pin_configure();
|
||||
furi_hal_ibutton_pin_write(false);
|
||||
@@ -133,7 +133,7 @@ static void furi_hal_rfid_pins_emulate() {
|
||||
&gpio_rfid_carrier, GpioModeAltFunctionPushPull, GpioPullNo, GpioSpeedLow, GpioAltFn2TIM2);
|
||||
}
|
||||
|
||||
static void furi_hal_rfid_pins_read() {
|
||||
static void furi_hal_rfid_pins_read(void) {
|
||||
// ibutton low
|
||||
furi_hal_ibutton_pin_configure();
|
||||
furi_hal_ibutton_pin_write(false);
|
||||
@@ -154,7 +154,7 @@ static void furi_hal_rfid_pins_read() {
|
||||
furi_hal_gpio_init(&gpio_rfid_data_in, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
}
|
||||
|
||||
static void furi_hal_rfid_pins_field() {
|
||||
static void furi_hal_rfid_pins_field(void) {
|
||||
// ibutton low
|
||||
furi_hal_ibutton_pin_configure();
|
||||
furi_hal_ibutton_pin_write(false);
|
||||
@@ -171,11 +171,11 @@ static void furi_hal_rfid_pins_field() {
|
||||
&gpio_rfid_carrier, GpioModeAltFunctionPushPull, GpioPullNo, GpioSpeedLow, GpioAltFn2TIM2);
|
||||
}
|
||||
|
||||
void furi_hal_rfid_pin_pull_release() {
|
||||
void furi_hal_rfid_pin_pull_release(void) {
|
||||
furi_hal_gpio_write(&gpio_nfc_irq_rfid_pull, true);
|
||||
}
|
||||
|
||||
void furi_hal_rfid_pin_pull_pulldown() {
|
||||
void furi_hal_rfid_pin_pull_pulldown(void) {
|
||||
furi_hal_gpio_write(&gpio_nfc_irq_rfid_pull, false);
|
||||
}
|
||||
|
||||
@@ -201,19 +201,19 @@ void furi_hal_rfid_tim_read_start(float freq, float duty_cycle) {
|
||||
furi_hal_rfid_tim_read_continue();
|
||||
}
|
||||
|
||||
void furi_hal_rfid_tim_read_continue() {
|
||||
void furi_hal_rfid_tim_read_continue(void) {
|
||||
LL_TIM_EnableAllOutputs(FURI_HAL_RFID_READ_TIMER);
|
||||
}
|
||||
|
||||
void furi_hal_rfid_tim_read_pause() {
|
||||
void furi_hal_rfid_tim_read_pause(void) {
|
||||
LL_TIM_DisableAllOutputs(FURI_HAL_RFID_READ_TIMER);
|
||||
}
|
||||
|
||||
void furi_hal_rfid_tim_read_stop() {
|
||||
void furi_hal_rfid_tim_read_stop(void) {
|
||||
furi_hal_bus_disable(FURI_HAL_RFID_READ_TIMER_BUS);
|
||||
}
|
||||
|
||||
static void furi_hal_rfid_tim_emulate() {
|
||||
static void furi_hal_rfid_tim_emulate(void) {
|
||||
LL_TIM_SetPrescaler(FURI_HAL_RFID_EMULATE_TIMER, 0);
|
||||
LL_TIM_SetCounterMode(FURI_HAL_RFID_EMULATE_TIMER, LL_TIM_COUNTERMODE_UP);
|
||||
LL_TIM_SetAutoReload(FURI_HAL_RFID_EMULATE_TIMER, 1);
|
||||
@@ -258,7 +258,7 @@ static void furi_hal_capture_dma_isr(void* context) {
|
||||
}
|
||||
|
||||
void furi_hal_rfid_tim_read_capture_start(FuriHalRfidReadCaptureCallback callback, void* context) {
|
||||
furi_assert(furi_hal_rfid);
|
||||
furi_check(furi_hal_rfid);
|
||||
|
||||
furi_hal_rfid->read_capture_callback = callback;
|
||||
furi_hal_rfid->context = context;
|
||||
@@ -308,7 +308,7 @@ void furi_hal_rfid_tim_read_capture_start(FuriHalRfidReadCaptureCallback callbac
|
||||
furi_hal_rfid_comp_start();
|
||||
}
|
||||
|
||||
void furi_hal_rfid_tim_read_capture_stop() {
|
||||
void furi_hal_rfid_tim_read_capture_stop(void) {
|
||||
furi_hal_rfid_comp_stop();
|
||||
|
||||
furi_hal_interrupt_set_isr(FURI_HAL_RFID_EMULATE_TIMER_IRQ, NULL, NULL);
|
||||
@@ -338,7 +338,7 @@ void furi_hal_rfid_tim_emulate_dma_start(
|
||||
size_t length,
|
||||
FuriHalRfidDMACallback callback,
|
||||
void* context) {
|
||||
furi_assert(furi_hal_rfid);
|
||||
furi_check(furi_hal_rfid);
|
||||
|
||||
// setup interrupts
|
||||
furi_hal_rfid->dma_callback = callback;
|
||||
@@ -401,7 +401,7 @@ void furi_hal_rfid_tim_emulate_dma_start(
|
||||
LL_TIM_EnableCounter(FURI_HAL_RFID_EMULATE_TIMER);
|
||||
}
|
||||
|
||||
void furi_hal_rfid_tim_emulate_dma_stop() {
|
||||
void furi_hal_rfid_tim_emulate_dma_stop(void) {
|
||||
LL_TIM_DisableCounter(FURI_HAL_RFID_EMULATE_TIMER);
|
||||
LL_TIM_DisableAllOutputs(FURI_HAL_RFID_EMULATE_TIMER);
|
||||
|
||||
@@ -431,7 +431,7 @@ void furi_hal_rfid_set_read_pulse(uint32_t pulse) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void furi_hal_rfid_comp_start() {
|
||||
void furi_hal_rfid_comp_start(void) {
|
||||
LL_COMP_Enable(COMP1);
|
||||
// Magic
|
||||
uint32_t wait_loop_index = ((80 / 10UL) * ((SystemCoreClock / (100000UL * 2UL)) + 1UL));
|
||||
@@ -440,7 +440,7 @@ void furi_hal_rfid_comp_start() {
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_rfid_comp_stop() {
|
||||
void furi_hal_rfid_comp_stop(void) {
|
||||
LL_COMP_Disable(COMP1);
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ void furi_hal_rfid_comp_set_callback(FuriHalRfidCompCallback callback, void* con
|
||||
}
|
||||
|
||||
/* Comparator trigger event */
|
||||
void COMP_IRQHandler() {
|
||||
void COMP_IRQHandler(void) {
|
||||
if(LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_20)) {
|
||||
LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_20);
|
||||
}
|
||||
@@ -467,7 +467,7 @@ void COMP_IRQHandler() {
|
||||
}
|
||||
}
|
||||
|
||||
static void furi_hal_rfid_field_tim_setup() {
|
||||
static void furi_hal_rfid_field_tim_setup(void) {
|
||||
// setup timer counter
|
||||
furi_hal_bus_enable(FURI_HAL_RFID_FIELD_COUNTER_TIMER_BUS);
|
||||
|
||||
@@ -582,6 +582,8 @@ void furi_hal_rfid_field_detect_stop(void) {
|
||||
}
|
||||
|
||||
bool furi_hal_rfid_field_is_present(uint32_t* frequency) {
|
||||
furi_check(frequency);
|
||||
|
||||
*frequency = furi_hal_rfid->field.counter * 10;
|
||||
return (
|
||||
(*frequency >= FURI_HAL_RFID_FIELD_FREQUENCY_MIN) &&
|
||||
|
||||
@@ -15,19 +15,19 @@ extern "C" {
|
||||
|
||||
/** Initialize RFID subsystem
|
||||
*/
|
||||
void furi_hal_rfid_init();
|
||||
void furi_hal_rfid_init(void);
|
||||
|
||||
/** Config rfid pins to reset state
|
||||
*/
|
||||
void furi_hal_rfid_pins_reset();
|
||||
void furi_hal_rfid_pins_reset(void);
|
||||
|
||||
/** Release rfid pull pin
|
||||
*/
|
||||
void furi_hal_rfid_pin_pull_release();
|
||||
void furi_hal_rfid_pin_pull_release(void);
|
||||
|
||||
/** Pulldown rfid pull pin
|
||||
*/
|
||||
void furi_hal_rfid_pin_pull_pulldown();
|
||||
void furi_hal_rfid_pin_pull_pulldown(void);
|
||||
|
||||
/** Start read timer
|
||||
* @param freq timer frequency
|
||||
@@ -37,21 +37,21 @@ void furi_hal_rfid_tim_read_start(float freq, float duty_cycle);
|
||||
|
||||
/** Pause read timer, to be able to continue later
|
||||
*/
|
||||
void furi_hal_rfid_tim_read_pause();
|
||||
void furi_hal_rfid_tim_read_pause(void);
|
||||
|
||||
/** Continue read timer
|
||||
*/
|
||||
void furi_hal_rfid_tim_read_continue();
|
||||
void furi_hal_rfid_tim_read_continue(void);
|
||||
|
||||
/** Stop read timer
|
||||
*/
|
||||
void furi_hal_rfid_tim_read_stop();
|
||||
void furi_hal_rfid_tim_read_stop(void);
|
||||
|
||||
typedef void (*FuriHalRfidReadCaptureCallback)(bool level, uint32_t duration, void* context);
|
||||
|
||||
void furi_hal_rfid_tim_read_capture_start(FuriHalRfidReadCaptureCallback callback, void* context);
|
||||
|
||||
void furi_hal_rfid_tim_read_capture_stop();
|
||||
void furi_hal_rfid_tim_read_capture_stop(void);
|
||||
|
||||
typedef void (*FuriHalRfidDMACallback)(bool half, void* context);
|
||||
|
||||
@@ -62,7 +62,7 @@ void furi_hal_rfid_tim_emulate_dma_start(
|
||||
FuriHalRfidDMACallback callback,
|
||||
void* context);
|
||||
|
||||
void furi_hal_rfid_tim_emulate_dma_stop();
|
||||
void furi_hal_rfid_tim_emulate_dma_stop(void);
|
||||
|
||||
/** Set read timer period
|
||||
*
|
||||
@@ -77,10 +77,10 @@ void furi_hal_rfid_set_read_period(uint32_t period);
|
||||
void furi_hal_rfid_set_read_pulse(uint32_t pulse);
|
||||
|
||||
/** Start/Enable comparator */
|
||||
void furi_hal_rfid_comp_start();
|
||||
void furi_hal_rfid_comp_start(void);
|
||||
|
||||
/** Stop/Disable comparator */
|
||||
void furi_hal_rfid_comp_stop();
|
||||
void furi_hal_rfid_comp_stop(void);
|
||||
|
||||
typedef void (*FuriHalRfidCompCallback)(bool level, void* context);
|
||||
|
||||
@@ -88,10 +88,10 @@ typedef void (*FuriHalRfidCompCallback)(bool level, void* context);
|
||||
void furi_hal_rfid_comp_set_callback(FuriHalRfidCompCallback callback, void* context);
|
||||
|
||||
/** Start/Enable Field Presence detect */
|
||||
void furi_hal_rfid_field_detect_start();
|
||||
void furi_hal_rfid_field_detect_start(void);
|
||||
|
||||
/** Stop/Disable Field Presence detect */
|
||||
void furi_hal_rfid_field_detect_stop();
|
||||
void furi_hal_rfid_field_detect_stop(void);
|
||||
|
||||
/** Check Field Presence
|
||||
*
|
||||
|
||||
@@ -60,12 +60,12 @@ static const uint32_t furi_hal_rtc_log_baud_rates[] = {
|
||||
[FuriHalRtcLogBaudRate1843200] = 1843200,
|
||||
};
|
||||
|
||||
static void furi_hal_rtc_reset() {
|
||||
static void furi_hal_rtc_reset(void) {
|
||||
LL_RCC_ForceBackupDomainReset();
|
||||
LL_RCC_ReleaseBackupDomainReset();
|
||||
}
|
||||
|
||||
static bool furi_hal_rtc_start_clock_and_switch() {
|
||||
static bool furi_hal_rtc_start_clock_and_switch(void) {
|
||||
// Clock operation require access to Backup Domain
|
||||
LL_PWR_EnableBkUpAccess();
|
||||
|
||||
@@ -90,7 +90,7 @@ static bool furi_hal_rtc_start_clock_and_switch() {
|
||||
}
|
||||
}
|
||||
|
||||
static void furi_hal_rtc_recover() {
|
||||
static void furi_hal_rtc_recover(void) {
|
||||
DateTime datetime = {0};
|
||||
|
||||
// Handle fixable LSE failure
|
||||
@@ -127,7 +127,7 @@ static void furi_hal_rtc_recover() {
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_rtc_init_early() {
|
||||
void furi_hal_rtc_init_early(void) {
|
||||
// Enable RTCAPB clock
|
||||
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_RTCAPB);
|
||||
|
||||
@@ -151,10 +151,10 @@ void furi_hal_rtc_init_early() {
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_rtc_deinit_early() {
|
||||
void furi_hal_rtc_deinit_early(void) {
|
||||
}
|
||||
|
||||
void furi_hal_rtc_init() {
|
||||
void furi_hal_rtc_init(void) {
|
||||
LL_RTC_InitTypeDef RTC_InitStruct;
|
||||
RTC_InitStruct.HourFormat = LL_RTC_HOURFORMAT_24HOUR;
|
||||
RTC_InitStruct.AsynchPrescaler = 127;
|
||||
@@ -169,7 +169,7 @@ void furi_hal_rtc_init() {
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
void furi_hal_rtc_sync_shadow() {
|
||||
void furi_hal_rtc_sync_shadow(void) {
|
||||
if(!LL_RTC_IsShadowRegBypassEnabled(RTC)) {
|
||||
LL_RTC_ClearFlag_RS(RTC);
|
||||
while(!LL_RTC_IsActiveFlag_RS(RTC)) {
|
||||
@@ -177,7 +177,7 @@ void furi_hal_rtc_sync_shadow() {
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_rtc_reset_registers() {
|
||||
void furi_hal_rtc_reset_registers(void) {
|
||||
for(size_t i = 0; i < RTC_BKP_NUMBER; i++) {
|
||||
furi_hal_rtc_set_register(i, 0);
|
||||
}
|
||||
@@ -205,7 +205,7 @@ void furi_hal_rtc_set_log_level(uint8_t level) {
|
||||
furi_log_set_level(level);
|
||||
}
|
||||
|
||||
uint8_t furi_hal_rtc_get_log_level() {
|
||||
uint8_t furi_hal_rtc_get_log_level(void) {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
return data->log_level;
|
||||
@@ -222,7 +222,7 @@ void furi_hal_rtc_set_log_device(FuriHalRtcLogDevice device) {
|
||||
furi_hal_rtc_log_baud_rates[furi_hal_rtc_get_log_baud_rate()]);
|
||||
}
|
||||
|
||||
FuriHalRtcLogDevice furi_hal_rtc_get_log_device() {
|
||||
FuriHalRtcLogDevice furi_hal_rtc_get_log_device(void) {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
return data->log_device;
|
||||
@@ -239,7 +239,7 @@ void furi_hal_rtc_set_log_baud_rate(FuriHalRtcLogBaudRate baud_rate) {
|
||||
furi_hal_rtc_log_baud_rates[furi_hal_rtc_get_log_baud_rate()]);
|
||||
}
|
||||
|
||||
FuriHalRtcLogBaudRate furi_hal_rtc_get_log_baud_rate() {
|
||||
FuriHalRtcLogBaudRate furi_hal_rtc_get_log_baud_rate(void) {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
return data->log_baud_rate;
|
||||
@@ -280,7 +280,7 @@ void furi_hal_rtc_set_boot_mode(FuriHalRtcBootMode mode) {
|
||||
furi_hal_rtc_set_register(FuriHalRtcRegisterSystem, data_reg);
|
||||
}
|
||||
|
||||
FuriHalRtcBootMode furi_hal_rtc_get_boot_mode() {
|
||||
FuriHalRtcBootMode furi_hal_rtc_get_boot_mode(void) {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
return data->boot_mode;
|
||||
@@ -293,7 +293,7 @@ void furi_hal_rtc_set_heap_track_mode(FuriHalRtcHeapTrackMode mode) {
|
||||
furi_hal_rtc_set_register(FuriHalRtcRegisterSystem, data_reg);
|
||||
}
|
||||
|
||||
FuriHalRtcHeapTrackMode furi_hal_rtc_get_heap_track_mode() {
|
||||
FuriHalRtcHeapTrackMode furi_hal_rtc_get_heap_track_mode(void) {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
return data->heap_track_mode;
|
||||
@@ -306,7 +306,7 @@ void furi_hal_rtc_set_locale_units(FuriHalRtcLocaleUnits value) {
|
||||
furi_hal_rtc_set_register(FuriHalRtcRegisterSystem, data_reg);
|
||||
}
|
||||
|
||||
FuriHalRtcLocaleUnits furi_hal_rtc_get_locale_units() {
|
||||
FuriHalRtcLocaleUnits furi_hal_rtc_get_locale_units(void) {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
return data->locale_units;
|
||||
@@ -319,7 +319,7 @@ void furi_hal_rtc_set_locale_timeformat(FuriHalRtcLocaleTimeFormat value) {
|
||||
furi_hal_rtc_set_register(FuriHalRtcRegisterSystem, data_reg);
|
||||
}
|
||||
|
||||
FuriHalRtcLocaleTimeFormat furi_hal_rtc_get_locale_timeformat() {
|
||||
FuriHalRtcLocaleTimeFormat furi_hal_rtc_get_locale_timeformat(void) {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
return data->locale_timeformat;
|
||||
@@ -332,7 +332,7 @@ void furi_hal_rtc_set_locale_dateformat(FuriHalRtcLocaleDateFormat value) {
|
||||
furi_hal_rtc_set_register(FuriHalRtcRegisterSystem, data_reg);
|
||||
}
|
||||
|
||||
FuriHalRtcLocaleDateFormat furi_hal_rtc_get_locale_dateformat() {
|
||||
FuriHalRtcLocaleDateFormat furi_hal_rtc_get_locale_dateformat(void) {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
return data->locale_dateformat;
|
||||
@@ -340,7 +340,7 @@ FuriHalRtcLocaleDateFormat furi_hal_rtc_get_locale_dateformat() {
|
||||
|
||||
void furi_hal_rtc_set_datetime(DateTime* datetime) {
|
||||
furi_check(!FURI_IS_IRQ_MODE());
|
||||
furi_assert(datetime);
|
||||
furi_check(datetime);
|
||||
|
||||
FURI_CRITICAL_ENTER();
|
||||
/* Disable write protection */
|
||||
@@ -379,7 +379,7 @@ void furi_hal_rtc_set_datetime(DateTime* datetime) {
|
||||
|
||||
void furi_hal_rtc_get_datetime(DateTime* datetime) {
|
||||
furi_check(!FURI_IS_IRQ_MODE());
|
||||
furi_assert(datetime);
|
||||
furi_check(datetime);
|
||||
|
||||
FURI_CRITICAL_ENTER();
|
||||
uint32_t time = LL_RTC_TIME_Get(RTC); // 0x00HHMMSS
|
||||
@@ -399,7 +399,7 @@ void furi_hal_rtc_set_fault_data(uint32_t value) {
|
||||
furi_hal_rtc_set_register(FuriHalRtcRegisterFaultData, value);
|
||||
}
|
||||
|
||||
uint32_t furi_hal_rtc_get_fault_data() {
|
||||
uint32_t furi_hal_rtc_get_fault_data(void) {
|
||||
return furi_hal_rtc_get_register(FuriHalRtcRegisterFaultData);
|
||||
}
|
||||
|
||||
@@ -407,11 +407,11 @@ void furi_hal_rtc_set_pin_fails(uint32_t value) {
|
||||
furi_hal_rtc_set_register(FuriHalRtcRegisterPinFails, value);
|
||||
}
|
||||
|
||||
uint32_t furi_hal_rtc_get_pin_fails() {
|
||||
uint32_t furi_hal_rtc_get_pin_fails(void) {
|
||||
return furi_hal_rtc_get_register(FuriHalRtcRegisterPinFails);
|
||||
}
|
||||
|
||||
uint32_t furi_hal_rtc_get_timestamp() {
|
||||
uint32_t furi_hal_rtc_get_timestamp(void) {
|
||||
DateTime datetime = {0};
|
||||
furi_hal_rtc_get_datetime(&datetime);
|
||||
return datetime_datetime_to_timestamp(&datetime);
|
||||
|
||||
@@ -100,7 +100,7 @@ void furi_hal_rtc_init(void);
|
||||
void furi_hal_rtc_sync_shadow(void);
|
||||
|
||||
/** Reset ALL RTC registers content */
|
||||
void furi_hal_rtc_reset_registers();
|
||||
void furi_hal_rtc_reset_registers(void);
|
||||
|
||||
/** Get RTC register content
|
||||
*
|
||||
|
||||
@@ -206,17 +206,17 @@ typedef struct {
|
||||
/** Pointer to currently used SPI Handle */
|
||||
FuriHalSpiBusHandle* furi_hal_sd_spi_handle = NULL;
|
||||
|
||||
static inline void sd_spi_select_card() {
|
||||
static inline void sd_spi_select_card(void) {
|
||||
furi_hal_gpio_write(furi_hal_sd_spi_handle->cs, false);
|
||||
furi_delay_us(10); // Entry guard time for some SD cards
|
||||
}
|
||||
|
||||
static inline void sd_spi_deselect_card() {
|
||||
static inline void sd_spi_deselect_card(void) {
|
||||
furi_delay_us(10); // Exit guard time for some SD cards
|
||||
furi_hal_gpio_write(furi_hal_sd_spi_handle->cs, true);
|
||||
}
|
||||
|
||||
static void sd_spi_bus_to_ground() {
|
||||
static void sd_spi_bus_to_ground(void) {
|
||||
furi_hal_gpio_init_ex(
|
||||
furi_hal_sd_spi_handle->miso,
|
||||
GpioModeOutputPushPull,
|
||||
@@ -242,7 +242,7 @@ static void sd_spi_bus_to_ground() {
|
||||
furi_hal_gpio_write(furi_hal_sd_spi_handle->sck, false);
|
||||
}
|
||||
|
||||
static void sd_spi_bus_rise_up() {
|
||||
static void sd_spi_bus_rise_up(void) {
|
||||
sd_spi_deselect_card();
|
||||
|
||||
furi_hal_gpio_init_ex(
|
||||
@@ -329,12 +329,12 @@ static FuriStatus sd_spi_wait_for_data(uint8_t data, uint32_t timeout_ms) {
|
||||
return FuriStatusOk;
|
||||
}
|
||||
|
||||
static inline void sd_spi_deselect_card_and_purge() {
|
||||
static inline void sd_spi_deselect_card_and_purge(void) {
|
||||
sd_spi_deselect_card();
|
||||
sd_spi_read_byte();
|
||||
}
|
||||
|
||||
static inline void sd_spi_purge_crc() {
|
||||
static inline void sd_spi_purge_crc(void) {
|
||||
sd_spi_read_byte();
|
||||
sd_spi_read_byte();
|
||||
}
|
||||
@@ -833,7 +833,7 @@ static inline void sd_cache_invalidate_range(uint32_t start_sector, uint32_t end
|
||||
sector_cache_invalidate_range(start_sector, end_sector);
|
||||
}
|
||||
|
||||
static inline void sd_cache_invalidate_all() {
|
||||
static inline void sd_cache_invalidate_all(void) {
|
||||
sector_cache_init();
|
||||
}
|
||||
|
||||
@@ -907,7 +907,7 @@ bool furi_hal_sd_is_present(void) {
|
||||
return result;
|
||||
}
|
||||
|
||||
uint8_t furi_hal_sd_max_mount_retry_count() {
|
||||
uint8_t furi_hal_sd_max_mount_retry_count(void) {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@@ -972,6 +972,8 @@ FuriStatus furi_hal_sd_get_card_state(void) {
|
||||
}
|
||||
|
||||
FuriStatus furi_hal_sd_read_blocks(uint32_t* buff, uint32_t sector, uint32_t count) {
|
||||
furi_check(buff);
|
||||
|
||||
FuriStatus status;
|
||||
bool single_sector = count == 1;
|
||||
|
||||
@@ -1009,6 +1011,8 @@ FuriStatus furi_hal_sd_read_blocks(uint32_t* buff, uint32_t sector, uint32_t cou
|
||||
}
|
||||
|
||||
FuriStatus furi_hal_sd_write_blocks(const uint32_t* buff, uint32_t sector, uint32_t count) {
|
||||
furi_check(buff);
|
||||
|
||||
FuriStatus status;
|
||||
|
||||
sd_cache_invalidate_range(sector, sector + count);
|
||||
@@ -1037,6 +1041,8 @@ FuriStatus furi_hal_sd_write_blocks(const uint32_t* buff, uint32_t sector, uint3
|
||||
}
|
||||
|
||||
FuriStatus furi_hal_sd_info(FuriHalSdInfo* info) {
|
||||
furi_check(info);
|
||||
|
||||
FuriStatus status;
|
||||
SD_CSD csd;
|
||||
SD_CID cid;
|
||||
|
||||
@@ -658,6 +658,7 @@ void furi_hal_serial_resume(FuriHalSerialHandle* handle) {
|
||||
|
||||
void furi_hal_serial_tx(FuriHalSerialHandle* handle, const uint8_t* buffer, size_t buffer_size) {
|
||||
furi_check(handle);
|
||||
|
||||
if(handle->id == FuriHalSerialIdUsart) {
|
||||
if(LL_USART_IsEnabled(USART1) == 0) return;
|
||||
|
||||
@@ -787,7 +788,7 @@ void furi_hal_serial_async_rx_stop(FuriHalSerialHandle* handle) {
|
||||
|
||||
bool furi_hal_serial_async_rx_available(FuriHalSerialHandle* handle) {
|
||||
furi_check(FURI_IS_IRQ_MODE());
|
||||
furi_assert(handle->id < FuriHalSerialIdMax);
|
||||
furi_check(handle->id < FuriHalSerialIdMax);
|
||||
|
||||
if(handle->id == FuriHalSerialIdUsart) {
|
||||
return LL_USART_IsActiveFlag_RXNE_RXFNE(USART1);
|
||||
@@ -798,7 +799,7 @@ bool furi_hal_serial_async_rx_available(FuriHalSerialHandle* handle) {
|
||||
|
||||
uint8_t furi_hal_serial_async_rx(FuriHalSerialHandle* handle) {
|
||||
furi_check(FURI_IS_IRQ_MODE());
|
||||
furi_assert(handle->id < FuriHalSerialIdMax);
|
||||
furi_check(handle->id < FuriHalSerialIdMax);
|
||||
|
||||
if(handle->id == FuriHalSerialIdUsart) {
|
||||
return LL_USART_ReceiveData8(USART1);
|
||||
@@ -841,7 +842,7 @@ static uint8_t furi_hal_serial_dma_rx_read_byte(FuriHalSerialHandle* handle) {
|
||||
|
||||
size_t furi_hal_serial_dma_rx(FuriHalSerialHandle* handle, uint8_t* data, size_t len) {
|
||||
furi_check(FURI_IS_IRQ_MODE());
|
||||
furi_assert(furi_hal_serial[handle->id].buffer_rx_ptr != NULL);
|
||||
furi_check(furi_hal_serial[handle->id].buffer_rx_ptr != NULL);
|
||||
size_t i = 0;
|
||||
size_t available = furi_hal_serial_dma_bytes_available(handle->id);
|
||||
if(available < len) {
|
||||
|
||||
@@ -18,13 +18,13 @@ static FuriMutex* furi_hal_speaker_mutex = NULL;
|
||||
|
||||
// #define FURI_HAL_SPEAKER_NEW_VOLUME
|
||||
|
||||
void furi_hal_speaker_init() {
|
||||
void furi_hal_speaker_init(void) {
|
||||
furi_assert(furi_hal_speaker_mutex == NULL);
|
||||
furi_hal_speaker_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
void furi_hal_speaker_deinit() {
|
||||
void furi_hal_speaker_deinit(void) {
|
||||
furi_check(furi_hal_speaker_mutex != NULL);
|
||||
furi_mutex_free(furi_hal_speaker_mutex);
|
||||
furi_hal_speaker_mutex = NULL;
|
||||
@@ -44,7 +44,7 @@ bool furi_hal_speaker_acquire(uint32_t timeout) {
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_speaker_release() {
|
||||
void furi_hal_speaker_release(void) {
|
||||
furi_check(!FURI_IS_IRQ_MODE());
|
||||
furi_check(furi_hal_speaker_is_mine());
|
||||
|
||||
@@ -57,7 +57,7 @@ void furi_hal_speaker_release() {
|
||||
furi_check(furi_mutex_release(furi_hal_speaker_mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
bool furi_hal_speaker_is_mine() {
|
||||
bool furi_hal_speaker_is_mine(void) {
|
||||
return (FURI_IS_IRQ_MODE()) ||
|
||||
(furi_mutex_get_owner(furi_hal_speaker_mutex) == furi_thread_get_current_id());
|
||||
}
|
||||
@@ -132,7 +132,7 @@ void furi_hal_speaker_set_volume(float volume) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void furi_hal_speaker_stop() {
|
||||
void furi_hal_speaker_stop(void) {
|
||||
furi_check(furi_hal_speaker_is_mine());
|
||||
LL_TIM_DisableAllOutputs(FURI_HAL_SPEAKER_TIMER);
|
||||
LL_TIM_DisableCounter(FURI_HAL_SPEAKER_TIMER);
|
||||
|
||||
@@ -23,48 +23,48 @@
|
||||
static FuriSemaphore* spi_dma_lock = NULL;
|
||||
static FuriSemaphore* spi_dma_completed = NULL;
|
||||
|
||||
void furi_hal_spi_dma_init() {
|
||||
void furi_hal_spi_dma_init(void) {
|
||||
spi_dma_lock = furi_semaphore_alloc(1, 1);
|
||||
spi_dma_completed = furi_semaphore_alloc(1, 1);
|
||||
}
|
||||
|
||||
void furi_hal_spi_bus_init(FuriHalSpiBus* bus) {
|
||||
furi_assert(bus);
|
||||
furi_check(bus);
|
||||
bus->callback(bus, FuriHalSpiBusEventInit);
|
||||
}
|
||||
|
||||
void furi_hal_spi_bus_deinit(FuriHalSpiBus* bus) {
|
||||
furi_assert(bus);
|
||||
furi_check(bus);
|
||||
bus->callback(bus, FuriHalSpiBusEventDeinit);
|
||||
}
|
||||
|
||||
void furi_hal_spi_bus_handle_init(FuriHalSpiBusHandle* handle) {
|
||||
furi_assert(handle);
|
||||
furi_check(handle);
|
||||
handle->callback(handle, FuriHalSpiBusHandleEventInit);
|
||||
}
|
||||
|
||||
void furi_hal_spi_bus_handle_deinit(FuriHalSpiBusHandle* handle) {
|
||||
furi_assert(handle);
|
||||
furi_check(handle);
|
||||
handle->callback(handle, FuriHalSpiBusHandleEventDeinit);
|
||||
}
|
||||
|
||||
void furi_hal_spi_acquire(FuriHalSpiBusHandle* handle) {
|
||||
furi_assert(handle);
|
||||
furi_check(handle);
|
||||
|
||||
furi_hal_power_insomnia_enter();
|
||||
|
||||
handle->bus->callback(handle->bus, FuriHalSpiBusEventLock);
|
||||
handle->bus->callback(handle->bus, FuriHalSpiBusEventActivate);
|
||||
|
||||
furi_assert(handle->bus->current_handle == NULL);
|
||||
furi_check(handle->bus->current_handle == NULL);
|
||||
|
||||
handle->bus->current_handle = handle;
|
||||
handle->callback(handle, FuriHalSpiBusHandleEventActivate);
|
||||
}
|
||||
|
||||
void furi_hal_spi_release(FuriHalSpiBusHandle* handle) {
|
||||
furi_assert(handle);
|
||||
furi_assert(handle->bus->current_handle == handle);
|
||||
furi_check(handle);
|
||||
furi_check(handle->bus->current_handle == handle);
|
||||
|
||||
// Handle event and unset handle
|
||||
handle->callback(handle, FuriHalSpiBusHandleEventDeactivate);
|
||||
@@ -93,10 +93,10 @@ bool furi_hal_spi_bus_rx(
|
||||
uint8_t* buffer,
|
||||
size_t size,
|
||||
uint32_t timeout) {
|
||||
furi_assert(handle);
|
||||
furi_assert(handle->bus->current_handle == handle);
|
||||
furi_assert(buffer);
|
||||
furi_assert(size > 0);
|
||||
furi_check(handle);
|
||||
furi_check(handle->bus->current_handle == handle);
|
||||
furi_check(buffer);
|
||||
furi_check(size > 0);
|
||||
|
||||
return furi_hal_spi_bus_trx(handle, buffer, buffer, size, timeout);
|
||||
}
|
||||
@@ -106,10 +106,11 @@ bool furi_hal_spi_bus_tx(
|
||||
const uint8_t* buffer,
|
||||
size_t size,
|
||||
uint32_t timeout) {
|
||||
furi_assert(handle);
|
||||
furi_assert(handle->bus->current_handle == handle);
|
||||
furi_assert(buffer);
|
||||
furi_assert(size > 0);
|
||||
furi_check(handle);
|
||||
furi_check(handle->bus->current_handle == handle);
|
||||
furi_check(buffer);
|
||||
furi_check(size > 0);
|
||||
|
||||
bool ret = true;
|
||||
|
||||
while(size > 0) {
|
||||
@@ -132,9 +133,9 @@ bool furi_hal_spi_bus_trx(
|
||||
uint8_t* rx_buffer,
|
||||
size_t size,
|
||||
uint32_t timeout) {
|
||||
furi_assert(handle);
|
||||
furi_assert(handle->bus->current_handle == handle);
|
||||
furi_assert(size > 0);
|
||||
furi_check(handle);
|
||||
furi_check(handle->bus->current_handle == handle);
|
||||
furi_check(size > 0);
|
||||
|
||||
bool ret = true;
|
||||
size_t tx_size = size;
|
||||
@@ -196,9 +197,9 @@ bool furi_hal_spi_bus_trx_dma(
|
||||
uint8_t* rx_buffer,
|
||||
size_t size,
|
||||
uint32_t timeout_ms) {
|
||||
furi_assert(handle);
|
||||
furi_assert(handle->bus->current_handle == handle);
|
||||
furi_assert(size > 0);
|
||||
furi_check(handle);
|
||||
furi_check(handle->bus->current_handle == handle);
|
||||
furi_check(size > 0);
|
||||
|
||||
// If scheduler is not running, use blocking mode
|
||||
if(furi_kernel_is_running()) {
|
||||
|
||||
@@ -77,17 +77,17 @@ const LL_SPI_InitTypeDef furi_hal_spi_preset_1edge_low_2m = {
|
||||
|
||||
FuriMutex* furi_hal_spi_bus_r_mutex = NULL;
|
||||
|
||||
void furi_hal_spi_config_init_early() {
|
||||
void furi_hal_spi_config_init_early(void) {
|
||||
furi_hal_spi_bus_init(&furi_hal_spi_bus_d);
|
||||
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_display);
|
||||
}
|
||||
|
||||
void furi_hal_spi_config_deinit_early() {
|
||||
void furi_hal_spi_config_deinit_early(void) {
|
||||
furi_hal_spi_bus_handle_deinit(&furi_hal_spi_bus_handle_display);
|
||||
furi_hal_spi_bus_deinit(&furi_hal_spi_bus_d);
|
||||
}
|
||||
|
||||
void furi_hal_spi_config_init() {
|
||||
void furi_hal_spi_config_init(void) {
|
||||
furi_hal_spi_bus_init(&furi_hal_spi_bus_r);
|
||||
|
||||
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_subghz);
|
||||
|
||||
@@ -62,12 +62,12 @@ void furi_hal_subghz_set_async_mirror_pin(const GpioPin* pin) {
|
||||
furi_hal_subghz.async_mirror_pin = pin;
|
||||
}
|
||||
|
||||
const GpioPin* furi_hal_subghz_get_data_gpio() {
|
||||
const GpioPin* furi_hal_subghz_get_data_gpio(void) {
|
||||
return &gpio_cc1101_g0;
|
||||
}
|
||||
|
||||
void furi_hal_subghz_init() {
|
||||
furi_assert(furi_hal_subghz.state == SubGhzStateInit);
|
||||
void furi_hal_subghz_init(void) {
|
||||
furi_check(furi_hal_subghz.state == SubGhzStateInit);
|
||||
furi_hal_subghz.state = SubGhzStateBroken;
|
||||
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||
@@ -135,8 +135,9 @@ void furi_hal_subghz_init() {
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_subghz_sleep() {
|
||||
furi_assert(furi_hal_subghz.state == SubGhzStateIdle);
|
||||
void furi_hal_subghz_sleep(void) {
|
||||
furi_check(furi_hal_subghz.state == SubGhzStateIdle);
|
||||
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||
|
||||
cc1101_switch_to_idle(&furi_hal_spi_bus_handle_subghz);
|
||||
@@ -149,7 +150,7 @@ void furi_hal_subghz_sleep() {
|
||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||
}
|
||||
|
||||
void furi_hal_subghz_dump_state() {
|
||||
void furi_hal_subghz_dump_state(void) {
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||
printf(
|
||||
"[furi_hal_subghz] cc1101 chip %d, version %d\r\n",
|
||||
@@ -159,6 +160,8 @@ void furi_hal_subghz_dump_state() {
|
||||
}
|
||||
|
||||
void furi_hal_subghz_load_custom_preset(const uint8_t* preset_data) {
|
||||
furi_check(preset_data);
|
||||
|
||||
//load config
|
||||
furi_hal_subghz_reset();
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||
@@ -189,6 +192,8 @@ void furi_hal_subghz_load_custom_preset(const uint8_t* preset_data) {
|
||||
}
|
||||
|
||||
void furi_hal_subghz_load_registers(const uint8_t* data) {
|
||||
furi_check(data);
|
||||
|
||||
furi_hal_subghz_reset();
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||
uint32_t i = 0;
|
||||
@@ -200,12 +205,17 @@ void furi_hal_subghz_load_registers(const uint8_t* data) {
|
||||
}
|
||||
|
||||
void furi_hal_subghz_load_patable(const uint8_t data[8]) {
|
||||
furi_check(data);
|
||||
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||
cc1101_set_pa_table(&furi_hal_spi_bus_handle_subghz, data);
|
||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||
}
|
||||
|
||||
void furi_hal_subghz_write_packet(const uint8_t* data, uint8_t size) {
|
||||
furi_check(data);
|
||||
furi_check(size);
|
||||
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||
cc1101_flush_tx(&furi_hal_spi_bus_handle_subghz);
|
||||
cc1101_write_reg(&furi_hal_spi_bus_handle_subghz, CC1101_FIFO, size);
|
||||
@@ -213,19 +223,19 @@ void furi_hal_subghz_write_packet(const uint8_t* data, uint8_t size) {
|
||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||
}
|
||||
|
||||
void furi_hal_subghz_flush_rx() {
|
||||
void furi_hal_subghz_flush_rx(void) {
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||
cc1101_flush_rx(&furi_hal_spi_bus_handle_subghz);
|
||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||
}
|
||||
|
||||
void furi_hal_subghz_flush_tx() {
|
||||
void furi_hal_subghz_flush_tx(void) {
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||
cc1101_flush_tx(&furi_hal_spi_bus_handle_subghz);
|
||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||
}
|
||||
|
||||
bool furi_hal_subghz_rx_pipe_not_empty() {
|
||||
bool furi_hal_subghz_rx_pipe_not_empty(void) {
|
||||
CC1101RxBytes status[1];
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||
cc1101_read_reg(
|
||||
@@ -238,7 +248,7 @@ bool furi_hal_subghz_rx_pipe_not_empty() {
|
||||
}
|
||||
}
|
||||
|
||||
bool furi_hal_subghz_is_rx_data_crc_valid() {
|
||||
bool furi_hal_subghz_is_rx_data_crc_valid(void) {
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||
uint8_t data[1];
|
||||
cc1101_read_reg(&furi_hal_spi_bus_handle_subghz, CC1101_STATUS_LQI | CC1101_BURST, data);
|
||||
@@ -251,19 +261,22 @@ bool furi_hal_subghz_is_rx_data_crc_valid() {
|
||||
}
|
||||
|
||||
void furi_hal_subghz_read_packet(uint8_t* data, uint8_t* size) {
|
||||
furi_check(data);
|
||||
furi_check(size);
|
||||
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||
cc1101_read_fifo(&furi_hal_spi_bus_handle_subghz, data, size);
|
||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||
}
|
||||
|
||||
void furi_hal_subghz_shutdown() {
|
||||
void furi_hal_subghz_shutdown(void) {
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||
// Reset and shutdown
|
||||
cc1101_shutdown(&furi_hal_spi_bus_handle_subghz);
|
||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||
}
|
||||
|
||||
void furi_hal_subghz_reset() {
|
||||
void furi_hal_subghz_reset(void) {
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
cc1101_switch_to_idle(&furi_hal_spi_bus_handle_subghz);
|
||||
@@ -273,7 +286,7 @@ void furi_hal_subghz_reset() {
|
||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||
}
|
||||
|
||||
void furi_hal_subghz_idle() {
|
||||
void furi_hal_subghz_idle(void) {
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||
cc1101_switch_to_idle(&furi_hal_spi_bus_handle_subghz);
|
||||
//waiting for the chip to switch to IDLE mode
|
||||
@@ -281,7 +294,7 @@ void furi_hal_subghz_idle() {
|
||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||
}
|
||||
|
||||
void furi_hal_subghz_rx() {
|
||||
void furi_hal_subghz_rx(void) {
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||
cc1101_switch_to_rx(&furi_hal_spi_bus_handle_subghz);
|
||||
//waiting for the chip to switch to Rx mode
|
||||
@@ -289,7 +302,7 @@ void furi_hal_subghz_rx() {
|
||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||
}
|
||||
|
||||
bool furi_hal_subghz_tx() {
|
||||
bool furi_hal_subghz_tx(void) {
|
||||
if(furi_hal_subghz.regulation != SubGhzRegulationTxRx) return false;
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||
cc1101_switch_to_tx(&furi_hal_spi_bus_handle_subghz);
|
||||
@@ -299,7 +312,7 @@ bool furi_hal_subghz_tx() {
|
||||
return true;
|
||||
}
|
||||
|
||||
float furi_hal_subghz_get_rssi() {
|
||||
float furi_hal_subghz_get_rssi(void) {
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||
int32_t rssi_dec = cc1101_get_rssi(&furi_hal_spi_bus_handle_subghz);
|
||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||
@@ -314,7 +327,7 @@ float furi_hal_subghz_get_rssi() {
|
||||
return rssi;
|
||||
}
|
||||
|
||||
uint8_t furi_hal_subghz_get_lqi() {
|
||||
uint8_t furi_hal_subghz_get_lqi(void) {
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||
uint8_t data[1];
|
||||
cc1101_read_reg(&furi_hal_spi_bus_handle_subghz, CC1101_STATUS_LQI | CC1101_BURST, data);
|
||||
@@ -385,7 +398,7 @@ void furi_hal_subghz_set_path(FuriHalSubGhzPath path) {
|
||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||
}
|
||||
|
||||
static bool furi_hal_subghz_start_debug() {
|
||||
static bool furi_hal_subghz_start_debug(void) {
|
||||
bool ret = false;
|
||||
if(furi_hal_subghz.async_mirror_pin != NULL) {
|
||||
furi_hal_gpio_write(furi_hal_subghz.async_mirror_pin, false);
|
||||
@@ -399,7 +412,7 @@ static bool furi_hal_subghz_start_debug() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool furi_hal_subghz_stop_debug() {
|
||||
static bool furi_hal_subghz_stop_debug(void) {
|
||||
bool ret = false;
|
||||
if(furi_hal_subghz.async_mirror_pin != NULL) {
|
||||
furi_hal_gpio_init(
|
||||
@@ -445,7 +458,9 @@ static void furi_hal_subghz_capture_ISR(void* context) {
|
||||
}
|
||||
|
||||
void furi_hal_subghz_start_async_rx(FuriHalSubGhzCaptureCallback callback, void* context) {
|
||||
furi_assert(furi_hal_subghz.state == SubGhzStateIdle);
|
||||
furi_check(furi_hal_subghz.state == SubGhzStateIdle);
|
||||
furi_check(callback);
|
||||
|
||||
furi_hal_subghz.state = SubGhzStateAsyncRx;
|
||||
|
||||
furi_hal_subghz_capture_callback = callback;
|
||||
@@ -511,8 +526,8 @@ void furi_hal_subghz_start_async_rx(FuriHalSubGhzCaptureCallback callback, void*
|
||||
furi_hal_subghz_capture_delta_duration = 0;
|
||||
}
|
||||
|
||||
void furi_hal_subghz_stop_async_rx() {
|
||||
furi_assert(furi_hal_subghz.state == SubGhzStateAsyncRx);
|
||||
void furi_hal_subghz_stop_async_rx(void) {
|
||||
furi_check(furi_hal_subghz.state == SubGhzStateAsyncRx);
|
||||
furi_hal_subghz.state = SubGhzStateIdle;
|
||||
|
||||
// Shutdown radio
|
||||
@@ -610,7 +625,7 @@ static inline uint32_t furi_hal_subghz_async_tx_middleware_get_duration(
|
||||
}
|
||||
|
||||
static void furi_hal_subghz_async_tx_refill(uint32_t* buffer, size_t samples) {
|
||||
furi_assert(furi_hal_subghz.state == SubGhzStateAsyncTx);
|
||||
furi_check(furi_hal_subghz.state == SubGhzStateAsyncTx);
|
||||
|
||||
while(samples > 0) {
|
||||
volatile uint32_t duration = furi_hal_subghz_async_tx_middleware_get_duration(
|
||||
@@ -650,7 +665,7 @@ static void furi_hal_subghz_async_tx_refill(uint32_t* buffer, size_t samples) {
|
||||
|
||||
static void furi_hal_subghz_async_tx_dma_isr(void* context) {
|
||||
UNUSED(context);
|
||||
furi_assert(furi_hal_subghz.state == SubGhzStateAsyncTx);
|
||||
furi_check(furi_hal_subghz.state == SubGhzStateAsyncTx);
|
||||
|
||||
#if SUBGHZ_DMA_CH1_CHANNEL == LL_DMA_CHANNEL_1
|
||||
if(LL_DMA_IsActiveFlag_HT1(SUBGHZ_DMA)) {
|
||||
@@ -670,8 +685,8 @@ static void furi_hal_subghz_async_tx_dma_isr(void* context) {
|
||||
}
|
||||
|
||||
bool furi_hal_subghz_start_async_tx(FuriHalSubGhzAsyncTxCallback callback, void* context) {
|
||||
furi_assert(furi_hal_subghz.state == SubGhzStateIdle);
|
||||
furi_assert(callback);
|
||||
furi_check(furi_hal_subghz.state == SubGhzStateIdle);
|
||||
furi_check(callback);
|
||||
|
||||
//If transmission is prohibited by regional settings
|
||||
if(furi_hal_subghz.regulation != SubGhzRegulationTxRx) return false;
|
||||
@@ -773,12 +788,12 @@ bool furi_hal_subghz_start_async_tx(FuriHalSubGhzAsyncTxCallback callback, void*
|
||||
return true;
|
||||
}
|
||||
|
||||
bool furi_hal_subghz_is_async_tx_complete() {
|
||||
bool furi_hal_subghz_is_async_tx_complete(void) {
|
||||
return (furi_hal_subghz.state == SubGhzStateAsyncTx) && (LL_TIM_GetAutoReload(TIM2) == 0);
|
||||
}
|
||||
|
||||
void furi_hal_subghz_stop_async_tx() {
|
||||
furi_assert(furi_hal_subghz.state == SubGhzStateAsyncTx);
|
||||
void furi_hal_subghz_stop_async_tx(void) {
|
||||
furi_check(furi_hal_subghz.state == SubGhzStateAsyncTx);
|
||||
|
||||
// Shutdown radio
|
||||
furi_hal_subghz_idle();
|
||||
|
||||
@@ -43,21 +43,21 @@ void furi_hal_subghz_set_async_mirror_pin(const GpioPin* pin);
|
||||
*
|
||||
* @return pointer to the gpio pin structure
|
||||
*/
|
||||
const GpioPin* furi_hal_subghz_get_data_gpio();
|
||||
const GpioPin* furi_hal_subghz_get_data_gpio(void);
|
||||
|
||||
/** Initialize and switch to power save mode Used by internal API-HAL
|
||||
* initialization routine Can be used to reinitialize device to safe state and
|
||||
* send it to sleep
|
||||
*/
|
||||
void furi_hal_subghz_init();
|
||||
void furi_hal_subghz_init(void);
|
||||
|
||||
/** Send device to sleep mode
|
||||
*/
|
||||
void furi_hal_subghz_sleep();
|
||||
void furi_hal_subghz_sleep(void);
|
||||
|
||||
/** Dump info to stdout
|
||||
*/
|
||||
void furi_hal_subghz_dump_state();
|
||||
void furi_hal_subghz_dump_state(void);
|
||||
|
||||
/** Load custom registers from preset
|
||||
*
|
||||
@@ -88,13 +88,13 @@ void furi_hal_subghz_write_packet(const uint8_t* data, uint8_t size);
|
||||
*
|
||||
* @return true if not empty
|
||||
*/
|
||||
bool furi_hal_subghz_rx_pipe_not_empty();
|
||||
bool furi_hal_subghz_rx_pipe_not_empty(void);
|
||||
|
||||
/** Check if received data crc is valid
|
||||
*
|
||||
* @return true if valid
|
||||
*/
|
||||
bool furi_hal_subghz_is_rx_data_crc_valid();
|
||||
bool furi_hal_subghz_is_rx_data_crc_valid(void);
|
||||
|
||||
/** Read packet from FIFO
|
||||
*
|
||||
@@ -105,47 +105,47 @@ void furi_hal_subghz_read_packet(uint8_t* data, uint8_t* size);
|
||||
|
||||
/** Flush rx FIFO buffer
|
||||
*/
|
||||
void furi_hal_subghz_flush_rx();
|
||||
void furi_hal_subghz_flush_rx(void);
|
||||
|
||||
/** Flush tx FIFO buffer
|
||||
*/
|
||||
void furi_hal_subghz_flush_tx();
|
||||
void furi_hal_subghz_flush_tx(void);
|
||||
|
||||
/** Shutdown Issue SPWD command
|
||||
* @warning registers content will be lost
|
||||
*/
|
||||
void furi_hal_subghz_shutdown();
|
||||
void furi_hal_subghz_shutdown(void);
|
||||
|
||||
/** Reset Issue reset command
|
||||
* @warning registers content will be lost
|
||||
*/
|
||||
void furi_hal_subghz_reset();
|
||||
void furi_hal_subghz_reset(void);
|
||||
|
||||
/** Switch to Idle
|
||||
*/
|
||||
void furi_hal_subghz_idle();
|
||||
void furi_hal_subghz_idle(void);
|
||||
|
||||
/** Switch to Receive
|
||||
*/
|
||||
void furi_hal_subghz_rx();
|
||||
void furi_hal_subghz_rx(void);
|
||||
|
||||
/** Switch to Transmit
|
||||
*
|
||||
* @return true if the transfer is allowed by belonging to the region
|
||||
*/
|
||||
bool furi_hal_subghz_tx();
|
||||
bool furi_hal_subghz_tx(void);
|
||||
|
||||
/** Get RSSI value in dBm
|
||||
*
|
||||
* @return RSSI value
|
||||
*/
|
||||
float furi_hal_subghz_get_rssi();
|
||||
float furi_hal_subghz_get_rssi(void);
|
||||
|
||||
/** Get LQI
|
||||
*
|
||||
* @return LQI value
|
||||
*/
|
||||
uint8_t furi_hal_subghz_get_lqi();
|
||||
uint8_t furi_hal_subghz_get_lqi(void);
|
||||
|
||||
/** Check if frequency is in valid range
|
||||
*
|
||||
@@ -192,7 +192,7 @@ void furi_hal_subghz_start_async_rx(FuriHalSubGhzCaptureCallback callback, void*
|
||||
|
||||
/** Disable signal timings capture Resets GPIO and TIM2
|
||||
*/
|
||||
void furi_hal_subghz_stop_async_rx();
|
||||
void furi_hal_subghz_stop_async_rx(void);
|
||||
|
||||
/** Async TX callback type
|
||||
* @param context callback context
|
||||
@@ -213,11 +213,11 @@ bool furi_hal_subghz_start_async_tx(FuriHalSubGhzAsyncTxCallback callback, void*
|
||||
*
|
||||
* @return true if TX complete
|
||||
*/
|
||||
bool furi_hal_subghz_is_async_tx_complete();
|
||||
bool furi_hal_subghz_is_async_tx_complete(void);
|
||||
|
||||
/** Stop async transmission and cleanup resources Resets GPIO, TIM2, and DMA1
|
||||
*/
|
||||
void furi_hal_subghz_stop_async_tx();
|
||||
void furi_hal_subghz_stop_async_tx(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ bool furi_hal_usb_set_config(FuriHalUsbInterface* new_if, void* ctx) {
|
||||
return return_data.bool_value;
|
||||
}
|
||||
|
||||
FuriHalUsbInterface* furi_hal_usb_get_config() {
|
||||
FuriHalUsbInterface* furi_hal_usb_get_config(void) {
|
||||
UsbApiEventReturnData return_data = {
|
||||
.void_value = NULL,
|
||||
};
|
||||
@@ -168,7 +168,7 @@ FuriHalUsbInterface* furi_hal_usb_get_config() {
|
||||
return return_data.void_value;
|
||||
}
|
||||
|
||||
void furi_hal_usb_lock() {
|
||||
void furi_hal_usb_lock(void) {
|
||||
UsbApiEventMessage msg = {
|
||||
.lock = api_lock_alloc_locked(),
|
||||
.type = UsbApiEventTypeLock,
|
||||
@@ -177,7 +177,7 @@ void furi_hal_usb_lock() {
|
||||
furi_hal_usb_send_message(&msg);
|
||||
}
|
||||
|
||||
void furi_hal_usb_unlock() {
|
||||
void furi_hal_usb_unlock(void) {
|
||||
UsbApiEventMessage msg = {
|
||||
.lock = api_lock_alloc_locked(),
|
||||
.type = UsbApiEventTypeUnlock,
|
||||
@@ -186,7 +186,7 @@ void furi_hal_usb_unlock() {
|
||||
furi_hal_usb_send_message(&msg);
|
||||
}
|
||||
|
||||
bool furi_hal_usb_is_locked() {
|
||||
bool furi_hal_usb_is_locked(void) {
|
||||
UsbApiEventReturnData return_data = {
|
||||
.bool_value = false,
|
||||
};
|
||||
@@ -201,7 +201,7 @@ bool furi_hal_usb_is_locked() {
|
||||
return return_data.bool_value;
|
||||
}
|
||||
|
||||
void furi_hal_usb_disable() {
|
||||
void furi_hal_usb_disable(void) {
|
||||
UsbApiEventMessage msg = {
|
||||
.lock = api_lock_alloc_locked(),
|
||||
.type = UsbApiEventTypeDisable,
|
||||
@@ -210,7 +210,7 @@ void furi_hal_usb_disable() {
|
||||
furi_hal_usb_send_message(&msg);
|
||||
}
|
||||
|
||||
void furi_hal_usb_enable() {
|
||||
void furi_hal_usb_enable(void) {
|
||||
UsbApiEventMessage msg = {
|
||||
.lock = api_lock_alloc_locked(),
|
||||
.type = UsbApiEventTypeEnable,
|
||||
@@ -219,7 +219,7 @@ void furi_hal_usb_enable() {
|
||||
furi_hal_usb_send_message(&msg);
|
||||
}
|
||||
|
||||
void furi_hal_usb_reinit() {
|
||||
void furi_hal_usb_reinit(void) {
|
||||
UsbApiEventMessage msg = {
|
||||
.lock = api_lock_alloc_locked(),
|
||||
.type = UsbApiEventTypeReinit,
|
||||
@@ -358,7 +358,7 @@ static void usb_process_mode_change(FuriHalUsbInterface* interface, void* contex
|
||||
}
|
||||
}
|
||||
|
||||
static void usb_process_mode_reinit() {
|
||||
static void usb_process_mode_reinit(void) {
|
||||
// Temporary disable callback to avoid getting false reset events
|
||||
usbd_reg_event(&udev, usbd_evt_reset, NULL);
|
||||
FURI_LOG_I(TAG, "USB Reinit");
|
||||
|
||||
@@ -186,7 +186,7 @@ static bool smartcard_inserted = true;
|
||||
static CcidCallbacks* callbacks[CCID_TOTAL_SLOTS] = {NULL};
|
||||
|
||||
static void* ccid_set_string_descr(char* str) {
|
||||
furi_assert(str);
|
||||
furi_check(str);
|
||||
|
||||
size_t len = strlen(str);
|
||||
struct usb_string_descriptor* dev_str_desc = malloc(len * 2 + 2);
|
||||
@@ -292,7 +292,7 @@ void CALLBACK_CCID_GetSlotStatus(
|
||||
void CALLBACK_CCID_SetParametersT0(
|
||||
struct pc_to_rdr_set_parameters_t0* requestSetParametersT0,
|
||||
struct rdr_to_pc_parameters_t0* responseSetParametersT0) {
|
||||
furi_assert(requestSetParametersT0->bProtocolNum == 0x00); //T0
|
||||
furi_check(requestSetParametersT0->bProtocolNum == 0x00); //T0
|
||||
responseSetParametersT0->bMessageType = RDR_TO_PC_PARAMETERS;
|
||||
responseSetParametersT0->bSlot = requestSetParametersT0->bSlot;
|
||||
responseSetParametersT0->bSeq = requestSetParametersT0->bSeq;
|
||||
@@ -381,11 +381,11 @@ void CALLBACK_CCID_XfrBlock(
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_ccid_ccid_insert_smartcard() {
|
||||
void furi_hal_ccid_ccid_insert_smartcard(void) {
|
||||
smartcard_inserted = true;
|
||||
}
|
||||
|
||||
void furi_hal_ccid_ccid_remove_smartcard() {
|
||||
void furi_hal_ccid_ccid_remove_smartcard(void) {
|
||||
smartcard_inserted = false;
|
||||
}
|
||||
|
||||
@@ -410,7 +410,7 @@ static void ccid_tx_ep_callback(usbd_device* dev, uint8_t event, uint8_t ep) {
|
||||
int32_t bytes_read = usbd_ep_read(
|
||||
usb_dev, ep, &ReceiveBuffer, sizeof(ccid_bulk_message_header_t) + CCID_DATABLOCK_SIZE);
|
||||
//minimum request size is header size
|
||||
furi_assert((uint16_t)bytes_read >= sizeof(ccid_bulk_message_header_t));
|
||||
furi_check((uint16_t)bytes_read >= sizeof(ccid_bulk_message_header_t));
|
||||
ccid_bulk_message_header_t* message = (ccid_bulk_message_header_t*)&ReceiveBuffer; //-V641
|
||||
|
||||
if(message->bMessageType == PC_TO_RDR_ICCPOWERON) {
|
||||
@@ -455,14 +455,14 @@ static void ccid_tx_ep_callback(usbd_device* dev, uint8_t event, uint8_t ep) {
|
||||
struct rdr_to_pc_data_block* responseDataBlock =
|
||||
(struct rdr_to_pc_data_block*)&SendBuffer;
|
||||
|
||||
furi_assert(receivedXfrBlock->dwLength <= CCID_DATABLOCK_SIZE);
|
||||
furi_assert(
|
||||
furi_check(receivedXfrBlock->dwLength <= CCID_DATABLOCK_SIZE);
|
||||
furi_check(
|
||||
(uint16_t)bytes_read >=
|
||||
sizeof(ccid_bulk_message_header_t) + receivedXfrBlock->dwLength);
|
||||
|
||||
CALLBACK_CCID_XfrBlock(receivedXfrBlock, responseDataBlock);
|
||||
|
||||
furi_assert(responseDataBlock->dwLength <= CCID_DATABLOCK_SIZE);
|
||||
furi_check(responseDataBlock->dwLength <= CCID_DATABLOCK_SIZE);
|
||||
|
||||
usbd_ep_write(
|
||||
usb_dev,
|
||||
@@ -476,8 +476,8 @@ static void ccid_tx_ep_callback(usbd_device* dev, uint8_t event, uint8_t ep) {
|
||||
struct rdr_to_pc_parameters_t0* responseSetParametersT0 =
|
||||
(struct rdr_to_pc_parameters_t0*)&SendBuffer; //-V641
|
||||
|
||||
furi_assert(requestSetParametersT0->dwLength <= CCID_DATABLOCK_SIZE);
|
||||
furi_assert(
|
||||
furi_check(requestSetParametersT0->dwLength <= CCID_DATABLOCK_SIZE);
|
||||
furi_check(
|
||||
(uint16_t)bytes_read >=
|
||||
sizeof(ccid_bulk_message_header_t) + requestSetParametersT0->dwLength);
|
||||
|
||||
|
||||
@@ -472,7 +472,7 @@ static void cdc_deinit(usbd_device* dev) {
|
||||
}
|
||||
|
||||
void furi_hal_cdc_set_callbacks(uint8_t if_num, CdcCallbacks* cb, void* context) {
|
||||
furi_assert(if_num < IF_NUM_MAX);
|
||||
furi_check(if_num < IF_NUM_MAX);
|
||||
|
||||
if(callbacks[if_num] != NULL) {
|
||||
if(callbacks[if_num]->state_callback != NULL) {
|
||||
@@ -494,12 +494,12 @@ void furi_hal_cdc_set_callbacks(uint8_t if_num, CdcCallbacks* cb, void* context)
|
||||
}
|
||||
|
||||
struct usb_cdc_line_coding* furi_hal_cdc_get_port_settings(uint8_t if_num) {
|
||||
furi_assert(if_num < IF_NUM_MAX);
|
||||
furi_check(if_num < IF_NUM_MAX);
|
||||
return &cdc_config[if_num];
|
||||
}
|
||||
|
||||
uint8_t furi_hal_cdc_get_ctrl_line_state(uint8_t if_num) {
|
||||
furi_assert(if_num < IF_NUM_MAX);
|
||||
furi_check(if_num < IF_NUM_MAX);
|
||||
return cdc_ctrl_line_state[if_num];
|
||||
}
|
||||
|
||||
|
||||
@@ -257,11 +257,11 @@ static void* cb_ctx;
|
||||
static uint8_t led_state;
|
||||
static bool boot_protocol = false;
|
||||
|
||||
bool furi_hal_hid_is_connected() {
|
||||
bool furi_hal_hid_is_connected(void) {
|
||||
return hid_connected;
|
||||
}
|
||||
|
||||
uint8_t furi_hal_hid_get_led_state() {
|
||||
uint8_t furi_hal_hid_get_led_state(void) {
|
||||
return led_state;
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ bool furi_hal_hid_kb_release(uint16_t button) {
|
||||
return hid_send_report(ReportIdKeyboard);
|
||||
}
|
||||
|
||||
bool furi_hal_hid_kb_release_all() {
|
||||
bool furi_hal_hid_kb_release_all(void) {
|
||||
for(uint8_t key_nb = 0; key_nb < HID_KB_MAX_KEYS; key_nb++) {
|
||||
hid_report.keyboard.boot.btn[key_nb] = 0;
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ static bool hid_u2f_connected = false;
|
||||
static HidU2fCallback callback;
|
||||
static void* cb_ctx;
|
||||
|
||||
bool furi_hal_hid_u2f_is_connected() {
|
||||
bool furi_hal_hid_u2f_is_connected(void) {
|
||||
return hid_u2f_connected;
|
||||
}
|
||||
|
||||
|
||||
@@ -116,11 +116,11 @@ static void furi_hal_version_set_name(const char* name) {
|
||||
furi_hal_version.ble_mac[5] = (uint8_t)((company_id & 0x0000FF00) >> 8);
|
||||
}
|
||||
|
||||
static void furi_hal_version_load_otp_default() {
|
||||
static void furi_hal_version_load_otp_default(void) {
|
||||
furi_hal_version_set_name(NULL);
|
||||
}
|
||||
|
||||
static void furi_hal_version_load_otp_v0() {
|
||||
static void furi_hal_version_load_otp_v0(void) {
|
||||
const FuriHalVersionOTPv0* otp = (FuriHalVersionOTPv0*)FURI_HAL_VERSION_OTP_ADDRESS;
|
||||
|
||||
furi_hal_version.timestamp = otp->header_timestamp;
|
||||
@@ -132,7 +132,7 @@ static void furi_hal_version_load_otp_v0() {
|
||||
furi_hal_version_set_name(otp->name);
|
||||
}
|
||||
|
||||
static void furi_hal_version_load_otp_v1() {
|
||||
static void furi_hal_version_load_otp_v1(void) {
|
||||
const FuriHalVersionOTPv1* otp = (FuriHalVersionOTPv1*)FURI_HAL_VERSION_OTP_ADDRESS;
|
||||
|
||||
furi_hal_version.timestamp = otp->header_timestamp;
|
||||
@@ -146,7 +146,7 @@ static void furi_hal_version_load_otp_v1() {
|
||||
furi_hal_version_set_name(otp->name);
|
||||
}
|
||||
|
||||
static void furi_hal_version_load_otp_v2() {
|
||||
static void furi_hal_version_load_otp_v2(void) {
|
||||
const FuriHalVersionOTPv2* otp = (FuriHalVersionOTPv2*)FURI_HAL_VERSION_OTP_ADDRESS;
|
||||
|
||||
// 1st block, programmed afer baking
|
||||
@@ -171,7 +171,7 @@ static void furi_hal_version_load_otp_v2() {
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_version_init() {
|
||||
void furi_hal_version_init(void) {
|
||||
switch(furi_hal_version_get_otp_version()) {
|
||||
case FuriHalVersionOtpVersionUnknown:
|
||||
case FuriHalVersionOtpVersionEmpty:
|
||||
@@ -195,7 +195,7 @@ void furi_hal_version_init() {
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
FuriHalVersionOtpVersion furi_hal_version_get_otp_version() {
|
||||
FuriHalVersionOtpVersion furi_hal_version_get_otp_version(void) {
|
||||
if(*(uint64_t*)FURI_HAL_VERSION_OTP_ADDRESS == 0xFFFFFFFF) {
|
||||
return FuriHalVersionOtpVersionEmpty;
|
||||
} else {
|
||||
@@ -218,31 +218,31 @@ FuriHalVersionOtpVersion furi_hal_version_get_otp_version() {
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t furi_hal_version_get_hw_version() {
|
||||
uint8_t furi_hal_version_get_hw_version(void) {
|
||||
return furi_hal_version.board_version;
|
||||
}
|
||||
|
||||
uint8_t furi_hal_version_get_hw_target() {
|
||||
uint8_t furi_hal_version_get_hw_target(void) {
|
||||
return furi_hal_version.board_target;
|
||||
}
|
||||
|
||||
uint8_t furi_hal_version_get_hw_body() {
|
||||
uint8_t furi_hal_version_get_hw_body(void) {
|
||||
return furi_hal_version.board_body;
|
||||
}
|
||||
|
||||
FuriHalVersionColor furi_hal_version_get_hw_color() {
|
||||
FuriHalVersionColor furi_hal_version_get_hw_color(void) {
|
||||
return furi_hal_version.board_color;
|
||||
}
|
||||
|
||||
uint8_t furi_hal_version_get_hw_connect() {
|
||||
uint8_t furi_hal_version_get_hw_connect(void) {
|
||||
return furi_hal_version.board_connect;
|
||||
}
|
||||
|
||||
FuriHalVersionRegion furi_hal_version_get_hw_region() {
|
||||
FuriHalVersionRegion furi_hal_version_get_hw_region(void) {
|
||||
return furi_hal_version.board_region;
|
||||
}
|
||||
|
||||
const char* furi_hal_version_get_hw_region_name() {
|
||||
const char* furi_hal_version_get_hw_region_name(void) {
|
||||
switch(furi_hal_version_get_hw_region()) {
|
||||
case FuriHalVersionRegionUnknown:
|
||||
return "R00";
|
||||
@@ -258,27 +258,27 @@ const char* furi_hal_version_get_hw_region_name() {
|
||||
return "R??";
|
||||
}
|
||||
|
||||
FuriHalVersionDisplay furi_hal_version_get_hw_display() {
|
||||
FuriHalVersionDisplay furi_hal_version_get_hw_display(void) {
|
||||
return furi_hal_version.board_display;
|
||||
}
|
||||
|
||||
uint32_t furi_hal_version_get_hw_timestamp() {
|
||||
uint32_t furi_hal_version_get_hw_timestamp(void) {
|
||||
return furi_hal_version.timestamp;
|
||||
}
|
||||
|
||||
const char* furi_hal_version_get_name_ptr() {
|
||||
const char* furi_hal_version_get_name_ptr(void) {
|
||||
return *furi_hal_version.name == 0x00 ? NULL : furi_hal_version.name;
|
||||
}
|
||||
|
||||
const char* furi_hal_version_get_device_name_ptr() {
|
||||
const char* furi_hal_version_get_device_name_ptr(void) {
|
||||
return furi_hal_version.device_name + 1;
|
||||
}
|
||||
|
||||
const char* furi_hal_version_get_ble_local_device_name_ptr() {
|
||||
const char* furi_hal_version_get_ble_local_device_name_ptr(void) {
|
||||
return furi_hal_version.device_name;
|
||||
}
|
||||
|
||||
const uint8_t* furi_hal_version_get_ble_mac() {
|
||||
const uint8_t* furi_hal_version_get_ble_mac(void) {
|
||||
return furi_hal_version.ble_mac;
|
||||
}
|
||||
|
||||
@@ -286,10 +286,10 @@ const struct Version* furi_hal_version_get_firmware_version(void) {
|
||||
return version_get();
|
||||
}
|
||||
|
||||
size_t furi_hal_version_uid_size() {
|
||||
size_t furi_hal_version_uid_size(void) {
|
||||
return 64 / 8;
|
||||
}
|
||||
|
||||
const uint8_t* furi_hal_version_uid() {
|
||||
const uint8_t* furi_hal_version_uid(void) {
|
||||
return (const uint8_t*)UID64_BASE;
|
||||
}
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
#include <furi_hal_version.h>
|
||||
|
||||
bool furi_hal_version_do_i_belong_here() {
|
||||
bool furi_hal_version_do_i_belong_here(void) {
|
||||
return (furi_hal_version_get_hw_target() == 7) || (furi_hal_version_get_hw_target() == 0);
|
||||
}
|
||||
|
||||
const char* furi_hal_version_get_model_name() {
|
||||
const char* furi_hal_version_get_model_name(void) {
|
||||
return "Flipper Zero";
|
||||
}
|
||||
|
||||
const char* furi_hal_version_get_model_code() {
|
||||
const char* furi_hal_version_get_model_code(void) {
|
||||
return "FZ.1";
|
||||
}
|
||||
|
||||
const char* furi_hal_version_get_fcc_id() {
|
||||
const char* furi_hal_version_get_fcc_id(void) {
|
||||
return "2A2V6-FZ";
|
||||
}
|
||||
|
||||
const char* furi_hal_version_get_ic_id() {
|
||||
const char* furi_hal_version_get_ic_id(void) {
|
||||
return "27624-FZ";
|
||||
}
|
||||
|
||||
const char* furi_hal_version_get_mic_id() {
|
||||
const char* furi_hal_version_get_mic_id(void) {
|
||||
return "210-175991";
|
||||
}
|
||||
|
||||
const char* furi_hal_version_get_srrc_id() {
|
||||
const char* furi_hal_version_get_srrc_id(void) {
|
||||
return "2023DJ16420";
|
||||
}
|
||||
|
||||
const char* furi_hal_version_get_ncc_id() {
|
||||
const char* furi_hal_version_get_ncc_id(void) {
|
||||
return "CCAJ23LP34D0T3";
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#define TAG "FuriHalVibro"
|
||||
|
||||
void furi_hal_vibro_init() {
|
||||
void furi_hal_vibro_init(void) {
|
||||
furi_hal_gpio_init(&gpio_vibro, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
|
||||
furi_hal_gpio_write(&gpio_vibro, false);
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
|
||||
Reference in New Issue
Block a user