Skip to content

Commit 8e895e1

Browse files
committed
Add floppyio for rp2040
Tested on RP2040 Feather with a 3.5" Prodigy diskette, the whole surface reads 100% across 3+ trials.
1 parent e32f0c1 commit 8e895e1

File tree

4 files changed

+43
-3
lines changed

4 files changed

+43
-3
lines changed

lib/adafruit_floppy

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* This file is part of the Micro Python project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2022 Jeff Epler for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#pragma once
28+
29+
// empirical-ish from RP2040 @ 125MHz for floppy_flux_readinto
30+
#define FLOPPYIO_SAMPLERATE (24000000)
31+
// empirical-ish from RP2040 @ 125MHz for floppy_mfm_readinto
32+
// my guess is these are slower because the more complex routine falls out of cache, but it's just
33+
// speculation because the loops are very similar. When looking at raw bins with a modified
34+
// version of adafruit_floppy, it can be seen that there are _two_ peaks for T2 and T3, rather
35+
// than a single one, around 36 (mostly) and 43 (rarer), compared to a single peak around 48.
36+
#define T2_5 (54)
37+
#define T3_5 (75)

ports/raspberrypi/mpconfigport.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CIRCUITPY_ALARM ?= 1
55

66
CIRCUITPY_RP2PIO ?= 1
77
CIRCUITPY_NEOPIXEL_WRITE ?= $(CIRCUITPY_RP2PIO)
8+
CIRCUITPY_FLOPPYIO ?= 1
89
CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_DISPLAYIO)
910
CIRCUITPY_FULL_BUILD ?= 1
1011
CIRCUITPY_AUDIOMP3 ?= 1

shared-module/floppyio/__init__.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,19 @@
2424
* THE SOFTWARE.
2525
*/
2626

27-
#include "hal_gpio.h"
28-
2927
#include "py/runtime.h"
3028

3129
#include "shared-bindings/time/__init__.h"
3230
#include "shared-bindings/floppyio/__init__.h"
3331
#include "common-hal/floppyio/__init__.h"
3432
#include "shared-bindings/digitalio/DigitalInOut.h"
3533

34+
#ifndef T2_5
3635
#define T2_5 (FLOPPYIO_SAMPLERATE * 5 / 2 / 1000000)
36+
#endif
37+
#ifndef T3_5
3738
#define T3_5 (FLOPPYIO_SAMPLERATE * 7 / 2 / 1000000)
39+
#endif
3840

3941
#define MFM_IO_MMIO (1)
4042
#include "lib/adafruit_floppy/src/mfm_impl.h"

0 commit comments

Comments
 (0)