Skip to content

Commit 5c83d05

Browse files
EddieParisdpgeorge
authored andcommitted
esp8266/esppwm: Clip negative duty numbers to 0.
Prior to this patch a negative duty would lead to full PWM.
1 parent ab7819c commit 5c83d05

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

ports/esp8266/esppwm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,12 @@ pwm_start(void)
210210
/******************************************************************************
211211
* FunctionName : pwm_set_duty
212212
* Description : set each channel's duty params
213-
* Parameters : uint8 duty : 0 ~ PWM_DEPTH
213+
* Parameters : int16_t duty : 0 ~ PWM_DEPTH
214214
* uint8 channel : channel index
215215
* Returns : NONE
216216
*******************************************************************************/
217217
void ICACHE_FLASH_ATTR
218-
pwm_set_duty(uint16 duty, uint8 channel)
218+
pwm_set_duty(int16_t duty, uint8 channel)
219219
{
220220
uint8 i;
221221
for(i=0;i<pwm_channel_num;i++){

ports/esp8266/esppwm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
void pwm_init(void);
88
void pwm_start(void);
99

10-
void pwm_set_duty(uint16_t duty, uint8_t channel);
10+
void pwm_set_duty(int16_t duty, uint8_t channel);
1111
uint16_t pwm_get_duty(uint8_t channel);
1212
void pwm_set_freq(uint16_t freq, uint8_t channel);
1313
uint16_t pwm_get_freq(uint8_t channel);

0 commit comments

Comments
 (0)