hardfault_implementation.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
  2. *
  3. * The information contained herein is property of Nordic Semiconductor ASA.
  4. * Terms and conditions of usage are described in detail in NORDIC
  5. * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
  6. *
  7. * Licensees are granted free, non-transferable use of the information. NO
  8. * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
  9. * the file.
  10. *
  11. */
  12. #include "hardfault.h"
  13. #include "nrf.h"
  14. #include "compiler_abstraction.h"
  15. #include "nordic_common.h"
  16. #ifdef SOFTDEVICE_PRESENT
  17. #include "nrf_soc.h"
  18. #endif
  19. #if defined(DEBUG_NRF)
  20. /**
  21. * @brief Pointer to the last received stack pointer.
  22. *
  23. * This pointer is set in the debug version of the HardFault handler.
  24. * It helps to debug HardFault reasons.
  25. */
  26. volatile HardFault_stack_t *HardFault_p_stack;
  27. #endif
  28. /*lint -save -e14 */
  29. __WEAK void HardFault_process(HardFault_stack_t *p_stack)
  30. {
  31. // Restart the system by default
  32. NVIC_SystemReset();
  33. }
  34. /*lint -restore */
  35. void HardFault_c_handler( uint32_t *p_stack_address )
  36. {
  37. #if defined(DEBUG_NRF)
  38. HardFault_p_stack = (HardFault_stack_t*)p_stack_address;
  39. /* Generate breakpoint if debugger is connected */
  40. __BKPT(0);
  41. #endif
  42. HardFault_process((HardFault_stack_t*)p_stack_address);
  43. }