7. Step 4: Stop

void Stop();
void StopMotor();

Stop
Stop currently just calls StopMotor. However, if you add a timed delay before turning the motor off, you would want to replace this code with the code that will start/reset the timer.

StopMotor
StopMotor turns the motor off. Once the motor is turned off, the floppy drive can no longer be selected; in addition, some computers will require a complete reset before performing the next operation.


Code

void Floppy::Stop() {
	StopMotor();
}


void Floppy::StopMotor() {
	if (MotorRunning) {
		DigitalOutputRegister &= 0xFC - (1 << (DriveIndex + dorMotorShift));
		WriteByteToPort(IOBase[ControllerIndex] + flpWDigitalOutputRegister, DigitalOutputRegister);
		// Since not all floppy drive controllers raise an interrupt when the motor has stopped, we won't wait.

		AtCylinder = 255;		// The cylinder we were at is no longer valid, since the motor has stopped.
		MotorRunning = false;
	}
}