Skip to content

Commit 6a50eca

Browse files
committed
pwmout - STM - add read methods for period and pulsewidth
1 parent 2d5e517 commit 6a50eca

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

targets/TARGET_STM/pwmout_api.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,11 @@ void pwmout_period_us(pwmout_t *obj, int us)
386386
__HAL_TIM_ENABLE(&TimHandle);
387387
}
388388

389+
int pwmout_read_period_us(pwmout_t *obj)
390+
{
391+
return obj->period;
392+
}
393+
389394
void pwmout_pulsewidth(pwmout_t *obj, float seconds)
390395
{
391396
pwmout_pulsewidth_us(obj, seconds * 1000000.0f);
@@ -402,6 +407,12 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us)
402407
pwmout_write(obj, value);
403408
}
404409

410+
int pwmout_read_pulsewidth_us(pwmout_t *obj)
411+
{
412+
float tmp = pwmout_read(obj);
413+
return (int)(tmp * (float)obj->period);
414+
}
415+
405416
const PinMap *pwmout_pinmap()
406417
{
407418
return PinMap_PWM;

0 commit comments

Comments
 (0)