Skip to content

Conversation

jsbatch
Copy link
Contributor

@jsbatch jsbatch commented Oct 1, 2025

This change implements an ADC driver for the PSOC C3 family of devices using the High Performance Programmable Analog Subsystem (HPPASS).

  • Updates device tree and KConfig files based on new ADC driver implementation.
  • Updates modules/hal/infineon to include new support files.
  • Adds HPPASS SAR ADC driver files used in PSOC C3 series of devices.
  • Adds sample and test overlays to provide support for: adc_api

 * Separates HPPASS and HPPASS SAR ADC in the device tree
 * Makes HPPASS SAR ADC a child of the HPPASS system to reflect hardware
   architecture.
 * Adds binding files for HPPASS Analog and HPPASS SAR ADC drivers.

Signed-off-by: John Batch <[email protected]>
Copy link

github-actions bot commented Oct 1, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
hal_infineon zephyrproject-rtos/hal_infineon@f78b8f8 zephyrproject-rtos/hal_infineon#32 zephyrproject-rtos/hal_infineon#32/files

DNM label due to: 1 project with PR revision

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@github-actions github-actions bot added manifest manifest-hal_infineon DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Oct 1, 2025
@zephyrbot zephyrbot added area: Devicetree Bindings platform: Infineon Infineon Technologies AG area: Boards/SoCs area: Samples Samples area: Tests Issues related to a particular existing or missing test area: ADC Analog-to-Digital Converter (ADC) labels Oct 1, 2025
@jsbatch jsbatch force-pushed the main-hppass_adc_dev branch from ca90ca1 to cb02c8c Compare October 1, 2025 18:22
Adds HPPASS related files to the cmake list and adding KConfig
definitions for HPPASS and HPPASS SAR ADC.

Signed-off-by: John Batch <[email protected]>
@jsbatch jsbatch force-pushed the main-hppass_adc_dev branch from cb02c8c to fee044b Compare October 1, 2025 21:37
@nashif nashif assigned talih0 and unassigned nashif Oct 4, 2025
#define HPPASS_SAR_DIR_CHANNEL_CNT 12
#define IFX_HPPASS_SAR_SAMPLER_GAIN_MSK 0x03
#define IFX_HPPASS_SAR_SAMPLER_GAIN_WIDTH 2
#define IFX_HPPASS_ADC_VREF_MV DT_INST_PROP(0, vref_mv)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is part of the config struct already. Should use that instead of MACRO

Copy link
Contributor Author

@jsbatch jsbatch Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed it from the config struct. The config struct never uses the vref_mv, and the macro is used by the adc_api definition directly. This usage is consistent with other drivers, ex: adc_max32.c, adc_ambiq.c, adc_mcux_adc12.c, etc. I've also updated it to be generated based on the ADC number instead of hardcoding to 0.

* Device supports up to 28 channels. Note that channels 12-15, 16-19, 20-23, and 24-27 are
* multiplexed in hardware and share samplers.
*/
#define HPPASS_SAR_ADC_MAX_CHANNELS 28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be coming from the DTSI node?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to get this from PDL header file.

/* Enable directly sampled channels. */
group_cfg.dirSampMsk = channels & ADC_SAMPLER_DIRECT_MASK;

/* Enable Muxed channels. We need to determine if the sampler is enabled and what the mux
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* Enable Muxed channels. We need to determine if the sampler is enabled and what the mux
/* Enable Muxed channels. We need to determine if the sampler is enabled and what the mux

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double spacing after a sentence is a typing style (admittedly old), so this is intentional. It doesn't appear to be explicitly mentioned in Zephyr coding guidelines.

group_cfg.muxSampMsk = 0;
if ((channels & ADC_SAMPLER_12_CHANNEL_GROUP) != 0) {
group_cfg.muxChanIdx[0] = 0;
for (int i = 0; i < 4; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a descriptive MACRO for 4 in the for loop (here and other instances)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added macro and reworked this section to use a loop instead of four separate calls.

Comment on lines 154 to 155
if ((channels & ADC_SAMPLER_13_CHANNEL_GROUP) != 0) {
group_cfg.muxChanIdx[1] = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ((channels & ADC_SAMPLER_13_CHANNEL_GROUP) != 0) {
group_cfg.muxChanIdx[1] = 0;
if ((channels & ADC_SAMPLER_13_CHANNEL_GROUP) != 0) {
group_cfg.muxChanIdx[1] = 0;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworked this section to use a loop instead of separate blocks.

*
* @param dev Pointer to the device structure for the driver instance.
*
* Interrupt Handler for the combined group results interrupt. This handler is common all group
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Interrupt Handler for the combined group results interrupt. This handler is common all group
* Interrupt Handler for the combined group results interrupt. This handler is common all group

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentional, see above.

* @param dev Pointer to the device structure for the driver instance.
*
* Interrupt Handler for the combined group results interrupt. This handler is common all group
* completion interrupts. Individual group completion interrupts are available if needed for more
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* completion interrupts. Individual group completion interrupts are available if needed for more
* completion interrupts. Individual group completion interrupts are available if needed for more

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

const struct adc_sequence *sequence = &data->ctx.sequence;
uint32_t result_status = Cy_HPPASS_SAR_Result_GetStatus();

/* Make sure all requested channels have completed*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* Make sure all requested channels have completed*/
/* Make sure all requested channels have completed */

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

*/
struct ifx_hppass_sar_adc_channel_config {
/** Channel number */
uint8_t channel_id;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uint8_t channel_id;
uint8_t id;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed definition and uses.

set(zephyr_ifx_cycfg_dir ${ZEPHYR_HAL_INFINEON_MODULE_DIR}/zephyr-ifx-cycfg/soc_psc3)

zephyr_include_directories(${zephyr_ifx_cycfg_dir})
zephyr_library_sources(${zephyr_ifx_cycfg_dir}/ifx_hppass_analog.c)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
zephyr_library_sources(${zephyr_ifx_cycfg_dir}/ifx_hppass_analog.c)
zephyr_library_sources_ifdef(CONFIG_USE_INFINEON_HPPASS_SAR_ADC ${zephyr_ifx_cycfg_dir}/ifx_hppass_analog.c)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to use the ifdef version.

Adds HPPASS SAR ADC driver and HPPASS Analog driver files to support
ADC conversion for the PSOC C3 family of MCUs.

Signed-off-by: John Batch <[email protected]>
Adding files to allow running the following samples and tests for the
Infineon HPPASS SAR ADC driver on the PSOC C3 family of MCUs:
  * samples/drivers/adc_dt
  * samples/drivers/adc_sequence
  * tests/drivers/adc/adc_api
  * tests/drivers/adc/adc_error_case
Also modifies the adc_error_cases test to use supported resolution on
the PSOC C3.

Signed-off-by: John Batch <[email protected]>
@jsbatch jsbatch force-pushed the main-hppass_adc_dev branch from c5cab79 to c382886 Compare October 8, 2025 22:27
Copy link

sonarqubecloud bot commented Oct 8, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ADC Analog-to-Digital Converter (ADC) area: Boards/SoCs area: Devicetree Bindings area: Samples Samples area: Tests Issues related to a particular existing or missing test DNM (manifest) This PR should not be merged (controlled by action-manifest) manifest manifest-hal_infineon platform: Infineon Infineon Technologies AG

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants