mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Add stack unwinding code for HardFault exception
This commit is contained in:
parent
bce35ca678
commit
ef6be8ab3c
@ -1,103 +1,137 @@
|
|||||||
#include "usbd_core.h"
|
#include <stdio.h>
|
||||||
#include <stm32f4xx_exti.h>
|
#include <usbd_core.h>
|
||||||
#define BREAK() __asm__ volatile ("BKPT");
|
#include <stm32f4xx_exti.h>
|
||||||
|
/* disable optimization for this file */
|
||||||
extern USB_OTG_CORE_HANDLE USB_OTG_Core;
|
#pragma GCC push_options
|
||||||
extern uint32_t USBD_OTG_ISR_Handler (USB_OTG_CORE_HANDLE *pdev);
|
#pragma GCC optimize ("O0")
|
||||||
|
#define UNUSED(x) x __attribute__((unused))
|
||||||
/**
|
#define BREAK() __asm__ volatile ("BKPT");
|
||||||
* @brief This function handles NMI exception.
|
extern USB_OTG_CORE_HANDLE USB_OTG_Core;
|
||||||
* @param None
|
extern uint32_t USBD_OTG_ISR_Handler (USB_OTG_CORE_HANDLE *pdev);
|
||||||
* @retval None
|
|
||||||
*/
|
/**
|
||||||
void NMI_Handler(void)
|
* @brief This function handles NMI exception.
|
||||||
{
|
* @param None
|
||||||
BREAK();
|
* @retval None
|
||||||
}
|
*/
|
||||||
|
void NMI_Handler(void)
|
||||||
/**
|
{
|
||||||
* @brief This function handles Hard Fault exception.
|
BREAK();
|
||||||
* @param None
|
}
|
||||||
* @retval None
|
|
||||||
*/
|
void prvGetRegistersFromStack( uint32_t *pulFaultStackAddress )
|
||||||
void HardFault_Handler(void)
|
{
|
||||||
{
|
UNUSED(volatile uint32_t r0);
|
||||||
BREAK();
|
UNUSED(volatile uint32_t r1);
|
||||||
}
|
UNUSED(volatile uint32_t r2);
|
||||||
|
UNUSED(volatile uint32_t r3);
|
||||||
/**
|
UNUSED(volatile uint32_t r12);
|
||||||
* @brief This function handles Memory Manage exception.
|
UNUSED(volatile uint32_t lr); /* Link register. */
|
||||||
* @param None
|
UNUSED(volatile uint32_t pc); /* Program counter. */
|
||||||
* @retval None
|
UNUSED(volatile uint32_t psr);/* Program status register. */
|
||||||
*/
|
|
||||||
void MemManage_Handler(void)
|
r0 = pulFaultStackAddress[ 0 ];
|
||||||
{
|
r1 = pulFaultStackAddress[ 1 ];
|
||||||
BREAK();
|
r2 = pulFaultStackAddress[ 2 ];
|
||||||
}
|
r3 = pulFaultStackAddress[ 3 ];
|
||||||
|
|
||||||
/**
|
r12 = pulFaultStackAddress[ 4 ];
|
||||||
* @brief This function handles Bus Fault exception.
|
lr = pulFaultStackAddress[ 5 ];
|
||||||
* @param None
|
pc = pulFaultStackAddress[ 6 ];
|
||||||
* @retval None
|
psr = pulFaultStackAddress[ 7 ];
|
||||||
*/
|
|
||||||
void BusFault_Handler(void)
|
BREAK();
|
||||||
{
|
}
|
||||||
BREAK();
|
|
||||||
}
|
//static void HardFault_Handler( void ) __attribute__( ( naked ) );
|
||||||
|
void HardFault_Handler(void)
|
||||||
/**
|
{
|
||||||
* @brief This function handles Usage Fault exception.
|
__asm volatile
|
||||||
* @param None
|
(
|
||||||
* @retval None
|
" tst lr, #4 \n"
|
||||||
*/
|
" ite eq \n"
|
||||||
void UsageFault_Handler(void)
|
" mrseq r0, msp \n"
|
||||||
{
|
" mrsne r0, psp \n"
|
||||||
BREAK();
|
" ldr r1, [r0, #24] \n"
|
||||||
}
|
" ldr r2, handler2_address_const \n"
|
||||||
|
" bx r2 \n"
|
||||||
/**
|
" handler2_address_const: .word prvGetRegistersFromStack \n"
|
||||||
* @brief This function handles SVCall exception.
|
);
|
||||||
* @param None
|
}
|
||||||
* @retval None
|
|
||||||
*/
|
/**
|
||||||
void SVC_Handler(void)
|
* @brief This function handles Memory Manage exception.
|
||||||
{
|
* @param None
|
||||||
BREAK();
|
* @retval None
|
||||||
}
|
*/
|
||||||
|
void MemManage_Handler(void)
|
||||||
/**
|
{
|
||||||
* @brief This function handles Debug Monitor exception.
|
BREAK();
|
||||||
* @param None
|
}
|
||||||
* @retval None
|
|
||||||
*/
|
/**
|
||||||
void DebugMon_Handler(void)
|
* @brief This function handles Bus Fault exception.
|
||||||
{
|
* @param None
|
||||||
}
|
* @retval None
|
||||||
|
*/
|
||||||
/**
|
void BusFault_Handler(void)
|
||||||
* @brief This function handles PendSVC exception.
|
{
|
||||||
* @param None
|
BREAK();
|
||||||
* @retval None
|
}
|
||||||
*/
|
|
||||||
void PendSV_Handler(void)
|
/**
|
||||||
{
|
* @brief This function handles Usage Fault exception.
|
||||||
extern void pendsv_isr_handler(void);
|
* @param None
|
||||||
pendsv_isr_handler();
|
* @retval None
|
||||||
}
|
*/
|
||||||
|
void UsageFault_Handler(void)
|
||||||
void OTG_FS_WKUP_IRQHandler(void)
|
{
|
||||||
{
|
BREAK();
|
||||||
if(USB_OTG_Core.cfg.low_power)
|
}
|
||||||
{
|
|
||||||
*(uint32_t *)(0xE000ED10) &= 0xFFFFFFF9 ;
|
/**
|
||||||
SystemInit();
|
* @brief This function handles SVCall exception.
|
||||||
USB_OTG_UngateClock(&USB_OTG_Core);
|
* @param None
|
||||||
}
|
* @retval None
|
||||||
EXTI_ClearITPendingBit(EXTI_Line18);
|
*/
|
||||||
}
|
void SVC_Handler(void)
|
||||||
|
{
|
||||||
void OTG_FS_IRQHandler(void)
|
BREAK();
|
||||||
{
|
}
|
||||||
USBD_OTG_ISR_Handler (&USB_OTG_Core);
|
|
||||||
}
|
/**
|
||||||
|
* @brief This function handles Debug Monitor exception.
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void DebugMon_Handler(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles PendSVC exception.
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void PendSV_Handler(void)
|
||||||
|
{
|
||||||
|
extern void pendsv_isr_handler(void);
|
||||||
|
pendsv_isr_handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OTG_FS_WKUP_IRQHandler(void)
|
||||||
|
{
|
||||||
|
if(USB_OTG_Core.cfg.low_power)
|
||||||
|
{
|
||||||
|
*(uint32_t *)(0xE000ED10) &= 0xFFFFFFF9 ;
|
||||||
|
SystemInit();
|
||||||
|
USB_OTG_UngateClock(&USB_OTG_Core);
|
||||||
|
}
|
||||||
|
EXTI_ClearITPendingBit(EXTI_Line18);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OTG_FS_IRQHandler(void)
|
||||||
|
{
|
||||||
|
USBD_OTG_ISR_Handler (&USB_OTG_Core);
|
||||||
|
}
|
||||||
|
#pragma GCC pop_options
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user