distortos  v0.4.0
object-oriented C++ RTOS for microcontrollers
leds.hpp
Go to the documentation of this file.
1 
12 #ifndef SOURCE_BOARD_STM32_STM32F4_STM32F4DISCOVERY_INCLUDE_DISTORTOS_BOARD_LEDS_HPP_
13 #define SOURCE_BOARD_STM32_STM32F4_STM32F4DISCOVERY_INCLUDE_DISTORTOS_BOARD_LEDS_HPP_
14 
16 
17 #include <cstddef>
18 
20 #ifdef CONFIG_CHIP_STM32_GPIOV2_GPIOD_ENABLE
21 #define DISTORTOS_BOARD_LD3_LED_ENABLE 1
22 #else // !def CONFIG_CHIP_STM32_GPIOV2_GPIOD_ENABLE
23 #define DISTORTOS_BOARD_LD3_LED_ENABLE 0
24 #endif // !def CONFIG_CHIP_STM32_GPIOV2_GPIOD_ENABLE
25 
27 #ifdef CONFIG_CHIP_STM32_GPIOV2_GPIOD_ENABLE
28 #define DISTORTOS_BOARD_LD4_LED_ENABLE 1
29 #else // !def CONFIG_CHIP_STM32_GPIOV2_GPIOD_ENABLE
30 #define DISTORTOS_BOARD_LD4_LED_ENABLE 0
31 #endif // !def CONFIG_CHIP_STM32_GPIOV2_GPIOD_ENABLE
32 
34 #ifdef CONFIG_CHIP_STM32_GPIOV2_GPIOD_ENABLE
35 #define DISTORTOS_BOARD_LD5_LED_ENABLE 1
36 #else // !def CONFIG_CHIP_STM32_GPIOV2_GPIOD_ENABLE
37 #define DISTORTOS_BOARD_LD5_LED_ENABLE 0
38 #endif // !def CONFIG_CHIP_STM32_GPIOV2_GPIOD_ENABLE
39 
41 #ifdef CONFIG_CHIP_STM32_GPIOV2_GPIOD_ENABLE
42 #define DISTORTOS_BOARD_LD6_LED_ENABLE 1
43 #else // !def CONFIG_CHIP_STM32_GPIOV2_GPIOD_ENABLE
44 #define DISTORTOS_BOARD_LD6_LED_ENABLE 0
45 #endif // !def CONFIG_CHIP_STM32_GPIOV2_GPIOD_ENABLE
46 
48 #define DISTORTOS_BOARD_TOTAL_LEDS (DISTORTOS_BOARD_LD3_LED_ENABLE + DISTORTOS_BOARD_LD4_LED_ENABLE + \
49  DISTORTOS_BOARD_LD5_LED_ENABLE + DISTORTOS_BOARD_LD6_LED_ENABLE)
50 
51 namespace distortos
52 {
53 
54 #ifdef CONFIG_BOARD_LEDS_ENABLE
55 
56 namespace chip
57 {
58 
59 class ChipOutputPin;
60 
61 } // namespace chip
62 
63 #endif // def CONFIG_BOARD_LEDS_ENABLE
64 
65 namespace board
66 {
67 
70 
71 /*---------------------------------------------------------------------------------------------------------------------+
72 | LED indexes
73 +---------------------------------------------------------------------------------------------------------------------*/
74 
75 enum
76 {
77 #if DISTORTOS_BOARD_LD3_LED_ENABLE == 1
80 #endif // DISTORTOS_BOARD_LD3_LED_ENABLE == 1
81 #if DISTORTOS_BOARD_LD4_LED_ENABLE == 1
84 #endif // DISTORTOS_BOARD_LD4_LED_ENABLE == 1
85 #if DISTORTOS_BOARD_LD5_LED_ENABLE == 1
88 #endif // DISTORTOS_BOARD_LD5_LED_ENABLE == 1
89 #if DISTORTOS_BOARD_LD6_LED_ENABLE == 1
92 #endif // DISTORTOS_BOARD_LD6_LED_ENABLE == 1
93 };
94 
95 #ifdef CONFIG_BOARD_LEDS_ENABLE
96 
97 /*---------------------------------------------------------------------------------------------------------------------+
98 | alternative (color-based) LED indexes
99 +---------------------------------------------------------------------------------------------------------------------*/
100 
101 #if DISTORTOS_BOARD_LD3_LED_ENABLE == 1
102 constexpr size_t orangeLedIndex {ld3LedIndex};
104 #endif // DISTORTOS_BOARD_LD3_LED_ENABLE == 1
105 
106 #if DISTORTOS_BOARD_LD4_LED_ENABLE == 1
107 constexpr size_t greenLedIndex {ld4LedIndex};
109 #endif // DISTORTOS_BOARD_LD4_LED_ENABLE == 1
110 
111 #if DISTORTOS_BOARD_LD5_LED_ENABLE == 1
112 constexpr size_t redLedIndex {ld5LedIndex};
114 #endif // DISTORTOS_BOARD_LD5_LED_ENABLE == 1
115 
116 #if DISTORTOS_BOARD_LD6_LED_ENABLE == 1
117 constexpr size_t blueLedIndex {ld6LedIndex};
119 #endif // DISTORTOS_BOARD_LD6_LED_ENABLE == 1
120 
121 /*---------------------------------------------------------------------------------------------------------------------+
122 | indexed access to LED objects
123 +---------------------------------------------------------------------------------------------------------------------*/
124 
127 
128 #endif // def CONFIG_BOARD_LEDS_ENABLE
129 
130 } // namespace board
131 
132 } // namespace distortos
133 
134 #endif // SOURCE_BOARD_STM32_STM32F4_STM32F4DISCOVERY_INCLUDE_DISTORTOS_BOARD_LEDS_HPP_
index of LD3 LED (orange)
Definition: leds.hpp:79
#define DISTORTOS_BOARD_TOTAL_LEDS
total number of LEDs on the board
Definition: leds.hpp:48
index of LD5 LED (red)
Definition: leds.hpp:87
index of LD6 LED (blue)
Definition: leds.hpp:91
constexpr size_t blueLedIndex
alternative index of LD6 LED (blue)
Definition: leds.hpp:118
constexpr size_t orangeLedIndex
alternative index of LD3 LED (orange)
Definition: leds.hpp:103
Definition: ChipOutputPin.hpp:31
distortos configuration
index of LD4 LED (green)
Definition: leds.hpp:83
Top-level namespace of distortos project.
constexpr size_t greenLedIndex
alternative index of LD4 LED (green)
Definition: leds.hpp:108
constexpr size_t totalLeds
total number of LEDs on the board
Definition: leds.hpp:69
constexpr size_t redLedIndex
alternative index of LD5 LED (red)
Definition: leds.hpp:113
chip::ChipOutputPin leds[totalLeds]
array with all LED objects
Definition: STM32F4DISCOVERY-leds.cpp:29