This fixes the problem that `adc_raw_to_millivolts` only returns half of
the actual voltage.
Signed-off-by: Caspar Friedrich <c.s.w.friedrich@gmail.com>
Found via static analyis. When `adc_kb1200_start_read` succeeds, no
value is set for `error` so it is still uninitialized when it is
returned.
Signed-off-by: François Baldassari <francois@memfault.com>
Use information encoded in conversion result value to validate it.
Check if MSB bit is set to zero.
Check if channel number included in the result matches channel
number selected for conversion.
Use bitmask to extract converted value instead of math calculations.
Signed-off-by: Lukasz Madej <l.madej@grinn-global.com>
k_thread_name_set() function returns an error if CONFIG_THREAD_NAME is
not enabled which may make the driver not functional.
Fix the issue by adding a check against CONFIG_THREAD_NAME avaliability
before calling k_thread_name_set() function so the driver can operate
properly with CONFIG_THREAD_NAME disabled.
Signed-off-by: Lukasz Madej <l.madej@grinn-global.com>
Add configuration of internal refference voltage value so raw ADC
readings can be converted to mV utilizing adc_raw_to_millivolts()
ADC API function.
Signed-off-by: Lukasz Madej <l.madej@grinn-global.com>
The adc_ads1119 driver is unable to overwrite the configuration register,
the chip therefore always works with its default settings. Register access
macros are fixed by this commit.
Fixes: #70091
Signed-off-by: Jan Kubiznak <jan.kubiznak@deveritec.com>
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>
Add a blank define for the case where DMA channels are defined in ADC node
of the dts but STM32_ADC_DMA is not enabled. Otherwise compilation fails.
Also fix the way the DMA channel is configured by using a standard DT
macro, otherwise it doesn't work for dma-v2bis DMA types.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
Added the STM32G0X SOC series to the list of SOC that need to disable the
ADC while setting the oversampling bits to prevent writing over the
CKMODE bits.
Signed-off-by: Alexandre Poizat <apoizat@kalrayinc.com>
Use K_KERNEL_STACK_SIZEOF() for calculating thread stack size, as this
takes K_KERNEL_STACK_RESERVED into account.
Fixes: #69129
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Use K_KERNEL_STACK_SIZEOF() for calculating thread stack size, as this
takes K_KERNEL_STACK_RESERVED into account.
Fixes: #69133
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Use K_KERNEL_STACK_SIZEOF() for calculating thread stack size, as this
takes K_KERNEL_STACK_RESERVED into account.
Fixes: #69132
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Use K_KERNEL_STACK_SIZEOF() for calculating thread stack size, as this
takes K_KERNEL_STACK_RESERVED into account.
Fixes: #69131
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Use K_KERNEL_STACK_SIZEOF() for calculating thread stack size, as this
takes K_KERNEL_STACK_RESERVED into account.
Fixes: #69130
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Do not disable the ADC after the end of the measurement to avoid systematic
enabling which is time-consuming in case the configuration is unchanged.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
Prevents the system to go in Suspend to RAM low power mode while ADC
measurement is in progress.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
For series that have two sampling time common channels, only one was used.
This commit add the support for the second one. The first two different
acquisition time values are used for the sequence and all further values
must match either of them, otherwise generating an error.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
The TLA2021 driver depends on it's i2c controller and therefore needs
to be initialized later. ADC_INIT_PRIORITY by default equals
KERNEL_INIT_PRIORITY_DEVICE which should be used by independent devices.
Using this by default causing projects to fail where this driver is
enabled implicitly through board configuration and the priority is not
explicitly set.
Signed-off-by: Caspar Friedrich <c.s.w.friedrich@gmail.com>
Several STM32 variants include both shared IRQs for some ADCs and
separate IRQs for others (for example, STM32G473 has 5 ADCs, ADC1 and
ADC2 share one IRQ while ADC3, ADC4 and ADC5 each have unique
IRQs). The STM32 ADC driver however previously only supported either
separate IRQ lines for each operational ADC in the devicetree or a
single shared IRQ for all operational ADCs in the devicetree which
prevented all ADCs from being usable at the same time when the variant
contained a mix of both shared and separate ADC IRQ lines (only either
all the shared or all the separate and one of the shared might be used
at most for one application).
To allow for all ADCs in an STM32 variant to be usable in a single
application, generate an ISR and initialization function for each
unique IRQn as defined in the devicetree and give the task of
initialization to the first ADC which connects to that particular
IRQ. Each ISR function will generate code to call the ISR for each ADC
associated with that IRQn as was previously done for
CONFIG_ADC_STM32_SHARED_IRQS, allowing an ISR to be shared for the
ADCs sharing an IRQ while simultaneously providing separate ISRs for
each IRQ. Thus, the only information required to have ADCs either
share an ISR or not is provided by the devicetree.
Signed-off-by: Michael R Rosen <mrrosen@alumni.cmu.edu>
The current driver initializes the IADC with the default configuration
(IADC_INITSINGLE_DEFAULT), which aligns the data to the right.
To correctly read the 12-bit sample, it should be masked from the right
instead.
Signed-off-by: Paulo Santos <pauloroberto.santos@edge.ufal.br>
When using one of the internal channels (die_temp, vbat, vref) the
channels are enabled in the individual drivers and disabled again
whenever an adc conversion is complete.
This creates a race condition if the ADC is used from multiple threads.
This commit moves the disabling of the channels to the individual
drivers.
Signed-off-by: Brian Juel Folkmann <bju@trackunit.com>
Updated API version enables multi-instance GPIOTE driver.
Additionally obsolete symbol that was used to specify
API version in the past was removed.
Affected drivers have been adjusted and appropriate changes
in affected files have been made.
Signed-off-by: Jakub Zymelka <jakub.zymelka@nordicsemi.no>
Turning on clock via clock controller and
resetting ADC device via reset controller on initializing.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Configure the sw trigger just after calibration
So the conversion can start on regular channel on the
software control bit.
Signed-off-by: Francois Ramu <francois.ramu@st.com>
This commit adds support for more STM32 CPUs that has
a different DMA interface. This was tested only for
the nucleo_l476rg.
Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
Previously the STM32 DMA driver was dependent on a very specific
name for the DMA in the DTS. This hidden requirement has caused
a bit of confusion. This commit changes the driver to instead
always use the first DMA listed in the ADC node's dma property.
Should fix: #65387
Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
Do not enable subsystem/driver shell modules by default and stop abusing
CONFIG_SHELL_MINIMAL, which is internal to the shell subsystem, to decide
when to enable a driver shell.
The list of shell modules has grown considerably through the
years. Enabling CONFIG_SHELL for doing e.g. an interactive debug session
leads to a large number of shell modules also being enabled unless
explicitly disabled, which again leads to non-negligible increases in
RAM/ROM usage.
This commit attempts to establish a policy of subsystem/driver shell
modules being disabled by default, requiring the user/application to
explicitly enable only those needed.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Affected CONFIG_ADC_ADS114S0X_GPIO=y build.
register_addresses was wrong type for
ads114s0x_write_multiple_registers()
Signed-off-by: Nick Ward <nix.ward@gmail.com>