Skip to content

Fixed issue with PWM not being freed when the object is destroyed #10074

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

Merged
merged 1 commit into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions drivers/PwmOut.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class PwmOut {
~PwmOut()
{
core_util_critical_section_enter();
pwmout_free(&_pwm);
Copy link
Contributor

Choose a reason for hiding this comment

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

@ARMmbed/mbed-os-hal what was the reason not having this earlier ? I recall some discussions in some other drivers around definition of _free and implications for the rest of targets with change like this one.

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought it was because not all the targets had this function. If this is the case then CI should catch any problems.

Copy link
Contributor

Choose a reason for hiding this comment

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

That is it !

We do not have 100 percent coverage in CI, I am thinking to be on safer side to have this on 5.13 rather - to keep this on master for some time.

unlock_deep_sleep();
core_util_critical_section_exit();
}
Expand Down
10 changes: 7 additions & 3 deletions targets/TARGET_Cypress/TARGET_PSOC6/pwmout_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,13 @@ void pwmout_init(pwmout_t *obj, PinName pin)

void pwmout_free(pwmout_t *obj)
{
/* Does nothing because it is not called in the MBED PWMOUT driver
* destructor. The pwmout_init handles multiple calls of constructor.
*/
#if DEVICE_SLEEP && DEVICE_LPTICKER
if (!Cy_SysPm_UnregisterCallback(&obj->pm_callback_handler)) {
error("PM callback unregistration failed!");
}
#endif
Cy_TCPWM_PWM_Disable(obj->base, obj->counter_id);
Cy_TCPWM_PWM_DeInit(obj->base, obj->counter_id, &pwm_config);
}

void pwmout_write(pwmout_t *obj, float percent)
Expand Down