diff options
author | Sam Hurst <shurst@google.com> | 2016-08-23 11:43:23 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-09-02 15:12:13 -0700 |
commit | 26c5a22125916a53b62ac8226eb10af4c7a77c58 (patch) | |
tree | 4d81c2a2b7a73bb54d4bb2f671610e6346aaafe0 /include/pwm.h | |
parent | 8e4c2c630403ae816b2b0cc7dd9b5182880ffbd1 (diff) | |
download | chrome-ec-26c5a22125916a53b62ac8226eb10af4c7a77c58.tar.gz |
pwm: Increse PWM duty resolution to 16bits
The current PWM interface allows for a pwm duty setting ranging from
0 to 100, resulting in a very coarse adjustment. To alleviate the
problem, the interface now allows for a pwm duty setting in the range
of 0 to 65535.
BUG=chromium:615109
BRANCH=None
TEST=Manual on chell.
`ectool pwmsetduty 1 65535` - Verify LCD backlight goes to 100%
`ectool pwmgetduty 1` - Prints 65535
`ectool pwmsetduty 1 0` - Verify LCD backlight goes to 0%
`ectool pwmgetduty 1` - Prints 0
terminal pwmduty tests:
>pwmduty
PWM channels:
0: 100%
1: 62%
2: 100%
3: 80%
> pwmduty 1 50
Setting channel 1 to 50%
1: 50%
> pwmduty 1 0
Setting channel 1 to 0%
1: disabled
> pwmduty 1 100
Setting channel 1 to 100%
1: 100%
> pwmduty 1 raw 0
Setting channel 1 to raw 0%
1: disabled
> pwmduty 1 raw 65535
Setting channel 1 to raw 65535%
1: 65535
> pwmduty
PWM channels:
0: 100%
1: 100%
2: 100%
3: 80%
> pwmduty 1 raw 30000
Setting channel 1 to raw 30000%
1: 30000
> pwmduty
PWM channels:
0: 100%
1: 46%
2: 100%
3: 80%
Change-Id: I299b77585f3988e72d9ac918bdde7dc5fa3df6de
Reviewed-on: https://chromium-review.googlesource.com/374481
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Sam Hurst <shurst@google.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'include/pwm.h')
-rw-r--r-- | include/pwm.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/pwm.h b/include/pwm.h index 08cea7e43a..9c349d1fb6 100644 --- a/include/pwm.h +++ b/include/pwm.h @@ -20,6 +20,16 @@ void pwm_enable(enum pwm_channel ch, int enabled); int pwm_get_enabled(enum pwm_channel ch); /** + * Set PWM channel duty cycle (0-65535). + */ +void pwm_set_raw_duty(enum pwm_channel ch, uint16_t duty); + +/** + * Get PWM channel duty cycle. + */ +uint16_t pwm_get_raw_duty(enum pwm_channel ch); + +/** * Set PWM channel duty cycle (0-100). */ void pwm_set_duty(enum pwm_channel ch, int percent); |