Skip to content
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

ports/psoc6: Adding deinit to pin and adc machine classes. #95

Merged
merged 8 commits into from
Oct 17, 2023

Conversation

jaenrig-ifx
Copy link
Member

By creating this pull request you agree to the terms in CONTRIBUTING.md.
https://github.com/Infineon/.github/blob/master/CONTRIBUTING.md
--- DO NOT DELETE ANYTHING ABOVE THIS LINE ---

CONTRIBUTING.md also tells you what to expect in the PR process.

This PR will change the destination branch after #94 is merged. Please, review the other one first.

Description

  • Adding obj deinit and module deinit to machine.Pin.
  • Adding obj deinit and module deinit to machine.ADC and machine.ADCBlock. Additional cleanup refactoring to accommodate pin_phy and scope of each friend classes.

@jaenrig-ifx jaenrig-ifx changed the base branch from hw-pin-mgmt to multi-board-support October 12, 2023 07:56
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
Copy link
Member

@NikhitaR-IFX NikhitaR-IFX left a comment

Choose a reason for hiding this comment

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

All looks good to me!
Just a concern - if a physical pin deinit is done in respective module (for example let's say ADC), then again deiniting it from main has an additional affect? Currently does it check if module using the phy pin has already deinited and if not only then do from also main,c or is it not needed to consider that?

adcblock_deinit();
mod_pin_deinit();
mod_adc_block_deinit();
mod_pin_phy_deinit();
Copy link
Member

Choose a reason for hiding this comment

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

Does it matter the order in which you de-init?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not really. But pin_phy_deinit() is actually redundant, as the others should have taken care of that.

@@ -23,6 +23,39 @@ const adc_block_channel_pin_map_t adc_block_pin_map[] = {
/******************************************************************************/
// MicroPython bindings for machine.ADC

// Private helper function to get channel number for provided pin
int16_t _get_adc_channel_number_for_pin(uint32_t pin) {
for (int i = 0; i < (sizeof(adc_block_pin_map) / sizeof(adc_block_pin_map[0])); i++)
Copy link
Member

Choose a reason for hiding this comment

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

adc_block_pin_map has "PIN_P10_0". This needs to be changed no as the definition is no more available or?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we have to check that according to how we integrate that part :)

@jaenrig-ifx
Copy link
Member Author

All looks good to me! Just a concern - if a physical pin deinit is done in respective module (for example let's say ADC), then again deiniting it from main has an additional affect? Currently does it check if module using the phy pin has already deinited and if not only then do from also main,c or is it not needed to consider that?

The module deinit when soft reseting will take care of deiniting every instance that was not deinited explicitly.
If the application calls deinit() function then it won´t do anything, because all those objects are already deallocated. deinitialization from pin_phy point of view is only setting the pin to not allocated. But those are static instances, which are not really constructed/destructed dinamically.

Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
@jaenrig-ifx jaenrig-ifx merged commit 47d005a into multi-board-support Oct 17, 2023
18 of 20 checks passed
@jaenrig-ifx jaenrig-ifx deleted the machine_pin_adc_deinit branch October 17, 2023 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants