1
0
mirror of https://github.com/mist-devel/mist-firmware.git synced 2026-04-26 04:17:40 +00:00

Generic 8 bit file upload

This commit is contained in:
harbaum
2014-06-27 08:26:06 +00:00
parent e7b9fc3a95
commit 65efc52684
4 changed files with 60 additions and 15 deletions

16
main.c
View File

@@ -108,9 +108,7 @@ extern void inserttestfloppy();
int main(void)
{
unsigned char rc;
unsigned char key;
unsigned short spiclk;
uint8_t tmp;
uint8_t mmc_ok = 0;
#ifdef __GNUC__
@@ -138,8 +136,8 @@ int main(void)
// TODO: If MMC fails try to wait for USB storage
spiclk = MCLK / ((AT91C_SPI_CSR[0] & AT91C_SPI_SCBR) >> 8) / 1000000;
iprintf("spiclk: %u MHz\r", spiclk);
tmp = MCLK / ((AT91C_SPI_CSR[0] & AT91C_SPI_SCBR) >> 8) / 1000000;
iprintf("spiclk: %u MHz\r", tmp);
usb_init();
@@ -174,6 +172,11 @@ int main(void)
usb_cdc_open();
// if it's a 8 bit core check if it has a config string
// (and thus has a user interface/osd)
if(user_io_core_type() == CORE_TYPE_8BIT)
tmp = (user_io_8bit_get_string(0) != NULL);
while (1) {
cdc_control_poll();
@@ -199,9 +202,8 @@ int main(void)
}
// 8 bit cores can also have a ui
if(user_io_core_type() == CORE_TYPE_8BIT) {
if((user_io_core_type() == CORE_TYPE_8BIT) && tmp)
HandleUI();
}
}
return 0;
}

8
menu.c
View File

@@ -326,9 +326,9 @@ void HandleUI(void)
strcat(s, p);
OsdWrite(0, s, menusub==0, 0);
} else
OsdWrite(0, " no file", 0,1);
OsdWrite(0, " No file I/O", 0,1);
OsdWrite(1, " 8 bit menu test", 0,0);
OsdWrite(1, "", 0,0);
OsdWrite(2, "", 0,0);
OsdWrite(3, "", 0,0);
OsdWrite(4, "", 0,0);
@@ -356,9 +356,9 @@ void HandleUI(void)
break;
case MENU_8BIT_MAIN_FILE_SELECTED : // file successfully selected
iprintf("selecte file %s\n", file.name);
user_io_file_tx(&file);
menustate = MENU_8BIT_MAIN1;
// close menu afterwards
menustate = MENU_NONE1;
break;
/******************************************************************/

View File

@@ -131,6 +131,14 @@ void user_io_detect_core_type() {
case CORE_TYPE_8BIT:
puts("Identified 8BIT core");
// send a reset
user_io_8bit_set_status(UIO_STATUS_RESET, UIO_STATUS_RESET);
/* wait 5ms */
TIMER_wait(5);
// release reset
user_io_8bit_set_status(0, UIO_STATUS_RESET);
break;
}
}
@@ -295,8 +303,11 @@ void user_io_file_tx(fileTYPE *file) {
iprintf("Selected file %s with %lu bytes to send\n", file->name, bytes2send);
// prepare transmission of new file
EnableFpga();
SPI(UIO_FILE_TX);
SPI(0xff);
DisableFpga();
while(bytes2send) {
iprintf(".");
@@ -306,8 +317,13 @@ void user_io_file_tx(fileTYPE *file) {
FileRead(file, sector_buffer);
for(p = sector_buffer, c=0;c < chunk;c++)
EnableFpga();
SPI(UIO_FILE_TX_DAT);
for(p = sector_buffer, c=0;c < chunk;c++)
SPI(*p++);
DisableFpga();
bytes2send -= chunk;
@@ -315,7 +331,13 @@ void user_io_file_tx(fileTYPE *file) {
if(bytes2send)
FileNextSector(file);
}
// signal end of transmission
EnableFpga();
SPI(UIO_FILE_TX);
SPI(0x00);
DisableFpga();
iprintf("\n");
}
@@ -328,7 +350,6 @@ char *user_io_8bit_get_string(char index) {
// clear buffer
buffer[0] = 0;
/* read status byte */
EnableIO();
SPI(UIO_GET_STRING);
@@ -361,6 +382,20 @@ char *user_io_8bit_get_string(char index) {
return buffer;
}
void user_io_8bit_set_status(unsigned char new_status, unsigned char mask) {
static unsigned char status = 0;
// keep everything not masked
status &= ~mask;
// updated masked bits
status |= new_status & mask;
EnableIO();
SPI(UIO_SET_STATUS);
SPI(status);
DisableIO();
}
void user_io_poll() {
if((core_type != CORE_TYPE_MINIMIG) &&
(core_type != CORE_TYPE_PACE) &&
@@ -724,7 +759,8 @@ static char key_used_by_osd(unsigned short s) {
// in atari mode eat all keys if the OSD is online,
// else none as it's up to the core to forward keys
// to the OSD
return(core_type == CORE_TYPE_MIST);
return((core_type == CORE_TYPE_MIST) ||
(core_type == CORE_TYPE_8BIT));
}
void user_io_kbd(unsigned char m, unsigned char *k) {

View File

@@ -38,13 +38,16 @@
#define UIO_JOYSTICK5 0x12 // -"-
#define UIO_JOYSTICK6 0x13 // -"-
// codes as currently used by 8bit only
#define UIO_GET_STRING 0x14
#define UIO_SET_STATUS 0x15
// codes as used by 8bit (atari 800, zx81)
// codes as used by 8bit (atari 800, zx81) via SS2
#define UIO_GET_STATUS 0x50
#define UIO_SECTOR_SND 0x51
#define UIO_SECTOR_RCV 0x52
#define UIO_FILE_TX 0x53
#define UIO_FILE_TX_DAT 0x54
#define JOY_RIGHT 0x01
#define JOY_LEFT 0x02
@@ -67,6 +70,9 @@
#define CORE_TYPE_MIST 0xa3 // mist atari st core
#define CORE_TYPE_8BIT 0xa4 // atari 800/c64 like core
// user io status bits (currently only used by 8bit)
#define UIO_STATUS_RESET 0x01
void user_io_init();
void user_io_detect_core_type();
unsigned char user_io_core_type();
@@ -77,6 +83,7 @@ char user_io_user_button();
void user_io_osd_key_enable(char);
void user_io_serial_tx(char *, uint16_t);
char *user_io_8bit_get_string(char);
void user_io_8bit_set_status(unsigned char, unsigned char);
void user_io_file_tx(fileTYPE *);
// io controllers interface for FPGA ethernet emulation using usb ethernet