Numworks Epsilon  1.4.1
Graphing Calculator Operating System
led.h
Go to the documentation of this file.
1 #ifndef ION_DEVICE_LED_H
2 #define ION_DEVICE_LED_H
3 
4 #include "regs/regs.h"
5 
6 namespace Ion {
7 namespace LED {
8 namespace Device {
9 
10 /* Pin | Role | Mode | Function
11  * -----+-------------------+-----------------------+----------
12  * PB0 | LED blue | Alternate Function 2 | TIM3_CH3
13  * PB1 | LED green | Alternate Function 2 | TIM3_CH4
14  * PC7 | LED red | Alternate Function 2 | TIM3_CH2
15  */
16 
17 void init();
18 void shutdown();
19 /* This call bypasses the timer, and immediately enforces a given LED state. */
20 void enforceState(bool red, bool green, bool blue);
21 
22 void initGPIO();
23 void shutdownGPIO();
24 void initTimer();
25 void shutdownTimer();
26 
27 constexpr static GPIOPin RGBPins[] = {
28  GPIOPin(GPIOC, 7), GPIOPin(GPIOB, 1), GPIOPin(GPIOB, 0)
29 };
30 
31 
32 constexpr uint16_t PWMPeriod = 40000;
33 
35  /* This function is a linear function from colors [0->255] to duty cycles [0->PWMPeriod].*/
36  return ((uint32_t)value)*(PWMPeriod/255);
37 }
38 
39 }
40 }
41 }
42 
43 #endif
constexpr uint16_t PWMPeriod
Definition: led.h:32
void shutdown()
Definition: led.cpp:25
void init()
Definition: led.cpp:20
void shutdownGPIO()
Definition: led.cpp:40
void enforceState(bool red, bool green, bool blue)
Definition: led.cpp:89
unsigned short uint16_t
Definition: stdint.h:5
unsigned char uint8_t
Definition: stdint.h:4
void initTimer()
Definition: led.cpp:47
constexpr GPIO GPIOB(1)
unsigned int uint32_t
Definition: stdint.h:6
void initGPIO()
Definition: led.cpp:30
void LED(const char *input)
Definition: led.cpp:11
void shutdownTimer()
Definition: led.cpp:83
Definition: gpio.h:95
uint16_t dutyCycleForUInt8(uint8_t value)
Definition: led.h:34
Definition: backlight.h:6
constexpr GPIO GPIOC(2)