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
34
inline
uint16_t
dutyCycleForUInt8
(
uint8_t
value) {
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
Ion::LED::Device::PWMPeriod
constexpr uint16_t PWMPeriod
Definition:
led.h:32
Ion::LED::Device::shutdown
void shutdown()
Definition:
led.cpp:25
Ion::LED::Device::init
void init()
Definition:
led.cpp:20
Ion::LED::Device::shutdownGPIO
void shutdownGPIO()
Definition:
led.cpp:40
Ion::LED::Device::enforceState
void enforceState(bool red, bool green, bool blue)
Definition:
led.cpp:89
uint16_t
unsigned short uint16_t
Definition:
stdint.h:5
uint8_t
unsigned char uint8_t
Definition:
stdint.h:4
Ion::LED::Device::initTimer
void initTimer()
Definition:
led.cpp:47
GPIOB
constexpr GPIO GPIOB(1)
uint32_t
unsigned int uint32_t
Definition:
stdint.h:6
Ion::LED::Device::initGPIO
void initGPIO()
Definition:
led.cpp:30
Ion::Device::Bench::Command::LED
void LED(const char *input)
Definition:
led.cpp:11
Ion::LED::Device::shutdownTimer
void shutdownTimer()
Definition:
led.cpp:83
GPIOPin
Definition:
gpio.h:95
regs.h
Ion::LED::Device::dutyCycleForUInt8
uint16_t dutyCycleForUInt8(uint8_t value)
Definition:
led.h:34
Ion
Definition:
backlight.h:6
GPIOC
constexpr GPIO GPIOC(2)
epsilon
ion
src
device
led.h
Generated by
1.8.14