Commit graph

24 commits

Author SHA1 Message Date
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
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
Tomasz Bursztyka 97326c0445 device: Fix structure attributes access
Since struct devconfig was merged earlier into struct device, let's fix
accessing config_info, name, ... attributes everywhere via:

grep -rlZ 'dev->config->' | xargs -0 sed -i 's/dev->config->/dev->/g'

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-05-08 23:07:44 +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 b04b399d63 drivers: pwm: nrfx: Convert to use DTS NODELABEL for instance detection
Move to using NODELABEL references to enable driver instances for
PWM0..3.  This will allow us to remove per-instance PWM Kconfig symbols.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-05 08:40:19 -05:00
Martí Bolívar be84c4ebbf drivers: pwm: nordic: move to new DT API
DT API conversion only.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-04-24 17:00:13 +02:00
Marek Pieta 75e36ed352 drivers: pwm_nrfx: Wait until PWM is stopped before restarting it
Change adds waiting until PWM is stopped before restarting it. Without
the change, calling the pwm_nrfx_pin_set function multiple times in
quick succession could cause a race condition causing the PWM to
remain stopped in case it should be restarted.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2020-03-19 12:29:51 +01:00
Andrzej Głąbek 668d401293 modules: hal: nordic: Define NRFX_ASSERT as __ASSERT_NO_MSG
Update hal_nordic's revision, so that NRFX_ASSERT uses __ASSERT_NO_MSG
directly, not through the assert macro that comes from from libc,
as the definition of the latter might be different when some specific
libc version is used, and this could generate troubles.

Replace also uses of assert() with __ASSERT_NO_MSG() in nrfx driver
shims that use this macro without including the corresponding header
file (i.e. that implicitly rely on assert.h being included from
nrfx_glue.h, which is no longer the case).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-03-10 17:21:27 +01:00
Henrik Brix Andersen db611e6781 drivers: pwm: add support for inverted PWM signals
Add support for requesting an inverted PWM pulse (active-low) when
setting up the period and pulse width of a PWM pin. This is useful
when driving external, active-low circuitry (e.g. an LED) with a PWM
signal.

All in-tree PWM drivers is updated to match the new API signature, but
no driver support for inverted PWM signals is added yet.

All in-tree PWM consumers are updated to pass a flags value of 0
(0 meaning default, which is normal PWM polarity).

Fixes #21384.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-01-07 18:13:18 +01:00
Andrzej Głąbek b1d5eed262 drivers: nrfx: Update implementations after switching to nrfx 2.0.0
Update calls to nrfx HAL functions to reflect API changes introduced in
nrfx 2.0.0. All these functions are now called with the first parameter
pointing to the structure of registers of the relevant peripheral.
Also a few functions got renamed:
- nrf_gpiote_int_is_enabled to nrf_gpiote_int_enable_check
- nrf_gpiote_event_is_set to nrf_gpiote_event_check
- nrf_rng_event_get to nrf_rng_event_check
- nrf_rng_int_get to nrf_rng_int_enable_check
- nrf_rtc_event_pending to nrf_rtc_event_check
- nrf_rtc_int_is_enabled to nrf_rtc_int_enable_check
- nrf_timer_cc_read to nrf_timer_cc_get
- nrf_timer_cc_write to nrf_timer_cc_set

Default configuration values were removed from nrfx_config files,
so the drivers pwm_nrfx and spi_nrfx_spis no longer can use those.

Function nrfx_pwm_init() now takes one more parameter - context pointer
that is passed to the event handler, not used in the pwm_nrfx driver.

HALs for UART and UARTE now allow configuration of the parity type
and the number of stop bits, for SoCs that provide the corresponding
registers.

Signed-off-by: Karol Lasończyk <karol.lasonczyk@nordicsemi.no>
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-11-08 14:54:12 +01:00
Andrzej Głąbek 51d055c520 drivers: pwm_nrfx: Fix the driver to allow changing period on the fly
Previously it was not possible to change the PWM period, even if only
a single channel was in use, without first stopping the peripheral,
i.e. setting pulse cycles for the channel to 0. This patch corrects
this behavior.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-11-07 16:14:29 +01:00
Jim Paris f1137e4782 drivers: pwm_nrfx: use IS_ENABLED to eliminate a bunch of #ifndefs
For the macros that take on 0/1 values, we can use the existing
IS_ENABLED macro to remove a bunch of code.

Signed-off-by: Jim Paris <jim@jtan.com>
2019-09-25 17:42:53 +02:00
Jim Paris 4aaa08acfd drivers: pwm_nrfx: Add support for center-aligned mode
Add support for up-and-down counter mode, which aligns the center of
each channel's pulses instead of their initial edges.  This is enabled
on a PWM periphral by adding the "center-aligned" property to the
device tree, e.g.:

    &pwm0 {
        status = "okay";
        center-aligned;
        ch0-pin = <15>;
        ch1-pin = <17>;
        ch1-inverted;
    };

Signed-off-by: Jim Paris <jim@jtan.com>
2019-09-25 17:42:53 +02:00
Anas Nashif 5843884887 cleanup: include/: move pwm.h to drivers/pwm.h
move pwm.h to drivers/pwm.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
Andrzej Głąbek c0a15c8bd6 drivers: pwm_nrfx: Correct prescaler value for undivided clock
When there is no need to divide the PWM clock (i.e. the requested
period cycles fit the 15-bit PWM counter), the prescaler value
should be 0, not 1.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-04-23 15:32:35 -07:00
Patrik Flykt 97b3bd11a7 drivers: Rename reserved function names
Rename reserved function names in drivers/ subdirectory. Update
function macros concatenatenating function names with '##'. As
there is a conflict between the existing gpio_sch_manage_callback()
and _gpio_sch_manage_callback() names, leave the latter unmodified.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-04-03 17:31:00 -04:00
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
Ramakrishna Pallala e1639b5345 device: Extend device_set_power_state API to support async requests
The existing device_set_power_state() API works only in synchronous
mode and this is not desirable for devices(ex: Gyro) which take
longer time (few 100 mSec) to suspend/resume.

To support async mode, a new callback argument is added to the API.
The device drivers can asynchronously suspend/resume and call the
callback function upon completion of the async request.

This commit adds the missing callback parameter to all the drivers
to make it compliant with the new API.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2019-03-14 14:26:15 +01:00
Piotr Zięcik ddf744deee drivers: pwm_nrfx: Use Device Tree label as instance name
This commit replaces Kconfig options defining PWM instance
names by device tree labels.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-02-27 12:50:59 +01:00
Gaute Gamnes 2d5ea10f31 drivers: pwm: nrf: Removed Kconfig prescaler option. Rewrite HW driver
1. Kconfig options clock_prescaler removed.
2. Rewritten pwm_nrfx.c nRF HW PWM driver.

Signed-off-by: Gaute Gamnes <gaute.gamnes@nordicsemi.no>
2018-12-11 15:18:14 +01:00
Gaute Gamnes d6e66d0453 drivers: pwm: nrf: Migrate Kconfig options to DT
1. Kconfig options CH pin removed.
2. Kconfig options CH inverted removed.
3. Modified pwm_nrfx.c driver to use DT
   defines instead of Kconfig.

Signed-off-by: Gaute Gamnes <gaute.gamnes@nordicsemi.no>
2018-12-11 15:18:14 +01:00
Marek Pieta 39551cfbb8 drivers: pwm: Add power management to pwm_nrfx
Change adds power management to pwm_nrfx.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2018-11-16 15:01:16 +01:00
Anas Nashif ff9c20826c driver: pwm: use new logger
move PWM driver to use new logger.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-08 17:49:12 -04:00
Justin DeMartino cfc18f2102 drivers: pwm: Add shim for nrfx PWM HW driver
Adds a translation layer to make the nrfx driver for nrf52 PWM
peripheral accessible via the Zephyr's API.

Signed-off-by: Justin DeMartino <jdemarti@gmail.com>
2018-06-22 11:56:01 +02:00