Skip to content

Commit 8ae4db2

Browse files
committed
Support VGA timing and support for faster SPI1 bus
- config menu for spi bus and pixel clock Amiga keys - WASD to move up/down/left/right OSD offsets - keypad ( ) for VGA/15kHz timing - keypad + - for sync polarity Added SAVE+RESET to config menu - default to this if SPI has changed Factory default now does a reset
1 parent 512d557 commit 8ae4db2

File tree

6 files changed

+305
-49
lines changed

6 files changed

+305
-49
lines changed

attic/pins.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
| 4 | | | Y | Amiga KB_CLK |
88
| 5 | | | | |
99
| 6 | | | Y | I2C SCL |
10-
| 7 | | | Y | I2C SDA |
10+
| 7 | | Disp.Out.SPI1 | Y | I2C SDA |
1111
| 8 | Y | CSYNC/HSYNC | Y | User Out (U0) |
1212
| 9 | Y | Serial Tx | Y | User Out (U1) |
1313
|10 | Y | Serial Rx | Y | User Out (U2) |

inc/config.h

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ extern struct __packed config {
1919

2020
uint16_t rows;
2121

22+
#define DISP_15KHZ 0
23+
#define DISP_VGA 1
24+
uint16_t display_timing;
25+
26+
#define DISP_SPI2 0
27+
#define DISP_SPI1 1
28+
uint16_t display_spi;
29+
2230
#define DISPCTL_tristate 0 /* PB15 is tristate outside OSD; PA15 unused */
2331
#define DISPCTL_enable_high 1 /* PA15 is Display Enable: Active HIGH */
2432
#define DISPCTL_enable_low 2 /* PA15 is Display Enable: Active LOW */

inc/util.h

+11
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@ void display_off(void);
9393
#define AMI_LEFT 0x4f
9494
#define AMI_RIGHT 0x4e
9595
#define AMI_UP 0x4c
96+
#define AMI_KPLEFTPAREN 0x5a
97+
#define AMI_KPRIGHTPAREN 0x5b
98+
#define AMI_KPSLASH 0x5c
99+
#define AMI_KPPLUS 0x5e
100+
#define AMI_KPMINUS 0x4a
101+
102+
#define AMI_W 0x11
103+
#define AMI_A 0x20
104+
#define AMI_S 0x21
105+
#define AMI_D 0x22
106+
96107
extern bool_t keyboard_held;
97108
bool_t amiga_key_pressed(uint8_t keycode);
98109
#define amiga_key_pressed_now(k) (amiga_key_pressed(k) & 1)

src/config.c

+47-6
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ const static struct config *flash_config = (struct config *)0x0800fc00;
1818

1919
struct config config;
2020

21+
extern void setup_spi(void);
22+
2123
static void config_printk(const struct config *conf)
2224
{
2325
printk("\nCurrent config:\n");
2426
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 );
2530
printk(" H.Off: %u\n", conf->h_off);
2631
printk(" V.Off: %u\n", conf->v_off);
2732
printk(" Rows: %u\n", conf->rows);
@@ -82,6 +87,8 @@ static enum {
8287
C_banner,
8388
/* Output */
8489
C_polarity,
90+
C_disptiming,
91+
C_spibus,
8592
C_h_off,
8693
C_v_off,
8794
/* LCD */
@@ -142,7 +149,7 @@ void config_process(uint8_t b)
142149
uint8_t _b;
143150
static uint8_t pb;
144151
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;
146153
static struct config old_config;
147154

148155
_b = b;
@@ -168,6 +175,10 @@ void config_process(uint8_t b)
168175
case C_SAVE:
169176
config_write_flash(&config);
170177
break;
178+
case C_SAVEREBOOT:
179+
config_write_flash(&config);
180+
while(1) {} /* hang and let WDT reboot */
181+
break;
171182
case C_USE:
172183
break;
173184
case C_DISCARD:
@@ -176,6 +187,9 @@ void config_process(uint8_t b)
176187
case C_RESET:
177188
config = dfl_config;
178189
config_write_flash(&config);
190+
while(1) {} /* hang and let WDT reboot */
191+
break;
192+
case C_NC_MAX:
179193
break;
180194
}
181195
printk("\n");
@@ -208,6 +222,25 @@ void config_process(uint8_t b)
208222
if (b)
209223
cnf_prt(1, "Active %s", config.polarity ? "HIGH" : "LOW");
210224
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;
211244
case C_h_off:
212245
if (changed)
213246
cnf_prt(0, "H.Off (1-199):");
@@ -262,16 +295,24 @@ void config_process(uint8_t b)
262295
cnf_prt(1, "%u", config.max_cols);
263296
break;
264297
case C_save: {
265-
const static char *str[] = { "Save", "Use",
298+
const static char *str[] = { "Save", "Save+Reset", "Use",
266299
"Discard", "Factory Reset" };
267300
if (changed) {
268301
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;
270312
}
271-
if (b & B_LEFT)
272-
new_config = (new_config - 1) & 3;
273313
if (b & B_RIGHT)
274-
new_config = (new_config + 1) & 3;
314+
if (++new_config >= C_NC_MAX)
315+
new_config = 0;
275316
if (b)
276317
cnf_prt(1, "%s", str[new_config]);
277318
break;

src/default_config.c

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ const static struct config dfl_config = {
1818
.max_cols = 40,
1919
.dispctl_mode = DISPCTL_tristate,
2020
.rows = 2,
21+
.display_timing = DISP_15KHZ,
22+
.display_spi = DISP_SPI2,
2123

2224
#define F(x) (x-1) /* Hotkey (F1-F10) array index */
2325
#define U(x) (1u<<x) /* User pin (U0-U2) bitmask */

0 commit comments

Comments
 (0)