From 91daca69391901ac109b33e7af8a94669ac4a62e Mon Sep 17 00:00:00 2001 From: Louis Yung-Chieh Lo Date: Fri, 21 Oct 2011 22:10:24 +0800 Subject: Add ec_keyboard_test.c This CL also includes 4 pieces: 1. main files: environment-independent (main.c) and -dependent (ec_keyboard_test.c). 2. stub files: chip_stub/keyboard.c simulates the real hardware. chip_stub/keyboard.h is the header of testing functions. 3. initial keyboard lib code: ec_keyboard.h 4. rename Cr* function name to Ec* under chip_interface/. BUG=None TEST=make && make runtests Expect seeing the output debug message from cros_ec/lib/ec_keyboard.c. Change-Id: Ia7e8022060eb0a5d0a11abcbdb3f524942f5c68d --- chip_interface/ac_present.h | 15 ++++++----- chip_interface/battery.h | 31 ++++++++++++----------- chip_interface/flash.h | 21 +++++++++------- chip_interface/keyboard_backlight.h | 11 +++++--- chip_interface/lid.h | 17 +++++++------ chip_interface/power_button.h | 19 ++++++++------ chip_interface/timer.h | 11 +++++--- cros_ec/Makefile | 19 ++++++++++---- cros_ec/chip_stub/keyboard.c | 50 +++++++++++++++++++++++++++++++++++++ cros_ec/chip_stub/keyboard.h | 14 +++++++++++ cros_ec/include/core.h | 14 +++++++++++ cros_ec/include/ec_common.h | 13 ++++++++++ cros_ec/include/ec_keyboard.h | 8 +++++- cros_ec/lib/ec_keyboard.c | 24 ++++++++++++++++++ cros_ec/main.c | 24 ++++++++++++++++++ cros_ec/test/Makefile | 11 +++++--- cros_ec/test/ec_keyboard_test.c | 31 +++++++++++++++++++++++ cros_ec/test/fakemain.c | 16 ------------ 18 files changed, 272 insertions(+), 77 deletions(-) create mode 100644 cros_ec/chip_stub/keyboard.c create mode 100644 cros_ec/chip_stub/keyboard.h create mode 100644 cros_ec/include/core.h create mode 100644 cros_ec/lib/ec_keyboard.c create mode 100644 cros_ec/test/ec_keyboard_test.c delete mode 100644 cros_ec/test/fakemain.c diff --git a/chip_interface/ac_present.h b/chip_interface/ac_present.h index c2bb0d9d77..02a152dc16 100644 --- a/chip_interface/ac_present.h +++ b/chip_interface/ac_present.h @@ -1,7 +1,10 @@ -/* power_button.h - Power button function. - * Hides chip-specific implementation behind this interface. +/* 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. * - * (Chromium license) */ + * power_button.h - Power button function. + * Hides chip-specific implementation behind this interface. + */ #ifndef __CHIP_INTERFACE_AC_PRESENT_H #define __CHIP_INTERFACE_AC_PRESENT_H @@ -10,18 +13,18 @@ * Initialize the AC present as GPIO input pin and enable interrupt for * callback. */ -EcError CrAcPresentInit(void); +EcError EcAcPresentInit(void); /* Calls GPIOPinRead() to read the GPIO state. */ /* TODO: has the state been debounced? */ -EcError CrAcPrensentState(void); +EcError EcAcPrensentState(void); /* Register a calback function. It is called while AC is plugged in or * unplugged. */ -EcError CrAcPresentRegister(void (*callback)(void)); +EcError EcAcPresentRegister(void (*callback)(void)); /* Below is the example code to register this function. */ #if 0 diff --git a/chip_interface/battery.h b/chip_interface/battery.h index e5c3337a9c..5c2e0b49a1 100644 --- a/chip_interface/battery.h +++ b/chip_interface/battery.h @@ -1,7 +1,10 @@ -/* power_button.h - Power button function. - * Hides chip-specific implementation behind this interface. +/* 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. * - * (Chromium license) */ + * power_button.h - Power button function. + * Hides chip-specific implementation behind this interface. + */ #ifndef __CHIP_INTERFACE_BATTERY_H #define __CHIP_INTERFACE_BATTERY_H @@ -9,26 +12,26 @@ /*********** Battery SMBus *********************************************/ /* Initialize the SMBus */ -EcError CrBatteryInit(void); +EcError EcBatteryInit(void); /* Send a command to battery. Blocking */ -EcError CrBatterySendCommand(...); +EcError EcBatterySendCommand(...); /* non-blocking read so that it can support both polling mode * and interrupt callback. */ -EcError CrBatteryRecvCommand(...); +EcError EcBatteryRecvCommand(...); /* Register a callback when a packet comes from SMBus */ -EcError CrRegisterBatteryInterrupt(void (*isr)(...)); +EcError EcRegisterBatteryInterrupt(void (*isr)(...)); #if 0 /* example code */ void BatteryPacketArrive(...) { - CrBatteryRecvCommand(); // read the packet. + EcBatteryRecvCommand(); // read the packet. } ... somewhere in code ... - CrRegisterBatteryInterrupt(BatteryPacketArrive); + EcRegisterBatteryInterrupt(BatteryPacketArrive); #endif @@ -38,22 +41,22 @@ void BatteryPacketArrive(...) { * Initialize the battery present as GPIO input pin and enable interrupt for * callback. */ -EcError CrBatteryPresentInit(void); +EcError EcBatteryPresentInit(void); /* Calls GPIOPinRead() to read the GPIO state. */ /* TODO: has the state been debounced? */ -EcError CrBatteryPrensentState(void); +EcError EcBatteryPrensentState(void); /* Register a calback function. It is called while AC is plugged in or * unplugged. */ -EcError CrBatteryPresentRegister(void (*callback)(void)); +EcError EcBatteryPresentRegister(void (*callback)(void)); /* Below is the example code to register this function. */ #if 0 /* This callback function is implemented in Chrome OS features layer. */ void BatteryStateChanged(void) { - int battery_present = CrBatteryPresentState(); + int battery_present = EcBatteryPresentState(); if (battery_present) { // start to authenticate battery; // once authenticated, charge the battery; @@ -62,7 +65,7 @@ void BatteryStateChanged(void) { } } ... somewhere in init code ... - CrBatteryPresentRegister(BatteryStateChanged); + EcBatteryPresentRegister(BatteryStateChanged); #endif /* #if 0 */ diff --git a/chip_interface/flash.h b/chip_interface/flash.h index ec622a0863..b5e0a9b5a7 100644 --- a/chip_interface/flash.h +++ b/chip_interface/flash.h @@ -1,29 +1,32 @@ -/* flash.h - flash interface +/* 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. * - * (Chromium license) */ + * flash.h - flash interface + */ #ifndef __CHIP_INTERFACE_FLASH_H #define __CHIP_INTERFACE_FLASH_H /* returns the flash size and erase clock structure. */ -EcError CrFlashQuery(*size, *erase_block) { +EcError EcFlashQuery(*size, *erase_block) { -EcError CrFlashRead(addr_t offset, length, uint8_t *data); +EcError EcFlashRead(addr_t offset, length, uint8_t *data); -EcError CrFlashWrite(addr_t offset, length, uint8_t *data); +EcError EcFlashWrite(addr_t offset, length, uint8_t *data); -EcError CrFlashErase(addr_t offset, length); +EcError EcFlashErase(addr_t offset, length); -EcError CrFlashSetWriteProtectRange(addr_t offset, length); +EcError EcFlashSetWriteProtectRange(addr_t offset, length); /* TODO: change to Randall's new model */ /* Set lock bit (the SRP bit in SPI) */ -EcError CrFlashEnableWriteProtect(void); +EcError EcFlashEnableWriteProtect(void); /* TODO: change to Randall's new model */ /* Always return FAILED because FMPPEn cannot be reset to 1 * until a power-on reset or after committed (see p. 577). */ -int CrFlashDisableWriteProtect(void); +int EcFlashDisableWriteProtect(void); #endif /* __CHIP_INTERFACE_FLASH_H */ diff --git a/chip_interface/keyboard_backlight.h b/chip_interface/keyboard_backlight.h index cb3735de44..b51661a252 100644 --- a/chip_interface/keyboard_backlight.h +++ b/chip_interface/keyboard_backlight.h @@ -1,6 +1,9 @@ -/* keyboard_backlight.h - Keyboard backlight +/* 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. * - * (Chromium license) */ + * keyboard_backlight.h - Keyboard backlight + */ #ifndef __CHIP_INTERFACE_KEYBOARD_BACKLIGHT_H #define __CHIP_INTERFACE_KEYBOARD_BACKLIGHT_H @@ -14,9 +17,9 @@ */ /* Configure PWM port and set the initial backlight value. */ -EcError CrKeyboardBacklightInit(uint16_t init_lightness); +EcError EcKeyboardBacklightInit(uint16_t init_lightness); /* Set the mapped PWM value */ -EcError CrKeyboardBacklightSet(uint16_t lightness); +EcError EcKeyboardBacklightSet(uint16_t lightness); #endif /* __CHIP_INTERFACE_KEYBOARD_BACKLIGHT_H */ diff --git a/chip_interface/lid.h b/chip_interface/lid.h index cffa35c4f4..8c680428f8 100644 --- a/chip_interface/lid.h +++ b/chip_interface/lid.h @@ -1,26 +1,29 @@ -/* lid.h - handle lid open/close +/* 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. * - * (Chromium license) */ + * lid.h - handle lid open/close + */ #ifndef __CHIP_INTERFACE_LID_H #define __CHIP_INTERFACE_LID_H /* Initialize the GPIO pin */ -EcError CrLidSwitchInit(void); +EcError EcLidSwitchInit(void); /* Calls GPIOPinRead() to read the GPIO state. */ /* TODO: has the state been debounced? */ -EcError CrLidSwitchState(void); +EcError EcLidSwitchState(void); /* Register a calback function. It is called while lid state is changed. */ -EcError CrLidSwitchRegister(void (*callback)(void)); +EcError EcLidSwitchRegister(void (*callback)(void)); /* Below is the example code to register this function. */ #if 0 /* This callback function is implemented in Chrome OS features layer. */ void LidSwitchChanged(void) { - int lid_open = CrLidSwitchState(); + int lid_open = EcLidSwitchState(); if (lid_open) { if (system is in S3) { // resume system @@ -32,7 +35,7 @@ void LidSwitchChanged(void) { } } ... somewhere in init code ... - CrLidSwitchRegister(LidSwitchChanged); + EcLidSwitchRegister(LidSwitchChanged); #endif #endif /* __CHIP_INTERFACE_LID_H */ diff --git a/chip_interface/power_button.h b/chip_interface/power_button.h index bc6d43e2d1..6b7293065e 100644 --- a/chip_interface/power_button.h +++ b/chip_interface/power_button.h @@ -1,7 +1,10 @@ -/* power_button.h - Power button function. - * Hides chip-specific implementation behind this interface. +/* 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. * - * (Chromium license) */ + * power_button.h - Power button function. + * Hides chip-specific implementation behind this interface. + */ #ifndef __CHIP_INTERFACE_POWER_BUTTON_H #define __CHIP_INTERFACE_POWER_BUTTON_H @@ -10,24 +13,24 @@ * Initialize the power button as GPIO input pin and enable interrupt for * keyboard scanner code. */ -EcError CrPowerButtonInit(void); +EcError EcPowerButtonInit(void); /* Calls GPIOPinRead() to read the GPIO state. */ /* TODO: has the state been debounced? */ -EcError CrPowerButtonGetState(void); +EcError EcPowerButtonGetState(void); /* Register a calback function. It is called while power button is changing its * state (pressed or released ). */ -EcError CrPowerButtonRegister(void (*callback)(void)); +EcError EcPowerButtonRegister(void (*callback)(void)); /* Below is the example code to register this function. */ #if 0 /* This callback function is implemented in Chrome OS features layer. */ void PowerButtonCallback(void) { - int pressed = CrPowerButtonGetState(); + int pressed = EcPowerButtonGetState(); if (!prev_status) { if (pressed) { // Power button is just pressed. Generate scan code, @@ -42,7 +45,7 @@ void PowerButtonCallback(void) { } ... somewhere in init code ... - CrPowerButtonRegister(PowerButtonCallback); + EcPowerButtonRegister(PowerButtonCallback); #endif /* #if 0 */ diff --git a/chip_interface/timer.h b/chip_interface/timer.h index fa290abef5..b064939296 100644 --- a/chip_interface/timer.h +++ b/chip_interface/timer.h @@ -1,14 +1,17 @@ -/* timer.h - periodical timer +/* 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. * - * (Chromium license) */ + * timer.h - periodical timer + */ #ifndef __CHIP_INTERFACE_TIMER_H #define __CHIP_INTERFACE_TIMER_H /* init hardware and prepare ISR */ -EcError CrPeriodicalTimerInit(void); +EcError EcPeriodicalTimerInit(void); -EcError CrPeriodicalTimerRegister( +EcError EcPeriodicalTimerRegister( int interval /* ms */, int (*timer)(int /* delta ms from last call */)); diff --git a/cros_ec/Makefile b/cros_ec/Makefile index 33433fd1f1..ac2ac5b264 100644 --- a/cros_ec/Makefile +++ b/cros_ec/Makefile @@ -9,7 +9,8 @@ TESTDIR = $(CROS_EC_TOP)/test BUILD_ROOT := ${BUILD}/$(shell basename ${CROS_EC_TOP}) LIBS = $(CROS_EC_LIB) # Firmware library must be self-contained -INCLUDES += -I$(LIBDIR)/include +INCLUDES += -I$(LIBDIR)/include \ + -I$(TOP) ifeq ($(FIRMWARE_ARCH),) INCLUDES += -I$(STUBDIR)/include @@ -17,20 +18,28 @@ else INCLUDES += -I$(FWDIR)/arch/$(FIRMWARE_ARCH)/include endif +CORE_SRCS = \ + main.c + # find ./lib -iname '*.c' | sort + +CORE_OBJS = $(CORE_SRCS:%.c=${BUILD_ROOT}/%.o) + LIB_SRCS = \ ./lib/ec_console.c \ - ./lib/ec_host_command.c + ./lib/ec_host_command.c \ + ./lib/ec_keyboard.c LIB_OBJS = $(LIB_SRCS:%.c=${BUILD_ROOT}/%.o) STUB_SRCS = \ ./chip_stub/ec_os.c \ - ./chip_stub/ec_uart.c + ./chip_stub/ec_uart.c \ + ./chip_stub/keyboard.c STUB_OBJS = $(STUB_SRCS:%.c=${BUILD_ROOT}/%.o) -ALL_SRCS = ${LIB_SRCS} ${STUB_SRCS} +ALL_SRCS = ${CORE_SRCS} ${LIB_SRCS} ${STUB_SRCS} ifeq ($(FIRMWARE_ARCH),) all : $(CROS_EC_LIB) $(CHIP_STUB_LIB) @@ -40,7 +49,7 @@ endif include ../common.mk -$(CROS_EC_LIB) : $(LIB_OBJS) +$(CROS_EC_LIB) : $(CORE_OBJS) $(LIB_OBJS) rm -f $@ ar qc $@ $^ diff --git a/cros_ec/chip_stub/keyboard.c b/cros_ec/chip_stub/keyboard.c new file mode 100644 index 0000000000..547df3614f --- /dev/null +++ b/cros_ec/chip_stub/keyboard.c @@ -0,0 +1,50 @@ +/* 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. + * + * Chip stub code of keyboard. Implements the chip interface. + */ + +#include +#include "chip_interface/keyboard.h" + +static EcKeyboardCallback core_keyboard_callback; +static uint8_t virtual_matrix[MAX_KEYBOARD_MATRIX_COLS]; + +EcError EcKeyboardRegisterCallback(EcKeyboardCallback cb) { + core_keyboard_callback = cb; + return EC_SUCCESS; +} + + +EcError EcKeyboardGetState(uint8_t *bit_array) { + /* TODO: implement later */ + return EC_SUCCESS; +} + + +/* Called by test code. This simulates a key press or release. + * Usually, the test code would expect a scan code is received at host side. + */ +EcError SimulateKeyStateChange(int col, int row, int state) { + ASSERT(col < MAX_KEYBOARD_MATRIX_COLS); + ASSERT(row < MAX_KEYBOARD_MATRIX_ROWS); + + if (!core_keyboard_callback) return EC_ERROR_UNKNOWN; + + state = (state) ? 1 : 0; + int current_state = (virtual_matrix[col] >> row) & 1; + + if (state && !current_state) { + /* key is just pressed down */ + virtual_matrix[col] |= 1 << row; + core_keyboard_callback(col, row, state); + } else if (!state && current_state) { + virtual_matrix[col] &= ~(1 << row); + core_keyboard_callback(col, row, state); + } else { + /* Nothing happens if a key has been pressed or released. */ + } + + return EC_SUCCESS; +} diff --git a/cros_ec/chip_stub/keyboard.h b/cros_ec/chip_stub/keyboard.h new file mode 100644 index 0000000000..a3357eec4f --- /dev/null +++ b/cros_ec/chip_stub/keyboard.h @@ -0,0 +1,14 @@ +/* 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. + * + * The keyboard stub header file for test code to include. + */ + + +#ifndef __EC_CHIP_STUB_KEYBOARD_H_ +#define __EC_CHIP_STUB_KEYBOARD_H_ + +EcError SimulateKeyStateChange(int col, int row, int state); + +#endif /* __EC_CHIP_STUB_KEYBOARD_H_ */ diff --git a/cros_ec/include/core.h b/cros_ec/include/core.h new file mode 100644 index 0000000000..2d88b4f77f --- /dev/null +++ b/cros_ec/include/core.h @@ -0,0 +1,14 @@ +/* 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. + * + */ +#ifndef __CROS_EC_INCLUDE_CORE_H +#define __CROS_EC_INCLUDE_CORE_H + +#include "ec_common.h" + +/* main.c */ +EcError CoreMain(); + +#endif /* __CROS_EC_INCLUDE_CORE_H */ diff --git a/cros_ec/include/ec_common.h b/cros_ec/include/ec_common.h index d5adb4e280..1a40958509 100644 --- a/cros_ec/include/ec_common.h +++ b/cros_ec/include/ec_common.h @@ -9,6 +9,7 @@ #define __CROS_EC_COMMON_H #include +#include /* FIXME: will be removed for portibility in the future */ /* Functions which return error return one of these. This is an * integer instead of an enum to support module-internal error @@ -33,4 +34,16 @@ enum EcErrorList { EC_ERROR_INTERNAL_LAST = 0x1FFFF }; + +/* TODO: move to a proper .h file */ +#define PRINTF(fmt, ...) printf(fmt, __VA_ARGS__) + +/* TODO: move to a proper .h file */ +#define ASSERT(expr) do { \ + if (!(expr)) { \ + PRINTF("ASSERT(%s) failed at file %s:%d.\n", \ + #expr, __FILE__, __LINE__); \ + } \ + } while (0) + #endif /* __CROS_EC_COMMON_H */ diff --git a/cros_ec/include/ec_keyboard.h b/cros_ec/include/ec_keyboard.h index c1c5d5e250..4f00209953 100644 --- a/cros_ec/include/ec_keyboard.h +++ b/cros_ec/include/ec_keyboard.h @@ -8,13 +8,19 @@ #ifndef __CROS_EC_KEYBOARD_H #define __CROS_EC_KEYBOARD_H + +/* The initialize code of keyboard lib. Called by core main. */ +EcError EcKeyboardInit(); + + /* Register the board-specific keyboard matrix translation function. * The callback function accepts col/row and returns the scan code. */ -EcError CrKeyboardMatrixRegister( +EcError EcKeyboardMatrixRegister( int8_t col_num, int8_t row_num, EcError (*callback)( int8_t column, int8_t row, int8_t pressed, uint8_t *scan_code, int32_t* len)); + #endif /* __CROS_EC_KEYBOARD_H */ diff --git a/cros_ec/lib/ec_keyboard.c b/cros_ec/lib/ec_keyboard.c new file mode 100644 index 0000000000..f126f9eed8 --- /dev/null +++ b/cros_ec/lib/ec_keyboard.c @@ -0,0 +1,24 @@ +/* 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. + * + * Chrome OS EC keyboard code. + */ + +#include "cros_ec/include/ec_common.h" +#include "chip_interface/keyboard.h" + +static void KeyboardStateChanged(int col, int row, int is_pressed) { + PRINTF("File %s:%s(): col=%d row=%d is_pressed=%d\n", + __FILE__, __FUNCTION__, col, row, is_pressed); +} + + +EcError EcKeyboardInit() { + EcError ret; + + ret = EcKeyboardRegisterCallback(KeyboardStateChanged); + if (ret != EC_SUCCESS) return ret; + + return EC_SUCCESS; +} diff --git a/cros_ec/main.c b/cros_ec/main.c index e69de29bb2..1a4dd78787 100644 --- a/cros_ec/main.c +++ b/cros_ec/main.c @@ -0,0 +1,24 @@ +/* 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. + * + * This is the main function of Chrome OS EC core. + * Called by platform-dependent main function. + * + */ +#include "cros_ec/include/core.h" +#include "cros_ec/include/ec_common.h" +#include "cros_ec/include/ec_keyboard.h" + + +EcError CoreMain() { + EcError ret; + + ret = EcKeyboardInit(); + if (ret != EC_SUCCESS) { + printf("EcKeyboardInit() failed: %d\n", ret); + return ret; + } + + return EC_SUCCESS; +} diff --git a/cros_ec/test/Makefile b/cros_ec/test/Makefile index 035a3f825c..84c766495d 100644 --- a/cros_ec/test/Makefile +++ b/cros_ec/test/Makefile @@ -3,10 +3,11 @@ # found in the LICENSE file. INCLUDES += -I./include \ - -I$(CROS_EC_DIR)/lib/include + -I$(CROS_EC_DIR)/lib/include \ + -I../../ BUILD_ROOT = ${BUILD}/cros_ec/test -TEST_NAMES = ec_os_test +TEST_NAMES = ec_os_test ec_keyboard_test TEST_BINS = $(addprefix ${BUILD_ROOT}/,$(TEST_NAMES)) @@ -21,6 +22,9 @@ CFLAGS += -MMD -MF $@.d -Xlinker --allow-multiple-definition LIBS := ${TEST_LIB} $(CROS_EC_LIB) $(CHIP_STUB_LIB) +.SUFFIXES: +.SUFFIXES: .o .c + ifneq (${RUNTESTS},) EXTRA_TARGET = runtests endif @@ -37,9 +41,10 @@ ${BUILD_ROOT}/%.o : %.c ${BUILD_ROOT}/% : %.c ${LIBS} $(CC) $(CFLAGS) $(INCLUDES) $< ${LIBS} -o $@ -lrt -ALLTESTS = ec_os_test +ALLTESTS = ec_os_test ec_keyboard_test runtests: ${BUILD_ROOT}/ec_os_test + ${BUILD_ROOT}/ec_keyboard_test -include ${ALL_DEPS} diff --git a/cros_ec/test/ec_keyboard_test.c b/cros_ec/test/ec_keyboard_test.c new file mode 100644 index 0000000000..bcdb83cc6d --- /dev/null +++ b/cros_ec/test/ec_keyboard_test.c @@ -0,0 +1,31 @@ +/* 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. + * + * Testing code. Running at Linux environment. + */ +#include "cros_ec/include/ec_common.h" +#include "cros_ec/include/core.h" +#include "cros_ec/chip_stub/keyboard.h" + + +int run_test_cases() { + /* Just a simple test */ + SimulateKeyStateChange(2, 3, 1); + /* Expect KeyboardStateChanged() in cros_ec/keyboard.c shows something. */ + + return 0; +} + + +int main(int argc, char **argv) { + + EcError ret; + + /* Call Google EC core initial code. */ + ret = CoreMain(); + if (ret != EC_SUCCESS) + return 1; + + return run_test_cases(); +} diff --git a/cros_ec/test/fakemain.c b/cros_ec/test/fakemain.c deleted file mode 100644 index 40316d08eb..0000000000 --- a/cros_ec/test/fakemain.c +++ /dev/null @@ -1,16 +0,0 @@ -/* 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. - */ - -/* Fake main routine, to make sure lib functions link */ - -#include "ec_console.h" -#include "ec_uart.h" - -int main(void) { - - - - return 0; -} -- cgit v1.2.1