|
Adafruit Library
|
An abstract base class for chattin with floppy drives. More...
#include <Adafruit_Floppy.h>
Public Member Functions | |
| bool | begin (void) |
| Initializes the GPIO pins but do not start the motor or anything. More... | |
| virtual void | end () |
| Disables floppy communication, allowing pins to be used for general input and output. | |
| virtual void | soft_reset (void) |
| Initializes the GPIO pins but do not start the motor or anything. | |
| virtual void | select (bool selected)=0 |
| Whether to select this drive. More... | |
| bool | drive_is_selected (void) |
| Is the drive selected based on interal caching. More... | |
| virtual bool | spin_motor (bool motor_on)=0 |
| Turn on or off the floppy motor, if on we wait till we get an index pulse! More... | |
| bool | motor_is_spinning (void) |
| Is the drive motor spinning based on interal caching. More... | |
| bool | index_pulses_seen (void) |
| Are index pulses being seen? More... | |
| virtual bool | goto_track (int track_num)=0 |
| Seek to the desired track, requires the motor to be spun up! More... | |
| virtual bool | side (int head)=0 |
| Which head/side to read from. More... | |
| virtual int | get_side ()=0 |
| Current head in use, based on internal caching. More... | |
| virtual int | track (void)=0 |
| The current track location, based on internal caching. More... | |
| virtual bool | get_write_protect ()=0 |
| Check whether the floppy in the drive is write protected. More... | |
| virtual bool | get_track0_sense ()=0 |
| Check whether the track0 sensor is active. More... | |
| virtual bool | get_ready_sense ()=0 |
| Check whether the ready output is active. More... | |
| virtual bool | set_density (bool high_density)=0 |
| Set the density for flux reading and writing. More... | |
| size_t | decode_track_mfm (uint8_t *sectors, size_t n_sectors, uint8_t *sector_validity, const uint8_t *pulses, size_t n_pulses, float nominal_bit_time_us, bool clear_validity=false, uint8_t *logical_track=nullptr) |
| Decode one track of previously captured MFM data. More... | |
| size_t | encode_track_mfm (const uint8_t *sectors, size_t n_sectors, uint8_t *pulses, size_t max_pulses, float nominal_bit_time_us, uint8_t logical_track) |
| Encode one track of previously captured MFM data. More... | |
| size_t | capture_track (volatile uint8_t *pulses, size_t max_pulses, int32_t *falling_index_offset, bool store_greaseweazle=false, uint32_t capture_ms=0, uint32_t index_wait_ms=250) __attribute__((optimize("O3"))) |
| Capture one track's worth of flux transitions, between two falling index pulses. More... | |
| bool | write_track (uint8_t *pulses, size_t n_pulses, bool store_greaseweazle=false, bool use_index=true) __attribute__((optimize("O3"))) |
| Write one track of flux pulse data, starting at the index pulse. More... | |
| void | print_pulse_bins (uint8_t *pulses, size_t n_pulses, uint8_t max_bins=64, bool is_gw_format=false, uint32_t min_bin_size=100) |
| Pretty print a simple histogram of flux transitions. More... | |
| void | print_pulses (uint8_t *pulses, size_t n_pulses, bool is_gw_format=false) |
| Pretty print the counts in a list of flux transitions. More... | |
| uint32_t | getSampleFrequency (void) |
| Get the sample rate that we read and emit pulses at, platform and implementation-dependant. More... | |
Public Attributes | |
| int8_t | led_pin = -1 |
| Debug LED output for tracing. | |
| uint16_t | select_delay_us = 10 |
| delay after drive select (usecs) | |
| uint16_t | step_delay_us = 10000 |
| delay between head steps (usecs) | |
| uint16_t | settle_delay_ms = 15 |
| settle delay after seek (msecs) | |
| uint16_t | motor_delay_ms = 1000 |
| delay after motor on (msecs) | |
| uint16_t | watchdog_delay_ms |
| quiescent time until drives reset (msecs) More... | |
| uint8_t | bus_type = BUSTYPE_IBMPC |
| what kind of floppy drive we're using | |
| Stream * | debug_serial = nullptr |
| optional debug stream for serial output | |
Protected Member Functions | |
| Adafruit_FloppyBase (int indexpin, int wrdatapin, int wrgatepin, int rddatapin, bool is_apple2=false) | |
| Create a hardware interface to a floppy drive. More... | |
| bool | read_index () |
| Poll the status of the index pulse. More... | |
Protected Attributes | |
| bool | is_drive_selected |
| cached drive select state | |
| bool | is_motor_spinning |
| cached motor spinning state | |
| bool | is_index_seen |
| cached index pulses seen state | |
An abstract base class for chattin with floppy drives.
|
protected |
Create a hardware interface to a floppy drive.
| indexpin | A pin connected to the floppy Index Sensor output |
| wrdatapin | A pin connected to the floppy Write Data input |
| wrgatepin | A pin connected to the floppy Write Gate input |
| rddatapin | A pin connected to the floppy Read Data output |
| is_apple2 | True if the flux write waveform is like Apple Disk ][ |
| bool Adafruit_FloppyBase::begin | ( | void | ) |
Initializes the GPIO pins but do not start the motor or anything.
|
pure virtual |
Whether to select this drive.
| selected | True to select/enable |
Implemented in Adafruit_Apple2Floppy, and Adafruit_Floppy.
|
inline |
Is the drive selected based on interal caching.
|
pure virtual |
Turn on or off the floppy motor, if on we wait till we get an index pulse!
| motor_on | True to turn on motor, False to turn it off |
Implemented in Adafruit_Apple2Floppy, and Adafruit_Floppy.
|
inline |
Is the drive motor spinning based on interal caching.
|
inline |
Are index pulses being seen?
|
pure virtual |
Seek to the desired track, requires the motor to be spun up!
| track_num | The track to step to |
Implemented in Adafruit_Apple2Floppy, and Adafruit_Floppy.
|
pure virtual |
Which head/side to read from.
| head | Head 0 or 1 |
Implemented in Adafruit_Apple2Floppy, and Adafruit_Floppy.
|
pure virtual |
Current head in use, based on internal caching.
Implemented in Adafruit_Apple2Floppy, and Adafruit_Floppy.
|
pure virtual |
The current track location, based on internal caching.
Implemented in Adafruit_Apple2Floppy, and Adafruit_Floppy.
|
pure virtual |
Check whether the floppy in the drive is write protected.
Implemented in Adafruit_Apple2Floppy, and Adafruit_Floppy.
|
pure virtual |
Check whether the track0 sensor is active.
Implemented in Adafruit_Apple2Floppy, and Adafruit_Floppy.
|
pure virtual |
Check whether the ready output is active.
Implemented in Adafruit_Apple2Floppy, and Adafruit_Floppy.
|
pure virtual |
Set the density for flux reading and writing.
| high_density | false for low density, true for high density |
Implemented in Adafruit_Apple2Floppy, and Adafruit_Floppy.
| size_t Adafruit_FloppyBase::decode_track_mfm | ( | uint8_t * | sectors, |
| size_t | n_sectors, | ||
| uint8_t * | sector_validity, | ||
| const uint8_t * | pulses, | ||
| size_t | n_pulses, | ||
| float | nominal_bit_time_us, | ||
| bool | clear_validity = false, |
||
| uint8_t * | logical_track = nullptr |
||
| ) |
Decode one track of previously captured MFM data.
| sectors | A pointer to an array of memory we can use to store into, 512*n_sectors bytes |
| n_sectors | The number of sectors (e.g., 18 for a standard 3.5", 1.44MB format) |
| sector_validity | An array of values set to 1 if the sector was captured, 0 if not captured (no IDAM, CRC error, etc) |
| pulses | An array of pulses from capture_track |
| n_pulses | An array of pulses from capture_track |
| nominal_bit_time_us | The nominal time of one MFM bit, usually 1.0f (double density) or 2.0f (high density) |
| clear_validity | Whether to clear the validity flag. Set to false if re-reading a track with errors. |
| logical_track | If not NULL, updated with the logical track number of the last sector read. (track & side numbers are not otherwise verified) |
| size_t Adafruit_FloppyBase::encode_track_mfm | ( | const uint8_t * | sectors, |
| size_t | n_sectors, | ||
| uint8_t * | pulses, | ||
| size_t | max_pulses, | ||
| float | nominal_bit_time_us, | ||
| uint8_t | logical_track | ||
| ) |
Encode one track of previously captured MFM data.
| sectors | A pointer to an array of memory we can use to store into, 512*n_sectors bytes |
| n_sectors | The number of sectors (e.g., 18 for a standard 3.5", 1.44MB format) |
| pulses | An array of pulses from capture_track |
| max_pulses | The maximum number of pulses that may be stored |
| nominal_bit_time_us | The nominal time of one MFM bit, usually 1.0f (double density) or 2.0f (high density) |
| logical_track | The logical track number, or -1 to use track() |
| size_t Adafruit_FloppyBase::capture_track | ( | volatile uint8_t * | pulses, |
| size_t | max_pulses, | ||
| int32_t * | falling_index_offset, | ||
| bool | store_greaseweazle = false, |
||
| uint32_t | capture_ms = 0, |
||
| uint32_t | index_wait_ms = 250 |
||
| ) |
Capture one track's worth of flux transitions, between two falling index pulses.
| pulses | A pointer to an array of memory we can use to store into |
| max_pulses | The size of the allocated pulses array |
| falling_index_offset | Pointer to a uint32_t where we will store the "flux index" where the second index pulse fell. usually we read 110-125% of one track so there is an overlap of index pulse reads |
| store_greaseweazle | Pass in true to pack long pulses with two bytes |
| capture_ms | If not zero, we will capture at least one revolution and extra time will be determined by this variable. e.g. 250ms means one revolution plus about 50 ms post-index |
| index_wait_ms | If not zero, wait at most this many ms for an index pulse to arrive |
| bool Adafruit_FloppyBase::write_track | ( | uint8_t * | pulses, |
| size_t | n_pulses, | ||
| bool | store_greaseweazle = false, |
||
| bool | use_index = true |
||
| ) |
Write one track of flux pulse data, starting at the index pulse.
| pulses | An array of timer-count pulses |
| n_pulses | How many bytes are in the pulse array |
| store_greaseweazle | If true, long pulses are 'packed' in gw format |
| use_index | If true, write starts at the index pulse. |
| void Adafruit_FloppyBase::print_pulse_bins | ( | uint8_t * | pulses, |
| size_t | n_pulses, | ||
| uint8_t | max_bins = 64, |
||
| bool | is_gw_format = false, |
||
| uint32_t | min_bin_size = 100 |
||
| ) |
Pretty print a simple histogram of flux transitions.
| pulses | A pointer to an array of memory containing pulse counts |
| n_pulses | The size of the pulses in the array |
| max_bins | The maximum number of histogram bins to use (default 64) |
| is_gw_format | Set to true if we pack long pulses with two bytes |
| min_bin_size | Bins with fewer samples than this are skipped, not printed |
| void Adafruit_FloppyBase::print_pulses | ( | uint8_t * | pulses, |
| size_t | n_pulses, | ||
| bool | is_gw_format = false |
||
| ) |
Pretty print the counts in a list of flux transitions.
| pulses | A pointer to an array of memory containing pulse counts |
| n_pulses | The size of the pulses in the array |
| is_gw_format | Set to true if we pack long pulses with two bytes |
| uint32_t Adafruit_FloppyBase::getSampleFrequency | ( | void | ) |
Get the sample rate that we read and emit pulses at, platform and implementation-dependant.
|
protected |
Poll the status of the index pulse.
| uint16_t Adafruit_FloppyBase::watchdog_delay_ms |
quiescent time until drives reset (msecs)
1.8.13