summaryrefslogtreecommitdiff
path: root/src/driver
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-12-26 11:39:12 +0100
committerDaniel Friesel <derf@finalrewind.org>2021-12-26 11:39:12 +0100
commitba778ead40ddf8f1282e78cc8b5dd42e6c4fe1c5 (patch)
treed68a9d003ed09ede30b653ac374e05ac67e45a58 /src/driver
parent05644dec7f2ecffa26dc04b9be8d6ad03a2e79ea (diff)
max44009: handle overrange condition
Diffstat (limited to 'src/driver')
-rw-r--r--src/driver/max44009.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/driver/max44009.cc b/src/driver/max44009.cc
index bab4da5..8a8ff3e 100644
--- a/src/driver/max44009.cc
+++ b/src/driver/max44009.cc
@@ -2,6 +2,9 @@
* Copyright 2020 Daniel Friesel
*
* SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Driver for MAX44009 Ambient Light Sensor.
+ * Does not support interrupts.
*/
#include "driver/max44009.h"
#if defined(MULTIPASS_ARCH_HAS_I2C) && !defined(CONFIG_driver_softi2c)
@@ -37,6 +40,11 @@ float MAX44009::getLux()
*/
exponent = (luxHigh & 0xF0) >> 4;
+ if (exponent == 0x0f) {
+ // overrange condition
+ return -1;
+ }
+
/*
* Cast base and mantissa to float to avoid calculation errors
* because of 16bit integer overflows.