Skip to content

Commit

Permalink
update for SP/diskII handling with softsp
Browse files Browse the repository at this point in the history
  • Loading branch information
robjustice committed Oct 6, 2023
1 parent 24f5bfc commit fc8d6ab
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
7 changes: 7 additions & 0 deletions lib/bus/iwm/iwm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,13 @@ void IRAM_ATTR iwmBus::service()
// expect a command packet
// should not ACK unless we know this is our Command

// force floppy off when SP bus is enabled, needed for softsp
if (_old_enable_state != iwm_enable_state_t::off)
{
_old_enable_state = iwm_enable_state_t::off;
diskii_xface.stop();
}

if (sp_command_mode != sp_cmd_state_t::command)
{
// iwm_ack_deassert(); // go hi-Z
Expand Down
20 changes: 13 additions & 7 deletions lib/bus/iwm/iwm_ll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ void IRAM_ATTR phi_isr_handler(void *arg)
// update the head position based on phases
// put the right track in the SPI buffer

uint32_t int_gpio_num = (uint32_t) arg; // gpio that triggered the interrupt
int error; // checksum error return
uint8_t c;

Expand Down Expand Up @@ -114,7 +115,10 @@ void IRAM_ATTR phi_isr_handler(void *arg)
break;
}
}
else if (diskii_xface.iwm_enable_states() & 0b11)
// add extra condition here to stop edge case where on softsp, the disk is stepping inadvertantly when SP bus is
// disabled. PH1 gets set low first, then PH3 follows a very short time after. We look for the interrupt on PH1 (33)
// and then PH1 = 0 (going low) and PH3 = 1 (still high)
else if ((diskii_xface.iwm_enable_states() & 0b11) && !((int_gpio_num == 33 && _phases == 0b1000)))
{
if (theFuji._fnDisk2s[diskii_xface.iwm_enable_states() - 1].move_head())
{
Expand Down Expand Up @@ -633,10 +637,10 @@ void iwm_ll::setup_gpio()


// attach the interrupt service routine
gpio_isr_handler_add((gpio_num_t)SP_PHI0, phi_isr_handler, NULL);
gpio_isr_handler_add((gpio_num_t)SP_PHI1, phi_isr_handler, NULL);
gpio_isr_handler_add((gpio_num_t)SP_PHI2, phi_isr_handler, NULL);
gpio_isr_handler_add((gpio_num_t)SP_PHI3, phi_isr_handler, NULL);
gpio_isr_handler_add((gpio_num_t)SP_PHI0, phi_isr_handler, (void*) (gpio_num_t)SP_PHI0);
gpio_isr_handler_add((gpio_num_t)SP_PHI1, phi_isr_handler, (void*) (gpio_num_t)SP_PHI1);
gpio_isr_handler_add((gpio_num_t)SP_PHI2, phi_isr_handler, (void*) (gpio_num_t)SP_PHI2);
gpio_isr_handler_add((gpio_num_t)SP_PHI3, phi_isr_handler, (void*) (gpio_num_t)SP_PHI3);
}

void iwm_sp_ll::encode_packet(uint8_t source, iwm_packet_type_t packet_type, uint8_t status, const uint8_t* data, uint16_t num)
Expand Down Expand Up @@ -1055,8 +1059,10 @@ uint8_t IRAM_ATTR iwm_diskii_ll::iwm_enable_states()
// only enable diskII if we are either not on an en35 capable host, or we are on an en35host and /EN35=high
if (!IWM.en35Host || (IWM.en35Host && (GPIO.in1.val & (0x01 << (SP_EN35 - 32)))))
{
states |= (GPIO.in1.val & (0x01 << (SP_DRIVE1 - 32))) ? 0b00 : 0b01;
states |= (GPIO.in & (0x01 << SP_DRIVE2)) ? 0b00 : 0b10;
if (!(states |= (GPIO.in1.val & (0x01 << (SP_DRIVE1 - 32))) ? 0b00 : 0b01))
{
states |= (GPIO.in & (0x01 << SP_DRIVE2)) ? 0b00 : 0b10;
}
}
return states;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/media/apple/mediaType.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define _MEDIA_TYPE_

#include <stdio.h>
#include <fujiHost.h>
#include"../fuji/fujiHost.h"

#define INVALID_SECTOR_VALUE 65536

Expand Down

0 comments on commit fc8d6ab

Please sign in to comment.