boards: mbed_lpc1768: adapt to gpio driver.
This commit is contained in:
parent
6be31d1faa
commit
c99c07aeb2
3
boards/mbed_lpc1768/Makefile.dep
Normal file
3
boards/mbed_lpc1768/Makefile.dep
Normal file
@ -0,0 +1,3 @@
|
||||
ifneq (,$(filter saul_default,$(USEMODULE)))
|
||||
USEMODULE += saul_gpio
|
||||
endif
|
||||
@ -1,4 +1,5 @@
|
||||
# Put defined MCU peripherals here (in alphabetical order)
|
||||
FEATURES_PROVIDED += periph_gpio
|
||||
FEATURES_PROVIDED += periph_timer
|
||||
FEATURES_PROVIDED += periph_uart
|
||||
|
||||
|
||||
@ -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 */
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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" {
|
||||
@ -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)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
||||
61
boards/mbed_lpc1768/include/gpio_params.h
Normal file
61
boards/mbed_lpc1768/include/gpio_params.h
Normal file
@ -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 */
|
||||
/** @} */
|
||||
Loading…
x
Reference in New Issue
Block a user