Commit graph

50 commits

Author SHA1 Message Date
Marc Herbert 2cd51a33ce samples: make find_package(Zephyr...) REQUIRED
This provides a better error message when building with CMake and
forgetting ZEPHYR_BASE or not registering Zephyr in the CMake package
registry. See parent commit for more details (split from parent for
better readability).

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-05-29 10:47:25 +02:00
Kumar Gala d711e7b7d8 samples: sensor: Convert to new DT_INST macros
Convert older DT_INST_ macro use the new include/devicetree.h
DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-31 07:09:33 -05:00
Torsten Rasmussen 407b49b35c cmake: use find_package to locate Zephyr
Using find_package to locate Zephyr.

Old behavior was to use $ENV{ZEPHYR_BASE} for inclusion of boiler plate
code.

Whenever an automatic run of CMake happend by the build system / IDE
then it was required that ZEPHYR_BASE was defined.
Using ZEPHYR_BASE only to locate the Zephyr package allows CMake to
cache the base variable and thus allowing subsequent invocation even
if ZEPHYR_BASE is not set in the environment.

It also removes the risk of strange build results if a user switchs
between different Zephyr based project folders and forgetting to reset
ZEPHYR_BASE before running ninja / make.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-03-27 16:23:46 +01:00
Peter Bigot c273b5d885 drivers: sensor: mcp9808: update to new GPIO API
Since this was converted to the setup/handle/process idiom in master
the conversion is straightforward.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter A. Bigot f05cbb421d drivers: sensor: mcp9808: fix various problems and improve test
Correct handling of device encoded temperature values, which combine a
12-bit 2s complement signed value with a separate sign bit.  Rework
conversion between device and sensor temperature representations to
support negative temperatures in both domains.

Use a much simpler trigger configuration where the alert is driven by
comparator output, rather than as an interrupt that requires a pair of
I2C transactions to read and clear the flag.

Refactor the trigger infrastructure to use the setup/handle/process
idiom, which reduces duplicated code and to correctly detect alerts
present when the triggers are set.

Completely replace the sample with something that demonstrates
updating upper and lower threshold values to track moving
temperatures.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-01-08 20:33:51 -05:00
Peter Bigot 86461ac559 samples: sensor: mcp9808: fix frdm_k64f devicetree overlay
The device address can only be 0x18 through 0x1F.  C6 is connected to
the FXOS870 and is not exposed on a header: switch to Arduino D0.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-11-13 15:16:54 -06:00
Peter Bigot 83b2bb614b drivers: sensor: mcp9808: clean up I2C API usage
The i2c_msg API details do not work correctly with Nordic TWI.  Switch
to the higher-level and simpler API for register read and write.  Also
add a tree configuration on a Nordic-based board.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-11-13 15:16:54 -06:00
Kumar Gala 30ea840eb1 sensor: mcp9808: Convert to DTS
Convert mcp9808 sensor driver and sample app to utilize device tree.

Introduce a dts board overlay on the frdm_k64f board to ensure we at
least have a single platform in which the sample gets built.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-11-08 07:44:54 -06:00
Peter Bigot 6e5db350b2 coccinelle: standardize k_sleep calls with integer timeouts
Re-run with updated script to convert integer literal delay arguments to
k_sleep to use the standard timeout macros.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-10-09 08:38:10 -04:00
Anas Nashif 8c1f89fa99 cleanup: include/: move sensor.h to drivers/sensor.h
move sensor.h to drivers/sensor.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Anas Nashif da5f185e06 samples: add test identifier
Add unique identifier instead of just 'test' for samples.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-03-29 17:44:11 -04:00
Anas Nashif 5060ca6a30 cmake: increase minimal required version to 3.13.1
Move to latest cmake version with many bug fixes and enhancements.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-01-03 11:51:29 -05:00
Reto Schneider 7eabab2f5d samples, tests: Use semi-accurate project names
When using an IDE (e.g. Eclipse, Qt Creator), the project name gets
displayed. This greatly simplifies the navigation between projects when
having many of them open at the same time. Naming every project "NONE"
defeats this functionality.

