Commit graph

43 commits

Author SHA1 Message Date
Jeppe Odgaard 17b1912bc3 drivers: ad559x: add i2c bus support
Rename ad5592 files in dts, driver and include to ad559x and add support
for I2C bus which is required for AD5593.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2024-04-01 12:18:47 -05:00
Henrik Brix Andersen 24b68fa67f drivers: adc: shell: update list of compatibles
Update the list of ADC compatibles based on the compatibles from
dts/bindings/adc/*.yaml.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-01-12 12:09:53 +00:00
Henrik Brix Andersen 0cd776e7dd drivers: adc: shell: sort the list of compatibles
Sort the list of supported ADC compatibles alphabetically.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-01-12 12:09:53 +00:00
Bartosz Bilas ad3c5a27b4 drivers: adc: add driver for AD5592
Add MFD subdriver for the built-in ADC controller
in AD5592 chip.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2023-11-08 10:07:41 +01:00
Nick Ward 4fe5beb2c5 drivers: adc: shell: add differential command
Add differential command.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-09-25 16:42:10 +02:00
Nick Ward f2af46aaa0 drivers: adc: shell: remove \n from logs
Remove \n from logs.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-09-25 16:42:10 +02:00
Nick Ward 50462228f2 drivers: adc: shell: fix - read result is signed
Previously negative read results were being printed
by the shell as large uint16_t.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-09-25 16:42:10 +02:00
Benedikt Schmidt 413267ea4f drivers: adc: add MAX11102-MAX11117 to ADC shell
Add all available instances of the ADC series
MAX11102-MAX11117 to the ADC shell.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-09-14 08:32:46 -05:00
Cong Nguyen Huu a872aa9a5e drivers: adc: support adc shell for mr_canhubk3
Add device nxp_s32_adc_sar  to adc shell list

Signed-off-by: Cong Nguyen Huu <cong.nguyenhuu@nxp.com>
2023-08-03 08:28:31 +00:00
Benedikt Schmidt d2e89eb512 drivers: adc: make all enabled ADCs available in the shell
Previously, only a single type of ADCs was always available
in the ADC shell. This change enables the usage of the ADC
shell for different ADC types at the same time.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-07-24 08:14:03 -05:00
Jordan Montgomery b1e9a813fe drivers: adc: adc-shell: Add support for ADS111x ADCs to adc-shell.c
The adc-shell uses a hardcoded list of defines to check whether it should
throw a compile-time error. The ADS1119 and ADS1112 driver both support
the APIs needed by the shell, so this commit enables support for them in
the hardcoded support list.

Signed-off-by: Jordan Montgomery <jordan.montgomery@getcruise.com>
2023-06-17 07:49:59 -04:00
Antonio Tessarolo 4598e6bf0a drivers/adc: imx6sx ADC support.
This commit adds support for adc_vf610 ADC.

Signed-off-by: Antonio Tessarolo <anthonytexdev@gmail.com>
2023-05-08 16:42:40 +02:00
Gerard Marull-Paretas 667eeb11fb shell: fix MISRA 5.7 violations on struct shell
MISRA Rule 5.7 requires uniqueness of tag identifiers. Shell is
frequently problematic because many code uses `const struct shell
*shell`. This causes CI noise every time one of these shell files is
edited, so let's update all of them with `const struct shell *sh`
instead.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-14 12:21:08 +02:00
Kumar Gala a29bc8d086 adc: fix armclang compiler warnings with is*() functions
We get compile warnings of the form:

error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint (and the other is* functions) return an int, change check
to an explicit test against the return value.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-04 14:07:14 +02:00
scott worley 6b8bc83f54 tests: adc: Microchip XEC fix ADC API test and ADC shell
Microchip XEC ADC and ADC V2 driver were merged into one
That PR did not change the ADC API test and ADC shell resulting
in twister build failures. Fixed both ADC API test and ADC shell.

Signed-off-by: scott worley <scott.worley@microchip.com>
2023-03-24 11:28:20 -04:00
Pieter De Gendt 0b45710219 drivers: adc: adc_sam: Introduce Atmel SAM ADC driver
This commit adds support for Atmel SAM ADC driver with up to
16 channels.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-03-23 09:41:00 +01:00
Marek Matej 937ea00e7a drivers: adc: esp32: Add support for single-shot conversion
Allow single-shot adc conversion on all supported targets.

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2022-12-23 23:45:05 +00:00
Xinyang Tan 535f5a6c04 shell: support setting help string for each entry in a dictionary command
Add support for setting the help description for each entry in a dictionary
command. Currently the syntax string alone may not provide sufficient
description of its entry. This commit also helps keep the help messages
consistent with existing style.

Signed-off-by: Xinyang Tan <xinyang.tan@delve.com>
2022-12-05 18:40:46 +01:00
TOKITA Hiroshi f3fd686b96 drivers: adc: shell: Support RaspberryPi Pico ADC
Add ADC shell support for RaspberryPi Pico.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2022-09-06 17:11:19 +02:00
Gerard Marull-Paretas fb60aab245 drivers: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all drivers to the new
prefix <zephyr/...>. 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-06 19:58:21 +02:00
Gerard Marull-Paretas 87b982d878 drivers: adc: shell: use DEVICE_DT_GET
ADC instances can be obtained at compile time, so use DEVICE_DT_GET.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-17 11:37:33 +01:00
Andrei Auchynnikau 3b3a30612f drivers: add adc driver for the NXP RT series
adc driver is based on the NXP MCUX hal library

Signed-off-by: Andrei Auchynnikau <ovchinnikov@strim-tech.com>
2021-10-22 15:43:36 -05:00
Scott Worley 19dd46ef68 Microchip: MEC172x: ADC driver
Add ADC driver version 2 for MEC172x using new in-tree headers
and device tree properties. Update the ADC shell for the new driver.

Signed-off-by: Scott Worley <scott.worley@microchip.com>
2021-08-11 19:44:31 -04:00
Tomasz Michalec d83647dea6 drivers: adc: add ADC emulator
ADC emulator is designed to be used in tests on native_posix board. It
supports 1-16 bit resolution range and all GAINs from enum adc_gain.
Reference voltages and number of emulated channels are set through dts.
Using special API from drivers/adc/adc_emul.h it is possible to set
constant voltage value returned by given ADC channel or set custom
function which allows to simulate complex output.
Also reference voltages can be changed in runtime using the API.

The CL also includes:
- Add adc definitions of ADC emulator in
  tests/drivers/adc/adc_api/src/test_adc.c for supporting test suites.
- Add test for ADC emulator API in tests/drivers/adc/adc_emul/

Signed-off-by: Tomasz Michalec <tm@semihalf.com>
2021-05-07 15:27:37 +02:00
Tim Lin cd96046bee ite: drivers/adc: add adc drivers on it8xxx2_evb platform
This commit is about the it8xxx2 analog to digital converter
driver. Support 8 channels ch0~ch7 and 10-bit resolution.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2021-04-13 13:01:56 -04:00
Pavlo Hamov 8e02c4cdf4 shell: adc: support cc322xx
Control cc322xx ADC from shell

Signed-off-by: Pavlo Hamov <pasha.gamov@gmail.com>
2021-02-19 10:43:58 -06:00
Mulin Chao a279b4cfb7 drivers: adc: add adc support in npcx7 series
NPCX7 includes a 10-bit resolution Analog-to-Digital Converter (ADC). Up
to 10 voltage inputs can be measured and a internal voltage reference
(VREF), 2.816V (typical) is used for measurement. It can be triggered
automatically in Autoscan mode. Each input channel is assigned a
separate result register, which is updated at the end of the conversion.

The CL also includes:
— Add npcx adc device tree declarations.
— Zephyr adc api implementation.
— Add adc definitions of npcx7 in
  tests/drivers/adc/adc_api/src/test_adc.c for supporting test suites.

Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-12-07 12:11:17 -05:00
Jakub Rzeszutko 6ed13678b8 adc_shell: rework commands
ADC shell commands can be only executed on the property label
existing in the device tree. It is realized by the dynamic subcommand
returning existing ADC Label.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2020-10-14 14:12:54 +02:00
Jakub Rzeszutko 333e5e0166 adc_shell: extend channel command
The channel command has been extended with subcommands: id, positive,
and negetive. Some boards require positive input configuration before
measurement can be started.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2020-10-14 14:12:54 +02:00
Jakub Rzeszutko fb653608b4 adc_shell: use shell to validate arguments count
Use dedicated shell macros so argument count can be validated before
the command handler is executed. This change simplifies the command
handlers implementation inside the adc_shell file.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2020-10-14 14:12:54 +02:00
Jakub Rzeszutko ceb3c4c576 adc_shell: introduce dictionary commands
Changed gain and reference commands to dictionary commands.
This change removes an obsolete look-up table (string <-> value)
for gain and reference commands.
Now, each modification of gain or reference value will require only
a dictionary command update.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2020-10-14 14:12:54 +02: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
Marcin Niestroj fdeed32844 adc: adc_shell: suppress -Wchar-subscripts with isdigit()
Suppress -Wchar-subscripts warnings when building with Newlib, by
casting isdigit() parameter to unsigned char.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-07-09 11:28:54 +02: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
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 7e0eed9235 devicetree: allow access to all nodes
Usually, we want to operate only on "available" device
nodes ("available" means "status is okay and a matching binding is
found"), but that's not true in all cases.

Sometimes we want to operate on special nodes without matching
bindings, such as those describing memory.

To handle the distinction, change various additional devicetree APIs
making it clear that they operate only on available device nodes,
adjusting gen_defines and devicetree.h implementation details
accordingly:

- emit macros for all existing nodes in gen_defines.py, regardless
  of status or matching binding
- rename DT_NUM_INST to DT_NUM_INST_STATUS_OKAY
- rename DT_NODE_HAS_COMPAT to DT_NODE_HAS_COMPAT_STATUS_OKAY
- rename DT_INST_FOREACH to DT_INST_FOREACH_STATUS_OKAY
- rename DT_ANY_INST_ON_BUS to DT_ANY_INST_ON_BUS_STATUS_OKAY
- rewrite DT_HAS_NODE_STATUS_OKAY in terms of a new DT_NODE_HAS_STATUS
- resurrect DT_HAS_NODE in the form of DT_NODE_EXISTS
- remove DT_COMPAT_ON_BUS as a public API
- use the new default_prop_types edtlib parameter

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-08 19:37:18 -05:00
Kumar Gala 99d14e9075 adc: adc_shell: Fix compile error
Had an extra comma between macro and macro usage that casued the
following compile error:

	adc_shell.c:477:22: error: expected expression before ',' token

Easy fix to remove trailing comma in ADC_SHELL_COMMAND

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-06 23:56:33 -05:00
Martí Bolívar 87e1743ae0 devicetree: replace DT_HAS_DRV_INST with DT_INST_FOREACH
Make drivers multi-instance wherever possible using DT_INST_FOREACH.
This allows removing DT_HAS_DRV_INST in favor of making drivers just
do the right thing regardless of how many instances there are.

There are a few exceptions:

- SoC drivers which use CMake input files (like i2c_dw.c) or otherwise
  would require more time to convert than I have at the moment. For the
  sake of expediency, just inline the DT_HAS_DRV_INST expansion for
  now in these cases.

- SoC drivers which are explicitly single-instance (like the nRF SAADC
  driver). Again for the sake of expediency, drop a BUILD_ASSERT in
  those cases to make sure the assumption that all supported SoCs have
  at most one available instance is valid, failing fast otherwise.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-06 17:35:08 -05:00
Kumar Gala 897652a536 adc: adc_shell: Rework device name extraction from devicetree
Replace having dts_fixup.h files define DT_ADC_{0..2}_NAME with using
the new devicetree.h macros.  We test to see what driver compat is
enabled via DT_HAS_COMPAT and set DT_DRV_COMPAT to that compat.  Than we
can utilize the DT_INST_LABEL() macro to extract the name of the device.

We also replace the Kconfig ADC_{0..2} symbols with DT_HAS_DRV_INST.
This will allow us to remove those Kconfig symbols as this was the only
usage.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-02 10:27:07 -05:00
Peter Bigot dfd293a5c3 treewide: use full path to adc.h header
The build infrastructure should not be adding the drivers subdirectory
to the include path.  Fix the legacy uses that depended on that
addition.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-01-26 17:52:12 +01:00
Kumar Gala 24ae1b1aa7 include: Fix use of <misc/FOO.h> -> <sys/FOO.h>
Fix #include <misc/FOO.h> as misc/FOO.h has been deprecated and
should be #include <sys/FOO.h>.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-12-10 08:39:37 -05:00
Henrik Brix Andersen aefd30cd45 shell: adc: add support for ADC instance 2
Add support for configuring and reading ADC instance number 2.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2019-10-24 12:49:13 -05:00
Nicolai Glud e5e45af4b0 shell: adc: adc shell for testing adcs
The adc shell makes it possible to configure ADC_0 and ADC_1 for testing
purposes. It includes helpful printouts if the number of arguments is
wrong.

Signed-off-by: Nicolai Glud <nigd@prevas.dk>
2019-06-28 10:07:18 -05:00