Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions boards/mbed_lpc1768/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_gpio
endif
1 change: 1 addition & 0 deletions boards/mbed_lpc1768/Makefile.features
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Put defined MCU peripherals here (in alphabetical order)
FEATURES_PROVIDED += periph_gpio
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart

Expand Down
41 changes: 19 additions & 22 deletions boards/mbed_lpc1768/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,33 @@
* @brief Board specific implementations for the mbed LPC1768 board
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Bas Stottelaar <basstottelaar@gmail.com>
*
* @}
*/

#include "board.h"

static void leds_init(void);
#include "periph/gpio.h"

extern void SystemInit(void);

/**
* @brief Initialize the on-board LEDs.
*/
static void leds_init(void)
{
gpio_init(LED0_PIN, GPIO_OUT);
gpio_init(LED1_PIN, GPIO_OUT);
gpio_init(LED2_PIN, GPIO_OUT);
gpio_init(LED3_PIN, GPIO_OUT);

LED0_OFF;
LED1_OFF;
LED2_OFF;
LED3_OFF;
}

void board_init(void)
{
/* initialize core clocks via CMSIS function */
Expand All @@ -32,24 +50,3 @@ void board_init(void)
/* initialize the boards LEDs */
leds_init();
}

/**
* @brief Initialize the boards on-board LEDs (LED1 to LED4)
*
* The LED initialization is hard-coded in this function. As the LEDs are soldered
* onto the board they are fixed to their CPU pins.
*
* The LEDs are connected to the following pins:
* - LED1: P1.18
* - LED2: P1.20
* - LED3: P1.21
* - LED4: P1.23
*/
static void leds_init(void)
{
/* configure LED pins as output */
LED_PORT->FIODIR |= (LED0_MASK | LED1_MASK | LED2_MASK | LED3_MASK);

/* clear all LEDs */
LED_PORT->FIOCLR = (LED0_MASK | LED1_MASK | LED2_MASK | LED3_MASK);
}
35 changes: 14 additions & 21 deletions boards/mbed_lpc1768/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
#ifndef BOARD_H
#define BOARD_H

#include <stdint.h>

#include "bitarithm.h"
#include "cpu.h"
#include "periph_conf.h"
#include "periph/gpio.h"