This patch tries to use sensible project names while not duplicating
too much of what is already represented in the path. This is done by
using the name of the directory the relevant CMakeLists.txt file is
stored in. To ensure unique project names in the samples (and again, in
the tests folder) folder, small manual adjustments have been done.

Signed-off-by: Reto Schneider <code@reto-schneider.ch>
2018-10-27 21:31:25 -04:00
Anas Nashif deaab90641 tests/samples: cleanup tags
Remove redundant 'sample' tag and add something that matches the
functionality and features being tested, demonstrated.

Avoid short abbriviations and using full names for fs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-16 09:17:51 -04:00
Sebastian Bøe 55ee53ce91 cmake: Prepend 'cmake_minimum_required()' into 'app' build scripts
Prepend the text 'cmake_minimum_required(VERSION 3.8.2)' into the
application and test build scripts.

Modern versions of CMake will spam users with a deprecation warning
when the toplevel CMakeLists.txt does not specify a CMake
version. This is documented in bug #8355.

To resolve this we include a cmake_minimum_required() line into the
toplevel build scripts. Additionally, cmake_minimum_required is
invoked from within boilerplate.cmake. The highest version will be
enforced.

This patch allows us to afterwards change CMake policy CMP000 from OLD
to NEW which in turn finally rids us of the verbose warning.

The extra boilerplate is considered more acceptable than the verbosity
of the CMP0000 policy.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-08-15 04:06:50 -07:00
Paras Jain 61f91f8fec samples: sensor : mcp9808: check return value
Check the return value while setting sensor trigger

Coverity-CID: 186196

Signed-off-by: Paras Jain <parasjain2000@gmail.com>
2018-06-01 14:41:42 -05:00
Ulf Magnusson 9a06d119a8 samples: mcp9808: Fix CONFIG_MCP9808_TRIGGER_GLOBAL_THREAD assignment
CONFIG_MCP9808_TRIGGER_GLOBAL never existed. Looks like a typo.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-05-24 09:21:32 -04:00
Armando Visconti 87d6c50e47 sensors: Add separation between ambient and die temperature
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>
2018-04-03 22:29:11 -04:00
Anas Nashif 31a23dca68 samples: mcp9808: fix dependencies and test cleanup
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-28 20:24:29 -05:00
Anas Nashif 23f81eeb42 tests/samples: fixed yaml syntax
Use a map directory, avoid the list which makes parsing a bit
cumbersome.

Fixes #5109

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-11 14:47:08 -05:00
Sebastian Bøe 0829ddfe9a kbuild: Removed KBuild
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Sebastian Bøe 12f8f76165 Introduce cmake-based rewrite of KBuild
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.

Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.

This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.

For users that just want to continue their work with minimal
disruption the following should suffice:

Install CMake 3.8.2+

Port any out-of-tree Makefiles to CMake.

Learn the absolute minimum about the new command line interface:

$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..

$ cd build
$ make

PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Anas Nashif 0356590df5 tests: samples: fix yaml syntax
Fix indentation and syntax and make it pass yamllint tool.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-15 08:15:00 -04:00
Anas Nashif 470c5f3189 tests: remove testcase.ini files
We now use yaml files.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-21 20:56:53 -04:00
Anas Nashif cc24f4b03c tests: samples: convert testcase files to yaml
This will prepare test cases and samples with metadata and information
that will be consumed by the sanitycheck script which will be changed to
parse YAML files instead of ini.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-21 20:56:53 -04:00
David B. Kinder cbec29ab95 doc: change UTF-8 chars to sphinx inline replaces
Avoiding use of UTF-8 characters (trip up some tools)

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-06-16 07:35:11 -05:00
David B. Kinder 6a7527b5b4 doc: add labels to sensor sample docs for linking
Docs need a label at the top so we can use :ref:`labelname`
to create a link to that doc from other docs.

