led.h
920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef ION_DEVICE_LED_H
#define ION_DEVICE_LED_H
#include "regs/regs.h"
namespace Ion {
namespace LED {
namespace Device {
/* Pin | Role | Mode | Function
* -----+-------------------+-----------------------+----------
* PB0 | LED blue | Alternate Function 2 | TIM3_CH3
* PB1 | LED green | Alternate Function 2 | TIM3_CH4
* PC7 | LED red | Alternate Function 2 | TIM3_CH2
*/
enum class Mode {
PWM,
Blink
};
enum class Color {
Red,
Green,
Blue
};
void init();
void shutdown();
void setPeriodAndDutyCycles(Mode mode, float dutyCycleRed, float dutyCycleGreen, float dutyCycleBlue, uint16_t period = 0);
void initGPIO();
void shutdownGPIO();
void initTimer();
void shutdownTimer();
constexpr static GPIOPin RGBPins[] = {
GPIOPin(GPIOC, 7), GPIOPin(GPIOB, 1), GPIOPin(GPIOB, 0)
};
constexpr uint16_t PWMPeriod = 40000;
}
}
}
#endif