Merge pull request #10074 from morser499/cy-mbed-os-5.12.0-pwm-free

Fixed issue with PWM not being freed when the object is destroyed
pull/9904/head
Cruz Monrreal 2019-03-27 00:21:54 -05:00 committed by GitHub
commit 0395150bfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -68,6 +68,7 @@ public:
~PwmOut()
{
core_util_critical_section_enter();
pwmout_free(&_pwm);
unlock_deep_sleep();
core_util_critical_section_exit();
}

View File

@ -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)