Change-Id: I37c654fb0bb7ebdf288af01e41ce5497969f8968
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-04-04 20:47:35 +00:00
David B. Kinder 2cb045420c doc: fix .rst files canonical heading order
The headings on some .rst files were not following the expected
heading order of using # for h1, * for h2, = for h3, and - for h4
This patch fixes that, and the doc/templates/*.tmpl files created
for folks to use as templates for creating board and sample docs.

Change-Id: I0263b005648558d5ea41a681ceaa4798c9594dd9
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-01-20 16:06:36 -08:00
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00
Bogdan Davidoaia 30162aedf1 sensor: remove sensor value type
Remove the type field from the sensor value structure. All values will
have the type previously defined by SENSOR_VALUE_TYPE_INT_PLUS_MICRO.

This simplifies the interface, as apps will know what value type to
expect. Apps that prefer to use double values can optain them using the
sensor_value_to_double function.

Change-Id: I3588d74258030eb16c3f89d8eead13cca4606b18
Signed-off-by: Bogdan Davidoaia <bogdan.davidoaia@linaro.org>
2017-01-15 01:09:33 +00:00
Anas Nashif a6997bbc17 samples: sensors: fix documentation layout of MCP9808 sample
Change-Id: Iab5426a0689fd7ac22933e3c61e22d217af7f067
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-01-06 16:32:31 -05:00
Bogdan Davidoaia 4946e3e6e6 sensor: remove SENSOR_VALUE_TYPE_INT
Remove SENSOR_VALUE_TYPE_INT as it is the same as
SENSOR_VALUE_TYPE_INT_PLUS_MICRO with val2 set to 0.

Change-Id: If5a9c579b7267701c27f40fd887acae47d64edc5
Signed-off-by: Bogdan Davidoaia <bogdan.m.davidoaia@intel.com>
2016-12-13 21:51:10 +00:00
Flavio Santes 5f818bfcd3 sensors/mcp9808: Evaluate sensor_channel_get return code
The sensor_channel_get return code is now evaluated.

Change-Id: Ib931d6caba65af7195bad53c62e6e5a3033b49e8
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-11-17 01:30:00 -06:00
Flavio Santes 0e20d45272 sensors/mcp9808: Evaluate sensor_sample_fetch return code
sensor_sample_fetch return code is now evaluated.

Coverity-CID: 151957

Change-Id: I79b9f44c79ac13e8d7da55c9e3866ad504a4a450
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-11-17 01:25:12 -06:00
Anas Nashif d622b09bc0 samples: tests: remove obsolete KERNEL_TYPE and kernel variables
Remove those from Makefiles and testcase.ini, we now support unified kernel
only and sanitycheck script now knows how to deal with this.

Change-Id: I853ebcadfa7b56a4de5737d95f2ba096babb2e13
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-11-04 15:47:25 -04:00
Anas Nashif 5d3634d0b1 sensors: mcp9808: convert to and build with unified kernel
Change-Id: I8bd15fd5c353c2040ffb99e759b7739d435f2829
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-11-03 01:45:49 +00:00
Anas Nashif 5925eaf5f1 optimize testcase runs for sensors
Change-Id: If701d1824572bed068712750fbd14758806ba70f
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-10-26 23:47:39 +00:00
Anas Nashif 95bf69197d samples: sensors: cleanup mcp9808 sample and refine documentation
Enhance documentation and build for Quark D2000 Devboard by default.

Change-Id: I3417c31a8898a076465d25f45d7821820b480290
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-10-26 23:46:38 +00:00
Anas Nashif f482200f9c samples: remove useless filters in testcase.ini
Change-Id: Iaf7f77a738a48918752347c97019660355de370a
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-10-07 14:07:24 +00:00
Anas Nashif 4589f2c468 samples: use printf/printk directly instead of macros
In many cases there is no need to define a macro for printing to
the console, just use the correct variant directly.

Jira: ZEP-240
Change-Id: I9952deda4bfc60424f01fca2443d037562d13d0d
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-09-14 16:56:02 +00:00
Andrew Boie 701f0598a8 Revert "misc: Remove generic PRINT macros from sensor samples"
This reverts commit 107f38acf6.

Change-Id: I6c5aa1323da485fc7a04452537d67c797a18bba5
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-08-23 13:19:44 -07:00
Andrew Boie a0a5e82205 samples: mcp9808: build for sanitycheck runs
Change-Id: I593478da5f9f168be8415ada83b97876fe0b3b99
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-08-15 09:38:54 -07:00
Juan Manuel Cruz Alcaraz 107f38acf6 misc: Remove generic PRINT macros from sensor samples
Remove generic PRINT macros from sensor samples and replace
with SYS_LOG  module.

Jira: ZEP-240

Change-Id: I474efcd1daf8e621acd50d88b3a9662b8cd2b516
Signed-off-by: Juan Manuel Cruz Alcaraz <juan.m.cruz.alcaraz@intel.com>
2016-08-05 20:36:53 +00:00
Bogdan Davidoaia 72786486c6 sensor: remove CONFIG_SENSOR_DEBUG
Remove the CONFIG_SENSOR_DEBUG as it is no longer needed since switching
to SYS_LOG_* in the sensor susbsystem.

Also, use __ASSERT where CONFIG_SENSOR_DEBUG was used to validate
function parameters.

Change-Id: I80ed7209abfb92220fa229d246c5b3a43b887e32
Signed-off-by: Bogdan Davidoaia <bogdan.m.davidoaia@intel.com>
2016-05-21 21:20:13 +00:00
Anas Nashif 0140da310b i2c: unify kconfig options and share them across drivers
Reduces Kconfig variables by ~20

Change-Id: If39f7d49482d62417c621f98bc8c0c78df0d4139
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-05-12 10:57:22 +00:00
Murtaza Alexandru f1b95df34e sensor: rename SENSOR_TYPE_* to SENSOR_VALUE_TYPE_*
Rename sensor_value_type enums from SENSOR_TYPE_* to more concludent
name SENSOR_VALUE_TYPE_*. This change is required if we want to
introduce SENSOR_TYPE_* (SENSOR_TYPE_ACCEL - if the sensor/driver
supports accelerometer, SENSOR_TYPE_MAGN - etc.) in the future.
Also it is more clear with this notation what these enums are referring
to.

Change-Id: Ic58e29288669e10c0695e0f86f59b0e57f7ac38c
Signed-off-by: Murtaza Alexandru <alexandru.murtaza@intel.com>
2016-04-26 18:09:41 +00:00
Vlad Dogaru fd094f8cfc samples: revert to default CFLAGS
SDK version 0.7.5 has fixed ZEP-62.  It is no longer necessary to use
-O0 in order to get correct readings from sensors.

Change-Id: Ia8ac2f55453b7dfdda71fe2f41863cbd0b366739
Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com>
2016-04-08 17:24:38 +00:00
Vlad Dogaru 49d96d95ab sensor: Add threshold trigger support for MCP9808
The MCP9808 supports threshold triggering.  Add support for this feature
in the driver and the sample application.

If triggering is activated, the driver can create its own fiber or use
the system-wide sensor fiber.

Origin: Original
Change-Id: Ie825a22245cb48cbdffba3049011e4d305975d53
Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com>
2016-03-15 18:04:19 -04:00
Vlad Dogaru d30b3ca516 samples: Add sample app for MCP9808 sensor
The app simply reads the temperature from the connected MCP9808 sensor.
It forces -O0 compile flags, as the default (-Os) triggers a compiler
bug when converting temperature readings.

Origin: Original
Change-Id: I0654543e3d361a862bdf78b44fdc1430cb6aad51
Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com>
2016-03-15 18:04:19 -04:00