mirror of
https://github.com/dougg3/mac-rom-simm-programmer.git
synced 2024-11-22 06:32:23 +00:00
Fix a few minor issues
I noticed that after I implemented the SPI optimization of cycle counting instead of polling on SPIF, the first "normal" SPI transaction I tried would fail. This is because nothing was clearing the SPIF flag anymore, and the normal SPI driver still looks at it. So it was thinking that the latest transaction was already completed (it wasn't). Worked around this by making sure we clear the flag in SPI_Assert. I'm not concerned about performance impact here because the actual clean SPI driver is not used in performance-bound situations. Fixed an issue that identified the wrong pins as shorted to ground in the electrical test functionality. Whoops!
This commit is contained in:
parent
39f34d67c4
commit
82df6ea459
@ -101,7 +101,7 @@ void ParallelBus_Init(void)
|
||||
|
||||
// Set all data lines to pulled-up inputs
|
||||
ParallelBus_SetDataDir(0);
|
||||
ParallelBus_SetDataPullups(0xFFFFFFFF);
|
||||
ParallelBus_SetDataPullups(0xFFFFFFFFUL);
|
||||
dataIsOutput = false;
|
||||
// Note: During normal operation of read/write cycles, the pullups in the
|
||||
// MCP23S17 will remember they are enabled, so we can do an optimization
|
||||
|
@ -157,6 +157,18 @@ void SPI_ReleaseBus(SPIDevice *spi)
|
||||
void SPI_Assert(SPIDevice *spi)
|
||||
{
|
||||
GPIO_SetOff(spi->csPin);
|
||||
|
||||
// Due to the optimization we do in ParallelBus talking directly to the
|
||||
// SPI hardware without going through this driver, we need to make sure
|
||||
// that the SPIF flag is cleared here. Otherwise we may think we're done
|
||||
// too early, which would cause us to screw up the next SPI transfer.
|
||||
// This happens because the optimized code doesn't look at SPSR, so the
|
||||
// SPIF flag never gets cleared from the previous SPI operation.
|
||||
if (SPSR & (1 << SPIF))
|
||||
{
|
||||
// Reading the data register clears the flag if it's set
|
||||
(void)SPDR;
|
||||
}
|
||||
}
|
||||
|
||||
/** Deasserts an SPI device's chip select pin
|
||||
|
@ -93,7 +93,7 @@ int SIMMElectricalTest_Run(void (*errorHandler)(uint8_t, uint8_t))
|
||||
// (We have to ignore them during the second phase of the test)
|
||||
SIMMElectricalTest_ResetGroundShorts();
|
||||
|
||||
// First check for anything shorted to ground. Set all lines as inputs wit
|
||||
// First check for anything shorted to ground. Set all lines as inputs with
|
||||
// a weak pull-up resistor. Then read the values back and check for any
|
||||
// zeros. This would indicate a short to ground.
|
||||
ParallelBus_SetAddressDir(0);
|
||||
@ -116,8 +116,6 @@ int SIMMElectricalTest_Run(void (*errorHandler)(uint8_t, uint8_t))
|
||||
|
||||
// Read the address pins back first
|
||||
uint32_t readback = ParallelBus_ReadAddress();
|
||||
if (readback != SIMM_ADDRESS_PINS_MASK)
|
||||
{
|
||||
// Check each bit for a LOW which would indicate a short to ground
|
||||
for (i = 0; i <= SIMM_HIGHEST_ADDRESS_LINE; i++)
|
||||
{
|
||||
@ -142,12 +140,9 @@ int SIMMElectricalTest_Run(void (*errorHandler)(uint8_t, uint8_t))
|
||||
readback >>= 1;
|
||||
curPin++;
|
||||
}
|
||||
}
|
||||
|
||||
// Repeat the exact same process for the data pins
|
||||
readback = ParallelBus_ReadData();
|
||||
if (readback != SIMM_DATA_PINS_MASK)
|
||||
{
|
||||
for (i = 0; i <= SIMM_HIGHEST_DATA_LINE; i++)
|
||||
{
|
||||
if (!(readback & 1))
|
||||
@ -163,7 +158,6 @@ int SIMMElectricalTest_Run(void (*errorHandler)(uint8_t, uint8_t))
|
||||
readback >>= 1;
|
||||
curPin++;
|
||||
}
|
||||
}
|
||||
|
||||
// Check chip select in the same way...
|
||||
if (!ParallelBus_ReadCS())
|
||||
|
Loading…
Reference in New Issue
Block a user