HomeAut
led.h
1 #ifndef LED_H_
2 #define LED_H_
3 
4 
5 
6 /*------------------------------------------------------------------------------
7  * Includes
8  *----------------------------------------------------------------------------*/
9 
10 #include "include.h"
11 #include "options.h"
12 #include "board.h"
13 
14 
15 
16 /*------------------------------------------------------------------------------
17  * Macros & definitions
18  *----------------------------------------------------------------------------*/
19 
20 
21 // TODO: PWM LED
22 
23 #define LED_TIMER_PERIOD_VALUE (uint32_t)(666 - 1) /* Period Value */
24 
25 
26 #define LED_BLUE_SET_PERCENT(percent) LED_PWM_ChangePercent(&TimLedBlueHandle,LED_BLUE_TIMER_CHANNEL,percent);
27 #define LED_GREEN_SET_PERCENT(percent) LED_PWM_ChangePercent(&TimLedGreenHandle,LED_GREEN_TIMER_CHANNEL,percent);
28 
29 
30 /*
31 #define PULSE1_VALUE (uint32_t)(PERIOD_VALUE/2) //Capture Compare 1 Value
32 #define PULSE2_VALUE (uint32_t)(PERIOD_VALUE*37.5/100) // Capture Compare 2 Value
33 #define PULSE3_VALUE (uint32_t)(PERIOD_VALUE/4) // Capture Compare 3 Value
34 #define PULSE4_VALUE (uint32_t)(PERIOD_VALUE*12.5/100) // Capture Compare 4 Value
35 */
36 
37 
38 
39 /*------------------------------------------------------------------------------
40  * Type definitions
41  *----------------------------------------------------------------------------*/
42 
43 typedef enum
44 {
45  LED_SET_DONTCARE,
46  LED_SET_ON,
47  LED_SET_OFF,
48  LED_SET_TOGGLE,
49  LED_GET_STATUS,
50  // Do not use:
51  LED_TYPE_COUNT
52 } LED_SetType;
53 
54 
55 
56 /*------------------------------------------------------------------------------
57  * Global variables
58  *----------------------------------------------------------------------------*/
59 
60 extern TIM_HandleTypeDef TimLedBlueHandle;
61 extern TIM_HandleTypeDef TimLedGreenHandle;
62 
63 
64 
65 /*------------------------------------------------------------------------------
66  * Global function declarations
67  *----------------------------------------------------------------------------*/
68 
69 void LED_Init(void);
70 void LED_Test(void);
71 bool LED_SetLed(uint8_t num, LED_SetType ledSet);
72 bool LED_GetStatus(uint8_t num);
73 uint8_t LED_GetNumFromName(const char*name);
74 LED_SetType LED_GetTypeFromString(const char*typeString);
75 
76 
77 void LED_InitTimers(void);
78 void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim);
79 void LED_PWM_ChangePercent(TIM_HandleTypeDef *TimHandle,
80  uint32_t timerChannel, uint8_t percent);
81 
82 
83 
84 #endif // LED_H