diff options
author | Jack Rosenthal <jrosenth@chromium.org> | 2022-06-27 15:04:18 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-07-01 07:58:07 +0000 |
commit | c11084fd61e0100c64cc00199f725a6c21ed80b4 (patch) | |
tree | 58c014e95530480bfebbaf1df989866c71252e4e /driver | |
parent | 5a23e14e7c2cb0561e24a1108fa09019cd64a164 (diff) | |
download | chrome-ec-c11084fd61e0100c64cc00199f725a6c21ed80b4.tar.gz |
driver/temp_sensor/thermistor_ncp15wb.c: Format with clang-format
BUG=b:236386294
BRANCH=none
TEST=none
Change-Id: I3e84444da701af11f80643654dfcf3ee1fe57aef
Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729877
Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/temp_sensor/thermistor_ncp15wb.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/driver/temp_sensor/thermistor_ncp15wb.c b/driver/temp_sensor/thermistor_ncp15wb.c index dba06ee326..3cc05790d9 100644 --- a/driver/temp_sensor/thermistor_ncp15wb.c +++ b/driver/temp_sensor/thermistor_ncp15wb.c @@ -15,30 +15,30 @@ * For 50C through 100C, use linear interpolation from discreet points * in table below. For temps < 50C, use a simplified linear function. */ -#define ADC_DISCREET_RANGE_START_TEMP 50 +#define ADC_DISCREET_RANGE_START_TEMP 50 /* 10 bit ADC result corresponding to START_TEMP */ -#define ADC_DISCREET_RANGE_START_RESULT 407 +#define ADC_DISCREET_RANGE_START_RESULT 407 -#define ADC_DISCREET_RANGE_LIMIT_TEMP 100 +#define ADC_DISCREET_RANGE_LIMIT_TEMP 100 /* 10 bit ADC result corresponding to LIMIT_TEMP */ -#define ADC_DISCREET_RANGE_LIMIT_RESULT 107 +#define ADC_DISCREET_RANGE_LIMIT_RESULT 107 /* Table entries in steppings of 5C */ -#define ADC_DISCREET_RANGE_STEP 5 +#define ADC_DISCREET_RANGE_STEP 5 /* Discreet range ADC results (9 bit) per temperature, in 5 degree steps */ static const uint8_t adc_result[] = { - 203, /* 50 C */ - 178, /* 55 C */ - 157, /* 60 C */ - 138, /* 65 C */ - 121, /* 70 C */ - 106, /* 75 C */ - 93, /* 80 C */ - 81, /* 85 C */ - 70, /* 90 C */ - 61, /* 95 C */ - 53, /* 100 C */ + 203, /* 50 C */ + 178, /* 55 C */ + 157, /* 60 C */ + 138, /* 65 C */ + 121, /* 70 C */ + 106, /* 75 C */ + 93, /* 80 C */ + 81, /* 85 C */ + 70, /* 90 C */ + 61, /* 95 C */ + 53, /* 100 C */ }; /* @@ -46,8 +46,9 @@ static const uint8_t adc_result[] = { * to 50C, the temperature curve is roughly linear, so we don't need to include * data points in our table. */ -#define adc_to_temp(result) (ADC_DISCREET_RANGE_START_TEMP - \ - (((result) - ADC_DISCREET_RANGE_START_RESULT) * 3 + 16) / 32) +#define adc_to_temp(result) \ + (ADC_DISCREET_RANGE_START_TEMP - \ + (((result)-ADC_DISCREET_RANGE_START_RESULT) * 3 + 16) / 32) /* Convert ADC result (10 bit) to temperature in celsius */ int ncp15wb_calculate_temp(uint16_t adc) @@ -72,8 +73,7 @@ int ncp15wb_calculate_temp(uint16_t adc) tail = ARRAY_SIZE(adc_result) - 1; while (head != tail) { mid = (head + tail) / 2; - if (adc_result[mid] >= adc && - adc_result[mid+1] < adc) + if (adc_result[mid] >= adc && adc_result[mid + 1] < adc) break; if (adc_result[mid] > adc) head = mid + 1; @@ -85,7 +85,9 @@ int ncp15wb_calculate_temp(uint16_t adc) if (head != tail) { delta = adc_result[mid] - adc_result[mid + 1]; step = ((adc_result[mid] - adc) * - ADC_DISCREET_RANGE_STEP + delta / 2) / delta; + ADC_DISCREET_RANGE_STEP + + delta / 2) / + delta; } else { /* Edge case where adc = max */ mid = head; |