Loading...
Searching...
No Matches
stm32_leds.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2022 Otto-von-Guericke-Universität Magdeburg
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
21
22/* Using gpio_ll_arch for GPIO access. On STM32, accessing the GPIO output
23 * buffer via GPIO LL even works when the GPIO LL feature/module is not in
24 * use */
25#include "periph/gpio_ll.h"
26#include "kernel_defines.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
36#if defined(LED0_PORT_NUM) && defined (LED0_PIN_NUM)
37# define LED0_PIN GPIO_PIN(LED0_PORT_NUM, LED0_PIN_NUM)
38# define LED0_MASK (1 << LED0_PIN_NUM)
39# if IS_ACTIVE(LED0_IS_INVERTED)
40# define LED0_ON gpio_ll_clear(LED0_PORT, LED0_MASK)
41# define LED0_OFF gpio_ll_set(LED0_PORT, LED0_MASK)
42# else
43# define LED0_ON gpio_ll_set(LED0_PORT, LED0_MASK)
44# define LED0_OFF gpio_ll_clear(LED0_PORT, LED0_MASK)
45# endif
46# define LED0_TOGGLE gpio_ll_toggle(LED0_PORT, LED0_MASK)
47#endif
48
49#if defined(LED1_PORT_NUM) && defined (LED1_PIN_NUM)
50# define LED1_PIN GPIO_PIN(LED1_PORT_NUM, LED1_PIN_NUM)
51# define LED1_MASK (1 << LED1_PIN_NUM)
52# if IS_ACTIVE(LED1_IS_INVERTED)
53# define LED1_ON gpio_ll_clear(LED1_PORT, LED1_MASK)
54# define LED1_OFF gpio_ll_set(LED1_PORT, LED1_MASK)
55# else
56# define LED1_ON gpio_ll_set(LED1_PORT, LED1_MASK)
57# define LED1_OFF gpio_ll_clear(LED1_PORT, LED1_MASK)
58# endif
59# define LED1_TOGGLE gpio_ll_toggle(LED1_PORT, LED1_MASK)
60#endif
61
62#if defined(LED2_PORT_NUM) && defined (LED2_PIN_NUM)
63# define LED2_PIN GPIO_PIN(LED2_PORT_NUM, LED2_PIN_NUM)
64# define LED2_MASK (1 << LED2_PIN_NUM)
65# if IS_ACTIVE(LED2_IS_INVERTED)
66# define LED2_ON gpio_ll_clear(LED2_PORT, LED2_MASK)
67# define LED2_OFF gpio_ll_set(LED2_PORT, LED2_MASK)
68# else
69# define LED2_ON gpio_ll_set(LED2_PORT, LED2_MASK)
70# define LED2_OFF gpio_ll_clear(LED2_PORT, LED2_MASK)
71# endif
72# define LED2_TOGGLE gpio_ll_toggle(LED2_PORT, LED2_MASK)
73#endif
74
75#if defined(LED3_PORT_NUM) && defined (LED3_PIN_NUM)
76# define LED3_PIN GPIO_PIN(LED3_PORT_NUM, LED3_PIN_NUM)
77# define LED3_MASK (1 << LED3_PIN_NUM)
78# if IS_ACTIVE(LED3_IS_INVERTED)
79# define LED3_ON gpio_ll_clear(LED3_PORT, LED3_MASK)
80# define LED3_OFF gpio_ll_set(LED3_PORT, LED3_MASK)
81# else
82# define LED3_ON gpio_ll_set(LED3_PORT, LED3_MASK)
83# define LED3_OFF gpio_ll_clear(LED3_PORT, LED3_MASK)
84# endif
85# define LED3_TOGGLE gpio_ll_toggle(LED3_PORT, LED3_MASK)
86#endif
87
88#if defined(LED4_PORT_NUM) && defined (LED4_PIN_NUM)
89# define LED4_PIN GPIO_PIN(LED4_PORT_NUM, LED4_PIN_NUM)
90# define LED4_MASK (1 << LED4_PIN_NUM)
91# if IS_ACTIVE(LED4_IS_INVERTED)
92# define LED4_ON gpio_ll_clear(LED4_PORT, LED4_MASK)
93# define LED4_OFF gpio_ll_set(LED4_PORT, LED4_MASK)
94# else
95# define LED4_ON gpio_ll_set(LED4_PORT, LED4_MASK)
96# define LED4_OFF gpio_ll_clear(LED4_PORT, LED4_MASK)
97# endif
98# define LED4_TOGGLE gpio_ll_toggle(LED4_PORT, LED4_MASK)
99#endif
100
101#if defined(LED5_PORT_NUM) && defined (LED5_PIN_NUM)
102# define LED5_PIN GPIO_PIN(LED5_PORT_NUM, LED5_PIN_NUM)
103# define LED5_MASK (1 << LED5_PIN_NUM)
104# if IS_ACTIVE(LED5_IS_INVERTED)
105# define LED5_ON gpio_ll_clear(LED5_PORT, LED5_MASK)
106# define LED5_OFF gpio_ll_set(LED5_PORT, LED5_MASK)
107# else
108# define LED5_ON gpio_ll_set(LED5_PORT, LED5_MASK)
109# define LED5_OFF gpio_ll_clear(LED5_PORT, LED5_MASK)
110# endif
111# define LED5_TOGGLE gpio_ll_toggle(LED5_PORT, LED5_MASK)
112#endif
113
114#if defined(LED6_PORT_NUM) && defined (LED6_PIN_NUM)
115# define LED6_PIN GPIO_PIN(LED6_PORT_NUM, LED6_PIN_NUM)
116# define LED6_MASK (1 << LED6_PIN_NUM)
117# if IS_ACTIVE(LED6_IS_INVERTED)
118# define LED6_ON gpio_ll_clear(LED6_PORT, LED6_MASK)
119# define LED6_OFF gpio_ll_set(LED6_PORT, LED6_MASK)
120# else
121# define LED6_ON gpio_ll_set(LED6_PORT, LED6_MASK)
122# define LED6_OFF gpio_ll_clear(LED6_PORT, LED6_MASK)
123# endif
124# define LED6_TOGGLE gpio_ll_toggle(LED6_PORT, LED6_MASK)
125#endif
126
127#if defined(LED7_PORT_NUM) && defined (LED7_PIN_NUM)
128# define LED7_PIN GPIO_PIN(LED7_PORT_NUM, LED7_PIN_NUM)
129# define LED7_MASK (1 << LED7_PIN_NUM)
130# if IS_ACTIVE(LED7_IS_INVERTED)
131# define LED7_ON gpio_ll_clear(LED7_PORT, LED7_MASK)
132# define LED7_OFF gpio_ll_set(LED7_PORT, LED7_MASK)
133# else
134# define LED7_ON gpio_ll_set(LED7_PORT, LED7_MASK)
135# define LED7_OFF gpio_ll_clear(LED7_PORT, LED7_MASK)
136# endif
137# define LED7_TOGGLE gpio_ll_toggle(LED7_PORT, LED7_MASK)
138#endif
139
141
142#ifdef __cplusplus
143}
144#endif
145
Peripheral GPIO Low-Level API.
Common macros and compiler attributes/pragmas configuration.