summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx233/led-imx233.h
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2017-01-11 16:58:30 +0100
committerGerrit Rockbox <gerrit@rockbox.org>2017-01-16 20:08:13 +0100
commitb23b7088cbba364bd37a7ec5e6572f1ecf234e7a (patch)
tree38fd3014f7f667e0893245d3069e4ee41a9f18a4 /firmware/target/arm/imx233/led-imx233.h
parent759a78e5dff134f2632875f61aae60815eea6f5b (diff)
downloadrockbox-b23b7088cbba364bd37a7ec5e6572f1ecf234e7a.tar.gz
rockbox-b23b7088cbba364bd37a7ec5e6572f1ecf234e7a.zip
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.h69
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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (c) 2017 by Amaury Pouly
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef __LED_IMX233_H__
22#define __LED_IMX233_H__
23
24#include "system.h"
25
26/** LED API
27 *
28 * The following assumes each single LED is controllable by one
29 * or more channels. Each channel is either controlled by a GPIO (on/off) or a
30 * PWM. Each channel also has a color, so it is possible to describe
31 * a red-green LED for example. */
32
33/* LED channel color */
34enum imx233_led_color_t
35{
36 LED_RED,
37 LED_GREEN,
38 LED_BLUE,
39};
40
41/* LED channel */
42struct imx233_led_chan_t
43{
44 bool has_pwm; /* GPIO or PWM */
45 enum imx233_led_color_t color; /* color */
46 int gpio_bank, gpio_pin; /* GPIO bank and pin (also valid for PWM) */
47 int pwm_chan; /* for PWM: harware channel*/
48};
49
50/* LED */
51struct imx233_led_t
52{
53 int nr_chan; /* number of channels */
54 struct imx233_led_chan_t *chan; /* array of channels */
55};
56
57/* init: all LEDs are turned off on init */
58void imx233_led_init(void);
59/* get number of LEDs */
60int imx233_led_get_count(void);
61/* return an array of LEDs */
62struct imx233_led_t *imx233_led_get_info(void);
63/* set LED channel on/off, it also works for PWM channel by setting the PWM to
64 * constantly off or constantly on */
65void imx233_led_set(int led, int chan, bool on);
66/* set LED PWM: control the frequency and the duty cycle percentage (0-100) */
67void imx233_led_set_pwm(int led, int chan, int freq, int duty);
68
69#endif /* __LED_IMX233_H__ */