causeHardFault() function for different ports

This commit is contained in:
andreika-git 2023-11-14 22:44:54 +02:00 committed by rusefillc
parent db6b9ba5b9
commit aa7265a5bf
6 changed files with 32 additions and 0 deletions

View File

@ -138,6 +138,13 @@ void baseMCUInit(void) {
BOR_Set(BOR_Level_1); // one step above default value
}
void causeHardFault() {
// Set the function pointer to an invalid address
void (*invalidFunction)() = (void(*)())0xDEADBEEF;
// Calling the invalid function will trigger a hard fault
invalidFunction();
}
/* used to detect additional RAM available for LUA
* TODO: find RAM on AT32
* TODO: better name */

View File

@ -24,6 +24,13 @@ extern "C" {
void baseMCUInit(void) {
}
void causeHardFault() {
// Set the function pointer to an invalid address
void (*invalidFunction)() = (void(*)())0xDEADBEEF;
// Calling the invalid function will trigger a hard fault
invalidFunction();
}
void _unhandled_exception(void) {
/*lint -restore*/

View File

@ -16,6 +16,13 @@
void baseMCUInit(void) {
}
void causeHardFault() {
// Set the function pointer to an invalid address
void (*invalidFunction)() = (void(*)())0xDEADBEEF;
// Calling the invalid function will trigger a hard fault
invalidFunction();
}
void _unhandled_exception(void) {
/*lint -restore*/

View File

@ -12,6 +12,7 @@ void jump_to_bootloader();
#if EFI_USE_OPENBLT
void jump_to_openblt();
#endif
void causeHardFault();
bool allowFlashWhileRunning();
bool ramReadProbe(volatile const char *read_address);

View File

@ -110,6 +110,15 @@ void baseMCUInit(void) {
BOR_Set(BOR_Level_1); // one step above default value
}
void causeHardFault() {
#if EFI_PROD_CODE
// Set the function pointer to an invalid address
void (*invalidFunction)() = (void(*)())0xDEADBEEF;
// Calling the invalid function will trigger a hard fault
invalidFunction();
#endif /* EFI_PROD_CODE */
}
extern uint32_t __main_stack_base__;
typedef struct port_intctx intctx_t;

View File

@ -7,3 +7,4 @@ static bool isValidCanRxPin(brain_pin_e) { return true; }
#endif // HAL_USE_CAN
static bool allowFlashWhileRunning() { return true; }
static void causeHardFault() { }