Commit graph

236 commits

Author SHA1 Message Date
Patrik Flykt 24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Peter A. Bigot d080d1d791 tests: gpio: basic_api: correct constant test for interrupt trigger
Interrupts default to trigger on level for historical reasons, so use of
GPIO_INT_LEVEL` as a mask results in a zero value.  Use a mask macro to
isolate the trigger configuration.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-02-07 22:46:37 -06:00
Peter A. Bigot d75495709d drivers: gpio: fix mis-use of slist API in callback processing
The iterator over registered callbacks failed to account for the
possibility that the callback would remove itself from the list.  If
this occurred any remaining callbacks would no longer be reachable from
the node.  Switch to the slist iterator that is safe for self-removal.

Note that the slist API remains unsafe for removal of subsequent nodes.
Even with the corrected code removal of the next callback registration
(cached in tmp) will result in it being called anyway, with the
remaining unremoved registrations not being called.  If the next
callback were removed and re-registered on a different device, the
callbacks would be invoked for the wrong device.

Resolve this by a documentation change describing the conditions under
which a change to callback registration from within a callback are
permitted.  Add a similar note regarding the effect of adding a
callback.  The current event invocation behavior for callbacks added
within an event is explicitly left unspecified, though in the current
slist implementation newly added callbacks will not be invoked until the
next event.

Closes #10186

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-02-05 12:33:25 -06: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
Patrik Flykt 440b535602 tests: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Andrzej Głąbek 20202902f2 dts_fixups: Use DT_ prefix in all defined labels not related to Kconfig
These changes were obtained by running a script  created by
Ulf Magnusson <Ulf.Magnusson@nordicsemi.no> for the following
specification:

1. Read the contents of all dts_fixup.h files in Zephyr
2. Check the left-hand side of the #define macros (i.e. the X in
   #define X Y)
3. Check if that name is also the name of a Kconfig option
   3.a If it is, then do nothing
   3.b If it is not, then replace CONFIG_ with DT_ or add DT_ if it
       has neither of these two prefixes
4. Replace the use of the changed #define in the code itself
   (.c, .h, .ld)

Additionally, some tweaks had to be added to this script to catch some
of the macros used in the code in a parameterized form, e.g.:
- CONFIG_GPIO_STM32_GPIO##__SUFFIX##_BASE_ADDRESS
- CONFIG_UART_##idx##_TX_PIN
- I2C_SBCON_##_num##_BASE_ADDR
and to prevent adding DT_ prefix to the following symbols:
- FLASH_START
- FLASH_SIZE
- SRAM_START
- SRAM_SIZE
- _ROM_ADDR
- _ROM_SIZE
- _RAM_ADDR
- _RAM_SIZE
which are surprisingly also defined in some dts_fixup.h files.

Finally, some manual corrections had to be done as well:
- name##_IRQ -> DT_##name##_IRQ in uart_stm32.c

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-11-13 10:44:42 -06: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
Mieszko Mierunski 4f6aac1a67 dts: nrf5: Changed GPIO and GPIOTE define names
Changed names using nrf5 to nrf for consistency with other drivers.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2018-08-17 07:29:14 -07:00
Mieszko Mierunski b468b24d75 tests: gpio: Added nRF board to gpio test
Added pin definitions for gpio tests for PCA10056, PCA10048
and PCA10028

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2018-08-17 07:29:14 -07: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
Anas Nashif 305ec6751b tests: fix struct initialization
uncovcerd by clangm we are initialising too late and after first use.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-01 22:58:23 +02:00
Anas Nashif 49bb83138c tests: classify periphera tests
Fix testcase naming and follow <component>.<subcomponent> where it makes
sense.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-09 22:55:20 -04:00
Michael Hope f7c1903418 tests: gpio: add a configuration for the Arduino Zero.
Allows testing the new interrupt support.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-03-10 11:42:25 -06:00
Anas Nashif a0ba239886 tests: gpio: make test depend on gpio capability
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
Leandro Pereira da9b0ddf5b drivers: Rename random to entropy
This should clear up some of the confusion with random number
generators and drivers that obtain entropy from the hardware.  Also,
many hardware number generators have limited bandwidth, so it's natural
for their output to be only used for seeding a random number generator.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-11-01 08:26:29 -04: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
Leandro Pereira aa0e931ecc tests: gpio: Add support for ESP32
Adds an #elif for ESP32 boards.  Connect a wire from pin IO2 to pin IO4
so that the test can be executed.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-08-23 10:28:59 -04:00
Anas Nashif 3c50f7aa12 tests: samples: remove duplicate filtering
We have many testcases doing filtering both on the architecture level
and the platform level, which is redundant. Also many testcases are
running the same test twice on the same SoC for no good reason, cleanup
the tests and cleanup the filtering.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-27 17:44:23 -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 ddbf1255a9 test: fix misspellings
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-06-17 22:34:45 -04:00
Kumar Gala eaaa175b92 tests: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I6c676bc6c5e850a8725785554cd535e32067f33e
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 09:53:49 -05:00
Kumar Gala c7bc909914 tests/ztest: rename assert macros to be zephyr specific
ztest has a number of assert style macros and used a baseline assert()
that varies from the system definition of assert() so lets rename
everything as zassert to be clear.

Change-Id: I7f176b3bae94d1045054d665be8b5bda947e5bb0
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-13 21:17:33 +00:00
Qiu Peiyang 8d4f1bcb78 tests/gpio: enable gpio cases to run on more platforms
Add pin definitions to enable GPIO cases to run on
Quark D2000.
Add pin definitions to enable GPIO cases to run on
arduino_101_sss.

Change-Id: I97eadb8316b1f80b899b167a01effab815626dae
Signed-off-by: Qiu Peiyang <peiyangx.qiu@intel.com>
2017-03-07 23:03:01 +00:00
Qiu Peiyang 935663f05e tests: fix disabling of GPIO interrupt issue
According to ZEP-1717, removing the callback from
the gpio is not enough to disable interruptions.
You also need to call gpio_pin_configure() on
the input pin without the GPIO_INT flag to totally
disable the interrupt for the pin.

This commit will stop level interrupt from being
fired constantly.

Change-Id: I019d7cea0bc0d5e5ff4b74165472ed11de1733bb
Signed-off-by: Qiu Peiyang <peiyangx.qiu@intel.com>
2017-03-07 23:01:52 +00:00
Qiu Peiyang 0c87784c84 tests/gpio: fix test GPIO_INT_EDGE bug
When test GPIO_INT_EDGE, there is no code to skip GPIO_INT_LEVEL
and jump to the end of the function. So GPIO_INT_LEVEL will
always be checked (Besides, it't always true), even if it's
testing GPIO_INT_EDGE, which will cause GPIO_INT_EDGE cases fail.

Add a goto statement for GPIO_INT_EDGE to skip GPIO_INT_LEVEL.

Jira: ZEP-1685

Change-Id: I10ce21c04c49f34aafdc2cd2f60f3e5377d6f1f5
Signed-off-by: Qiu Peiyang <peiyangx.qiu@intel.com>
2017-02-12 01:04:09 +00:00
Qiu Peiyang 41ffe0240d tests/gpio: fix test GPIO_INT_LEVEL bug
According to include/gpio.h, GPIO_INT_LEVEL is 0,
which means the branch to test GPIO_INT_LEVEL is
always false and GPIO_INT_LEVEL cases will always
pass.

This patch also fixes another minor bug in main.c.

Coverity-CID: 160074

Change-Id: I1fefa978e65bf801f244b4c2960cb87a26b0829e
Signed-off-by: Qiu Peiyang <peiyangx.qiu@intel.com>
2017-01-25 14:25:48 +00:00
Qiu Peiyang cbeac3e97d tests/gpio: don't call risk function
According to Coverity, rand() is a risk function.
So we use another method to generate random value.

Coverity-CID: 160070

Change-Id: Icb7e06cd43cb8bade6596cc37e9d04bfc59e1de7
Signed-off-by: Qiu Peiyang <peiyangx.qiu@intel.com>
2017-01-25 14:25:03 +00: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
Qiu Peiyang a6aa60f502 tests/gpio: fix typo
Change-Id: Ic93d1e5dcb46455abd3ea2d7fe8790b2163c1c67
Signed-off-by: Qiu Peiyang <peiyangx.qiu@intel.com>
2017-01-05 23:54:18 +00:00
Andrew Boie 0f08bd8cf8 gpio_basic_api: fix format codes
Change-Id: I006a0c3efe24a6d41a488a466cba97e9bbd1c164
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-01-03 20:37:40 +00:00
Anas Nashif 66cfcc26bc tests: introduce Makefile.test
To customise test builds and support test related features such as time
stamps and a boot banner, introduce a Makefile variant that is dedicated
to testing.

Initially we introduce a new config overlay that is used for all tests, in
this case we enable BOOT_BANNER and BUILD_TIMESTAMP. This will print the
current version and the date, useful when reporting bugs and also an
indicator that the system has booted before the test has started.

For example:

[QEMU] CPU: qemu32
***** BOOTING ZEPHYR OS v1.6.99 - BUILD: Dec 21 2016 19:57:13 *****
tc_start() - Test Nanokernel CPU and thread routines
Initializing nanokernel objects
...
..

Change-Id: I224318cdeb55a301964ea366dbc577e2e3a09175
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-01-03 17:48:44 +00:00
jing wang b008914e42 tests: add gpio driver test case
the commit include 5 ztest cases, cover the basic gpio APIs
including callback relevant and pin read/write functions.
It proves workable on intel quark c1000 and
arduino 101 platform

Change-Id: Iab30aa841cfa440c1f773b5a8c5ce0d68346c353
Signed-off-by: jing wang <jing.j.wang@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-24 16:24:26 +00:00