@@ -18,10 +18,15 @@ const static struct config *flash_config = (struct config *)0x0800fc00;
18
18
19
19
struct config config ;
20
20
21
+ extern void setup_spi (void );
22
+
21
23
static void config_printk (const struct config * conf )
22
24
{
23
25
printk ("\nCurrent config:\n" );
24
26
printk (" Sync: Active %s\n" , conf -> polarity ? "HIGH" : "LOW" );
27
+ printk (" Pixel Timing: %s\n" , config .display_timing ? "VGA" : "15kHz" );
28
+ printk (" Video Output: SPI%s\n" , config .display_spi ? "1 (PA7)" : "2 (PB15)" );
29
+ printk (" Output Enable: %d\n" , config .dispctl_mode );
25
30
printk (" H.Off: %u\n" , conf -> h_off );
26
31
printk (" V.Off: %u\n" , conf -> v_off );
27
32
printk (" Rows: %u\n" , conf -> rows );
@@ -82,6 +87,8 @@ static enum {
82
87
C_banner ,
83
88
/* Output */
84
89
C_polarity ,
90
+ C_disptiming ,
91
+ C_spibus ,
85
92
C_h_off ,
86
93
C_v_off ,
87
94
/* LCD */
@@ -142,7 +149,7 @@ void config_process(uint8_t b)
142
149
uint8_t _b ;
143
150
static uint8_t pb ;
144
151
bool_t changed = FALSE;
145
- static enum { C_SAVE = 0 , C_USE , C_DISCARD , C_RESET } new_config ;
152
+ static enum { C_SAVE = 0 , C_SAVEREBOOT , C_USE , C_DISCARD , C_RESET , C_NC_MAX } new_config ;
146
153
static struct config old_config ;
147
154
148
155
_b = b ;
@@ -168,6 +175,10 @@ void config_process(uint8_t b)
168
175
case C_SAVE :
169
176
config_write_flash (& config );
170
177
break ;
178
+ case C_SAVEREBOOT :
179
+ config_write_flash (& config );
180
+ while (1 ) {} /* hang and let WDT reboot */
181
+ break ;
171
182
case C_USE :
172
183
break ;
173
184
case C_DISCARD :
@@ -176,6 +187,9 @@ void config_process(uint8_t b)
176
187
case C_RESET :
177
188
config = dfl_config ;
178
189
config_write_flash (& config );
190
+ while (1 ) {} /* hang and let WDT reboot */
191
+ break ;
192
+ case C_NC_MAX :
179
193
break ;
180
194
}
181
195
printk ("\n" );
@@ -208,6 +222,25 @@ void config_process(uint8_t b)
208
222
if (b )
209
223
cnf_prt (1 , "Active %s" , config .polarity ? "HIGH" : "LOW" );
210
224
break ;
225
+ case C_disptiming :
226
+ if (changed )
227
+ cnf_prt (0 , "Pixel Timing:" );
228
+ if (b & (B_LEFT |B_RIGHT )) {
229
+ config .display_timing ^= 1 ;
230
+ setup_spi ();
231
+ }
232
+ if (b )
233
+ cnf_prt (1 , "%s" , config .display_timing ? "VGA" : "15kHz" );
234
+ break ;
235
+ case C_spibus :
236
+ if (changed )
237
+ cnf_prt (0 , "SPI" );
238
+ if (b & (B_LEFT |B_RIGHT )) {
239
+ config .display_spi ^= 1 ;
240
+ }
241
+ if (b )
242
+ cnf_prt (1 , "%s" , config .display_spi ? "1 (PA7)" : "2 (PB15)" );
243
+ break ;
211
244
case C_h_off :
212
245
if (changed )
213
246
cnf_prt (0 , "H.Off (1-199):" );
@@ -262,16 +295,24 @@ void config_process(uint8_t b)
262
295
cnf_prt (1 , "%u" , config .max_cols );
263
296
break ;
264
297
case C_save : {
265
- const static char * str [] = { "Save" , "Use" ,
298
+ const static char * str [] = { "Save" , "Save+Reset" , " Use" ,
266
299
"Discard" , "Factory Reset" };
267
300
if (changed ) {
268
301
cnf_prt (0 , "Save New Config?" );
269
- new_config = C_SAVE ;
302
+ if (old_config .display_spi == config .display_spi )
303
+ new_config = C_SAVE ;
304
+ else
305
+ new_config = C_SAVEREBOOT ;
306
+ }
307
+ if (b & B_LEFT ) {
308
+ if (new_config > 0 )
309
+ -- new_config ;
310
+ else
311
+ new_config = C_NC_MAX - 1 ;
270
312
}
271
- if (b & B_LEFT )
272
- new_config = (new_config - 1 ) & 3 ;
273
313
if (b & B_RIGHT )
274
- new_config = (new_config + 1 ) & 3 ;
314
+ if (++ new_config >= C_NC_MAX )
315
+ new_config = 0 ;
275
316
if (b )
276
317
cnf_prt (1 , "%s" , str [new_config ]);
277
318
break ;
0 commit comments