diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2012-02-02 23:44:30 +0000 |
---|---|---|
committer | Vincent Palatin <vpalatin@chromium.org> | 2012-02-03 02:00:27 +0000 |
commit | 54f36995a4b626280b868f1efe6049591f3fc53c (patch) | |
tree | f97716aa89d2eb812de3efd8104930f75080663b /board/discovery | |
parent | b2b6eb46b32826386e8ab16ed623a6927df043da (diff) | |
download | chrome-ec-54f36995a4b626280b868f1efe6049591f3fc53c.tar.gz |
stm32l: basic GPIO support
No interrupt support yet.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BUG=None
TEST=on Discovery EC console, using "gpioget" and "gpioset" commands
check we can switch the LED and read the button state.
Change-Id: I01294643d3df070a535dab5a6be02c296487fca5
Diffstat (limited to 'board/discovery')
-rw-r--r-- | board/discovery/board.c | 20 | ||||
-rw-r--r-- | board/discovery/board.h | 8 |
2 files changed, 18 insertions, 10 deletions
diff --git a/board/discovery/board.c b/board/discovery/board.c index 560773d829..e6a360dbbd 100644 --- a/board/discovery/board.c +++ b/board/discovery/board.c @@ -6,7 +6,19 @@ #include "board.h" #include "common.h" +#include "gpio.h" #include "registers.h" +#include "util.h" + +/* GPIO signal list. Must match order from enum gpio_signal. */ +const struct gpio_info gpio_list[GPIO_COUNT] = { + /* Inputs with interrupt handlers are first for efficiency */ + {"USER_BUTTON", GPIO_A, (1<<0), GPIO_INT_BOTH, NULL}, + /* Other inputs */ + /* Outputs */ + {"BLUE_LED", GPIO_B, (1<<6), GPIO_OUT_LOW, NULL}, + {"GREEN_LED", GPIO_B, (1<<7), GPIO_OUT_LOW, NULL}, +}; void configure_board(void) { @@ -20,9 +32,6 @@ void configure_board(void) (0x7 << 12) | (0x7 << 8); STM32L_GPIO_MODER(B) = (STM32L_GPIO_MODER(B) & ~0x00F00000) | 0x00A00000; - - /* Green and blue LEDs : configure port 6 and 7 as output */ - STM32L_GPIO_MODER(B) |= (1 << (7 * 2)) | (1 << (6 * 2)); } /** @@ -37,11 +46,6 @@ int jtag_pre_init(void) return EC_SUCCESS; } -int gpio_pre_init(void) -{ - return EC_SUCCESS; -} - int eeprom_init(void) { return EC_SUCCESS; diff --git a/board/discovery/board.h b/board/discovery/board.h index 42365cacf2..25d681a18b 100644 --- a/board/discovery/board.h +++ b/board/discovery/board.h @@ -18,8 +18,12 @@ /* GPIO signal list */ enum gpio_signal { - GPIO_DUMMY0 = 0, /* Dummy GPIO */ - GPIO_DUMMY1, + /* Inputs with interrupt handlers are first for efficiency */ + GPIO_USER_BUTTON = 0, /* Blue user button */ + /* Other inputs */ + /* Outputs */ + GPIO_BLUE_LED, /* Blue debug LED */ + GPIO_GREEN_LED, /* Green debug LED */ /* Number of GPIOs; not an actual GPIO */ GPIO_COUNT |