#ifdef __cplusplus
extern "C" {
Expand All @@ -41,24 +40,18 @@ extern "C" {
#define LED2_PIN GPIO_PIN(1, 21)
#define LED3_PIN GPIO_PIN(1, 23)

#define LED_PORT (LPC_GPIO1)
#define LED0_MASK (BIT18)
#define LED1_MASK (BIT20)
#define LED2_MASK (BIT21)
#define LED3_MASK (BIT23)

#define LED0_ON (LED_PORT->FIOSET = LED0_MASK)
#define LED0_OFF (LED_PORT->FIOCLR = LED0_MASK)
#define LED0_TOGGLE (LED_PORT->FIOPIN ^= LED0_MASK)
#define LED1_ON (LED_PORT->FIOSET = LED1_MASK)
#define LED1_OFF (LED_PORT->FIOCLR = LED1_MASK)
#define LED1_TOGGLE (LED_PORT->FIOPIN ^= LED1_MASK)
#define LED2_ON (LED_PORT->FIOSET = LED2_MASK)
#define LED2_OFF (LED_PORT->FIOCLR = LED2_MASK)
#define LED2_TOGGLE (LED_PORT->FIOPIN ^= LED2_MASK)
#define LED3_ON (LED_PORT->FIOSET = LED3_MASK)
#define LED3_OFF (LED_PORT->FIOCLR = LED3_MASK)
#define LED3_TOGGLE (LED_PORT->FIOPIN ^= LED3_MASK)
#define LED0_ON gpio_set(LED0_PIN)
#define LED0_OFF gpio_clear(LED0_PIN)
#define LED0_TOGGLE gpio_toggle(LED0_PIN)
#define LED1_ON gpio_set(LED1_PIN)
#define LED1_OFF gpio_clear(LED1_PIN)
#define LED1_TOGGLE gpio_toggle(LED1_PIN)
#define LED2_ON gpio_set(LED2_PIN)
#define LED2_OFF gpio_clear(LED2_PIN)
#define LED2_TOGGLE gpio_toggle(LED2_PIN)
#define LED3_ON gpio_set(LED3_PIN)
#define LED3_OFF gpio_clear(LED3_PIN)
#define LED3_TOGGLE gpio_toggle(LED3_PIN)
/** @} */

/**
Expand Down
61 changes: 61 additions & 0 deletions boards/mbed_lpc1768/include/gpio_params.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (C) 2017 Bas Stottelaar <basstottelaar@gmail.com>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup boards_mbed_lpc1768
* @{
*
* @file
* @brief Board specific configuration of direct mapped GPIOs
*
* @author Bas Stottelaar <basstottelaar@gmail.com>
*/

#ifndef GPIO_PARAMS_H
#define GPIO_PARAMS_H

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

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief GPIO pin configuration
*/
static const saul_gpio_params_t saul_gpio_params[] =
{
{
.name = "LED 0",
.pin = LED0_PIN,
.mode = GPIO_OUT
},
{
.name = "LED 1",
.pin = LED1_PIN,
.mode = GPIO_OUT
},
{
.name = "LED 2",
.pin = LED2_PIN,
.mode = GPIO_OUT
},
{
.name = "LED 3",
.pin = LED3_PIN,
.mode = GPIO_OUT
}
};

#ifdef __cplusplus
}
#endif

#endif /* GPIO_PARAMS_H */
/** @} */
3 changes: 3 additions & 0 deletions boards/seeeduino_arch-pro/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_gpio
endif
1 change: 1 addition & 0 deletions boards/seeeduino_arch-pro/Makefile.features
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Put defined MCU peripherals here (in alphabetical order)
FEATURES_PROVIDED += periph_gpio
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart

Expand Down
42 changes: 18 additions & 24 deletions boards/seeeduino_arch-pro/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,26 @@

#include "board.h"

static void leds_init(void);
#include "periph/gpio.h"

extern void SystemInit(void);

/**
* @brief Initialize the on-board LEDs.
*/
static void leds_init(void)
{
gpio_init(LED0_PIN, GPIO_OUT);
gpio_init(LED1_PIN, GPIO_OUT);
gpio_init(LED2_PIN, GPIO_OUT);
gpio_init(LED3_PIN, GPIO_OUT);

LED0_OFF;
LED1_OFF;
LED2_OFF;
LED3_OFF;
}

void board_init(void)
{
/* initialize core clocks via CMSIS function */
Expand All @@ -33,26 +50,3 @@ void board_init(void)
/* initialize the boards LEDs */
leds_init();
}

/**
* @brief Initialize the boards on-board LEDs (LED1 to LED4)
*
* The LED initialization is hard-coded in this function. As the LEDs are
* soldered onto the board they are fixed to their CPU pins.
*
* The LEDs are connected to the following pins:
* - LED1: P1.18
* - LED2: P1.20
* - LED3: P1.21
* - LED4: P1.23
*
* The LEDs are active-low (current-sink).
*/
static void leds_init(void)
{
/* configure LED pins as output */
LED_PORT->FIODIR |= (LED0_MASK | LED1_MASK | LED2_MASK | LED3_MASK);

/* turn off all LEDs */
LED_PORT->FIOSET = (LED0_MASK | LED1_MASK | LED2_MASK | LED3_MASK);
}
35 changes: 14 additions & 21 deletions boards/seeeduino_arch-pro/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
#ifndef BOARD_H
#define BOARD_H

#include <stdint.h>

#include "bitarithm.h"
#include "cpu.h"
#include "periph_conf.h"
#include "periph/gpio.h"

#ifdef __cplusplus
extern "C" {
Expand All @@ -42,24 +41,18 @@ extern "C" {
#define LED2_PIN GPIO_PIN(1, 21)
#define LED3_PIN GPIO_PIN(1, 23)

#define LED_PORT (LPC_GPIO1)
#define LED0_MASK (BIT18)
#define LED1_MASK (BIT20)
#define LED2_MASK (BIT21)
#define LED3_MASK (BIT23)

#define LED0_ON (LED_PORT->FIOCLR = LED0_MASK)
#define LED0_OFF (LED_PORT->FIOSET = LED0_MASK)
#define LED0_TOGGLE (LED_PORT->FIOPIN ^= LED0_MASK)
#define LED1_ON (LED_PORT->FIOCLR = LED1_MASK)
#define LED1_OFF (LED_PORT->FIOSET = LED1_MASK)
#define LED1_TOGGLE (LED_PORT->FIOPIN ^= LED1_MASK)
#define LED2_ON (LED_PORT->FIOCLR = LED2_MASK)
#define LED2_OFF (LED_PORT->FIOSET = LED2_MASK)
#define LED2_TOGGLE (LED_PORT->FIOPIN ^= LED2_MASK)
#define LED3_ON (LED_PORT->FIOCLR = LED3_MASK)
#define LED3_OFF (LED_PORT->FIOSET = LED3_MASK)
#define LED3_TOGGLE (LED_PORT->FIOPIN ^= LED3_MASK)
#define LED0_ON gpio_clear(LED0_PIN)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not keeping the previous defines ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to keep implementation in one place (gpio.c), and not having two different ways to toggle a LED.

#define LED0_OFF gpio_set(LED0_PIN)
#define LED0_TOGGLE gpio_toggle(LED0_PIN)
#define LED1_ON gpio_clear(LED1_PIN)
#define LED1_OFF gpio_set(LED1_PIN)
#define LED1_TOGGLE gpio_toggle(LED1_PIN)
#define LED2_ON gpio_clear(LED2_PIN)
#define LED2_OFF gpio_set(LED2_PIN)
#define LED2_TOGGLE gpio_toggle(LED2_PIN)
#define LED3_ON gpio_clear(LED3_PIN)
#define LED3_OFF gpio_set(LED3_PIN)
#define LED3_TOGGLE gpio_toggle(LED3_PIN)
/** @} */

/**
Expand Down
65 changes: 65 additions & 0 deletions boards/seeeduino_arch-pro/include/gpio_params.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (C) 2017 Bas Stottelaar <basstottelaar@gmail.com>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup boards_seeduino_arch-pro
* @{
*
* @file
* @brief Board specific configuration of direct mapped GPIOs
*
* @author Bas Stottelaar <basstottelaar@gmail.com>
*/

#ifndef GPIO_PARAMS_H
#define GPIO_PARAMS_H

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

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief GPIO pin configuration
*/
static const saul_gpio_params_t saul_gpio_params[] =
{
{
.name = "LED 0",
.pin = LED0_PIN,
.mode = GPIO_OUT,
.flags = SAUL_GPIO_INVERTED
},
{
.name = "LED 1",
.pin = LED1_PIN,
.mode = GPIO_OUT,
.flags = SAUL_GPIO_INVERTED
},
{
.name = "LED 2",
.pin = LED2_PIN,
.mode = GPIO_OUT,
.flags = SAUL_GPIO_INVERTED
},
{
.name = "LED 3",
.pin = LED3_PIN,
.mode = GPIO_OUT,
.flags = SAUL_GPIO_INVERTED
}
};

#ifdef __cplusplus
}
#endif

#endif /* GPIO_PARAMS_H */
/** @} */
Loading