Commit graph

12 commits

Author SHA1 Message Date
Benedikt Schmidt 49ce054200 drivers: adc: fix thread function signatures
Fix the data acquisition thread function signatures to avoid a stack
corruption on thread exit.
Fixes #62637

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-10-30 12:24:34 +01:00
Flavio Ceolin b483c9251c drivers: adc: Fix misuse of const and k_tid_t
"const k_tid_t" is "struct k_thread * const" and not "const struct
k_thread *" as the code may be assuming. Just drop it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-23 11:35:33 +02:00
Daniel Leung 04a0cf7d79 kernel: deprecate K_THREAD_STACK_MEMBER
The macro K_THREAD_STACK_MEMBER has actually been deprecated
since v2.4.0 in the macro doxygen description, but it was
never marked with __DEPRECATED_MACRO. Since this was being
used in various drivers, make it follow the deprecation
process.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-10-12 11:07:00 +01:00
Chris Collins 2bf231f39a adc: ads1x1x: improve behaviour during i2c errors
Fixes #61401

The ADS1x1x driver has a bad habit of assuming i2c operations will
always suceed - this fixes the two worse cases in the code I could
identify (there may yet be more).

* During initial ADC setup, if either of the two I2C operations
  (read or write) fails, raise the error immediately to the caller
  rather than letting it fall through to the acquisition thread.

  This ensures that we only ever attempt to give a result that was
  definitely connected to our attempt to start the capture.

* If the acquisition thread encounters an I2C error, raise the error
  but do not terminate the aquisition thread.  This ensures the
  application can attempt to fix the condition that caused the I2C
  error and try again.

Signed-off-by: Chris Collins <kuroneko@sysadninjas.net>
2023-08-16 17:05:44 +02:00
Ryan McClelland 77fb2025a8 drivers: adc: ads1x1x: fix pga enum comment
The pga enum internal reference voltage and gain values
were fixed in the code, but a comment was forgotten to be
updated. Correct the comment to match how the code uses
the enum.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2023-05-31 10:35:53 +02:00
Ryan McClelland 9b7d71e044 drivers: adc: fix ref_internal for ads1x1x
The ADS1x13 does not have a PGA, and will have a fixed
internal reference voltage of 2048mV. This sets the internal
referece voltage for the ads1x1x to 2048 and adjust the gain
configuration to scale.

Signed-off-by: Ryan McClelland <ryanmcclelland@fb.com>
2022-11-08 11:33:25 -06: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
Ryan McClelland 86bb6abbd0 adc: ads1x1x: run clangformat
run clangformat on adc_ads1x1x.c

Signed-off-by: Ryan McClelland <ryanmcclelland@fb.com>
2022-07-04 16:28:43 +02:00
Ryan McClelland 3d7fc77678 adc: ads1x1x: macro cleanup
clean up the unique macros using existing macros

Signed-off-by: Ryan McClelland <ryanmcclelland@fb.com>
2022-07-04 16:28:43 +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
Nazar Kazakov f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00
Ryan McClelland 2eaede53af drivers: adc: add ads1x1x driver
This adds support for the ads101x (ads1013, ads1014, ads1015) and
ads111x (ads1113, ads1114, ads1115) family of i2c adc devices.

Signed-off-by: Ryan McClelland <ryanmcclelland@fb.com>
2022-02-22 10:49:39 +01:00