1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

boards: fix stm32-based boards with new gpio driver

This commit is contained in:
Vincent Dupont 2017-03-07 13:42:23 +01:00
parent 7b686b3015
commit c302b7601d
9 changed files with 56 additions and 82 deletions

View File

@ -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)
/** @} */

View File

@ -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)
/** @} */

View File

@ -19,6 +19,7 @@
*/
#include "board.h"
#include "periph/gpio.h"
static void leds_init(void);
@ -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);
}

View File

@ -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)
/** @} */

View File

@ -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)
/** @} */
/**

View File

@ -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)
/** @} */
/**

View File

@ -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)
/** @} */

View File

@ -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)
/** @} */

View File

@ -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)
/** @} */