1
mirror of https://github.com/flipperdevices/flipperzero-firmware.git synced 2025-12-12 04:41:26 +04:00

Furi,FuriHal: various improvements (#2819)

* Lib: adjust default contrast for ERC displays

* Furi: various improvements in check module

* Format Sources

* FurHal: ble early hardfault detection

---------

Co-authored-by: hedger <hedger@users.noreply.github.com>
This commit is contained in:
あく
2023-06-30 18:52:43 +09:00
committed by GitHub
parent 5d40193308
commit 6d9de25494
6 changed files with 218 additions and 33 deletions

View File

@@ -166,7 +166,11 @@ FURI_NORETURN void __furi_crash() {
RESTORE_REGISTERS_AND_HALT_MCU(true);
#ifndef FURI_DEBUG
} else {
furi_hal_rtc_set_fault_data((uint32_t)__furi_check_message);
uint32_t ptr = (uint32_t)__furi_check_message;
if(ptr < FLASH_BASE || ptr > (FLASH_BASE + FLASH_SIZE)) {
ptr = (uint32_t) "Check serial logs";
}
furi_hal_rtc_set_fault_data(ptr);
furi_hal_console_puts("\r\nRebooting system.\r\n");
furi_hal_console_puts("\033[0m\r\n");
furi_hal_power_reset();

View File

@@ -13,6 +13,8 @@
*/
#pragma once
#include <m-core.h>
#ifdef __cplusplus
extern "C" {
#define FURI_NORETURN [[noreturn]]
@@ -48,28 +50,47 @@ FURI_NORETURN void __furi_halt();
} while(0)
/** Check condition and crash if check failed */
#define furi_check(__e) \
do { \
if(!(__e)) { \
furi_crash(__FURI_CHECK_MESSAGE_FLAG); \
} \
#define __furi_check(__e, __m) \
do { \
if(!(__e)) { \
furi_crash(__m); \
} \
} while(0)
/** Check condition and crash if failed
*
* @param condition to check
* @param optional message
*/
#define furi_check(...) \
M_APPLY(__furi_check, M_DEFAULT_ARGS(2, (__FURI_CHECK_MESSAGE_FLAG), __VA_ARGS__))
/** Only in debug build: Assert condition and crash if assert failed */
#ifdef FURI_DEBUG
#define furi_assert(__e) \
do { \
if(!(__e)) { \
furi_crash(__FURI_ASSERT_MESSAGE_FLAG); \
} \
#define __furi_assert(__e, __m) \
do { \
if(!(__e)) { \
furi_crash(__m); \
} \
} while(0)
#else
#define furi_assert(__e) \
do { \
((void)(__e)); \
#define __furi_assert(__e, __m) \
do { \
((void)(__e)); \
((void)(__m)); \
} while(0)
#endif
/** Assert condition and crash if failed
*
* @warning only will do check if firmware compiled in debug mode
*
* @param condition to check
* @param optional message
*/
#define furi_assert(...) \
M_APPLY(__furi_assert, M_DEFAULT_ARGS(2, (__FURI_ASSERT_MESSAGE_FLAG), __VA_ARGS__))
#ifdef __cplusplus
}
#endif