FreeCalypso > hg > freecalypso-sw
comparison target-utils/pirexplore/lcd.c @ 76:07b686248ab7
pirexplore: finally got the backlight to turn on
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Thu, 01 Aug 2013 00:26:29 +0000 |
parents | 8138a6380ae3 |
children | fcbe1332b197 |
comparison
equal
deleted
inserted
replaced
75:c9768f5fb329 | 76:07b686248ab7 |
---|---|
1 #include <sys/types.h> | 1 #include <sys/types.h> |
2 #include "types.h" | 2 #include "types.h" |
3 | |
4 #define GPIO_OUT_REG (*(volatile u16 *)0xFFFE4802) | |
5 #define nCS4_ADDR0 (*(volatile u16 *)0x02800000) | |
6 #define nCS4_ADDR2 (*(volatile u16 *)0x02800002) | |
7 | |
8 fb_spca_write(addr, data) | |
9 { | |
10 GPIO_OUT_REG &= 0xFF7F; | |
11 nCS4_ADDR0 = addr; | |
12 nCS4_ADDR2 = data; | |
13 } | |
3 | 14 |
4 void | 15 void |
5 cmd_spca(argbulk) | 16 cmd_spca(argbulk) |
6 char *argbulk; | 17 char *argbulk; |
7 { | 18 { |
16 } | 27 } |
17 if (parse_hexarg(argv[1], 4, &data) < 0) { | 28 if (parse_hexarg(argv[1], 4, &data) < 0) { |
18 printf("ERROR: arg2 must be a valid 16-bit hex value\n"); | 29 printf("ERROR: arg2 must be a valid 16-bit hex value\n"); |
19 return; | 30 return; |
20 } | 31 } |
21 *(volatile u16 *)0x02800000 = addr; | 32 fb_spca_write(addr, data); |
22 *(volatile u16 *)0x02800002 = data; | |
23 } | 33 } |
34 | |
35 void | |
36 cmd_spcainit() | |
37 { | |
38 /* | |
39 * Apparently we have to give it a reset pulse, then immediately | |
40 * do the black magic register write sequence. | |
41 */ | |
42 GPIO_OUT_REG = 0x0000; | |
43 GPIO_OUT_REG = 0x0012; | |
44 /* non-understandable voodoo copied from OsmocomBB */ | |
45 fb_spca_write(0x7e, 0x00); /* internal register access */ | |
46 osmo_delay_ms(10); | |
47 fb_spca_write(0x7a, 0x00); /* keep CPU in reset state */ | |
48 osmo_delay_ms(10); | |
49 fb_spca_write(0x7f, 0x00); /* select main page */ | |
50 osmo_delay_ms(5); | |
51 fb_spca_write(0x72, 0x07); /* don't reshape timing, 16 bit mode */ | |
52 fb_spca_write(0x14, 0x03); | |
53 fb_spca_write(0x7f, 0x00); /* select main page */ | |
54 osmo_delay_ms(5); | |
55 fb_spca_write(0x06, 0xff); | |
56 fb_spca_write(0x7f, 0x09); | |
57 fb_spca_write(0x19, 0x08); /* backlight: 0x08 is on, 0x0c is off */ | |
58 fb_spca_write(0x23, 0x18); | |
59 } |