hardfault.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. #ifndef HARFAULT_H__
  13. #define HARFAULT_H__
  14. #include <stdint.h>
  15. #include <stddef.h>
  16. /**
  17. * @defgroup hardfault_default HardFault exception
  18. * @{
  19. * @brief Default HardFault exception implementation.
  20. * @ingroup app_common
  21. */
  22. /**
  23. * @brief Contents of the stack.
  24. *
  25. * This structure is used to re-create the stack layout after a HardFault exception was raised.
  26. */
  27. typedef struct HardFault_stack
  28. {
  29. uint32_t r0; ///< R0 register.
  30. uint32_t r1; ///< R1 register.
  31. uint32_t r2; ///< R2 register.
  32. uint32_t r3; ///< R3 register.
  33. uint32_t r12; ///< R12 register.
  34. uint32_t lr; ///< Link register.
  35. uint32_t pc; ///< Program counter.
  36. uint32_t psr; ///< Program status register.
  37. }HardFault_stack_t;
  38. /**
  39. * @brief Function for processing HardFault exceptions.
  40. *
  41. * An application that needs to process HardFault exceptions should provide an implementation of this function.
  42. * It will be called from the HardFault handler.
  43. * If no implementation is provided, the library uses a default one, which just restarts the MCU.
  44. *
  45. * @note If the DEBUG_NRF macro is defined, the software breakpoint is set just before the call
  46. * to this function.
  47. *
  48. * @param p_stack Pointer to the stack bottom.
  49. * This pointer might be NULL if the HardFault was called when the main stack was
  50. * the active stack and a stack overrun is detected.
  51. * In such a situation, the stack pointer is reinitialized to the default position,
  52. * and the stack content is lost.
  53. */
  54. void HardFault_process(HardFault_stack_t *p_stack);
  55. /** @} */
  56. #endif /* HARFAULT_H__ */