diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2017-01-11 16:58:30 +0100 |
---|---|---|
committer | Gerrit Rockbox <gerrit@rockbox.org> | 2017-01-16 20:08:13 +0100 |
commit | b23b7088cbba364bd37a7ec5e6572f1ecf234e7a (patch) | |
tree | 38fd3014f7f667e0893245d3069e4ee41a9f18a4 /firmware/target/arm/imx233/led-imx233.h | |
parent | 759a78e5dff134f2632875f61aae60815eea6f5b (diff) |
imx233: add small framework for LED
It handles GPIO and PWM based LEDs, possibly with several channels (red-green
LED for example). The debug allows one to play with the setting.
Currently the code supports the ZEN, ZEN X-Fi, and ZEN Mozaic.
Change-Id: I8c3b66e6ba21778acdb123daabb724280a7d1a4f
Diffstat (limited to 'firmware/target/arm/imx233/led-imx233.h')
-rw-r--r-- | firmware/target/arm/imx233/led-imx233.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/firmware/target/arm/imx233/led-imx233.h b/firmware/target/arm/imx233/led-imx233.h new file mode 100644 index 0000000000..658135c94a --- /dev/null +++ b/firmware/target/arm/imx233/led-imx233.h @@ -0,0 +1,69 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (c) 2017 by Amaury Pouly + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef __LED_IMX233_H__ +#define __LED_IMX233_H__ + +#include "system.h" + +/** LED API + * + * The following assumes each single LED is controllable by one + * or more channels. Each channel is either controlled by a GPIO (on/off) or a + * PWM. Each channel also has a color, so it is possible to describe + * a red-green LED for example. */ + +/* LED channel color */ +enum imx233_led_color_t +{ + LED_RED, + LED_GREEN, + LED_BLUE, +}; + +/* LED channel */ +struct imx233_led_chan_t +{ + bool has_pwm; /* GPIO or PWM */ + enum imx233_led_color_t color; /* color */ + int gpio_bank, gpio_pin; /* GPIO bank and pin (also valid for PWM) */ + int pwm_chan; /* for PWM: harware channel*/ +}; + +/* LED */ +struct imx233_led_t +{ + int nr_chan; /* number of channels */ + struct imx233_led_chan_t *chan; /* array of channels */ +}; + +/* init: all LEDs are turned off on init */ +void imx233_led_init(void); +/* get number of LEDs */ +int imx233_led_get_count(void); +/* return an array of LEDs */ +struct imx233_led_t *imx233_led_get_info(void); +/* set LED channel on/off, it also works for PWM channel by setting the PWM to + * constantly off or constantly on */ +void imx233_led_set(int led, int chan, bool on); +/* set LED PWM: control the frequency and the duty cycle percentage (0-100) */ +void imx233_led_set_pwm(int led, int chan, int freq, int duty); + +#endif /* __LED_IMX233_H__ */ |