STM32 RTOS 0.2.3
Bare-metal preemptive RTOS for STM32F446RE
Loading...
Searching...
No Matches
Fault

Configurable fault enables and the fault record. More...

Collaboration diagram for Fault:

Data Structures

struct  FaultRecord_t
 What Fault_Handler saw. More...

Typedefs

typedef struct FaultRecord_t FaultRecord_t
 What Fault_Handler saw.

Functions

void faultEnable (ScbRegisters_t *scb)
 Give MemManage, BusFault and UsageFault their own handlers, and trap integer division by zero.
void faultCapture (FaultRecord_t *record, const ScbRegisters_t *scb, const uint32_t *frame, uint32_t exc_return)
 Fill record from the fault status registers and the stacked frame.

Variables

FaultRecord_t faultRecord
 Filled by Fault_Handler; read it from the debugger.
FaultRecord_t faultRecord
 Filled by Fault_Handler; read it from the debugger.

Detailed Description

Configurable fault enables and the fault record.

Typedef Documentation

◆ FaultRecord_t

typedef struct FaultRecord_t FaultRecord_t

What Fault_Handler saw.

All zero until the first fault.

Function Documentation

◆ faultEnable()

void faultEnable ( ScbRegisters_t * scb)

Give MemManage, BusFault and UsageFault their own handlers, and trap integer division by zero.

Sets SHCSR.MEMFAULTENA, BUSFAULTENA and USGFAULTENA, and CCR.DIV_0_TRP. Without the trap, SDIV/UDIV by zero quietly return 0. Other bits are kept.

Parameters
scbSCB block (e.g. SCB).

Definition at line 14 of file fault.c.

References ScbRegisters_t::CCR, faultEnable(), SCB_CCR_DIV_0_TRP, SCB_SHCSR_BUSFAULTENA, SCB_SHCSR_MEMFAULTENA, SCB_SHCSR_USGFAULTENA, and ScbRegisters_t::SHCSR.

Referenced by faultEnable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ faultCapture()

void faultCapture ( FaultRecord_t * record,
const ScbRegisters_t * scb,
const uint32_t * frame,
uint32_t exc_return )

Fill record from the fault status registers and the stacked frame.

Called by Fault_Handler with the frame from MSP or PSP, as EXC_RETURN bit 2 selects. The frame is read only if CFSR.MSTKERR and STKERR are clear: when stacking failed, the frame is missing and reading it could fault again inside HardFault, which locks up the core.

Parameters
recordReceives the record; every field is written.
scbSCB block (e.g. SCB); read only, so the status bits stay set for the debugger.
frameThe stacked R0, R1, R2, R3, R12, LR, PC, xPSR, in that order.
exc_returnLR on handler entry.

Definition at line 20 of file fault.c.

References ScbRegisters_t::BFAR, FaultRecord_t::bfar, ScbRegisters_t::CFSR, FaultRecord_t::cfsr, FaultRecord_t::exc_return, FaultRecord_t::exception, faultCapture(), FaultRecord_t::frame_valid, ScbRegisters_t::HFSR, FaultRecord_t::hfsr, ScbRegisters_t::ICSR, FaultRecord_t::lr, ScbRegisters_t::MMFAR, FaultRecord_t::mmfar, FaultRecord_t::pc, FaultRecord_t::r0, FaultRecord_t::r1, FaultRecord_t::r12, FaultRecord_t::r2, FaultRecord_t::r3, SCB_CFSR_MSTKERR, SCB_CFSR_STKERR, SCB_ICSR_VECTACTIVE_Msk, SCB_ICSR_VECTACTIVE_Pos, and FaultRecord_t::xpsr.

Referenced by faultCapture().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ faultRecord [1/2]

FaultRecord_t faultRecord
extern

Filled by Fault_Handler; read it from the debugger.

Definition at line 12 of file fault.c.

◆ faultRecord [2/2]

FaultRecord_t faultRecord

Filled by Fault_Handler; read it from the debugger.

Definition at line 12 of file fault.c.