Skip to content

Commit

Permalink
Merge pull request #18415 from maribu/boards/common/stm32
Browse files Browse the repository at this point in the history
boards/common/stm32: clean up LED definitions
  • Loading branch information
maribu authored Aug 25, 2022
2 parents 3ae973a + db3c51d commit 8d14769
Show file tree
Hide file tree
Showing 41 changed files with 457 additions and 2,430 deletions.
26 changes: 8 additions & 18 deletions boards/alientek-pandora/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,14 @@ extern "C" {
* @name LED pin definitions and handlers
* @{
*/
#define LED0_PIN GPIO_PIN(PORT_E, 7) /**< LED0 gpio pin */
#define LED0_MASK (1 << 7) /**< LED0 gpio mask */
#define LED0_PIN_NUM 7
#define LED0_PORT_NUM PORT_E

#define LED0_ON (GPIOB->BSRR = LED0_MASK) /**< Turn on LED0 */
#define LED0_OFF (GPIOB->BSRR = (LED0_MASK << 16)) /**< Turn off LED0 */
#define LED0_TOGGLE (GPIOB->ODR ^= LED0_MASK) /**< Toggle LED0 */
#define LED1_PIN_NUM 8
#define LED1_PORT_NUM PORT_E

#define LED1_PIN GPIO_PIN(PORT_E, 8) /**< LED1 gpio pin */
#define LED1_MASK (1 << 8) /**< LED1 gpio mask */

#define LED1_ON (GPIOE->BSRR = LED1_MASK) /**< Turn on LED1 */
#define LED1_OFF (GPIOE->BSRR = (LED1_MASK << 16)) /**< Turn off LED1 */
#define LED1_TOGGLE (GPIOE->ODR ^= LED1_MASK) /**< Toggle LED1 */

#define LED2_PIN GPIO_PIN(PORT_E, 9) /**< LED2 gpio pin */
#define LED2_MASK (1 << 9) /**< LED2 gpio mask */

#define LED2_ON (GPIOE->BSRR = LED2_MASK) /**< Turn on LED2 */
#define LED2_OFF (GPIOE->BSRR = (LED2_MASK << 16)) /**< Turn off LED2 */
#define LED2_TOGGLE (GPIOE->ODR ^= LED2_MASK) /**< Toggle LED2 */
#define LED2_PIN_NUM 9
#define LED2_PORT_NUM PORT_E

/** @} */

Expand All @@ -75,5 +63,7 @@ extern "C" {
}
#endif

#include "stm32_leds.h"

#endif /* BOARD_H */
/** @} */
34 changes: 10 additions & 24 deletions boards/b-l072z-lrwan1/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,33 +54,17 @@ extern "C" {
* @name LED pin definitions and handlers
* @{
*/
#define LED0_PIN GPIO_PIN(PORT_A, 5)
#define LED0_MASK (1 << 5)
#define LED0_PIN_NUM 5
#define LED0_PORT_NUM PORT_A

#define LED0_ON (GPIOA->BSRR = LED0_MASK)
#define LED0_OFF (GPIOA->BSRR = (LED0_MASK << 16))
#define LED0_TOGGLE (GPIOA->ODR ^= LED0_MASK)
#define LED1_PIN_NUM 5
#define LED1_PORT_NUM PORT_B

#define LED1_PIN GPIO_PIN(PORT_B, 5)
#define LED1_MASK (1 << 5)
#define LED2_PIN_NUM 6
#define LED2_PORT_NUM PORT_B

#define LED1_ON (GPIOB->BSRR = LED1_MASK)
#define LED1_OFF (GPIOB->BSRR = (LED1_MASK << 16))
#define LED1_TOGGLE (GPIOB->ODR ^= LED1_MASK)

#define LED2_PIN GPIO_PIN(PORT_B, 6)
#define LED2_MASK (1 << 6)

#define LED2_ON (GPIOB->BSRR = LED2_MASK)
#define LED2_OFF (GPIOB->BSRR = (LED2_MASK << 16))
#define LED2_TOGGLE (GPIOB->ODR ^= LED2_MASK)

#define LED3_PIN GPIO_PIN(PORT_B, 7)
#define LED3_MASK (1 << 7)

#define LED3_ON (GPIOB->BSRR = LED3_MASK)
#define LED3_OFF (GPIOB->BSRR = (LED3_MASK << 16))
#define LED3_TOGGLE (GPIOB->ODR ^= LED3_MASK)
#define LED3_PIN_NUM 7
#define LED3_PORT_NUM PORT_B
/** @} */

/**
Expand All @@ -95,5 +79,7 @@ extern "C" {
}
#endif

#include "stm32_leds.h"

#endif /* BOARD_H */
/** @} */
18 changes: 6 additions & 12 deletions boards/b-l475e-iot01a/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,11 @@ extern "C" {
* @name LED pin definitions and handlers
* @{
*/
#define LED0_PIN GPIO_PIN(PORT_A, 5)
#define LED0_MASK (1 << 5)
#define LED0_PIN_NUM 5
#define LED0_PORT_NUM PORT_A

#define LED0_ON (GPIOA->BSRR = LED0_MASK)
#define LED0_OFF (GPIOA->BSRR = (LED0_MASK << 16))
#define LED0_TOGGLE (GPIOA->ODR ^= LED0_MASK)

#define LED1_PIN GPIO_PIN(PORT_B, 14)
#define LED1_MASK (1 << 14)

#define LED1_ON (GPIOB->BSRR = LED1_MASK)
#define LED1_OFF (GPIOB->BSRR = (LED1_MASK << 16))
#define LED1_TOGGLE (GPIOB->ODR ^= LED1_MASK)
#define LED1_PIN_NUM 14
#define LED1_PORT_NUM PORT_B
/** @} */

/**
Expand Down Expand Up @@ -87,5 +79,7 @@ extern "C" {
}
#endif

#include "stm32_leds.h"

#endif /* BOARD_H */
/** @} */
26 changes: 8 additions & 18 deletions boards/b-u585i-iot02a/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,14 @@ extern "C" {
* @name LED pin definitions and handlers
* @{
*/
#define LED0_PIN GPIO_PIN(PORT_E, 13)
#define LED0_MASK (1 << 13)
#define LED0_PIN_NUM 13
#define LED0_PORT_NUM PORT_E

#define LED0_ON (GPIOE->BSRR = LED0_MASK)
#define LED0_OFF (GPIOE->BSRR = (LED0_MASK << 16))
#define LED0_TOGGLE (GPIOE->ODR ^= LED0_MASK)
#define LED1_PIN_NUM 6
#define LED1_PORT_NUM PORT_H

#define LED1_PIN GPIO_PIN(PORT_H, 6)
#define LED1_MASK (1 << 6)

#define LED1_ON (GPIOH->BSRR = LED1_MASK)
#define LED1_OFF (GPIOH->BSRR = (LED1_MASK << 16))
#define LED1_TOGGLE (GPIOH->ODR ^= LED1_MASK)

#define LED2_PIN GPIO_PIN(PORT_H, 7)
#define LED2_MASK (1 << 7)

#define LED2_ON (GPIOH->BSRR = LED2_MASK)
#define LED2_OFF (GPIOH->BSRR = (LED2_MASK << 16))
#define LED2_TOGGLE (GPIOH->ODR ^= LED2_MASK)
#define LED2_PIN_NUM 7
#define LED2_PORT_NUM PORT_H
/** @} */

/**
Expand Down Expand Up @@ -79,5 +67,7 @@ extern "C" {
}
#endif

#include "stm32_leds.h"

#endif /* BOARD_H */
/** @} */
5 changes: 2 additions & 3 deletions boards/blackpill-128kib/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ extern "C" {
* @name Macros for controlling the on-board LED.
* @{
*/
#define LED0_PORT GPIOB /**< GPIO-Port the LED is connected to */
#define LED0_PORTNUM PORT_B /**< GPIO Port number the LED is connected to */
#define LED0_PINNUM (12) /**< Pin number the LED is connected to */
#define LED0_PORT_NUM PORT_B /**< GPIO Port number the LED is connected to */
#define LED0_PIN_NUM (12) /**< Pin number the LED is connected to */
/** @} */

#ifdef __cplusplus
Expand Down
5 changes: 2 additions & 3 deletions boards/blackpill/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ extern "C" {
* @name Macros for controlling the on-board LED.
* @{
*/
#define LED0_PORT GPIOB /**< GPIO-Port the LED is connected to */
#define LED0_PORTNUM PORT_B /**< GPIO Port number the LED is connected to */
#define LED0_PINNUM (12) /**< Pin number the LED is connected to */
#define LED0_PORT_NUM PORT_B /**< GPIO Port number the LED is connected to */
#define LED0_PIN_NUM 12 /**< Pin number the LED is connected to */
/** @} */

#ifdef __cplusplus
Expand Down
12 changes: 5 additions & 7 deletions boards/bluepill-stm32f030c8/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,16 @@ extern "C" {
* @name LED pin definitions and handlers
* @{
*/
#define LED0_PORT GPIOC
#define LED0_PIN GPIO_PIN(PORT_C, 13)
#define LED0_MASK (1 << 13)

#define LED0_ON (LED0_PORT->BSRR = (LED0_MASK << 16))
#define LED0_OFF (LED0_PORT->BSRR = (LED0_MASK << 0))
#define LED0_TOGGLE (LED0_PORT->ODR ^= LED0_MASK)
#define LED0_PIN_NUM 13
#define LED0_PORT_NUM PORT_C
#define LED0_IS_INVERTED 1
/** @} */

#ifdef __cplusplus
}
#endif

#include "stm32_leds.h"

#endif /* BOARD_H */
/** @} */
20 changes: 8 additions & 12 deletions boards/common/blxxxpill/include/board_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,15 @@ extern "C" {
* @name Macros for controlling the on-board LED.
* @{
*/
#ifndef LED0_PORT
#define LED0_PORT GPIOC /**< GPIO-Port the LED is connected to */
#ifndef LED0_PORT_NUM
#define LED0_PORT_NUM PORT_C /**< GPIO Port number the LED is connected to */
#endif
#ifndef LED0_PORTNUM
#define LED0_PORTNUM PORT_C /**< GPIO Port number the LED is connected to */
#ifndef LED0_PIN_NUM
#define LED0_PIN_NUM (13) /**< Pin number the LED is connected to */
#endif
#ifndef LED0_PINNUM
#define LED0_PINNUM (13) /**< Pin number the LED is connected to */
#ifndef LED0_IS_INVERTED
#define LED0_IS_INVERTED 1
#endif
#define LED0_PIN GPIO_PIN(LED0_PORTNUM, LED0_PINNUM) /**< GPIO-Pin the LED is connected to */
#define LED0_MASK (1 << LED0_PINNUM)

#define LED0_ON (LED0_PORT->BSRR = (LED0_MASK << 16)) /**< Turn LED0 on */
#define LED0_OFF (LED0_PORT->BSRR = LED0_MASK) /**< Turn LED0 off */
#define LED0_TOGGLE (LED0_PORT->ODR ^= LED0_MASK) /**< Toggle LED0 */
/** @} */

/**
Expand Down Expand Up @@ -74,5 +68,7 @@ extern "C" {
}
#endif

#include "stm32_leds.h"

#endif /* BOARD_COMMON_H */
/** @} */
25 changes: 8 additions & 17 deletions boards/common/iotlab/include/board_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,30 +77,21 @@ extern "C" {
* @name LED pin definitions and handlers
* @{
*/
#define LED0_PIN GPIO_PIN(PORT_D, 2)
#define LED1_PIN GPIO_PIN(PORT_B, 5)
#define LED2_PIN GPIO_PIN(PORT_C, 10)
#define LED0_PIN_NUM 2
#define LED0_PORT_NUM PORT_D

#define LED0_MASK (1 << 2)
#define LED1_MASK (1 << 5)
#define LED2_MASK (1 << 10)
#define LED1_PIN_NUM 5
#define LED1_PORT_NUM PORT_B

#define LED0_ON (GPIOD->ODR &= ~LED0_MASK)
#define LED0_OFF (GPIOD->ODR |= LED0_MASK)
#define LED0_TOGGLE (GPIOD->ODR ^= LED0_MASK)

#define LED1_ON (GPIOB->ODR &= ~LED1_MASK)
#define LED1_OFF (GPIOB->ODR |= LED1_MASK)
#define LED1_TOGGLE (GPIOB->ODR ^= LED1_MASK)

#define LED2_ON (GPIOC->ODR &= ~LED2_MASK)
#define LED2_OFF (GPIOC->ODR |= LED2_MASK)
#define LED2_TOGGLE (GPIOC->ODR ^= LED2_MASK)
#define LED2_PIN_NUM 10
#define LED2_PORT_NUM PORT_C
/** @} */

#ifdef __cplusplus
}
#endif

#include "stm32_leds.h"

#endif /* BOARD_COMMON_H */
/** @} */
35 changes: 12 additions & 23 deletions boards/common/nucleo144/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,23 @@ extern "C" {
*/
#if defined(CPU_MODEL_STM32L496ZG) || defined(CPU_MODEL_STM32L4R5ZI) || \
defined(CPU_MODEL_STM32L552ZE)
#define LED0_PORT GPIOC
#define LED0_PIN GPIO_PIN(PORT_C, 7)
#define LED0_MASK (1 << 7)
#define LED0_PIN_NUM 7
#define LED0_PORT_NUM PORT_C
#else
#define LED0_PORT GPIOB
#define LED0_PIN GPIO_PIN(PORT_B, 0)
#define LED0_MASK (1 << 0)
#define LED0_PIN_NUM 0
#define LED0_PORT_NUM PORT_B
#endif
#define LED0_ON (LED0_PORT->BSRR = LED0_MASK)
#define LED0_OFF (LED0_PORT->BSRR = (LED0_MASK << 16))
#define LED0_TOGGLE (LED0_PORT->ODR ^= LED0_MASK)

#define LED1_PIN GPIO_PIN(PORT_B, 7)
#define LED1_MASK (1 << 7)
#define LED1_ON (GPIOB->BSRR = LED1_MASK)
#define LED1_OFF (GPIOB->BSRR = (LED1_MASK << 16))
#define LED1_TOGGLE (GPIOB->ODR ^= LED1_MASK)
#define LED1_PIN_NUM 7
#define LED1_PORT_NUM PORT_B

#if defined(CPU_MODEL_STM32L552ZE)
#define LED2_PORT GPIOA
#define LED2_PIN GPIO_PIN(PORT_A, 9)
#define LED2_MASK (1 << 9)
#define LED2_PIN_NUM 9
#define LED2_PORT_NUM PORT_A
#else
#define LED2_PORT GPIOB
#define LED2_PIN GPIO_PIN(PORT_B, 14)
#define LED2_MASK (1 << 14)
#define LED2_PIN_NUM 14
#define LED2_PORT_NUM PORT_B
#endif
#define LED2_ON (LED2_PORT->BSRR = LED2_MASK)
#define LED2_OFF (LED2_PORT->BSRR = (LED2_MASK << 16))
#define LED2_TOGGLE (LED2_PORT->ODR ^= LED2_MASK)
/** @} */

/**
Expand All @@ -83,5 +70,7 @@ extern "C" {
}
#endif

#include "stm32_leds.h"

#endif /* BOARD_H */
/** @} */
9 changes: 4 additions & 5 deletions boards/common/nucleo32/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,15 @@ extern "C" {
* @name Macros for controlling the on-board LED (LD3).
* @{
*/
#define LED0_PIN GPIO_PIN(PORT_B, 3)
#define LED0_MASK (1 << 3)
#define LED0_ON (GPIOB->BSRR = LED0_MASK)
#define LED0_OFF (GPIOB->BSRR = (LED0_MASK << 16))
#define LED0_TOGGLE (GPIOB->ODR ^= LED0_MASK)
#define LED0_PIN_NUM 3
#define LED0_PORT_NUM PORT_B
/** @} */

#ifdef __cplusplus
}
#endif

#include "stm32_leds.h"

#endif /* BOARD_H */
/** @} */
16 changes: 6 additions & 10 deletions boards/common/nucleo64/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,12 @@ extern "C" {
* @{
*/
#if defined(CPU_MODEL_STM32F302R8) || defined(CPU_MODEL_STM32L433RC)
#define LED0_PORT GPIOB
#define LED0_PIN GPIO_PIN(PORT_B, 13)
#define LED0_MASK (1 << 13)
#define LED0_PIN_NUM 13
#define LED0_PORT_NUM PORT_B
#else
#define LED0_PORT GPIOA
#define LED0_PIN GPIO_PIN(PORT_A, 5)
#define LED0_MASK (1 << 5)
#define LED0_PIN_NUM 5
#define LED0_PORT_NUM PORT_A
#endif

#define LED0_ON (LED0_PORT->BSRR = LED0_MASK)
#define LED0_OFF (LED0_PORT->BSRR = (LED0_MASK << 16))
#define LED0_TOGGLE (LED0_PORT->ODR ^= LED0_MASK)
/** @} */

/**
Expand Down Expand Up @@ -97,5 +91,7 @@ static const motor_driver_config_t motor_driver_config[] = {
}
#endif

#include "stm32_leds.h"

#endif /* BOARD_H */
/** @} */
Loading

0 comments on commit 8d14769

Please sign in to comment.