mirror of https://github.com/ARMmbed/mbed-os.git
nRF52: properly clean pwm structures on deinit()
parent
2e964006b7
commit
56c508b974
|
@ -369,6 +369,27 @@ int pin_instance_pwm(PinName pwm)
|
|||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Brief Find hardware instance for the provided PWM pin and free it
|
||||
*
|
||||
* Parameter pwm pwm pin.
|
||||
*
|
||||
* Return Nothing
|
||||
*/
|
||||
void pin_instance_pwm_free(PinName pwm)
|
||||
{
|
||||
/* Search dynamic map for entry. */
|
||||
for (size_t index = 0; index < NORDIC_PWM_COUNT; index++) {
|
||||
|
||||
/* Pins match previous dynamic allocation, return instance. */
|
||||
if (nordic_internal_pwm[index] == pwm) {
|
||||
|
||||
nordic_internal_pwm[index] = NC;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* _ _ _____ _______
|
||||
|
|
|
@ -120,6 +120,15 @@ int pin_instance_spi(PinName mosi, PinName miso, PinName clk);
|
|||
*/
|
||||
int pin_instance_pwm(PinName pwm);
|
||||
|
||||
/**
|
||||
* Brief Find hardware instance for the provided PWM pin and free it
|
||||
*
|
||||
* Parameter pwm pwm pin.
|
||||
*
|
||||
* Return Nothing
|
||||
*/
|
||||
void pin_instance_pwm_free(PinName pwm);
|
||||
|
||||
/**
|
||||
* @brief Find hardware instance for the provided UART pins.
|
||||
*
|
||||
|
|
|
@ -173,6 +173,9 @@ void pwmout_free(pwmout_t *obj)
|
|||
|
||||
MBED_ASSERT(obj);
|
||||
|
||||
/* Also deinit the undelying PinMap_PWM entry */
|
||||
pin_instance_pwm_free(obj->pin);
|
||||
|
||||
/* Uninitialize PWM instance. */
|
||||
nrfx_pwm_uninit(&nordic_nrf5_pwm_instance[obj->instance]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue