Toggle navigation
Documentation
The friendly Operating System for the Internet of Things
Loading...
Searching...
No Matches
stm32_leds.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2022 Otto-von-Guericke-Universität Magdeburg
3
*
4
* This file is subject to the terms and conditions of the GNU Lesser
5
* General Public License v2.1. See the file LICENSE in the top level
6
* directory for more details.
7
*/
8
23
#ifndef STM32_LEDS_H
24
#define STM32_LEDS_H
25
26
/* GPIO_PORT() macro. This define even works when GPIO LL is not in used */
27
#include "gpio_ll_arch.h"
28
#include "
kernel_defines.h
"
29
30
#ifdef __cplusplus
31
extern
"C"
{
32
#endif
33
38
#if defined(LED0_PORT_NUM) && defined (LED0_PIN_NUM)
39
# define LED0_PORT ((GPIO_TypeDef *)GPIO_PORT(LED0_PORT_NUM))
40
# define LED0_PIN GPIO_PIN(LED0_PORT_NUM, LED0_PIN_NUM)
41
# define LED0_MASK (1 << LED0_PIN_NUM)
42
# if IS_ACTIVE(LED0_IS_INVERTED)
43
# define LED0_ON (LED0_PORT->BSRR = (LED0_MASK << 16))
44
# define LED0_OFF (LED0_PORT->BSRR = LED0_MASK)
45
# else
46
# define LED0_ON (LED0_PORT->BSRR = LED0_MASK)
47
# define LED0_OFF (LED0_PORT->BSRR = (LED0_MASK << 16))
48
# endif
49
# define LED0_TOGGLE (LED0_PORT->ODR ^= LED0_MASK)
50
#endif
51
52
#if defined(LED1_PORT_NUM) && defined (LED1_PIN_NUM)
53
# define LED1_PORT ((GPIO_TypeDef *)GPIO_PORT(LED1_PORT_NUM))
54
# define LED1_PIN GPIO_PIN(LED1_PORT_NUM, LED1_PIN_NUM)
55
# define LED1_MASK (1 << LED1_PIN_NUM)
56
# if IS_ACTIVE(LED1_IS_INVERTED)
57
# define LED1_ON (LED1_PORT->BSRR = (LED1_MASK << 16))
58
# define LED1_OFF (LED1_PORT->BSRR = LED1_MASK)
59
# else
60
# define LED1_ON (LED1_PORT->BSRR = LED1_MASK)
61
# define LED1_OFF (LED1_PORT->BSRR = (LED1_MASK << 16))
62
# endif
63
# define LED1_TOGGLE (LED1_PORT->ODR ^= LED1_MASK)
64
#endif
65
66
#if defined(LED2_PORT_NUM) && defined (LED2_PIN_NUM)
67
# define LED2_PORT ((GPIO_TypeDef *)GPIO_PORT(LED2_PORT_NUM))
68
# define LED2_PIN GPIO_PIN(LED2_PORT_NUM, LED2_PIN_NUM)
69
# define LED2_MASK (1 << LED2_PIN_NUM)
70
# if IS_ACTIVE(LED2_IS_INVERTED)
71
# define LED2_ON (LED2_PORT->BSRR = (LED2_MASK << 16))
72
# define LED2_OFF (LED2_PORT->BSRR = LED2_MASK)
73
# else
74
# define LED2_ON (LED2_PORT->BSRR = LED2_MASK)
75
# define LED2_OFF (LED2_PORT->BSRR = (LED2_MASK << 16))
76
# endif
77
# define LED2_TOGGLE (LED2_PORT->ODR ^= LED2_MASK)
78
#endif
79
80
#if defined(LED3_PORT_NUM) && defined (LED3_PIN_NUM)
81
# define LED3_PORT ((GPIO_TypeDef *)GPIO_PORT(LED3_PORT_NUM))
82
# define LED3_PIN GPIO_PIN(LED3_PORT_NUM, LED3_PIN_NUM)
83
# define LED3_MASK (1 << LED3_PIN_NUM)
84
# if IS_ACTIVE(LED3_IS_INVERTED)
85
# define LED3_ON (LED3_PORT->BSRR = (LED3_MASK << 16))
86
# define LED3_OFF (LED3_PORT->BSRR = LED3_MASK)
87
# else
88
# define LED3_ON (LED3_PORT->BSRR = LED3_MASK)
89
# define LED3_OFF (LED3_PORT->BSRR = (LED3_MASK << 16))
90
# endif
91
# define LED3_TOGGLE (LED3_PORT->ODR ^= LED3_MASK)
92
#endif
93
94
#if defined(LED4_PORT_NUM) && defined (LED4_PIN_NUM)
95
# define LED4_PORT ((GPIO_TypeDef *)GPIO_PORT(LED4_PORT_NUM))
96
# define LED4_PIN GPIO_PIN(LED4_PORT_NUM, LED4_PIN_NUM)
97
# define LED4_MASK (1 << LED4_PIN_NUM)
98
# if IS_ACTIVE(LED4_IS_INVERTED)
99
# define LED4_ON (LED4_PORT->BSRR = (LED4_MASK << 16))
100
# define LED4_OFF (LED4_PORT->BSRR = LED4_MASK)
101
# else
102
# define LED4_ON (LED4_PORT->BSRR = LED4_MASK)
103
# define LED4_OFF (LED4_PORT->BSRR = (LED4_MASK << 16))
104
# endif
105
# define LED4_TOGGLE (LED4_PORT->ODR ^= LED4_MASK)
106
#endif
107
108
#if defined(LED5_PORT_NUM) && defined (LED5_PIN_NUM)
109
# define LED5_PORT ((GPIO_TypeDef *)GPIO_PORT(LED5_PORT_NUM))
110
# define LED5_PIN GPIO_PIN(LED5_PORT_NUM, LED5_PIN_NUM)
111
# define LED5_MASK (1 << LED5_PIN_NUM)
112
# if IS_ACTIVE(LED5_IS_INVERTED)
113
# define LED5_ON (LED5_PORT->BSRR = (LED5_MASK << 16))
114
# define LED5_OFF (LED5_PORT->BSRR = LED5_MASK)
115
# else
116
# define LED5_ON (LED5_PORT->BSRR = LED5_MASK)
117
# define LED5_OFF (LED5_PORT->BSRR = (LED5_MASK << 16))
118
# endif
119
# define LED5_TOGGLE (LED5_PORT->ODR ^= LED5_MASK)
120
#endif
121
122
#if defined(LED6_PORT_NUM) && defined (LED6_PIN_NUM)
123
# define LED6_PORT ((GPIO_TypeDef *)GPIO_PORT(LED6_PORT_NUM))
124
# define LED6_PIN GPIO_PIN(LED6_PORT_NUM, LED6_PIN_NUM)
125
# define LED6_MASK (1 << LED6_PIN_NUM)
126
# if IS_ACTIVE(LED6_IS_INVERTED)
127
# define LED6_ON (LED6_PORT->BSRR = (LED6_MASK << 16))
128
# define LED6_OFF (LED6_PORT->BSRR = LED6_MASK)
129
# else
130
# define LED6_ON (LED6_PORT->BSRR = LED6_MASK)
131
# define LED6_OFF (LED6_PORT->BSRR = (LED6_MASK << 16))
132
# endif
133
# define LED6_TOGGLE (LED6_PORT->ODR ^= LED6_MASK)
134
#endif
135
136
#if defined(LED7_PORT_NUM) && defined (LED7_PIN_NUM)
137
# define LED7_PORT ((GPIO_TypeDef *)GPIO_PORT(LED7_PORT_NUM))
138
# define LED7_PIN GPIO_PIN(LED7_PORT_NUM, LED7_PIN_NUM)
139
# define LED7_MASK (1 << LED7_PIN_NUM)
140
# if IS_ACTIVE(LED7_IS_INVERTED)
141
# define LED7_ON (LED7_PORT->BSRR = (LED7_MASK << 16))
142
# define LED7_OFF (LED7_PORT->BSRR = LED7_MASK)
143
# else
144
# define LED7_ON (LED7_PORT->BSRR = LED7_MASK)
145
# define LED7_OFF (LED7_PORT->BSRR = (LED7_MASK << 16))
146
# endif
147
# define LED7_TOGGLE (LED7_PORT->ODR ^= LED7_MASK)
148
#endif
149
152
#ifdef __cplusplus
153
}
154
#endif
155
156
#endif
/* STM32_LEDS_H */
kernel_defines.h
Common macros and compiler attributes/pragmas configuration.
Generated on Thu Apr 25 2024 03:15:59 by
1.9.8