/* Set the period of the specified channel in microseconds.  */
void pwmout_period_us(pwmout_t *obj, int us)
/* Set the period of the specified channel in microseconds.  */
void pwmout_period_us(pwmout_t *obj, int us)
{
	u32 arr;
	float dc = pwmout_read(obj);
	u32 tmp = us * 40 / (prescaler + 1);
	if(tmp > 0x10000){
		prescaler = us * 40 / 0x10000;
		RTIM_PrescalerConfig(PWM_TIM[obj->pwm_idx >>BIT_PWM_TIM_IDX_SHIFT], prescaler, TIM_PSCReloadMode_Update);
	}
	obj->period = us;
	arr = us * 40 / (prescaler + 1) - 1;
	RTIM_ChangePeriod(PWM_TIM[obj->pwm_idx >>BIT_PWM_TIM_IDX_SHIFT], arr);
	pwmout_write(obj, dc);
}