diff options
author | Anton Staaf <robotboy@chromium.org> | 2014-07-01 09:02:28 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-07-09 20:30:21 +0000 |
commit | c14b0644e356c8edacdd2a8d0a070fbbc4c23b4c (patch) | |
tree | b2006f1358a2a6b48fd8e2e3a28c9666162e8a3d | |
parent | 0a9545cb9e48822d37073b2059848e66141803ff (diff) | |
download | chrome-ec-c14b0644e356c8edacdd2a8d0a070fbbc4c23b4c.tar.gz |
discovery-stm32f072: Initial working version
This version of the EC firmware just provides a console and some
blinking lights for the stm32f0 discovery board. This is a
convenient board to work with for peripheral bringup.
Signed-off-by: Anton Staaf <robotboy@chromium.org>
BRANCH=none
TEST=make buildall -j
Change-Id: I9ae87235e8a505d58fa7a5c996528c4dd6c3f2ac
Reviewed-on: https://chromium-review.googlesource.com/207130
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
-rw-r--r-- | board/discovery-stm32f072/Makefile | 20 | ||||
-rw-r--r-- | board/discovery-stm32f072/board.c | 41 | ||||
-rw-r--r-- | board/discovery-stm32f072/board.h | 40 | ||||
-rw-r--r-- | board/discovery-stm32f072/build.mk | 13 | ||||
-rw-r--r-- | board/discovery-stm32f072/ec.tasklist | 21 | ||||
-rw-r--r-- | board/discovery-stm32f072/gpio.inc | 19 |
6 files changed, 154 insertions, 0 deletions
diff --git a/board/discovery-stm32f072/Makefile b/board/discovery-stm32f072/Makefile new file mode 100644 index 0000000000..20874220b1 --- /dev/null +++ b/board/discovery-stm32f072/Makefile @@ -0,0 +1,20 @@ +# Copyright (c) 2014 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# +# Simple flashing command to reflash the discovery board using openocd +# +.PHONY: flash + +flash: + sudo openocd -f board/stm32f0discovery.cfg \ + -c "gdb_port 0" \ + -c "tcl_port 0" \ + -c "telnet_port 0" \ + -c "init" \ + -c "reset init" \ + -c "flash write_image erase ../../build/discovery-stm32f072/ec.bin 0x08000000" \ + -c "reset halt" \ + -c "resume" \ + -c "shutdown" diff --git a/board/discovery-stm32f072/board.c b/board/discovery-stm32f072/board.c new file mode 100644 index 0000000000..546b07d8d9 --- /dev/null +++ b/board/discovery-stm32f072/board.c @@ -0,0 +1,41 @@ +/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +/* STM32F072-discovery board configuration */ + +#include "common.h" +#include "gpio.h" +#include "hooks.h" +#include "registers.h" +#include "task.h" +#include "util.h" + +void button_event(enum gpio_signal signal); + +#include "gpio_list.h" + +void button_event(enum gpio_signal signal) +{ + static int count = 0; + + gpio_set_level(GPIO_LED_U, (count & 0x03) == 0); + gpio_set_level(GPIO_LED_R, (count & 0x03) == 1); + gpio_set_level(GPIO_LED_D, (count & 0x03) == 2); + gpio_set_level(GPIO_LED_L, (count & 0x03) == 3); + + count++; +} + +/* Initialize board. */ +static void board_init(void) +{ + gpio_enable_interrupt(GPIO_USER_BUTTON); +} +DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); + +/* Pins with alternate functions */ +const struct gpio_alt_func gpio_alt_funcs[] = { + {GPIO_A, 0xC000, 1, MODULE_UART}, /* USART2: PA14/PA15 */ +}; +const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); diff --git a/board/discovery-stm32f072/board.h b/board/discovery-stm32f072/board.h new file mode 100644 index 0000000000..459ac8eb3a --- /dev/null +++ b/board/discovery-stm32f072/board.h @@ -0,0 +1,40 @@ +/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* STM32F072-discovery board configuration */ + +#ifndef __BOARD_H +#define __BOARD_H + +/* 48 MHz SYSCLK clock frequency */ +#define CPU_CLOCK 48000000 + +/* the UART console is on USART2 (PA14/PA15) */ +#undef CONFIG_UART_CONSOLE +#define CONFIG_UART_CONSOLE 2 + +/* Optional features */ +#define CONFIG_STM_HWTIMER32 +#define CONFIG_HW_CRC + +#undef CONFIG_WATCHDOG_HELP +#undef CONFIG_LID_SWITCH + +/* + * Allow dangerous commands all the time, since we don't have a write protect + * switch. + */ +#define CONFIG_SYSTEM_UNLOCKED + +#ifndef __ASSEMBLER__ + +/* Timer selection */ +#define TIM_CLOCK32 2 + +#include "gpio_signal.h" + +#endif /* !__ASSEMBLER__ */ + +#endif /* __BOARD_H */ diff --git a/board/discovery-stm32f072/build.mk b/board/discovery-stm32f072/build.mk new file mode 100644 index 0000000000..f3d39ab655 --- /dev/null +++ b/board/discovery-stm32f072/build.mk @@ -0,0 +1,13 @@ +# -*- makefile -*- +# Copyright (c) 2014 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +# Board specific files build + +# the IC is STmicro STM32F072RBT6 +CHIP:=stm32 +CHIP_FAMILY:=stm32f0 +CHIP_VARIANT:=stm32f07x + +board-y=board.o diff --git a/board/discovery-stm32f072/ec.tasklist b/board/discovery-stm32f072/ec.tasklist new file mode 100644 index 0000000000..8ff4e8234b --- /dev/null +++ b/board/discovery-stm32f072/ec.tasklist @@ -0,0 +1,21 @@ +/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * List of enabled tasks in the priority order + * + * The first one has the lowest priority. + * + * For each task, use the macro TASK_ALWAYS(n, r, d, s) for base tasks and + * TASK_NOTEST(n, r, d, s) for tasks that can be excluded in test binaries, + * where : + * 'n' in the name of the task + * 'r' in the main routine of the task + * 'd' in an opaque parameter passed to the routine at startup + * 's' is the stack size in bytes; must be a multiple of 8 + */ +#define CONFIG_TASK_LIST \ + TASK_ALWAYS(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \ + TASK_ALWAYS(CONSOLE, console_task, NULL, TASK_STACK_SIZE) diff --git a/board/discovery-stm32f072/gpio.inc b/board/discovery-stm32f072/gpio.inc new file mode 100644 index 0000000000..f3e2106452 --- /dev/null +++ b/board/discovery-stm32f072/gpio.inc @@ -0,0 +1,19 @@ +/* -*- mode:c -*- + * + * Copyright (c) 2014 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Inputs with interrupt handlers are first for efficiency */ +GPIO(USER_BUTTON, A, 0, GPIO_INT_FALLING, button_event) + +/* Outputs */ +GPIO(LED_U, C, 6, GPIO_OUT_LOW, NULL) +GPIO(LED_D, C, 7, GPIO_OUT_LOW, NULL) +GPIO(LED_L, C, 8, GPIO_OUT_LOW, NULL) +GPIO(LED_R, C, 9, GPIO_OUT_LOW, NULL) + +/* Unimplemented signals which we need to emulate for now */ +UNIMPLEMENTED(ENTERING_RW) +UNIMPLEMENTED(WP_L) |