Skip to content

Commit

Permalink
Several floppy and OSD improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
harbaum committed Nov 28, 2023
1 parent cbdce8b commit ea33108
Show file tree
Hide file tree
Showing 20 changed files with 912 additions and 460 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ The MiSTeryNano is a work in progress. Current features are:
* Mapped to USB via BL616 MCU
* Mouse and keyboard via USB
* Joystick via IO pins of Tang Nano
* Floppy disk image stored on regular FAT/exFAT formatted SD card
* Floppy disk images
* Read support for drive A: and drive B:
* Images stored on regular FAT/exFAT formatted SD card

## Missing features

* Support for floppy drive B
* Support for hard disk images
* Floppy disk write support

Expand Down
25 changes: 13 additions & 12 deletions bl616/misterynano_fw/SPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,13 @@ The SDC target supports the following commands:

The ```SPI_SDC_STATUS``` is used to poll the SD card status. The first
byte returned is a generic status byte indicating whether the card
could be initialized and the card type (SDv1, SDv2, SDHC). The lower
two bits are request bytes which are set by the core if it needs to
read a sector. In the Atari ST core bit 0 indicates a request for
floppy A: and bit 1 for floppy B: (currently only floppy A is
implemented). The following four bytes contain the sector number the
core wants to read.
could be initialized and the card type (SDv1, SDv2, SDHC). Bit 1 of
the status byte indicates whether the SD card is currenly busy reading
or writing data. The second byte contains core requests. Currently the
lower two bits are used by the core to request sector data. In the
Atari ST core bit 0 indicates a request for floppy A: and bit 1 for
floppy B:. The following four bytes contain the sector number the core
wants to read.

The ```SPI_SDC_READ``` requests the core to read a sector from SD card
and use it for it's own purposes. The command is followed by four
Expand All @@ -179,10 +180,10 @@ data is not visible to the core. Instead it used by the MCU to display the
contents of the SD card and to determine where data is stored inside the images
files stored on the SD card.

The ```SPI_SDC_INSERTED``` command and the following four data bytes
are used to inform the core about the size of the selected disk
image. This is needed to translate between the track/sector/side
The ```SPI_SDC_INSERTED``` command and the following five data bytes
are used to inform the core about drive and the size of the selected
disk image. This is needed to translate between the track/sector/side
values typically used when reading from floppy disk into sector
offsets into the image file. A size of 0 indicates that no image
is currently selected. The core should then behave as if e.g. no
floppy disk is inserted.
offsets into the image file. A size of 0 indicates that no image is
currently selected. The core should then behave as if e.g. no floppy
disk is inserted.
2 changes: 1 addition & 1 deletion bl616/misterynano_fw/fatfs_conf_user.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ All configuration items must be included in the file */
#define FF_USE_FORWARD 0
/* This option switches f_forward() function. (0:Disable or 1:Enable) */

#define FF_USE_STRFUNC 0
#define FF_USE_STRFUNC 1
#define FF_PRINT_LLI 1
#define FF_PRINT_FLOAT 1
#define FF_STRF_ENCODE 3
Expand Down
185 changes: 185 additions & 0 deletions bl616/misterynano_fw/font_helvR08_te.c

Large diffs are not rendered by default.

20 changes: 7 additions & 13 deletions bl616/misterynano_fw/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@

#include "usb_config.h"

// #include "bflb_ef_ctrl.h"
// efuse_dev = bflb_device_get_by_name("ef_ctrl");
//bflb_ef_ctrl_write_direct(efuse_dev, EFUSE_DATA_START_ADDR, (uint32_t *)efuse_data_write, EFUSE_DATA_LEN, 1);
//bflb_ef_ctrl_read_direct(efuse_dev, EFUSE_DATA_START_ADDR, (uint32_t *)efuse_data_read, EFUSE_DATA_LEN, 1);

struct bflb_device_s *gpio;

#include <stdio.h>
Expand All @@ -25,16 +20,14 @@ struct bflb_device_s *gpio;
QueueHandle_t xQueue = NULL;

static void sdc_task(void *parms) {
spi_t *spi = (spi_t*)parms;

while(1) {
sdc_poll();
vTaskDelay(10);
// this delay needs to be rather short to ensure that the
// MCU responds fast enough to sector requests by the core
vTaskDelay(pdMS_TO_TICKS(1));
}
}

// OSD task gets a callback which it calls whenever the OSD
// opems or closes to inform the USB layer about the OSD state
static void osd_task(void *parms) {
menu_t *menu;

Expand All @@ -52,7 +45,8 @@ static void osd_task(void *parms) {
xQueueReceive( xQueue, &cmd, 0xffffffffUL);
menu_do(menu, cmd);

printf("BTN %d\r\n", bflb_gpio_read(gpio, GPIO_PIN_2));
// test poll the UPDATE button
// printf("BTN %d\r\n", bflb_gpio_read(gpio, GPIO_PIN_2));
}
}

Expand Down Expand Up @@ -114,11 +108,11 @@ int main(void) {
// printf("SET: %02x\r\n", *(unsigned char*)0x20010800);

// start a thread for the on screen display
xTaskCreate(osd_task, (char *)"osd_task", 512, spi, configMAX_PRIORITIES-3, &osd_handle);
xTaskCreate(osd_task, (char *)"osd_task", 4096, spi, configMAX_PRIORITIES-3, &osd_handle);

// create another task to frequently poll the FPGA via SPI for e.g.
// floppy disk requests
xTaskCreate(sdc_task, (char *)"sdc_task", 512, spi, configMAX_PRIORITIES-3, &sdc_handle);
xTaskCreate(sdc_task, (char *)"sdc_task", 4096, spi, configMAX_PRIORITIES-3, &sdc_handle);

vTaskStartScheduler();

Expand Down
Loading

0 comments on commit ea33108

Please sign in to comment.