-
Notifications
You must be signed in to change notification settings - Fork 8k
Drivers: ADC: Add ADC Driver for Infineon PSC3 Series #96877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
* 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]>
The following west manifest projects have changed revision in this Pull Request:
⛔ DNM label due to: 1 project with PR revision Note: This message is automatically posted and updated by the Manifest GitHub Action. |
ca90ca1
to
cb02c8c
Compare
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]>
cb02c8c
to
fee044b
Compare
drivers/adc/adc_ifx_hppass_sar.c
Outdated
#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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
drivers/adc/adc_ifx_hppass_sar.c
Outdated
* 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
drivers/adc/adc_ifx_hppass_sar.c
Outdated
/* 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* 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 |
There was a problem hiding this comment.
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.
drivers/adc/adc_ifx_hppass_sar.c
Outdated
group_cfg.muxSampMsk = 0; | ||
if ((channels & ADC_SAMPLER_12_CHANNEL_GROUP) != 0) { | ||
group_cfg.muxChanIdx[0] = 0; | ||
for (int i = 0; i < 4; i++) { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
drivers/adc/adc_ifx_hppass_sar.c
Outdated
if ((channels & ADC_SAMPLER_13_CHANNEL_GROUP) != 0) { | ||
group_cfg.muxChanIdx[1] = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* completion interrupts. Individual group completion interrupts are available if needed for more | |
* completion interrupts. Individual group completion interrupts are available if needed for more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
drivers/adc/adc_ifx_hppass_sar.c
Outdated
const struct adc_sequence *sequence = &data->ctx.sequence; | ||
uint32_t result_status = Cy_HPPASS_SAR_Result_GetStatus(); | ||
|
||
/* Make sure all requested channels have completed*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* Make sure all requested channels have completed*/ | |
/* Make sure all requested channels have completed */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
drivers/adc/adc_ifx_hppass_sar.c
Outdated
*/ | ||
struct ifx_hppass_sar_adc_channel_config { | ||
/** Channel number */ | ||
uint8_t channel_id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint8_t channel_id; | |
uint8_t id; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
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.
fee044b
to
c5cab79
Compare
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]>
c5cab79
to
c382886
Compare
|
This change implements an ADC driver for the PSOC C3 family of devices using the High Performance Programmable Analog Subsystem (HPPASS).