Skip to content

Commit

Permalink
boards: fix stm32-based boards with new gpio driver
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Dupont committed Mar 13, 2017
1 parent 7b686b3 commit c302b76
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 82 deletions.
12 changes: 6 additions & 6 deletions boards/f4vi1/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ extern "C" {
#define LED1_MASK (1 << 3)
#define LED2_MASK (1 << 2)

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

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

#define LED2_ON (LED_PORT->BSRRH = LED2_MASK)
#define LED2_OFF (LED_PORT->BSRRL = LED2_MASK)
#define LED2_ON (LED_PORT->BSRR = LED2_MASK)
#define LED2_OFF (LED_PORT->BSRR = (LED2_MASK << 16))
#define LED2_TOGGLE (LED_PORT->ODR ^= LED2_MASK)
/** @} */

Expand Down
4 changes: 2 additions & 2 deletions boards/limifrog-v1/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ extern "C" {
#define LED0_PORT (GPIOC)
#define LED0_MASK (1 << 3)

#define LED0_ON (LED0_PORT->BSRRL = LED0_MASK)
#define LED0_OFF (LED0_PORT->BSRRH = LED0_MASK)
#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
20 changes: 4 additions & 16 deletions boards/msbiot/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

#include "board.h"
#include "periph/gpio.h"

static void leds_init(void);

Expand All @@ -44,20 +45,7 @@ void board_init(void)
*/
static void leds_init(void)
{
/* enable clock for port GPIOB */
periph_clk_en(AHB1, RCC_AHB1ENR_GPIOBEN);

/* set output speed to 50MHz */
LED_PORT->OSPEEDR &= ~(0xF0030000);
LED_PORT->OSPEEDR |= 0xA0020000;
/* set output type to push-pull */
LED_PORT->OTYPER &= ~(0x0000C100);
/* configure pins as general outputs */
LED_PORT->MODER &= ~(0xF0030000);
LED_PORT->MODER |= 0x50010000;
/* disable pull resistors */
LED_PORT->PUPDR &= ~(0xF0030000);

/* turn all LEDs off */
LED_PORT->BSRRL = 0xC100;
gpio_init(GPIO_PIN(PORT_B, 8), GPIO_OUT);
gpio_init(GPIO_PIN(PORT_B, 14), GPIO_OUT);
gpio_init(GPIO_PIN(PORT_B, 15), GPIO_OUT);
}
12 changes: 6 additions & 6 deletions boards/msbiot/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ extern "C" {
#define LED1_MASK (1 << 14)
#define LED2_MASK (1 << 15)

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

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

#define LED2_ON (LED_PORT->BSRRH = LED2_MASK)
#define LED2_OFF (LED_PORT->BSRRL = LED2_MASK)
#define LED2_ON (LED_PORT->BSRR = LED2_MASK)
#define LED2_OFF (LED_PORT->BSRR = (LED2_MASK << 16))
#define LED2_TOGGLE (LED_PORT->ODR ^= LED2_MASK)
/** @} */

Expand Down
17 changes: 3 additions & 14 deletions boards/nucleo-common/include/board_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,9 @@ extern "C" {

#define LED0_MASK (1 << 5)

#if defined(CPU_FAM_STM32F4)
#define LED_CREG BSRRH
#else
#define LED_CREG BRR
#endif
#if defined(CPU_FAM_STM32F3) || defined(CPU_FAM_STM32F4) || defined(CPU_FAM_STM32L1)
#define LED_SREG BSRRL
#else
#define LED_SREG BSRR
#endif

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

/**
Expand Down
21 changes: 9 additions & 12 deletions boards/nucleo144-f413/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,23 @@ extern "C" {
* @brief LED pin definitions and handlers
* @{
*/
#define LED_CREG BSRRH
#define LED_SREG BSRRL

#define LED0_PIN GPIO_PIN(PORT_B, 0)
#define LED0_MASK (1 << 0)
#define LED0_ON (GPIOA->LED_SREG = LED0_MASK)
#define LED0_OFF (GPIOA->LED_CREG = LED0_MASK)
#define LED0_TOGGLE (GPIOA->ODR ^= LED0_MASK)
#define LED0_ON (GPIOB->BSRR = LED0_MASK)
#define LED0_OFF (GPIOB->BSRR = (LED0_MASK << 16))
#define LED0_TOGGLE (GPIOB->ODR ^= LED0_MASK)

#define LED1_PIN GPIO_PIN(PORT_B, 7)
#define LED1_MASK (1 << 7)
#define LED1_OFF (GPIOA->LED_CREG = LED1_MASK)
#define LED1_ON (GPIOA->LED_SREG = LED1_MASK)
#define LED1_TOGGLE (GPIOA->ODR ^= LED1_MASK)
#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, 14)
#define LED2_MASK (1 << 14)
#define LED2_ON (GPIOA->LED_SREG = LED2_MASK)
#define LED2_OFF (GPIOA->LED_CREG = LED2_MASK)
#define LED2_TOGGLE (GPIOA->ODR ^= LED2_MASK)
#define LED2_ON (GPIOB->BSRR = LED2_MASK)
#define LED2_OFF (GPIOB->BSRR = (LED2_MASK << 16))
#define LED2_TOGGLE (GPIOB->ODR ^= LED2_MASK)
/** @} */

/**
Expand Down
4 changes: 2 additions & 2 deletions boards/nucleo32-f303/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ extern "C" {

#define LED0_MASK (1 << 3)

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

Expand Down
32 changes: 16 additions & 16 deletions boards/stm32f3discovery/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,36 +50,36 @@ extern "C" {
#define LED6_MASK (1 << 12)
#define LED7_MASK (1 << 13)

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

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

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

#define LED3_ON (LED_PORT->BSRRL = LED3_MASK)
#define LED3_OFF (LED_PORT->BSRRH = LED3_MASK)
#define LED3_ON (LED_PORT->BSRR = LED3_MASK)
#define LED3_OFF (LED_PORT->BSRR = (LED3_MASK << 16))
#define LED3_TOGGLE (LED_PORT->ODR ^= LED3_MASK)

#define LED4_ON (LED_PORT->BSRRL = LED4_MASK)
#define LED4_OFF (LED_PORT->BSRRH = LED4_MASK)
#define LED4_ON (LED_PORT->BSRR = LED4_MASK)
#define LED4_OFF (LED_PORT->BSRR = (LED4_MASK << 16))
#define LED4_TOGGLE (LED_PORT->ODR ^= LED4_MASK)

#define LED5_ON (LED_PORT->BSRRL = LED5_MASK)
#define LED5_OFF (LED_PORT->BSRRH = LED5_MASK)
#define LED5_ON (LED_PORT->BSRR = LED5_MASK)
#define LED5_OFF (LED_PORT->BSRR = (LED5_MASK << 16))
#define LED5_TOGGLE (LED_PORT->ODR ^= LED5_MASK)

#define LED6_ON (LED_PORT->BSRRL = LED6_MASK)
#define LED6_OFF (LED_PORT->BSRRH = LED6_MASK)
#define LED6_ON (LED_PORT->BSRR = LED6_MASK)
#define LED6_OFF (LED_PORT->BSRR = (LED6_MASK << 16))
#define LED6_TOGGLE (LED_PORT->ODR ^= LED6_MASK)

#define LED7_ON (LED_PORT->BSRRL = LED7_MASK)
#define LED7_OFF (LED_PORT->BSRRH = LED7_MASK)
#define LED7_ON (LED_PORT->BSRR = LED7_MASK)
#define LED7_OFF (LED_PORT->BSRR = (LED7_MASK << 16))
#define LED7_TOGGLE (LED_PORT->ODR ^= LED7_MASK)
/** @} */

Expand Down
16 changes: 8 additions & 8 deletions boards/stm32f4discovery/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ extern "C" {
#define LED2_MASK (1 << 14)
#define LED3_MASK (1 << 15)

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

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

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

#define LED3_ON (LED_PORT->BSRRL = LED3_MASK)
#define LED3_OFF (LED_PORT->BSRRH = LED3_MASK)
#define LED3_ON (LED_PORT->BSRR = LED3_MASK)
#define LED3_OFF (LED_PORT->BSRR = (LED3_MASK << 16))
#define LED3_TOGGLE (LED_PORT->ODR ^= LED3_MASK)
/** @} */

Expand Down

0 comments on commit c302b76

Please sign in to comment.