bikelight.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /**
  2. * @file bikelight.h
  3. * @author Wang, Zhiyu(wangzy49@midea.com)
  4. * @brief Light of ebike
  5. * @version 0.1
  6. * @date 2021-10-09
  7. *
  8. * @copyright Copyright (c) 2021
  9. *
  10. */
  11. /************************************************************************
  12. Beginning of File, do not put anything above here except notes
  13. Compiler Directives:
  14. *************************************************************************/
  15. #ifndef BIKELIGHT_H
  16. #define BIKELIGHT_H
  17. /****************************************
  18. *
  19. * Definitions & Macros
  20. *
  21. ****************************************/
  22. #define BIKELIGHT_OUT_DEFAULT \
  23. { \
  24. 0, 0, 0, FALSE, LIGHT_Off \
  25. } // Default value of BIKELIGHT_OUT
  26. #define BIKELIGHT_COEF_DEFAULT \
  27. { \
  28. 0, 0, 0, 0, 0 \
  29. }
  30. #define LIGHT_POWER_ERROR_VOLTAGE_UP 70 // 0.1v
  31. #define LIGHT_POWER_ERROR_VOLTAGE_DOWN 50 // 0.1v
  32. #define LIGHT_POWER_ERROR_DETECT 2000 // ms
  33. #define LIGHT_POWER_ERROR_RECOVER 2000 // ms
  34. #define LIGHT_POWER_ERROR_SHUT 2000 // ms
  35. #define LIGHT_POWER_ERROR_TIMEUNIT 200 // ms
  36. /***************************************
  37. *
  38. * Type Definations
  39. *
  40. ***************************************/
  41. /**
  42. * @brief Light state
  43. *
  44. */
  45. typedef enum
  46. {
  47. LIGHT_Off = 0,
  48. LIGHT_On = 1,
  49. LIGHT_Error = 2,
  50. LIGHT_Shut = 3
  51. } LIGHT_STATE;
  52. /**
  53. * @brief BikeLight out
  54. *
  55. */
  56. typedef struct
  57. {
  58. UWORD uwBikeLightErrorCnt; // Cnt of detect GPIO low voltage
  59. UWORD uwBikeLightRecoverCnt; // Cnt of detect GPIO high voltage
  60. UWORD uwBikeLightShutCnt; // Cnt of detect GPIO high voltage
  61. BOOL blBikeLightErrorFlg; // flag of light error
  62. LIGHT_STATE LightState; // state of light
  63. } BIKELIGHT_OUT;
  64. typedef struct
  65. {
  66. UWORD uwBikeLightErrorCnt; // Cnt of detect GPIO low voltage
  67. UWORD uwBikeLightRecoverCnt; // Cnt of detect GPIO high voltage
  68. UWORD uwBikeLightShutCnt; // Cnt of detect GPIO high voltage
  69. UWORD uwBikeLightErrorVoltagePuDown; // flag of light error
  70. UWORD uwBikeLightErrorVoltagePuUp; // flag of light error
  71. } BIKELIGHT_COEF;
  72. /****************************************
  73. *
  74. * Exported variable
  75. *
  76. ****************************************/
  77. /***************************************
  78. *
  79. * Function Definations
  80. *
  81. ***************************************/
  82. void bikelight_voBikeLightInit(void); // interface function
  83. void bikelight_voBikeLightCoef(UWORD volt);
  84. void bikelight_voBikeLightControl(UWORD switchAction); // interface function
  85. void bikelight_voGetBikeLightError(UWORD LightPowerVolPu);
  86. /************************************************************************
  87. Flag Define (N/A)
  88. *************************************************************************/
  89. #endif
  90. /************************************************************************
  91. Copyright (c) 2018 Welling Motor Technology(Shanghai) Co. Ltd.
  92. All rights reserved.
  93. *************************************************************************
  94. End of this File (EOF):
  95. Do not put anything after this part!
  96. *************************************************************************/