blob: 077806ba73f86c3ef362a75e281a3f8ca3c50a7d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
/* 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.
*/
/* Temperature sensor module for Chrome EC */
#include "adc.h"
#include "common.h"
#include "lm4_adc.h"
#include "temp_sensor.h"
/* Initialize temperature reading to a sane value (27 C) */
static int last_val = 300;
int chip_temp_sensor_poll(void)
{
last_val = adc_read_channel(ADC_CH_EC_TEMP);
return EC_SUCCESS;
}
int chip_temp_sensor_get_val(int idx, int *temp_ptr)
{
if (last_val == ADC_READ_ERROR)
return EC_ERROR_UNKNOWN;
*temp_ptr = last_val;
return EC_SUCCESS;
}
|