Files
OpenCellular/common/mock_temp_sensor.c
Vic Yang 7ae80c0552 Thermal engine unit test
This test checks for the functionality of thermal engine.

BUG=chrome-os-partner:10241
TEST=Test passed
     Disable thermal engine overheating warning and test failed

Change-Id: Ideb0ff9ee4bd1617b11c56dfa2578a3f406381ff
Reviewed-on: https://gerrit.chromium.org/gerrit/25370
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
2012-06-25 07:15:50 -07:00

82 lines
1.7 KiB
C

/* Copyright (c) 2012 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.
*/
/* Mock temperature sensor module for Chrome EC */
#include "board.h"
#include "console.h"
#include "temp_sensor.h"
#include "timer.h"
#include "util.h"
/* Defined in board_temp_sensor.c. Must be in the same order as
* in enum temp_sensor_id.
*/
extern const struct temp_sensor_t temp_sensors[TEMP_SENSOR_COUNT];
static int temp_val[TEMP_SENSOR_TYPE_COUNT];
int temp_sensor_powered(enum temp_sensor_id id)
{
/* Always powered */
return 1;
}
int temp_sensor_read(enum temp_sensor_id id)
{
return temp_val[temp_sensors[id].type];
}
void temp_sensor_task(void)
{
/* Do nothing */
while (1)
usleep(5000000);
}
static int command_set_temp(int argc, char **argv, int type)
{
char *e;
int t;
ASSERT(argc == 2);
t = strtoi(argv[1], &e, 0);
temp_val[type] = t;
return EC_SUCCESS;
}
static int command_set_cpu_temp(int argc, char **argv)
{
return command_set_temp(argc, argv, TEMP_SENSOR_TYPE_CPU);
}
DECLARE_CONSOLE_COMMAND(setcputemp, command_set_cpu_temp,
"value",
"Set mock CPU temperature value",
NULL);
static int command_set_board_temp(int argc, char **argv)
{
return command_set_temp(argc, argv, TEMP_SENSOR_TYPE_BOARD);
}
DECLARE_CONSOLE_COMMAND(setboardtemp, command_set_board_temp,
"value",
"Set mock board temperature value",
NULL);
static int command_set_case_temp(int argc, char **argv)
{
return command_set_temp(argc, argv, TEMP_SENSOR_TYPE_CASE);
}
DECLARE_CONSOLE_COMMAND(setcasetemp, command_set_case_temp,
"value",
"Set mock case temperature value",
NULL);