Advertisement
tranthudo

drv_led.h

Jun 6th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.47 KB | None | 0 0
  1. /*****************************************************************************
  2.  *
  3.  * MODULE:             JN-AN-1217
  4.  *
  5.  * COMPONENT:          drv_leds.h
  6.  *
  7.  * DESCRIPTION:        API for control led
  8.  *
  9.  ***************************************************************************/
  10.  
  11. #ifndef DRV_LEDS_H_
  12. #define DRV_LEDS_H_
  13. /****************************************************************************/
  14. /***        Include files                                                 ***/
  15. /****************************************************************************/
  16. #include "jendefs.h"
  17. /****************************************************************************/
  18. /***        Macro Definitions                                             ***/
  19. /****************************************************************************/
  20. //#define DIM_LED_TIMER         E_AHI_TIMER_0
  21. //#define DIM_LED_TIMER         E_AHI_TIMER_1
  22. #define DIM_LED_TIMER           E_AHI_TIMER_2
  23. //#define DIM_LED_TIMER         E_AHI_TIMER_3
  24. //#define DIM_LED_TIMER         E_AHI_TIMER_4
  25.  
  26. #define DO_0_PIN                    (30) // Define pin number of DO_0
  27. #define DO_1_PIN                    (31) // Define pin number of DO_1
  28.  
  29. #define MAX_NUMBER_LEDS_SUPPORT     (32)
  30. #define MAX_NUMBER_GROUP_LED_BLINK  (5)
  31.  
  32. #ifndef DRV_LEDS_ZTIMER_STORAGE
  33. #define DRV_LEDS_ZTIMER_STORAGE     (MAX_NUMBER_GROUP_LED_BLINK)
  34. #endif /* DRV_LEDS_ZTIMER_STORAGE */
  35.  
  36. #define LED_BLINK_FOREVER           (-1)   // if u16NumberBlink <= -1 then led will blink forever
  37. /****************************************************************************/
  38. /***        Type Definitions                                              ***/
  39. /****************************************************************************/
  40. typedef enum
  41. {
  42.     LED_LEVEL_0,        // led off
  43.     LED_LEVEL_10,       // led on 10%
  44.     LED_LEVEL_20,       // led on 20%
  45.     LED_LEVEL_30,       // led on 30%
  46.     LED_LEVEL_40,       // led on 40%
  47.     LED_LEVEL_50,       // led on 50%
  48.     LED_LEVEL_60,       // led on 60%
  49.     LED_LEVEL_70,       // led on 70%
  50.     LED_LEVEL_80,       // led on 80%
  51.     LED_LEVEL_90,       // led on 90%
  52.     LED_LEVEL_100,      // Led on 100%
  53.     NUMBER_OF_LED_LEVEL,
  54. }DRV_LEDS_teLedLevel_t;
  55.  
  56. typedef void (*fnCbAfterBlink)(void*);
  57.  
  58. /****************************************************************************/
  59. /***        Exported Functions                                            ***/
  60. /****************************************************************************/
  61. PUBLIC bool_t DRV_LEDS_bInitialize(
  62.         uint8_t                     *u8ArrLedPin,
  63.         uint8_t                     u8NumberLed,
  64.         DRV_LEDS_teLedLevel_t       eLedLevel
  65. );
  66. /****************************************************************************
  67.  *
  68.  * NAME: DRV_LEDS_vBlinkLed()
  69.  *
  70.  * DESCRIPTION:
  71.  * - To blink led with a certain of blink:   i16NumberBlink > 0
  72.  * - To blink led in a duration:             i16NumberBlink < 0 and i16BlinkDuration > 0
  73.  * - To blink led forever:                   i16NumberBlink < 0 and i16BlinkDuration < 0
  74.  *
  75.  * - To blink alternately 2 groups of led: u8ArrLedPin != NULL and u8ArrLedPin2 != NULL and 0 < u8NumberLed,u8NumberLed2 < MAX_NUMBER_LEDS_SUPPORT
  76.  * - To blink a Group of Led: u8ArrLedPin != NULL and 0 < u8NumberLed,u8NumberLed2 < MAX_NUMBER_LEDS_SUPPORT
  77.  *                          And ( or u8ArrLedPin2 == NULL or u8NumberLed2 > MAX_NUMBER_LEDS_SUPPORT or u8NumberLed2 = 0)
  78.  * PARAMETER:
  79.  *
  80.  * RETURNS: void
  81.  *
  82.  ****************************************************************************/
  83. PUBLIC void DRV_LEDS_vBlinkLedsAlternately(
  84.         uint8_t                 *u8ArrLedPin,
  85.         uint8_t                 u8NumberLed,
  86.         uint8_t                 *u8ArrLedPin2,
  87.         uint8_t                 u8NumberLed2,
  88.         int16_t                 i16NumberBlink,
  89.         int16_t                 i16BlinkDuration,       //ms
  90.         uint16_t                u16TimeOn,              //ms
  91.         uint16_t                u16TimeOff,             //ms
  92.         fnCbAfterBlink          fnCallback,
  93.         void                    *pParams
  94. );
  95.  
  96. PUBLIC void DRV_LEDS_vStopBlinkLeds(
  97.         bool_t                  bStopBlinkAllLeds,
  98.         uint8_t                 *u8ArrLedPin,
  99.         uint8_t                 u8NumberLed
  100. );
  101.  
  102. PUBLIC void DRV_LEDS_vSetLevel(
  103.         DRV_LEDS_teLedLevel_t   eLedLevel
  104. );
  105.  
  106. PUBLIC void DRV_LEDS_vOn(
  107.         uint8_t                 u8LedPin
  108. );
  109.  
  110. PUBLIC void DRV_LEDS_vOff(
  111.         uint8_t                 u8LedPin
  112. );
  113. /****************************************************************************/
  114. /***        External Variables                                            ***/
  115. /****************************************************************************/
  116.  
  117. /****************************************************************************/
  118. /****************************************************************************/
  119. /****************************************************************************/
  120. #endif /* DRV_LEDS_H_ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement