diff options
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 @@ | |||
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 */ | ||
34 | enum imx233_led_color_t | ||
35 | { | ||
36 | LED_RED, | ||
37 | LED_GREEN, | ||
38 | LED_BLUE, | ||
39 | }; | ||
40 | |||
41 | /* LED channel */ | ||
42 | struct 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 */ | ||
51 | struct 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 */ | ||
58 | void imx233_led_init(void); | ||
59 | /* get number of LEDs */ | ||
60 | int imx233_led_get_count(void); | ||
61 | /* return an array of LEDs */ | ||
62 | struct 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 */ | ||
65 | void imx233_led_set(int led, int chan, bool on); | ||
66 | /* set LED PWM: control the frequency and the duty cycle percentage (0-100) */ | ||
67 | void imx233_led_set_pwm(int led, int chan, int freq, int duty); | ||
68 | |||
69 | #endif /* __LED_IMX233_H__ */ | ||