Commit graph

295 commits

Author SHA1 Message Date
Chris Friedt 480b74917d samples: lib: os: hash_map: add Hashmap sample code
This sample shows how to use `sys_hashmap`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-02-22 19:14:05 +01:00
Martin Jäger aef8419e9e samples: basic: custom devicetree binding demo
This sample shows how to define a custom devicetree binding to use
GPIO pins for a specific purpose.

Signed-off-by: Martin Jäger <martin@libre.solar>
2023-01-19 10:16:34 +01:00
Fabio Baltieri 792469aae9 yamllint: indentation: fix files in samples/
Fix the YAML files indentation for files in samples/.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-04 14:23:53 +01:00
Oliver Barta c17b102c65 samples: basic: fade_led: add support for rpi_pico board
PWM device needs to be enabled and configured on rpi_pico board.

Signed-off-by: Oliver Barta <o.barta89@gmail.com>
2023-01-02 13:03:46 +01:00
Oliver Barta c1852bebeb samples: basic: blinky_pwm: fix divider setting for rpi_pico
The fractional part of the divider value is a 4 bit value. Setting it to
255 leads to an overflow in pwm_rpi_get_clkdiv(). This has resulted in a
slight deviation from the reported timing, which is btw. printed in nsec.

Fixes: c5cb0d1a3b ("samples: blinky_pwm: Fix sample for rpi_pico")
Signed-off-by: Oliver Barta <o.barta89@gmail.com>
2023-01-02 13:03:46 +01:00
Bartosz Bilas 62eecf9142 samples: basic: button: use gpio_is_ready_dt
Switch to using the dedicated `gpio_is_ready_dt`
function instead of the raw `device_is_ready`.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-12-28 10:38:01 +01:00
Bartosz Bilas 135817c44d samples: basic: blinky: use gpio_is_ready_dt
Switch to using the dedicated `gpio_is_ready_dt`
function instead of the raw `device_is_ready`.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-12-28 10:38:01 +01:00
Erwan Gouriou 13acbf1b68 samples: blinky_pwm: Add nucleo_l476rg support
Enable use of nucleo_l476rg on this sample using a dedicated overlay.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-12-13 10:01:11 +00:00
Anas Nashif ba7d730e9b tests/samples: use integration_plaforms in more tests/samples
integration_platforms help us control what get built/executed in CI and
for each PR submitted. They do not filter out platforms, instead they
just minimize the amount of builds/testing for a particular
tests/sample.
Tests still run on all supported platforms when not in integration mode.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-29 16:03:23 +01:00
Jeppe Odgaard 7d27309816 samples: Basic system heap Demo
A demo to showcase some of the sys_heap functions

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2022-11-22 13:17:59 +09:00
Benjamin Perseghetti bc72ad318f boards: rddrone_fmuk66 fix pwm pinmux and servos
Fixes the channel 2 PWM pinmux adds servos and PWM LEDs.
Required to operate servo motors and status lighting.
Tested on RDDRONE board.

Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
Co-authored-by: Sumit Batra <sumit.batra@nxp.com>
Co-authored-by: Landon Haugh <landon.haugh1@gmail.com>
2022-11-16 10:18:46 -06:00
Yonatan Schachter c5cb0d1a3b samples: blinky_pwm: Fix sample for rpi_pico
The RP2040 needs a DTS overlay for the PWM to work with the
blinky_pwm examples. This commit adds the required overlay.

Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
2022-11-14 12:37:47 +01:00
Gaël PORTAY 1578a991bd samples: blinky_pwm: fix missing project renaming
The commit bfb1040612 has renamed the
sample blink_led to blinky_pwm, however, the project still have the
former name: blink_led.

This renames the project to its new name: blinky_pwm.

Signed-off-by: Gaël PORTAY <gael.portay@gmail.com>
2022-10-31 09:22:59 -05:00
Pierre Marzin 10d6685f57 samples: blinky_pwm: add rcar_h3ulcb_cr7 board overlay's
Use dts overlay to declare the pwm-led only when needed.
This is only used for demo purpose of PWM0 on RCAR gen3
boards (H3ULCB only at the moment).

Signed-off-by: Pierre Marzin <pierre.marzin@iot.bzh>
2022-09-07 15:50:49 +02:00
Gerard Marull-Paretas 79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02:00
Kumar Gala 0e1a7e0241 drivers: led: Remove unnecessary Kconfig settings
Having the LED device enabled in devicetree will now get the driver
enabled by default when CONFIG_LED=y is set.  So we can remove
setting driver enabling Kconfig values in various .conf files.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-11 17:46:43 +02:00
Kumar Gala 7e286bfc5e samples: basic: threads: Remove dts label prop usage
Replace access to dts 'label' property (which we are phasing out)
with simple int as the serve the purpose for error report.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-07 10:02:47 +02:00
Glauber Maroto Ferreira 5686368eec boards: riscv: esp32c3_devkitm: dts: use pin grouping
Updates device tree pin states definitions and node
descriptions to group pins sharing common properties.

Accordingly, updates in-tree overlays as well.

Signed-off-by: Glauber Maroto Ferreira <glauber.ferreira@espressif.com>
2022-07-01 16:22:18 +00:00
Glauber Maroto Ferreira f82d3d444d boards: xtensa: esp32s2_saola: dts: use pin grouping
Updates device tree pin states definitions and node
descriptions to group pins sharing common properties.

Accordingly, updates in-tree overlays as well.

Signed-off-by: Glauber Maroto Ferreira <glauber.ferreira@espressif.com>
2022-07-01 16:22:18 +00:00
Glauber Maroto Ferreira f79029a074 boards: xtensa: esp32: dts: use pin grouping
- update device tree pin states definitions and node
descriptions to group pins sharing common properties.
- update ESP32's in-tree overlays.

Signed-off-by: Glauber Maroto Ferreira <glauber.ferreira@espressif.com>
2022-07-01 16:22:18 +00:00
Lucas Tamborrino 7519ce35a5 samples: basic: blinky_pwm: add support for espressif boards
Add overlay for espressif boards that does not have a built-in LED.

Add instructions on README file about the required LED connection.

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
2022-06-29 14:48:25 +00:00
Lucas Tamborrino 02675bbc80 dts: esp32: full ledc configuration in binding
This commit moves the hardware configuration for ledc
peripheral to the device-tree instead of Kconfig.

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
2022-06-29 14:48:25 +00:00
Gerard Marull-Paretas 5bef7e71dd samples: basic: minimal: remove pinmux
Remove pinmux dependency, as it is going to be deprecated.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-06-06 15:39:50 -07:00
Gerard Marull-Paretas 23225c68c6 samples: basic: servo_motor: delete nrf52840dk wrong overlay
The overlay was accidentally pushed as part of another commit while
doing some pinctrl/pwm tests.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-11 10:49:05 +02:00
Gerard Marull-Paretas 1d45511888 samples: fade_led: update include paths
Use the <zephyr/...> prefix.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-09 12:45:29 -04:00
Gerard Marull-Paretas d342e4c4c1 linker: update files with <zephyr/...> include prefix
Linker files were not migrated with the new <zephyr/...> prefix.  Note
that the conversion has been scripted, refer to #45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-09 12:45:29 -04:00
Erwan Gouriou d6a4b6b9e4 samples: Migrate overlay includes to <zephyr/...>
Leftover of work done on #45420 and #45417.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-05-09 10:34:42 -04:00
Gerard Marull-Paretas c7b5b3c419 samples: migrate includes to contain <zephyr/...> prefix
In order to bring consistency in-tree, migrate all samples to the use
the new prefix <zephyr/...>. Note that the conversion has been scripted:

```python
from pathlib import Path
import re

EXTENSIONS = ("c", "h", "cpp", "rst")

for p in Path(".").glob("samples/**/*"):
    if not p.is_file() or p.suffix and p.suffix[1:] not in EXTENSIONS:
        continue

    content = ""
    with open(p) as f:
        for line in f:
            m = re.match(r"^(.*)#include <(.*)>(.*)$", line)
            if (m and
                not m.group(2).startswith("zephyr/") and
                (Path(".") / "include" / "zephyr" / m.group(2)).exists()):
                content += (
                    m.group(1) +
                    "#include <zephyr/" + m.group(2) +">" +
                    m.group(3) + "\n"
                )
            else:
                content += line

    with open(p, "w") as f:
        f.write(content)
```

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 11:29:59 +02:00
Gerard Marull-Paretas ae91933c4a drivers: pwm: always use nanoseconds for set
In order to be consistent with what is possible in Devicetree, always
take a period in nanoseconds. Other scales or units may be specified by
using, e.g., the PWM_MSEC() macros (all of them converting down to
nanoseconds). This change then deletes the "_nsec" and "_usec" versions
of the pwm_set call.

Note that this change limits the period to UINT32_MAX nanoseconds,
~4.3s. PWM is, in generali, used with periods below the second so it
should not be a problem.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-28 11:29:38 +02:00
Gerard Marull-Paretas 9e964d0a61 samples: basic: servo_motor: use pwm_dt_spec
The sample did not use PWM in a proper way: it relied on a PWM device
handle, but channel or flags were hardcoded in the code. This patch
changes the sample to use a local binding ("pwm-servo") where the `pwms`
property is defined. This allows to make use of pwm_dt_spec facilities,
reducing the overall sample complexity and making it more portable
without editing the source code. The custom binding also requires to
provide the minimum/maximum pulse width so that different servos can be
easily plugged in without the need to edit sources.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-28 11:29:38 +02:00
Gerard Marull-Paretas cd2d867fa6 samples: basic: rgb_led: use pwm_dt_spec
Simplify the sample by using pwm_dt_spec.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-28 11:29:38 +02:00
Gerard Marull-Paretas f60bb8741b samples: basic: fade_led: use pwm_dt_spec
Simplify sample by using pwm_dt_spec.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-28 11:29:38 +02:00
Gerard Marull-Paretas 627f9e9ec8 samples: basic: blinky_pwm: use pwm_dt_spec
Simplify the sample by using pwm_dt_spec facilities.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-28 11:29:38 +02:00
Gerard Marull-Paretas 10ee44c94b drivers/samples/tests: remove usage of deprecated PWM APIs
Use the new API calls that remove pin naming.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-28 11:29:38 +02:00
Andrzej Głąbek 92b3cc78e7 samples: servo_motor: Align with recent changes in pwm_nrf5_sw driver
- add `channel-gpios` property with GPIO assignment for the used PWM
  channel to the `sw_pwm` node
- replace ambiguous "pin 21" in the sample's README with "pin P19"
  that uses notation from the official micro:bit documentation and
  is consistent with this pin number within the edge_connector node

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-04-22 09:43:26 +02:00
Aleksandar Markovic 7af3b8cbb3 doc: Fix links to Zephyr include directory on Github
At some recent point, directory <zephyr-root>/include was moved to
<zephyr-root>/include/zephyr. However, links from documentation to
Zephyr source on Github were not updated. Update them now.

Signed-off-by: Aleksandar Markovic <aleksandar.markovic.sa@gmail.com>
2022-04-21 18:35:16 -04:00
Gerard Marull-Paretas e70e2fe4df samples: basic: blinky_pwm: delete overlay with LEDs not on board
Samples should run on a board if they have the peripheral connected, in
this case, if any LED on the board is connected to a PWM output. A
shield could be used to demonstrate a sample on a board that doesn't
have the required peripheral. In this case, it was also unclear where
that "external LED" had to be connected, unless one checks where channel
1 for PWM1 is routed to. All board LEDs are connected to pins that
cannot be driven by PWM.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-07 09:35:16 +02:00
Gerard Marull-Paretas bca7e65465 boards: arm: nucleo_l073rz: define PWM LEDs
The board had PWM LEDs defined in the blinky_pwm sample, mainly because
it conflicts with SPI1 pinmux. A better approach is to still define the
PWM LEDs in the board but keep the PWM controller disabled by default.
Then, samples just need to enable the PWM controller (and disable SPI if
used simultaneously).

Also updated period to 20ms (reasonable value for a PWM-driven LED).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-07 09:35:16 +02:00
Gerard Marull-Paretas 855cb90b6a boards: arm: nucleo_l4r5zi: define PWM LEDs
The board had PWM LEDs defined in the blinky_pwm sample, mainly because
it conflicts with SPI1 pinmux. A better approach is to still define the
PWM LEDs in the board but keep the PWM controller disabled by default.
Then, samples just need to enable the PWM controller (and disable SPI if
used simultaneously).

Also updated period to 20ms (reasonable value for a PWM-driven LED).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-07 09:35:16 +02:00
Gerard Marull-Paretas a65cec3042 boards: arm: nucleo_f091rc: define PWM LEDs
The board had PWM LEDs defined in the blinky_pwm sample, mainly because
it conflicts with SPI1 pinmux. A better approach is to still define the
PWM LEDs in the board but keep the PWM controller disabled by default.
Then, samples just need to enable the PWM controller (and disable SPI if
used simultaneously).

Also updated period to 20ms (reasonable value for a PWM-driven LED).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-07 09:35:16 +02:00
Gerard Marull-Paretas 5c61e4444b samples: fade_led/blinky_pwm: add pwm-leds compat check to filter
While the pwm-led0 alias may exist, it could happen that the node with
pwm-leds compatible is disabled, making the sample fail compilation.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-07 09:35:16 +02:00
Francois Ramu 8043fb922a samples: blinky pwm running on the nucleo_l4r5zi
Adding an overlay to configure the nucleo_l4r5zi for testing the pwm
blinky application on red led (PB14 on nucleo board)
Each has a specific pwm output from different timers/channels

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-03-31 10:28:47 +02:00
Francois Ramu 2620c53771 samples: pwm for stm32l073 and stm32f091 nucleo boards
The overlay are defined to run the samples application with PWM
feature on the nucleo_l073rz,nucleo_f091rc, nucleo_g474re

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-03-10 13:25:54 -05:00
Daniel DeGrasse 5094a6e08c samples: blinky_pwm: decreased min PWM period for blinky sample
Blinky PWM sample minimum pwm period was too high for iMX.RT PWM module.
decrease the minimum pwm period so sample will pass pwm calibration
phase.

Fixes #38954

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-02-10 14:33:08 -05:00
Martí Bolívar efc0e75463 samples: blinky: use a gpio_dt_spec
Using a gpio_dt_spec is the current best practice for getting at pins
defined in the DT, because it gets all the boilerplate and flags right
for you. Use that in blinky, keeping the documentation in sync with
the code.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-02-04 11:20:46 +01:00
Erwan Gouriou 215822d161 samples: Take into account PINCTRL in minimal configurations
Now that PINCTRL is available, don't forget to disable it
in minimal configurations.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-12-21 18:30:35 +01:00
Glauber Maroto Ferreira 2bea827f05 samples: blinky_pwm: esp_wrover_kit: pwm led support
- adds overlayed board info to support PWM LED
- adds support for blinky_pwm sample code.

Signed-off-by: Glauber Maroto Ferreira <glauber.ferreira@espressif.com>
2021-12-16 20:49:27 -05:00
Andrei-Edward Popa 02c2cae942 samples: blinky_pwm: added overlay for the esp32 board
added pwm leds in board overlay file,
added configs in board conf file

Signed-off-by: Andrei-Edward Popa <andrei_edward.popa@upb.ro>
2021-11-07 05:36:42 -05:00
Waqas Mazhar 33d4ac43e6 samples: basic: blinky_pwm: Add support for nucleo_wb55rg platform
Create a board overlay file in the application directory to add
pwm-led0 entry over default device tree. Also, include instruction
in the README file that connection of external LED at pin PA8 is
required for the demo to work.

Signed-off-by: Waqas Mazhar <waqas.mazhar@planetinnovation.com.au>
2021-08-31 19:56:22 -04:00
Torsten Rasmussen 1cccc8a8fe cmake: increase minimal required version to 3.20.0
Move to CMake 3.20.0.

At the Toolchain WG it was decided to move to CMake 3.20.0.

The main reason for increasing CMake version is better toolchain
support.

Better toolchain support is added in the following CMake versions:
- armclang, CMake 3.15
- Intel oneAPI, CMake 3.20
- IAR, CMake 3.15 and 3.20

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-20 09:47:34 +02:00
Jordan Yates be2e6a0850 samples: button: use gpio_dt_spec helpers
Convert pin setting and getting to `struct gpio_dt_spec` variants to
demonstrate usage of the new API.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-06-24 06:40:00 -05:00
Martí Bolívar fff2644189 samples: button: devicetree cleanups
Use a gpio_dt_spec, dropping device_get_binding. This in turn lets us
write everything in a single main() without sacrificing readability
since the LED is optional.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-05 20:46:43 +02:00
Martí Bolívar 7e1877e2b2 samples: threads: devicetree cleanups
Use a gpio_dt_spec, GPIO_DT_SPEC_GET_OR, and DT_PROP_OR.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-05 20:46:43 +02:00
Gerard Marull-Paretas ebfe9be01f doc: fix devicetree lexer warnings
Some warnings for invalid DT syntax have been fixed.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-04 22:42:15 -04:00
Gerard Marull-Paretas aa0b02bf75 doc: use pygments devicetree language support
Since Pygments 2.7.0 devicetree syntax is supported, so there is no need
to use a custom lexer. Version 2.9.0 introduces a fix that is required
for some devicetree snippets.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-04 22:42:15 -04:00
Martí Bolívar 51f55b437f twister: replace dt_compat_enabled_with_alias filter
Originally added in 7733b94224.

This filter is not well-formed. It's meant to match nodes like
/leds/led_0 in this DTS:

/ {
	aliases {
		led0 = &led0;
	};

	leds {
		compatible = "gpio-leds";
		led0: led_0 {
			gpios = <...>;
			label = "LED 0";
		};
	};
};

Uses look like this:

    filter: dt_compat_enabled_with_alias("gpio-leds", "led0")

But notice how the led_0 node doesn't have compatible "gpio-leds";
it's actually the *parent* node that has that compatible.

Replace this with a new filter, dt_enabled_alias_with_parent_compat(),
which is used like this:

    filter: dt_enabled_alias_with_parent_compat("led0", "gpio-leds")

This has a name and argument order that makes the meaning of the
filter clearer.

Replace in-tree users with the new filter.

Deprecate the old filter and warn about its use using the standard
logging module.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-03-10 15:09:09 -05:00
Jennifer Williams 62c7f82a0d samples: basic: blinky_pwm: fix bad path in README
The README gives as example the command to build
the sample with west. The path of the sample as
stated does not exist. This fixes it to blinky_pwm.

Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>
2021-03-04 11:29:53 +03:00
Kumar Gala e8224c3a08 samples: servo_motor: Convert to use DEVICE_DT_GET
Replace device_get_binding with DEVICE_DT_GET for getting access
to the pwm controller device.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-02-24 15:46:18 -06:00
Kumar Gala 1ca6828db9 samples: basic: Convert to use DEVICE_DT_GET
Replace device_get_binding with DEVICE_DT_GET for getting access
to the pwm controller device.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-02-24 13:45:46 -06:00
Krzysztof Chruscinski 7f08061f0c logging: Revamp menuconfig
Clean up logging menuconfig by grouping configuration into
sections like: mode, processing configuration, backends.

Additionlly, removed LOG_ENABLE_FANCY_OUTPUT_FORMATTING which is no
longer in use.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-01-26 06:15:42 -05:00
Anas Nashif dd931f93a2 power: standarize PM Kconfigs and cleanup
- Remove SYS_ prefix
- shorten POWER_MANAGEMENT to just PM
- DEVICE_POWER_MANAGEMENT -> PM_DEVICE

and use PM_ as the prefix for all PM related Kconfigs

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-12-09 15:18:29 -05:00
Daniel Leung 4a9ee68e12 samples: basic/minimal: disable memory pool when MT=n
This adds the option to disable kernel memory pool when
multithreading is also not enabled. This saves some
code space.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-09-19 05:49:13 -04:00
Tomasz Bursztyka e18fcbba5a device: Const-ify all device driver instance pointers
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Peter Bigot 0b286d7304 samples: remove unnecessary check for flags cell in gpios
The devicetree helper macro now provides zero when the cell is not
present.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-08-27 15:59:03 +02:00
Anas Nashif dca317c730 sanitycheck: inclusive language
change whitelist -> allow.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-08-27 07:04:07 -04:00
Martí Bolívar 5be0d00d41 treewide: remove unnecessary DT GPIO/PWM flags checks
Now that the relevant APIs generalize properly for bindings without
flags, we can remove some special case checks from the tree.

I couldn't find any more, but I did this kind of quickly, so it's
possible I missed some.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-08-04 07:35:26 -05:00
Anas Nashif eee3ffc7b9 tests/samples: enable for integration testing
Limit execution in CI when using --integration option of sanitycheck.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-07-30 08:00:03 -04:00
Anas Nashif 1fbbfc819a tests/samples: add tags to some tests
Some tests/samples had no tags, fill those..

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-07-20 17:44:16 -04:00
Simon Glass f895cf4d9c samples: fade_led: Correct the sample name in the docs
The docs do not match the directory this sample is in. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-06-09 10:24:43 -05:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
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
Martí Bolívar 6bc17e3211 samples: various servo_motor fixes
Though there were issues with this sample before e959386bd2 ("samples:
servo_motor: cleanups and changes"), that commit introduced further
bugs. This happened because the new pwm-servo alias that commit
switched to wasn't provided by any boards, so it wasn't built in CI.

Before that, however, the recommendation to use bbc_microbit in the
sample documentation was also buggy in a couple of ways:

    1. bbc_microbit doesn't have the pwm-0 alias the sample
       previously required, so it didn't build on that board

    2. the documentation's comment to use pin 0 on the edge connector
       is wrong; PWM channel 0 is wired to GPIO P0.0 on the SoC,
       which is actually pin 21 on the connector

Fix it all up.

Tested on bbc_microbit. I verified the pinout and also made sure that
the sample correctly generates pulses from 700 to 2300 usec.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-19 17:27:07 +02:00
Martí Bolívar c58db0c995 samples: threads: cleanups
Align the docs and source code with other changes done to the basic
samples.

Use numbers 0 and 1 to refer to the LEDs consistently. This matches
the generic devicetree aliases used by Zephyr, instead of using USR1
and USR2, which are specific to 96b_carbon.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-13 19:51:01 +02:00
Martí Bolívar e959386bd2 samples: servo_motor: cleanups and changes
Align the sample with changes made to other basic samples.

Move away from 'pwm-0' as a devicetree alias, requiring applications
to define a 'pwm-servo' alias. We are getting rid of the aliases that
just bounce through to node labels as soon as we can, might as well
get the applications ready now.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-13 19:51:01 +02:00
Martí Bolívar a0f940ae04 samples: rgb_led: cleanups
Align this sample with the changes made to the other basic samples.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-13 19:51:01 +02:00
Martí Bolívar b6e4e9f991 samples: minimal: cleanups
Touch up the README while we're looking at the basic samples.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-13 19:51:01 +02:00
Martí Bolívar 0156b6c185 samples: fade_led: cleanups and fixups
Align the sample and its documentation with the other basic samples.

Adjust the fade algorithm so that it looks better and takes less time
to verify by taking 2.5 seconds instead of 10.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-13 19:51:01 +02:00
Martí Bolívar bfb1040612 samples: rename blink_led to blinky_pwm
The difference between "blinky" and "blink_led" is not clear.
This rename makes it more obvious that "blinky_pwm", well,
blinks an LED using PWM.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-13 19:51:01 +02:00
Martí Bolívar aab2252817 samples: blink_led: cleanups and fixups
Align this sample's source code and documentation with other basic
samples.

Adjust the logging configuration and output some additional printk()s
at startup to make it more obvious that initial errors are device
specific and related to calibration.

Fix the period calculation logic so the sample does not stick at the
maximum and minimum periods for two consecutive four-second periods.
That is, instead of setting the pin period to MIN_PERIOD_USEC twice in
a row, do it only once before doubling again, and similarly for
max_period.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-13 19:51:01 +02:00
Martí Bolívar dff93ae00f samples: button: cleanups
Clean up the code and fix the documentation, which is out of date and
still refers to information from the days of board.h.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-13 19:51:01 +02:00
Martí Bolívar 63b74f0ec7 doc: samples: tweak blinky readme
The led0 alias doesn't have to be in BOARD.dts, though that is
customary.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-13 19:51:01 +02:00
Martí Bolívar 6e8775ff84 devicetree: remove DT_HAS_NODE_STATUS_OKAY
Several reviewers agreed that DT_HAS_NODE_STATUS_OKAY(...) was an
undesirable API for the following reasons:

- it's inconsistent with the rest of the DT_NODE_HAS_FOO names
- DT_NODE_HAS_FOO_BAR_BAZ(node) was agreed upon as a shorthand
  for macros which are equivalent to
  DT_NODE_HAS_FOO(node) && DT_NODE_HAS_BAR(node) &&
- DT_NODE_HAS_BAZ(node), and DT_HAS_NODE_STATUS_OKAY is an odd duck
- DT_NODE_HAS_STATUS(..., okay) was viewed as more readable anyway
- it is seen as a somewhat aesthetically challenged name

Replace all users with DT_NODE_HAS_STATUS(..., okay), which is
semantically equivalent.

This is mostly done with sed, but a few remaining cases were done by
hand, along with whitespace, docs, and comment changes. These special
cases include the Nordic SOC static assert files.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-13 18:24:42 +02:00
Martí Bolívar 3b7918360a doc: blinky: touch up README
The devicetree link is rendering as "Devicetree Guide" instead of
"devicetree". Fix that.

My guess is that most users won't care about the details of the
requirements, and rather just want to know if their board is supported
or not. So move the error you'll see on unsupported boards before the
details about how to add support (which involve a pretty significant
learning curve).

Also mention overlays as a way to get this working.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-06 17:25:49 +02:00
Kumar Gala fdd85d5ad7 dts: Rename DT_HAS_NODE macro to DT_HAS_NODE_STATUS_OKAY
Rename DT_HAS_NODE to DT_HAS_NODE_STATUS_OKAY so the semantics are
clear.  As going forward DT_HAS_NODE will report if a NODE exists
regardless of its status.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-06 05:25:41 -05:00
Kumar Gala 4e93b77552 samples: Convert DT_ALIAS_* to new DT_ALIAS() macro
Convert DT_ALIAS_* defines to use DT_ALIAS() plus other macros from
include/devicetree.h.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-04 15:28:20 -05:00
Kumar Gala cdd629cda2 samples: basic: threads: Rework to not define generated macros
Rather than redefining a macro which might be generated we should create
a new define name that should get used in the code.  Replace redefining
DT_ALIAS_LED0_GPIOS_FLAGS with LED0_FLAGS and DT_ALIAS_LED1_GPIOS_FLAGS
with LED1_FLAGS.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-04 15:28:20 -05:00
Kumar Gala 88a0f441da samples: basic: button: Rework to not define generated macros
Rather than redefining a macro which might be generated we should create
a new define name that should get used in the code.  Replace redefining
DT_ALIAS_SW0_GPIOS_FLAGS with SW0_FLAGS and DT_ALIAS_LED0_GPIOS_FLAGS
with LED0_FLAGS.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-04 15:28:20 -05:00
Stephanos Ioannidis 0e6ede8929 kconfig: Rename CONFIG_FLOAT to CONFIG_FPU
This commit renames the Kconfig `FLOAT` symbol to `FPU`, since this
symbol only indicates that the hardware Floating Point Unit (FPU) is
used and does not imply and/or indicate the general availability of
toolchain-level floating point support (i.e. this symbol is not
selected when building for an FPU-less platform that supports floating
point operations through the toolchain-provided software floating point
library).

Moreover, given that the symbol that indicates the availability of FPU
is named `CPU_HAS_FPU`, it only makes sense to use "FPU" in the name of
the symbol that enables the FPU.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-04-27 19:03:44 +02:00
Gerard Marull-Paretas cf2131d7f9 boards: nucleo_h743zi: add pwm support
Enables PWM support using the built-in red LED. Tested with:

- samples/basic/blink_led
- samples/basic/fade_led

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2020-04-04 15:00:11 +02:00
Peter Bigot ecf3bdb5b3 coccinelle: re-run timeout conversion semantic patch
Run the int_literal_to_timeout Coccinelle script to fix places where
it is clear that an integer duration is being passed where a timeout
value is required.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-04-02 19:47:51 +03:00
Kumar Gala 666c39a3cb samples: basic: servo_motor: Move dts overlays under boards
Move the dts overlay under a boards/ dir to make it match conf files.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-01 10:44:31 -04:00
Anas Nashif 175b8a7393 samples: use K_MSEC with k_sleep()
Couple of samples missing the conversion.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-04-01 09:25:42 -04:00
Andy Ross 32bb2395c2 timeout: Fix up API usage
Kernel timeouts have always been a 32 bit integer despite the
existence of generation macros, and existing code has been
inconsistent about using them.  Upcoming commits are going to make the
timeout arguments opaque, so fix things up to be rigorously correct.
Changes include:

+ Adding a K_TIMEOUT_EQ() macro for code that needs to compare timeout
  values for equality (e.g. with K_FOREVER or K_NO_WAIT).

+ Adding a k_msleep() synonym for k_sleep() which can continue to take
  integral arguments as k_sleep() moves away to timeout arguments.

+ Pervasively using the K_MSEC(), K_SECONDS(), et. al. macros to
  generate timeout arguments.

+ Removing the usage of K_NO_WAIT as the final argument to
  K_THREAD_DEFINE().  This is just a count of milliseconds and we need
  to use a zero.

This patch include no logic changes and should not affect generated
code at all.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-03-31 19:40:47 -04: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
Andrzej Głąbek 4253eae005 boards: nrf52840_pca10056: Rename board to nrf52840dk_nrf52840
The nRF52840 DK board target, so far known as nrf52840_pca10056,
is renamed to nrf52840dk_nrf52840.
Its documentation and all references to its name in the tree are
updated accordingly. Overlay and configuration files specific to
this board are also renamed, to match the new board name.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-03-27 09:14:08 +01:00
Martí Bolívar 0d1d441aec samples: convert blinky to new DT API
This doesn't sacrifice any readability when compiled for boards that
don't support this alias.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-24 10:11:20 -05:00
Ioannis Glaropoulos f3807f19dc boards: arm: nrf51_pca10028: rename board to nrf51dk_nrf51422
We rename the nRF51 Dev Kit board target (nrf51_pca10028)
to nrf51dk_nrf51422. We update all associated references
in the supportive documentation and all nRF51-related
cofigurations and overlay files in the samples and tests
in the tree.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-03-24 11:45:27 +01:00
Martí Bolívar 748c7757ea samples: blinky: clean up error on unsupported board
This sample requires led0 in the board devicetree's /aliases.
Improve the error message when that is not available.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-04 21:50:43 +02:00
Carles Cufi f80164525f samples: blinky: Improve documentation
Improve the documentation of the blinky sample, fixing typos, adding
links to the relevant DT documentation and cleaning up a bit.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-04 21:50:43 +02:00
Andrzej Głąbek aa544d678e samples: fade_led: Fix definition of PWM_FLAGS
As it incorrectly uses DT_ALIAS_PWM_LED0_PWMS_CHANNEL macro instead of
the *_FLAGS one.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-02-11 17:50:50 +02:00