Skip to content

Commit

Permalink
Support VGA timing and support for faster SPI1 bus
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
penfold42 committed Dec 7, 2019
1 parent 512d557 commit 8ae4db2
Show file tree
Hide file tree
Showing 6 changed files with 305 additions and 49 deletions.
2 changes: 1 addition & 1 deletion attic/pins.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
| 4 | | | Y | Amiga KB_CLK |
| 5 | | | | |
| 6 | | | Y | I2C SCL |
| 7 | | | Y | I2C SDA |
| 7 | | Disp.Out.SPI1 | Y | I2C SDA |
| 8 | Y | CSYNC/HSYNC | Y | User Out (U0) |
| 9 | Y | Serial Tx | Y | User Out (U1) |
|10 | Y | Serial Rx | Y | User Out (U2) |
Expand Down
8 changes: 8 additions & 0 deletions inc/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ extern struct __packed config {

uint16_t rows;

#define DISP_15KHZ 0
#define DISP_VGA 1
uint16_t display_timing;

#define DISP_SPI2 0
#define DISP_SPI1 1
uint16_t display_spi;

#define DISPCTL_tristate 0 /* PB15 is tristate outside OSD; PA15 unused */
#define DISPCTL_enable_high 1 /* PA15 is Display Enable: Active HIGH */
#define DISPCTL_enable_low 2 /* PA15 is Display Enable: Active LOW */
Expand Down
11 changes: 11 additions & 0 deletions inc/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ void display_off(void);
#define AMI_LEFT 0x4f
#define AMI_RIGHT 0x4e
#define AMI_UP 0x4c
#define AMI_KPLEFTPAREN 0x5a
#define AMI_KPRIGHTPAREN 0x5b
#define AMI_KPSLASH 0x5c
#define AMI_KPPLUS 0x5e
#define AMI_KPMINUS 0x4a

#define AMI_W 0x11
#define AMI_A 0x20
#define AMI_S 0x21
#define AMI_D 0x22

extern bool_t keyboard_held;
bool_t amiga_key_pressed(uint8_t keycode);
#define amiga_key_pressed_now(k) (amiga_key_pressed(k) & 1)
Expand Down
53 changes: 47 additions & 6 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ const static struct config *flash_config = (struct config *)0x0800fc00;

struct config config;

extern void setup_spi(void);

static void config_printk(const struct config *conf)
{
printk("\nCurrent config:\n");
printk(" Sync: Active %s\n", conf->polarity ? "HIGH" : "LOW");
printk(" Pixel Timing: %s\n", config.display_timing ? "VGA" : "15kHz");
printk(" Video Output: SPI%s\n", config.display_spi ? "1 (PA7)" : "2 (PB15)");
printk(" Output Enable: %d\n", config.dispctl_mode );
printk(" H.Off: %u\n", conf->h_off);
printk(" V.Off: %u\n", conf->v_off);
printk(" Rows: %u\n", conf->rows);
Expand Down Expand Up @@ -82,6 +87,8 @@ static enum {
C_banner,
/* Output */
C_polarity,
C_disptiming,
C_spibus,
C_h_off,
C_v_off,
/* LCD */
Expand Down Expand Up @@ -142,7 +149,7 @@ void config_process(uint8_t b)
uint8_t _b;
static uint8_t pb;
bool_t changed = FALSE;
static enum { C_SAVE = 0, C_USE, C_DISCARD, C_RESET } new_config;
static enum { C_SAVE = 0, C_SAVEREBOOT, C_USE, C_DISCARD, C_RESET, C_NC_MAX} new_config;
static struct config old_config;

_b = b;
Expand All @@ -168,6 +175,10 @@ void config_process(uint8_t b)
case C_SAVE:
config_write_flash(&config);
break;
case C_SAVEREBOOT:
config_write_flash(&config);
while(1) {} /* hang and let WDT reboot */
break;
case C_USE:
break;
case C_DISCARD:
Expand All @@ -176,6 +187,9 @@ void config_process(uint8_t b)
case C_RESET:
config = dfl_config;
config_write_flash(&config);
while(1) {} /* hang and let WDT reboot */
break;
case C_NC_MAX:
break;
}
printk("\n");
Expand Down Expand Up @@ -208,6 +222,25 @@ void config_process(uint8_t b)
if (b)
cnf_prt(1, "Active %s", config.polarity ? "HIGH" : "LOW");
break;
case C_disptiming:
if (changed)
cnf_prt(0, "Pixel Timing:");
if (b & (B_LEFT|B_RIGHT)) {
config.display_timing ^= 1;
setup_spi();
}
if (b)
cnf_prt(1, "%s", config.display_timing ? "VGA" : "15kHz");
break;
case C_spibus:
if (changed)
cnf_prt(0, "SPI");
if (b & (B_LEFT|B_RIGHT)) {
config.display_spi ^= 1;
}
if (b)
cnf_prt(1, "%s", config.display_spi ? "1 (PA7)" : "2 (PB15)");
break;
case C_h_off:
if (changed)
cnf_prt(0, "H.Off (1-199):");
Expand Down Expand Up @@ -262,16 +295,24 @@ void config_process(uint8_t b)
cnf_prt(1, "%u", config.max_cols);
break;
case C_save: {
const static char *str[] = { "Save", "Use",
const static char *str[] = { "Save", "Save+Reset", "Use",
"Discard", "Factory Reset" };
if (changed) {
cnf_prt(0, "Save New Config?");
new_config = C_SAVE;
if (old_config.display_spi == config.display_spi)
new_config = C_SAVE;
else
new_config = C_SAVEREBOOT;
}
if (b & B_LEFT) {
if (new_config > 0)
--new_config;
else
new_config = C_NC_MAX-1;
}
if (b & B_LEFT)
new_config = (new_config - 1) & 3;
if (b & B_RIGHT)
new_config = (new_config + 1) & 3;
if (++new_config >= C_NC_MAX)
new_config = 0;
if (b)
cnf_prt(1, "%s", str[new_config]);
break;
Expand Down
2 changes: 2 additions & 0 deletions src/default_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const static struct config dfl_config = {
.max_cols = 40,
.dispctl_mode = DISPCTL_tristate,
.rows = 2,
.display_timing = DISP_15KHZ,
.display_spi = DISP_SPI2,

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

0 comments on commit 8ae4db2

Please sign in to comment.