mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-28 01:51:33 +00:00
misc: led: pca9551_led: Fix problem with multiple blink frequencies
Only 2 frequencies are supported. The current driver implementation does not always use the 2 last configured blink frequencies. This patch fixes this problem. So that the last two entered frequencies are active. Signed-off-by: Stefan Roese <sr@denx.de> Cc: Fabio Estevam <fabio.estevam@freescale.com> Cc: Tom Rini <trini@konsulko.com>
This commit is contained in:
parent
6b33056836
commit
f5df36d0c8
1 changed files with 22 additions and 10 deletions
|
@ -32,7 +32,10 @@ struct pca9551_blink_rate {
|
||||||
u8 pwm; /* Pulse width modulation, see PCA9551_7.pdf p. 6 */
|
u8 pwm; /* Pulse width modulation, see PCA9551_7.pdf p. 6 */
|
||||||
};
|
};
|
||||||
|
|
||||||
static int freq0, freq1;
|
static int freq_last = -1;
|
||||||
|
static int mask_last = -1;
|
||||||
|
static int idx_last = -1;
|
||||||
|
static int mode_last;
|
||||||
|
|
||||||
static int pca9551_led_get_state(int led, int *state)
|
static int pca9551_led_get_state(int led, int *state)
|
||||||
{
|
{
|
||||||
|
@ -135,21 +138,30 @@ void __led_blink(led_id_t mask, int freq)
|
||||||
{
|
{
|
||||||
struct pca9551_blink_rate rate;
|
struct pca9551_blink_rate rate;
|
||||||
int mode;
|
int mode;
|
||||||
int blink;
|
int idx;
|
||||||
|
|
||||||
if ((freq0 == 0) || (freq == freq0)) {
|
if ((freq == freq_last) || (mask == mask_last)) {
|
||||||
blink = 0;
|
idx = idx_last;
|
||||||
mode = PCA9551_LED_STATE_BLINK0;
|
mode = mode_last;
|
||||||
freq0 = freq;
|
|
||||||
} else {
|
} else {
|
||||||
blink = 1;
|
/* Toggle blink index */
|
||||||
mode = PCA9551_LED_STATE_BLINK1;
|
if (idx_last == 0) {
|
||||||
freq1 = freq;
|
idx = 1;
|
||||||
|
mode = PCA9551_LED_STATE_BLINK1;
|
||||||
|
} else {
|
||||||
|
idx = 0;
|
||||||
|
mode = PCA9551_LED_STATE_BLINK0;
|
||||||
|
}
|
||||||
|
|
||||||
|
idx_last = idx;
|
||||||
|
mode_last = mode;
|
||||||
}
|
}
|
||||||
|
freq_last = freq;
|
||||||
|
mask_last = mask;
|
||||||
|
|
||||||
rate.psc = ((freq * 38) / 1000) - 1;
|
rate.psc = ((freq * 38) / 1000) - 1;
|
||||||
rate.pwm = 128; /* 50% duty cycle */
|
rate.pwm = 128; /* 50% duty cycle */
|
||||||
|
|
||||||
pca9551_led_set_blink_rate(blink, rate);
|
pca9551_led_set_blink_rate(idx, rate);
|
||||||
pca9551_led_set_state(mask, mode);
|
pca9551_led_set_state(mask, mode);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue