summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tcc780x/cowond2/backlight-cowond2.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/tcc780x/cowond2/backlight-cowond2.c')
-rw-r--r--firmware/target/arm/tcc780x/cowond2/backlight-cowond2.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/firmware/target/arm/tcc780x/cowond2/backlight-cowond2.c b/firmware/target/arm/tcc780x/cowond2/backlight-cowond2.c
new file mode 100644
index 0000000000..07286bdd09
--- /dev/null
+++ b/firmware/target/arm/tcc780x/cowond2/backlight-cowond2.c
@@ -0,0 +1,56 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Rob Purchase
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "backlight-target.h"
20#include "system.h"
21#include "backlight.h"
22#include "pcf50606.h"
23#include "tcc780x.h"
24
25static unsigned short backlight_brightness = DEFAULT_BRIGHTNESS_SETTING;
26
27int _backlight_init(void)
28{
29 _backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING);
30 return true;
31}
32
33void _backlight_set_brightness(int brightness)
34{
35 backlight_brightness = brightness;
36
37 int level = disable_irq_save();
38 pcf50606_write(PCF5060X_PWMC1, 0xe1 | (14-backlight_brightness)<<1);
39 pcf50606_write(PCF5060X_GPOC1, 0x3);
40 restore_irq(level);
41
42 if (brightness > 0)
43 _backlight_on();
44 else
45 _backlight_off();
46}
47
48void _backlight_on(void)
49{
50 GPIOA_SET = (1<<6);
51}
52
53void _backlight_off(void)
54{
55 GPIOA_CLEAR = (1<<6);
56}