A race condition was identified during the initialization of the
driver when the trigger function is enabled. This exposed two issues:
1 - The fxas21002_handle_int is trying to acquire the semaphore before
it gets initialized. To solve this we need to initialize the
semaphore before calling the fxas21002_trigger_init function.
2 - During the fxas21002_trigger initialization the i2c bus is used
(from fxas21002_handle_int function) at the same time as the
fxas21002_set_power is being called. To fix this we need to
initialize the semaphore with 0 and just release it after calling
the fxas21002_set_power function in the fxas21002_int
Signed-off-by: Diego Sueiro <diego.sueiro@gmail.com>
A race condition was identified during the initialization of the
driver when the trigger function is enabled. This exposed two issues:
1 - The fxos8700_handle_int is trying to acquire the semaphore before
it gets initialized. To solve this we need to initialize the
semaphore before calling the fxos8700_trigger_init function.
2 - During the fxos8700_trigger initialization the i2c bus is used
(from fxos8700_handle_int function) at the same time as the
fxos8700_set_power is being called. To fix this we need to
initialize the semaphore with 0 and just release it after calling
the fxos8700_set_power function in the fxos8700_int
These two scenarios was reproducible in the WaRP7 board with i.MX7 SoC.
Signed-off-by: Diego Sueiro <diego.sueiro@gmail.com>
Up until now, Zephyr has patched Kconfig to use the last 'default' with
a satisfied condition, instead of the first one. I'm not sure why the
patch was added (it predates Kconfiglib), but I suspect it's related to
Kconfig.defconfig files.
There are at least three problems with the patch:
1. It's inconsistent with how Kconfig works in other projects, which
might confuse newcomers.
2. Due to oversights, earlier 'range' properties are still preferred,
as well as earlier 'default' properties on choices.
In addition to being inconsistent, this makes it impossible to
override 'range' properties and choice 'default' properties if the
base definition of the symbol/choice already has 'range'/'default'
properties.
I've seen errors caused by the inconsistency, and I suspect there
are more.
3. A fork of Kconfiglib that adds the patch needs to be maintained.
Get rid of the patch and go back to standard Kconfig behavior, as
follows:
1. Include the Kconfig.defconfig files first instead of last in
Kconfig.zephyr.
2. Include boards/Kconfig and arch/<arch>/Kconfig first instead of
last in arch/Kconfig.
3. Include arch/<arch>/soc/*/Kconfig first instead of last in
arch/<arch>/Kconfig.
4. Swap a few other 'source's to preserve behavior for some scattered
symbols with multiple definitions.
Swap 'source's in some no-op cases too, where it might match the
intent.
5. Reverse the defaults on symbol definitions that have more than one
default.
Skip defaults that are mutually exclusive, e.g. where each default
has an 'if <some board>' condition. They are already safe.
6. Remove the prefer-later-defaults patch from Kconfiglib.
Testing was done with a Python script that lists all Kconfig
symbols/choices with multiple defaults, along with a whitelist of fixed
symbols. The script also verifies that there are no "unreachable"
defaults hidden by defaults without conditions
As an additional test, zephyr/.config was generated before and after the
change for several samples and checked to be identical (after sorting).
This commit includes some default-related cleanups as well:
- Simplify some symbol definitions, e.g. where a default has 'if FOO'
when the symbol already has 'depends on FOO'.
- Remove some redundant 'default ""' for string symbols. This is the
implicit default.
Piggyback fixes for swapped ranges on BT_L2CAP_RX_MTU and
BT_L2CAP_TX_MTU (caused by confusing inconsistency).
Piggyback some fixes for style nits too, e.g. unindented help texts.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Only basic features supported initially but more could be added from:
https://www.nxp.com/docs/en/data-sheet/MMA8451Q.pdffixes#9006
A sample app will be provided in a separate PR.
Signed-off-by: Lars Knudsen <larsgk@gmail.com>
This patch adds support for the Analog Devices ADT7420 High-Accuracy
16-bit Digital I2C Temperature Sensors. Optionally sensor threshold
events are supported.
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Bool symbols implicitly default to 'n'.
A 'default n' can make sense e.g. in a Kconfig.defconfig file, if you
want to override a 'default y' on the base definition of the symbol. It
isn't used like that on any of these symbols though.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
These cases weren't caught by the heuristic used by the warning added in
commit 6eabea3a7e ("Kconfiglib: Warn for unquoted string defaults"),
because "GPIO_0" has no lowercase characters in it.
Unquoted Kconfig values are are indistinguishable from reference to
(undefined) symbols in general. Quoting all string defaults will help
find "true" references to undefined Kconfig symbols, and makes it
clearer that the value is constant.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
As stated in LIS2DH datasheet in section "5.1.1 I2C Operation",
in order to read/write multiple bytes on I2C it is necessary
to add the autoincrement bit to the subaddress field.
Signed-off-by: Armando Visconti <armando.visconti@st.com>
The lis2dh_burst_write used "bus" as an input parameters, while
inside "dev" was referred. Now variable names are aligned.
Signed-off-by: Evgeny Kalugin <evgeny.kalugin@intel.com>
The choice symbol LSM6DSL_EXT0_LIS2MDL was given a 'default' in
Kboards/arm/96b_argonkey/Kconfig.defconfig, but 'default' has no effect
on choice symbols, triggering a warning from Kconfiglib.
Instead of adding a default to the choice symbol, change the default of
the 'choice' itself by giving it name and adding the default in
Kconfig.defconfig.
This requires that we remove the default on the "base" definition of the
'choice', due to some messiness related to the Zephyr-specific
prefer-later-defaults behavior (see the 'Zephyr-specific Kconfig
behavior for defaults' section in the Board Porting Guide). Choices were
overlooked when that patch was added to the C tools, meaning choices
still prefer earlier defaults. The crux is that Kconfig.defconfig files
are included last.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Rename CONFIG_PMS7003_SERIAL_TIMEOUT to CFG_PMS7003_SERIAL_TIMEOUT as it
was not exposed in Kconfig as a configurable option. So don't use the
CONFIG_ prefix for non-Kconfig symbols.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
In the code we had an if defined based on
CONFIG_BMM150_MAGN_SAMPLING_RATE_RUNTIME that should have been
CONFIG_BMM150_SAMPLING_RATE_RUNTIME.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Use the named choices feature introduced by PR #6966
and configure LSM6DSL on ArgonKey board.
The two named choices introduced in LSM6DSL are:
- LSM6DSL_BUS_TYPE (default LSM6DSL_I2C)
- LSM6DSL_TRIGGER_MODE (default LSM6DSL_TRIGGER_NONE)
Signed-off-by: Armando Visconti <armando.visconti@st.com>
This patch adds dts support to lps22hb/hts221/vl53l0x
I2C sensors as well as lsm6dsl SPI sensor.
Since some info, like gpio for irq triggering or SPI bus
characteristics, may be provided through dts, they need
to be made optional in the LSM6DSL driver by usage of
macros like HAS_DTS_SPI_PINS or HAS_DTS_SPI_DEVICE.
Signed-off-by: Armando Visconti <armando.visconti@st.com>
The various macros to do checks in system call handlers all
implictly would generate a kernel oops if a check failed.
This is undesirable for a few reasons:
* System call handlers that acquire resources in the handler
have no good recourse for cleanup if a check fails.
* In some cases we may want to propagate a return value back
to the caller instead of just killing the calling thread,
even though the base API doesn't do these checks.
These macros now all return a value, if nonzero is returned
the check failed. K_OOPS() now wraps these calls to generate
a kernel oops.
At the moment, the policy for all APIs has not changed. They
still all oops upon a failed check/
The macros now use the Z_ notation for private APIs.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Normally a syscall would check the current privilege level and then
decide to go to _impl_<syscall> directly or go through a
_handler_<syscall>.
__ZEPHYR_SUPERVISOR__ is a compiler optimization flag which will
make all the system calls from the driver files directly link
to the _impl_<syscall>. Thereby reducing the overhead of checking the
privileges.
In the previous implementation all the source files would be compiled
by zephyr_source() rule. This means that zephyr_* is a catchall CMake
library for source files that can be built purely with the include
paths, defines, and other compiler flags that all zephyr source
files uses. This states that adding one extra compiler flag for only
one complete directory would fail.
This limitation can be overcome by using zephyr_libray* APIs. This
creates a library for the required directories and it also supports
directory level properties.
Hence we use zephyr_library* to create a new library with
macro _ZEPHYR_SUPERVISOR_ for the optimization.
Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
This patch fixes an overrun detected via Coverity. The
lsm6dsl_odr_to_freq_val function takes an index as argument. If the
index is out of bounds, the expected behavior was to return the last
element of an array. The actual behavior was to overrun the array.
Fixes: #7482
Signed-off-by: Andy Gross <andy.gross@linaro.org>
Adds dts bindings for the fxas21002 interrupt pins to all boards that
have this sensor.
The fxas21002 driver is currently only aware of one sensor interrupt
pin, therefore the routing of INT1 or INT2 to the driver is handled in
each board's dts.fixup.
The fxas21002 sample application has been broken since the refactoring
of the mcux gpio driver to dts in commit
4e8f29f319. The sample is now fixed.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
Adds dts bindings for the fxos8700 interrupt pins to all boards that
have this sensor. The frdm_k64f and hexiwear_k64 connect both sensor
interrupt pins to the mcu, but the frdm_kw41z connects only one.
The fxos8700 driver is currently only aware of one sensor interrupt pin,
therefore the routing of INT1 or INT2 to the driver is handled in each
board's dts.fixup.
The fxos8700 sample application has been broken since the refactoring of
the mcux gpio driver to dts in commit
4e8f29f319. The sample is now fixed.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
The hts221 requires 2.2 ms at boot time to download
the flash content into the volatile mem and the
calibration values cannot be read before that.
This issue is causing following crash:
***** USAGE FAULT *****
Executing thread ID (thread): 0x20000234
Faulting instruction address: 0x80037de
Division by zero
Fatal fault in essential thread! Spinning...
Signed-off-by: Armando Visconti <armando.visconti@st.com>
The XSHUT pin, used to shutdown the device when it is not
in current use, is optional and some boards (like ArgonKey)
leave it tied to vdd. So, the driver must provide a way to
make this part configurable.
Signed-off-by: Armando Visconti <armando.visconti@st.com>
In order to be able to change at runtime the Output Data
Rate (ODR) as well as the Full-Scale (FS) for both the
Accelerometr and Gyroscope the driver needs to provide
the .attr_set callback.
Signed-off-by: Armando Visconti <armando.visconti@st.com>
In .h there are few typos that are fixed in this commit:
- Delete LSM6DSL_REG_CTRL3_C and LSM6DSL_REG_CTRL9_XL
register sections duplication.
- Fix LSM6DSL_REG_CTRL6_C address.
Signed-off-by: Armando Visconti <armando.visconti@st.com>
Adding sensorhub support. Only one slave device can be selected
among LIS2MDL (magnetometer) and LPS22HB (pressure and temperature).
Signed-off-by: Armando Visconti <armando.visconti@st.com>
Driver APIs might not implement all operations, making it possible for
a user thread to get the kernel to execute a function at 0x00000000.
Perform runtime checks in all the driver handlers, checking if they're
capable of performing the requested operation.
Fixes#6907.
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
The sensor channel type for the nRF TEMP peripheral is incorrectly set
to SENSOR_CHAN_AMBIENT_TEMP. This peripheral measures die temperature,
not ambient temperature.
Fix the sensor channel.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
Some device include a temperature sensor, usually used as a
companion for helping in drift compensation, that measure the
die temperature. This temperature IS NOT related to the the
ambient temperature, hence a clean separation between the two
is required.
This commit introduces a clean separation between the two
types of temperature leaving the old deprecated definition
still there.
The list of current drivers that read the die (and not the ambient)
temperature is the following:
- adxl362
- bma280
- bmg160
- bmi160
- fxos8700
- lis3mdl
- lsm6ds0
- lsm6dsl
- lsm9ds0
- mpu6050
Signed-off-by: Armando Visconti <armando.visconti@st.com>
Add SPI bus support to LSM6DSL sensor. The bus routines (i.e. I2C
and SPI) are defined in separate files, where proper r/w callbacks
are registered.
Signed-off-by: Armando Visconti <armando.visconti@st.com>
The sensor enables the readout of multiple consecutive registers if
the MSb of the sub-address is set. The other 7bit are the register
address.
Signed-off-by: Tobias Aschenbrenner <taschenb@posteo.de>
The existing nrf5_common.h now applies to other Nordic ICs that are not
part of the "5" family. Instead rename this to nrf_common.h to cover the
upcoming ICs that belong to other families.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Upcoming Nordic ICs that share many of the peripherals and architecture
with the currently supported nRF5x ones are no longer part of the nRF5
family. In order to accomodate that, rename the SoC family from nrf5 to
nrf, so that it can contain all of the members of the wider Nordic
family.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The arithmetic performed on the CO2 and VOC measurements is pointless as
the units of the sensor already match those of the API, furthermore the
multiplication will overflow the u32_t with CO2 or VOC readings greater
than 4294 ppm or ppb. This CO2 concentration is achievable by breathing
at the sensor.
Signed-off-by: Aapo Vienamo <aapo.vienamo@iki.fi>
A condition is added to the Kconfig file to disable config options which
will be supplied from the dts.
Signed-off-by: Aapo Vienamo <aapo.vienamo@iki.fi>
VL53L0X_PerformSingleRangingMeasurement() returns a signed 8-bit
integer, not an unsigned 8-bit integer, making the "< 0" comparison
worthless.
Coverity-CID: 182593
Coverity-CID: 182597
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
The I2C address of vl53l0x are write in hex, but the VL53L0X_I2C_ADDR
type is int.
Fix this by replace "int" with "hex".
Signed-off-by: Ding Tao <miyatsu@qq.com>
It makes no sense to set the restart condition flag on a first message
and some i2c bus drivers (like the stm32 v1 driver) actually reject
them by returning an error from i2c_transfer().
This patch fixes that by using i2c_burst_read() in tmp112_reg_read()
instead. For consistency, tmp112_reg_write() is also changed to use
i2c_burst_write().
Signed-off-by: Mark Vels <mark.vels@team-embedded.nl>