summaryrefslogtreecommitdiff
path: root/common/main.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2011-12-07 18:51:09 +0000
committerVincent Palatin <vpalatin@chromium.org>2011-12-07 19:10:02 +0000
commitbdf7da5b082f6d18dd27f1e5d8cca0b12154a28c (patch)
tree6f14312a6cc70d056efc2bede8728c0868266719 /common/main.c
parentabe5786058f4b60dc6d30e7d7c964aae850caa1f (diff)
downloadchrome-ec-bdf7da5b082f6d18dd27f1e5d8cca0b12154a28c.tar.gz
Initial sources import 1/3
source files mainly done by Randall. Signed-off-by: Randall Spangler <rspangler@chromium.org> Change-Id: Iaff83a842b17f3350fb6f2a3f1597ad4c29bd12a
Diffstat (limited to 'common/main.c')
-rw-r--r--common/main.c94
1 files changed, 94 insertions, 0 deletions
diff --git a/common/main.c b/common/main.c
new file mode 100644
index 0000000000..c9e1bbe75d
--- /dev/null
+++ b/common/main.c
@@ -0,0 +1,94 @@
+/* Copyright (c) 2011 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.
+ * Copyright 2011 Google Inc.
+ *
+ * Example of EC main loop
+ */
+
+#include "registers.h"
+#include "board.h"
+
+#include "adc.h"
+#include "clock.h"
+#include "console.h"
+#include "eeprom.h"
+#include "flash.h"
+#include "flash_commands.h"
+#include "gpio.h"
+#include "i2c.h"
+#include "keyboard.h"
+#include "lpc.h"
+#include "memory_commands.h"
+#include "port80.h"
+#include "powerdemo.h"
+#include "pwm.h"
+#include "system.h"
+#include "task.h"
+#include "temp_sensor.h"
+#include "timer.h"
+#include "uart.h"
+#include "vboot.h"
+#include "watchdog.h"
+
+/* example task blinking the user LED */
+void UserLedBlink(void)
+{
+ while (1) {
+ gpio_set(EC_GPIO_DEBUG_LED, 1);
+ usleep(500000);
+ watchdog_reload();
+ gpio_set(EC_GPIO_DEBUG_LED, 0);
+ usleep(500000);
+ watchdog_reload();
+ }
+}
+
+
+int main(void)
+{
+ /* Configure the pin multiplexers */
+ configure_board();
+ /* Set the CPU clocks / PLLs */
+ clock_init();
+
+ /* Do system, gpio, and vboot pre-initialization so we can jump to
+ * another image if necessary. This must be done as early as
+ * possible, so that the minimum number of components get
+ * re-initialized if we jump to another image. */
+ system_pre_init();
+ gpio_pre_init();
+ vboot_pre_init();
+
+ /* TODO - race condition on enabling interrupts. Module inits
+ * should call task_IntEnable(int) when they're ready... */
+ task_init();
+
+ watchdog_init(1100);
+ timer_init();
+ uart_init();
+ system_init();
+ gpio_init();
+ flash_init();
+ eeprom_init();
+ port_80_init();
+ lpc_init();
+ flash_commands_init();
+ vboot_init();
+ pwm_init();
+ i2c_init();
+ temp_sensor_init();
+ memory_commands_init();
+ keyboard_init();
+ adc_init();
+
+ /* Print the reset cause */
+ uart_printf("\n\n--- Chrome EC initialized! ---\n");
+ uart_printf("(image: %s, version: %s, last reset: %s)\n",
+ system_get_image_copy_string(),
+ system_get_version(SYSTEM_IMAGE_UNKNOWN),
+ system_get_reset_cause_string());
+
+ /* Launch task scheduling (never returns) */
+ return task_start();
+}