FreeCalypso > hg > freecalypso-sw
comparison target-utils/pirexplore/lcd.c @ 78:2c266d4339ff
pirexplore: lcdfill implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Thu, 01 Aug 2013 02:27:09 +0000 |
parents | fcbe1332b197 |
children | f65df1d640aa |
comparison
equal
deleted
inserted
replaced
77:fcbe1332b197 | 78:2c266d4339ff |
---|---|
1 /* | |
2 * Almost all of this Pirelli LCD black magic has been lifted from OsmocomBB. | |
3 */ | |
4 | |
1 #include <sys/types.h> | 5 #include <sys/types.h> |
2 #include "types.h" | 6 #include "types.h" |
3 | 7 |
4 #define GPIO_OUT_REG (*(volatile u16 *)0xFFFE4802) | 8 #define GPIO_OUT_REG (*(volatile u16 *)0xFFFE4802) |
5 #define nCS4_ADDR0 (*(volatile u16 *)0x02800000) | 9 #define nCS4_ADDR0 (*(volatile u16 *)0x02800000) |
119 cmd_lcdinit() | 123 cmd_lcdinit() |
120 { | 124 { |
121 GPIO_OUT_REG |= 0x0080; | 125 GPIO_OUT_REG |= 0x0080; |
122 fb_s6b33b1x_send_cmdlist(s6b33b1x_initdata); | 126 fb_s6b33b1x_send_cmdlist(s6b33b1x_initdata); |
123 } | 127 } |
128 | |
129 set_lcd_addr_region(xstart, xend, ystart, yend) | |
130 { | |
131 GPIO_OUT_REG |= 0x0080; | |
132 nCS4_ADDR0 = 0x42; | |
133 nCS4_ADDR0 = xstart; | |
134 nCS4_ADDR0 = xend; | |
135 nCS4_ADDR0 = 0x43; | |
136 nCS4_ADDR0 = ystart; | |
137 nCS4_ADDR0 = yend; | |
138 } | |
139 | |
140 void | |
141 cmd_lcdfill(argbulk) | |
142 char *argbulk; | |
143 { | |
144 int argc; | |
145 char *argv[6]; | |
146 u_long pixval; | |
147 int xstart, xend, ystart, yend; | |
148 int npix; | |
149 | |
150 if (parse_args(argbulk, 1, 5, argv, &argc) < 0) | |
151 return; | |
152 if (parse_hexarg(argv[0], 4, &pixval) < 0) { | |
153 printf("ERROR: arg1 must be a valid 16-bit hex value\n"); | |
154 return; | |
155 } | |
156 switch (argc) { | |
157 case 1: | |
158 xstart = ystart = 0; | |
159 xend = yend = 131; | |
160 break; | |
161 case 5: | |
162 xstart = atoi(argv[1]); | |
163 if (xstart < 0 || xstart > 131) { | |
164 range_err: printf("ERROR: coordinate arg out of range\n"); | |
165 return; | |
166 } | |
167 xend = atoi(argv[2]); | |
168 if (xend < 0 || xend > 131) | |
169 goto range_err; | |
170 ystart = atoi(argv[3]); | |
171 if (ystart < 0 || ystart > 131) | |
172 goto range_err; | |
173 yend = atoi(argv[4]); | |
174 if (yend < 0 || yend > 131) | |
175 goto range_err; | |
176 if (xend < xstart || yend < ystart) { | |
177 printf("ERROR: negative range\n"); | |
178 return; | |
179 } | |
180 break; | |
181 default: | |
182 printf("ERROR: wrong number of arguments\n"); | |
183 return; | |
184 } | |
185 set_lcd_addr_region(xstart, xend, ystart, yend); | |
186 npix = (xend + 1 - xstart) * (yend + 1 - ystart); | |
187 while (npix--) | |
188 nCS4_ADDR2 = pixval; | |
189 } |