hal_harderr.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /**
  2. * @file hal_harderr.h
  3. * @author Xiao Lifan (xiaolf6@midea.com)
  4. * @brief
  5. * @version 0.1
  6. * @date 2021-09-26
  7. *
  8. * @copyright Copyright (c) 2021
  9. *
  10. * @details The interface of system hard error detect and handling
  11. *
  12. */
  13. #ifndef _HAL_HARDERR_H_
  14. #define _HAL_HARDERR_H_
  15. #include "hal_config.h"
  16. /****************************************************************
  17. *
  18. * Standard Interface
  19. *
  20. * *************************************************************/
  21. /********************/
  22. /* Type definations */
  23. /********************/
  24. // typedef union
  25. // {
  26. // uint32_t all;
  27. // struct bit
  28. // {
  29. // uint32_t bit0:1;
  30. // uint32_t bit0:1;
  31. // };
  32. // } Hal_Harderr_FlagType;
  33. /******************************/
  34. /* Global Interface Variables */
  35. /******************************/
  36. /* !!!Important!!! */
  37. /* Interface Variable Should Not Be Modified By Application */
  38. /**
  39. * @brief The flag of triggered hardware error
  40. *
  41. */
  42. extern uint32_t Hal_HardErr_Flags;
  43. /*************************/
  44. /* Global Interface Hook */
  45. /*************************/
  46. /**
  47. * @brief Function called when hardware error are triggered
  48. *
  49. */
  50. extern void (*Hal_HardErr_TriggerHook)();
  51. /**
  52. * @brief Function called when hardware error are cleared
  53. *
  54. * @note The clear of the hardware err may lag
  55. *
  56. */
  57. extern void (*Hal_HardErr_ClearHook)();
  58. /*****************************************/
  59. /* Application Layer Interface Functions */
  60. /*****************************************/
  61. /**
  62. * @brief Get specified bit of hardware error flags
  63. *
  64. * @param bit bit index
  65. * @return uint8_t error status 0 - no error, 1 - error occurs
  66. */
  67. uint8_t Hal_HardErr_GetFlagStatus(uint8_t bit);
  68. /**
  69. * @brief Try clear hardware error
  70. *
  71. * @return uint8_t result of clear action 0 - success, 1 - falied
  72. */
  73. uint8_t Hal_HardErr_TryClearHardErr();
  74. /**************************************/
  75. /* Platform Layer Interface Functions */
  76. /**************************************/
  77. /**
  78. * @brief Init hardware error detection
  79. *
  80. */
  81. void Hal_HardErr_Init();
  82. /**
  83. * @brief Set the specified bit of hardware error flag
  84. *
  85. * @param bit bit index
  86. * @param state flag state
  87. */
  88. void Hal_HardErr_SetFlagStatus(uint8_t bit, uint8_t state);
  89. #endif