init
This commit is contained in:
parent
b1ac47d55b
commit
fdd8a7b604
9 changed files with 617 additions and 0 deletions
46
.github/ISSUE_TEMPLATE.md
vendored
Normal file
46
.github/ISSUE_TEMPLATE.md
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
Thank you for opening an issue on an Adafruit Arduino library repository. To
|
||||
improve the speed of resolution please review the following guidelines and
|
||||
common troubleshooting steps below before creating the issue:
|
||||
|
||||
- **Do not use GitHub issues for troubleshooting projects and issues.** Instead use
|
||||
the forums at http://forums.adafruit.com to ask questions and troubleshoot why
|
||||
something isn't working as expected. In many cases the problem is a common issue
|
||||
that you will more quickly receive help from the forum community. GitHub issues
|
||||
are meant for known defects in the code. If you don't know if there is a defect
|
||||
in the code then start with troubleshooting on the forum first.
|
||||
|
||||
- **If following a tutorial or guide be sure you didn't miss a step.** Carefully
|
||||
check all of the steps and commands to run have been followed. Consult the
|
||||
forum if you're unsure or have questions about steps in a guide/tutorial.
|
||||
|
||||
- **For Arduino projects check these very common issues to ensure they don't apply**:
|
||||
|
||||
- For uploading sketches or communicating with the board make sure you're using
|
||||
a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes
|
||||
very hard to tell the difference between a data and charge cable! Try using the
|
||||
cable with other devices or swapping to another cable to confirm it is not
|
||||
the problem.
|
||||
|
||||
- **Be sure you are supplying adequate power to the board.** Check the specs of
|
||||
your board and plug in an external power supply. In many cases just
|
||||
plugging a board into your computer is not enough to power it and other
|
||||
peripherals.
|
||||
|
||||
- **Double check all soldering joints and connections.** Flakey connections
|
||||
cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints.
|
||||
|
||||
- **Ensure you are using an official Arduino or Adafruit board.** We can't
|
||||
guarantee a clone board will have the same functionality and work as expected
|
||||
with this code and don't support them.
|
||||
|
||||
If you're sure this issue is a defect in the code and checked the steps above
|
||||
please fill in the following fields to provide enough troubleshooting information.
|
||||
You may delete the guideline and text above to just leave the following details:
|
||||
|
||||
- Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE**
|
||||
|
||||
- Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO
|
||||
VERSION HERE**
|
||||
|
||||
- List the steps to reproduce the problem below (if possible attach a sketch or
|
||||
copy the sketch code in too): **LIST REPRO STEPS BELOW**
|
||||
26
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
26
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
Thank you for creating a pull request to contribute to Adafruit's GitHub code!
|
||||
Before you open the request please review the following guidelines and tips to
|
||||
help it be more easily integrated:
|
||||
|
||||
- **Describe the scope of your change--i.e. what the change does and what parts
|
||||
of the code were modified.** This will help us understand any risks of integrating
|
||||
the code.
|
||||
|
||||
- **Describe any known limitations with your change.** For example if the change
|
||||
doesn't apply to a supported platform of the library please mention it.
|
||||
|
||||
- **Please run any tests or examples that can exercise your modified code.** We
|
||||
strive to not break users of the code and running tests/examples helps with this
|
||||
process.
|
||||
|
||||
Thank you again for contributing! We will try to test and integrate the change
|
||||
as soon as we can, but be aware we have many GitHub repositories to manage and
|
||||
can't immediately respond to every request. There is no need to bump or check in
|
||||
on a pull request (it will clutter the discussion of the request).
|
||||
|
||||
Also don't be worried if the request is closed or not integrated--sometimes the
|
||||
priorities of Adafruit's GitHub code (education, ease of use) might not match the
|
||||
priorities of the pull request. Don't fret, the open source community thrives on
|
||||
forks and GitHub makes it easy to keep your changes in a forked repo.
|
||||
|
||||
After reviewing the guidelines above you can delete this text from the pull request.
|
||||
32
.github/workflows/githubci.yml
vendored
Normal file
32
.github/workflows/githubci.yml
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
name: Arduino Library CI
|
||||
|
||||
on: [pull_request, push, repository_dispatch]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
repository: adafruit/ci-arduino
|
||||
path: ci
|
||||
|
||||
- name: pre-install
|
||||
run: bash ci/actions_install.sh
|
||||
|
||||
- name: test platforms
|
||||
run: python3 ci/build_platform.py metro_m4
|
||||
|
||||
- name: clang
|
||||
run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
|
||||
|
||||
- name: doxygen
|
||||
env:
|
||||
GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
|
||||
PRETTYNAME : "Adafruit Floppy Interface Library"
|
||||
run: bash ci/doxy_gen_and_deploy.sh
|
||||
226
Adafruit_Floppy.cpp
Normal file
226
Adafruit_Floppy.cpp
Normal file
|
|
@ -0,0 +1,226 @@
|
|||
#include "Adafruit_Floppy.h"
|
||||
|
||||
|
||||
#define read_index() (*indexPort & indexMask)
|
||||
#define read_data() (*dataPort & dataMask)
|
||||
|
||||
Adafruit_Floppy::Adafruit_Floppy(int8_t densitypin, int8_t indexpin, int8_t selectpin,
|
||||
int8_t motorpin, int8_t directionpin, int8_t steppin,
|
||||
int8_t wrdatapin, int8_t wrgatepin, int8_t track0pin,
|
||||
int8_t protectpin, int8_t rddatapin, int8_t sidepin,
|
||||
int8_t readypin)
|
||||
{
|
||||
_densitypin = densitypin;
|
||||
_indexpin = indexpin;
|
||||
_selectpin = selectpin;
|
||||
_motorpin = motorpin;
|
||||
_directionpin = directionpin;
|
||||
_steppin = steppin;
|
||||
_wrdatapin = wrdatapin;
|
||||
_wrgatepin = wrgatepin;
|
||||
_track0pin = track0pin;
|
||||
_protectpin = protectpin;
|
||||
_rddatapin = rddatapin;
|
||||
_sidepin = sidepin;
|
||||
_readypin = readypin;
|
||||
}
|
||||
|
||||
void Adafruit_Floppy::begin(void) {
|
||||
// deselect drive
|
||||
pinMode(_selectpin, OUTPUT);
|
||||
digitalWrite(_selectpin, HIGH);
|
||||
|
||||
// motor enable pin, drive low to turn on motor
|
||||
pinMode(_motorpin, OUTPUT);
|
||||
digitalWrite(_motorpin, HIGH);
|
||||
|
||||
// set motor direction (low is in, high is out)
|
||||
pinMode(_directionpin, OUTPUT);
|
||||
digitalWrite(_directionpin, LOW); // move inwards to start
|
||||
|
||||
// step track pin, pulse low for 3us min, 3ms max per pulse
|
||||
pinMode(_steppin, OUTPUT);
|
||||
digitalWrite(_steppin, HIGH);
|
||||
|
||||
// side selector
|
||||
pinMode(_sidepin, OUTPUT);
|
||||
digitalWrite(_sidepin, HIGH); // side 0 to start
|
||||
|
||||
pinMode(_indexpin, INPUT_PULLUP);
|
||||
pinMode(_track0pin, INPUT_PULLUP);
|
||||
pinMode(_protectpin, INPUT_PULLUP);
|
||||
pinMode(_readypin, INPUT_PULLUP);
|
||||
pinMode(_rddatapin, INPUT_PULLUP);
|
||||
|
||||
indexPort = (BusIO_PortReg *)portInputRegister(digitalPinToPort(_indexpin));
|
||||
indexMask = digitalPinToBitMask(_indexpin);
|
||||
}
|
||||
|
||||
|
||||
void Adafruit_Floppy::spin_up(void) {
|
||||
digitalWrite(_selectpin, HIGH);
|
||||
delay(10);
|
||||
// Main motor turn on
|
||||
digitalWrite(_motorpin, LOW);
|
||||
// Select drive
|
||||
digitalWrite(_selectpin, LOW);
|
||||
}
|
||||
|
||||
void Adafruit_Floppy::spin_down(void) {
|
||||
// Main motor turn off
|
||||
digitalWrite(_motorpin, HIGH);
|
||||
// De-select drive
|
||||
digitalWrite(_selectpin, HIGH);
|
||||
}
|
||||
|
||||
bool Adafruit_Floppy::goto_track(uint8_t track_num) {
|
||||
// track 0 is a very special case because its the only one we actually know we got to
|
||||
if (track_num == 0) {
|
||||
uint8_t max_steps = MAX_TRACKS;
|
||||
while (max_steps--) {
|
||||
if (!digitalRead(_track0pin)) {
|
||||
_track = 0;
|
||||
return true;
|
||||
}
|
||||
step(STEP_OUT, 1);
|
||||
}
|
||||
return false; // we 'timed' out!
|
||||
}
|
||||
if (!goto_track(0)) return false;
|
||||
step(STEP_IN, max(track_num, MAX_TRACKS-1));
|
||||
_track = track_num;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Adafruit_Floppy::step(bool dir, uint8_t times) {
|
||||
digitalWrite(_directionpin, dir);
|
||||
delayMicroseconds(10); // 1 microsecond, but we're generous
|
||||
|
||||
while (times--) {
|
||||
digitalWrite(_steppin, HIGH);
|
||||
delay(3); // 3ms min per step
|
||||
digitalWrite(_steppin, LOW);
|
||||
delay(3); // 3ms min per step
|
||||
digitalWrite(_steppin, HIGH); // end high
|
||||
}
|
||||
}
|
||||
|
||||
int8_t Adafruit_Floppy::track(void) {
|
||||
return _track;
|
||||
}
|
||||
|
||||
uint32_t Adafruit_Floppy::capture_track(uint8_t *pulses, uint32_t max_pulses) {
|
||||
uint8_t pulse_count;
|
||||
uint8_t *pulses_ptr = pulses;
|
||||
uint8_t *pulses_end = pulses + max_pulses;
|
||||
|
||||
BusIO_PortReg *dataPort, *ledPort;
|
||||
BusIO_PortMask dataMask, ledMask;
|
||||
dataPort = (BusIO_PortReg *)portInputRegister(digitalPinToPort(_rddatapin));
|
||||
dataMask = digitalPinToBitMask(_rddatapin);
|
||||
ledPort = (BusIO_PortReg *)portOutputRegister(digitalPinToPort(led_pin));
|
||||
ledMask = digitalPinToBitMask(led_pin);
|
||||
|
||||
memset(pulses, 0, max_pulses); // zero zem out
|
||||
|
||||
noInterrupts();
|
||||
wait_for_index_pulse_low();
|
||||
|
||||
// ok we have a h-to-l transition so...
|
||||
bool last_index_state = read_index();
|
||||
while (true) {
|
||||
bool index_state = read_index();
|
||||
// ahh another H to L transition, we're done with this track!
|
||||
if (last_index_state && !index_state) {
|
||||
break;
|
||||
}
|
||||
last_index_state = index_state;
|
||||
|
||||
// muahaha, now we can read track data!
|
||||
pulse_count = 0;
|
||||
// while pulse is in the low pulse, count up
|
||||
while (!read_data()) pulse_count++;
|
||||
*ledPort |= ledMask;
|
||||
|
||||
// while pulse is high, keep counting up
|
||||
while (read_data()) pulse_count++;
|
||||
*ledPort &= ~ledMask;
|
||||
|
||||
pulses_ptr[0] = pulse_count;
|
||||
pulses_ptr++;
|
||||
if (pulses_ptr == pulses_end) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// whew done
|
||||
interrupts();
|
||||
return pulses_ptr - pulses;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Adafruit_Floppy::wait_for_index_pulse_low(void) {
|
||||
// initial state
|
||||
bool index_state = read_index();
|
||||
bool last_index_state = index_state;
|
||||
|
||||
// wait until last index state is H and current state is L
|
||||
while (true) {
|
||||
index_state = read_index();
|
||||
if (last_index_state && !index_state) {
|
||||
return;
|
||||
}
|
||||
last_index_state = index_state;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Adafruit_Floppy::print_pulses(uint8_t *pulses, uint32_t num_pulses) {
|
||||
for (uint32_t i=0; i<num_pulses; i++) {
|
||||
Serial.print(pulses[i]);
|
||||
Serial.print(", ");
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void Adafruit_Floppy::print_pulse_bins(uint8_t *pulses, uint32_t num_pulses, uint8_t max_bins) {
|
||||
// lets bin em!
|
||||
uint32_t bins[max_bins][2];
|
||||
memset(bins, 0, max_bins*2*sizeof(uint32_t));
|
||||
|
||||
// we'll add each pulse to a bin so we can figure out the 3 buckets
|
||||
for (uint32_t i=0; i<num_pulses; i++) {
|
||||
uint8_t p = pulses[i];
|
||||
// find a bin for this pulse
|
||||
uint8_t bin = 0;
|
||||
for (bin=0; bin<max_bins; bin++) {
|
||||
// bin already exists? increment the count!
|
||||
if (bins[bin][0] == p) {
|
||||
bins[bin][1] ++;
|
||||
break;
|
||||
}
|
||||
if (bins[bin][0] == 0) {
|
||||
// ok we never found the bin, so lets make it this one!
|
||||
bins[bin][0] = p;
|
||||
bins[bin][1] = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bin == max_bins) Serial.println("oof we ran out of bins but we'll keep going");
|
||||
}
|
||||
// this is a very lazy way to print the bins sorted
|
||||
for (uint8_t pulse_w=1; pulse_w<255; pulse_w++) {
|
||||
for (uint8_t b=0; b<max_bins; b++) {
|
||||
if (bins[b][0] == pulse_w) {
|
||||
Serial.print(bins[b][0]);
|
||||
Serial.print(": ");
|
||||
Serial.println(bins[b][1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
52
Adafruit_Floppy.h
Normal file
52
Adafruit_Floppy.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#ifndef ADAFRUIT_FLOPPY_H
|
||||
#define ADAFRUIT_FLOPPY_H
|
||||
|
||||
#include "Arduino.h"
|
||||
#include <Adafruit_SPIDevice.h>
|
||||
|
||||
#define MAX_TRACKS 80
|
||||
#define STEP_OUT HIGH
|
||||
#define STEP_IN LOW
|
||||
#define MAX_FLUX_PULSE_PER_TRACK (500000 / 5) // 500khz / 5 hz per track rotation
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief A helper class for chattin with floppy drives
|
||||
*/
|
||||
/**************************************************************************/
|
||||
class Adafruit_Floppy {
|
||||
public:
|
||||
Adafruit_Floppy(int8_t densitypin, int8_t indexpin, int8_t selectpin,
|
||||
int8_t motorpin, int8_t directionpin, int8_t steppin,
|
||||
int8_t wrdatapin, int8_t wrgatepin, int8_t track0pin,
|
||||
int8_t protectpin, int8_t rddatapin, int8_t sidepin,
|
||||
int8_t readypin);
|
||||
void begin(void);
|
||||
void spin_up(void);
|
||||
void spin_down(void);
|
||||
bool goto_track(uint8_t track);
|
||||
uint8_t track(void);
|
||||
void step(bool dir, uint8_t times);
|
||||
|
||||
uint32_t capture_track(uint8_t *pulses, uint32_t max_pulses);
|
||||
void print_pulse_bins(uint8_t *pulses, uint32_t num_pulses, uint8_t max_bins = 64);
|
||||
void print_pulses(uint8_t *pulses, uint32_t num_pulses);
|
||||
|
||||
int8_t led_pin = LED_BUILTIN;
|
||||
|
||||
private:
|
||||
void wait_for_index_pulse_low(void);
|
||||
|
||||
// theres a lot of GPIO!
|
||||
int8_t _densitypin, _indexpin, _selectpin, _motorpin, _directionpin, _steppin,
|
||||
_wrdatapin, _wrgatepin, _track0pin, _protectpin, _rddatapin, _sidepin, _readypin;
|
||||
|
||||
int8_t _track = -1;
|
||||
|
||||
BusIO_PortReg *indexPort;
|
||||
BusIO_PortMask indexMask;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
127
code-of-conduct.md
Normal file
127
code-of-conduct.md
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
# Adafruit Community Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and leaders pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, gender identity and expression, level or type of
|
||||
experience, education, socio-economic status, nationality, personal appearance,
|
||||
race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
We are committed to providing a friendly, safe and welcoming environment for
|
||||
all.
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Be kind and courteous to others
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Collaborating with other community members
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and sexual attention or advances
|
||||
* The use of inappropriate images, including in a community member's avatar
|
||||
* The use of inappropriate language, including in a community member's nickname
|
||||
* Any spamming, flaming, baiting or other attention-stealing behavior
|
||||
* Excessive or unwelcome helping; answering outside the scope of the question
|
||||
asked
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate
|
||||
|
||||
The goal of the standards and moderation guidelines outlined here is to build
|
||||
and maintain a respectful community. We ask that you don’t just aim to be
|
||||
"technically unimpeachable", but rather try to be your best self.
|
||||
|
||||
We value many things beyond technical expertise, including collaboration and
|
||||
supporting others within our community. Providing a positive experience for
|
||||
other community members can have a much more significant impact than simply
|
||||
providing the correct answer.
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project leaders are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project leaders have the right and responsibility to remove, edit, or
|
||||
reject messages, comments, commits, code, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any community member for other behaviors that they deem
|
||||
inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Moderation
|
||||
|
||||
Instances of behaviors that violate the Adafruit Community Code of Conduct
|
||||
may be reported by any member of the community. Community members are
|
||||
encouraged to report these situations, including situations they witness
|
||||
involving other community members.
|
||||
|
||||
You may report in the following ways:
|
||||
|
||||
In any situation, you may send an email to <support@adafruit.com>.
|
||||
|
||||
On the Adafruit Discord, you may send an open message from any channel
|
||||
to all Community Helpers by tagging @community helpers. You may also send an
|
||||
open message from any channel, or a direct message to @kattni#1507,
|
||||
@tannewt#4653, @Dan Halbert#1614, @cater#2442, @sommersoft#0222, or
|
||||
@Andon#8175.
|
||||
|
||||
Email and direct message reports will be kept confidential.
|
||||
|
||||
In situations on Discord where the issue is particularly egregious, possibly
|
||||
illegal, requires immediate action, or violates the Discord terms of service,
|
||||
you should also report the message directly to Discord.
|
||||
|
||||
These are the steps for upholding our community’s standards of conduct.
|
||||
|
||||
1. Any member of the community may report any situation that violates the
|
||||
Adafruit Community Code of Conduct. All reports will be reviewed and
|
||||
investigated.
|
||||
2. If the behavior is an egregious violation, the community member who
|
||||
committed the violation may be banned immediately, without warning.
|
||||
3. Otherwise, moderators will first respond to such behavior with a warning.
|
||||
4. Moderators follow a soft "three strikes" policy - the community member may
|
||||
be given another chance, if they are receptive to the warning and change their
|
||||
behavior.
|
||||
5. If the community member is unreceptive or unreasonable when warned by a
|
||||
moderator, or the warning goes unheeded, they may be banned for a first or
|
||||
second offense. Repeated offenses will result in the community member being
|
||||
banned.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct and the enforcement policies listed above apply to all
|
||||
Adafruit Community venues. This includes but is not limited to any community
|
||||
spaces (both public and private), the entire Adafruit Discord server, and
|
||||
Adafruit GitHub repositories. Examples of Adafruit Community spaces include
|
||||
but are not limited to meet-ups, audio chats on the Adafruit Discord, or
|
||||
interaction at a conference.
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. As a community
|
||||
member, you are representing our community, and are expected to behave
|
||||
accordingly.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 1.4, available at
|
||||
<https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>,
|
||||
and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html).
|
||||
|
||||
For other projects adopting the Adafruit Community Code of
|
||||
Conduct, please contact the maintainers of those projects for enforcement.
|
||||
If you wish to use this code of conduct for your own project, consider
|
||||
explicitly mentioning your moderation policy or making a copy with your
|
||||
own moderation policy so as to avoid confusion.
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
#include <Adafruit_Floppy.h>
|
||||
|
||||
// Only tested on SAMD51 chipsets. TURN ON 180MHZ OVERCLOCK AND FASTEST OPTIMIZE!
|
||||
|
||||
#define DENSITY_PIN 5 // IDC 2
|
||||
// IDC 4 no connect
|
||||
// IDC 6 no connect
|
||||
#define INDEX_PIN 6 // IDC 8
|
||||
// IDC 10 no connect
|
||||
#define SELECT_PIN A5 // IDC 12
|
||||
// IDC 14 no connect
|
||||
#define MOTOR_PIN 9 // IDC 16
|
||||
#define DIR_PIN 10 // IDC 18
|
||||
#define STEP_PIN 11 // IDC 20
|
||||
#define READY_PIN A0 // IDC 22
|
||||
#define SIDE_PIN A1 // IDC
|
||||
#define READ_PIN 12
|
||||
#define PROT_PIN A3
|
||||
#define TRK0_PIN A4
|
||||
|
||||
#define WRDATA_PIN -1
|
||||
#define WRGATE_PIN -1
|
||||
|
||||
Adafruit_Floppy floppy(DENSITY_PIN, INDEX_PIN, SELECT_PIN,
|
||||
MOTOR_PIN, DIR_PIN, STEP_PIN,
|
||||
WRDATA_PIN, WRGATE_PIN, TRK0_PIN,
|
||||
PROT_PIN, READ_PIN, SIDE_PIN, READY_PIN);
|
||||
|
||||
// WARNING! there are 100K max flux pulses per track!
|
||||
uint8_t flux_transitions[MAX_FLUX_PULSE_PER_TRACK];
|
||||
|
||||
uint32_t time_stamp = 0;
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
while (!Serial) delay(100);
|
||||
|
||||
Serial.println("its time for a nice floppy transfer!");
|
||||
floppy.begin();
|
||||
|
||||
floppy.spin_up();
|
||||
delay(1000);
|
||||
|
||||
Serial.print("Seeking track...");
|
||||
if (! floppy.goto_track(1)) {
|
||||
Serial.println("Failed to seek to track");
|
||||
while (1) yield();
|
||||
}
|
||||
Serial.println("done!");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
uint32_t captured_flux = floppy.capture_track(flux_transitions, sizeof(flux_transitions));
|
||||
|
||||
Serial.print("Captured ");
|
||||
Serial.print(captured_flux);
|
||||
Serial.println(" flux transitions");
|
||||
|
||||
//floppy.print_pulses(flux_transitions, captured_flux);
|
||||
floppy.print_pulse_bins(flux_transitions, captured_flux);
|
||||
|
||||
if ((millis() - time_stamp) > 1000) {
|
||||
Serial.print("Ready? ");
|
||||
Serial.println(digitalRead(READY_PIN) ? "No" : "Yes");
|
||||
Serial.print("Write Protected? ");
|
||||
Serial.println(digitalRead(PROT_PIN) ? "No" : "Yes");
|
||||
Serial.print("Track 0? ");
|
||||
Serial.println(digitalRead(TRK0_PIN) ? "No" : "Yes");
|
||||
time_stamp = millis();
|
||||
}
|
||||
}
|
||||
10
library.properties
Normal file
10
library.properties
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
name=Adafruit Floppy
|
||||
version=1.0.0
|
||||
author=Adafruit
|
||||
maintainer=Adafruit <info@adafruit.com>
|
||||
sentence=Adafruit's floppy disk drive interfacing library
|
||||
paragraph=Adafruit's floppy disk drive interfacing library
|
||||
category=Communication
|
||||
url=https://github.com/adafruit/Adafruit_Floppy
|
||||
architectures=*
|
||||
depends=Adafruit BusIO
|
||||
26
license.txt
Normal file
26
license.txt
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 2019, Limor Fried for Adafruit Industries
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holders nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
Loading…
Reference in a new issue