Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port RunCPM to the Metro RP2350 with HSTX #2978

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library.deps
Original file line number Diff line number Diff line change
@@ -1 +1 @@
depends=Adafruit ILI9341, Adafruit BusIO, SD, Adafruit NeoPixel, Adafruit VS1053 Library, Adafruit BluefruitLE nRF51, Adafruit seesaw Library, Ethernet, Adafruit IO Arduino, FastLED, Adafruit LiquidCrystal, Adafruit SoftServo, TinyWireM, Adafruit AM radio library, WaveHC, Adafruit LED Backpack Library, MAX31850 OneWire, Adafruit VC0706 Serial Camera Library, RTClib, Adafruit SleepyDog Library, Adafruit Thermal Printer Library, Adafruit Zero I2S Library, Adafruit EPD, Adafruit SSD1351 library, Adafruit FONA Library, Adafruit Motor Shield V2 Library, Adafruit NeoMatrix, Adafruit Soundboard library, Adafruit Circuit Playground, ArduinoJson, Adafruit TCS34725, Adafruit Pixie, Adafruit GPS Library, TinyGPS, WiFi101, Adafruit DotStar, Adafruit Si7021 Library, Adafruit WS2801 Library, Mouse, Keyboard, Time, IRremote, Adafruit LSM9DS0 Library, Adafruit Arcada Library, MIDIUSB, PubSubClient, Adafruit LIS2MDL, Adafruit NeoPXL8, Adafruit MCP23017 Arduino Library, Adafruit MLX90640, LiquidCrystal, Adafruit NeoTrellis M4 Library, RGB matrix Panel, Adafruit MLX90614 Library, Adafruit RGB LCD Shield Library, MAX6675 library, Adafruit MP3, Adafruit Keypad, Adafruit Arcada GifDecoder, Keypad, Neosegment, Encoder, Adafruit TiCoServo, Adafruit Trellis Library, FauxmoESP, Adafruit LSM303 Accel, Adafruit LSM303DLH Mag, Adafruit LSM303DLHC, CapacitiveSensor, Adafruit Zero PDM Library, Adafruit DMA neopixel library, elapsedMillis, DST RTC, Adafruit SHARP Memory Display, Adafruit SPIFlash, BSEC Software Library, WiiChuck, Adafruit DPS310, Adafruit AHTX0, RotaryEncoder, Adafruit MCP9808 Library, LSM303, Adafruit Protomatter, Adafruit IS31FL3741 Library, Sensirion I2C SCD4x, Adafruit TestBed, Bounce2, Adafruit AHRS, Adafruit DRV2605 Library, STM32duino VL53L4CD, PicoDVI - Adafruit Fork, Adafruit MMA8451 Library, Adafruit TSC2007, GFX Library for Arduino, Adafruit PyCamera Library, Adafruit ADG72x, Adafruit BNO055, Adafruit SHT4x Library, Adafruit VCNL4200 Library, Adafruit GC9A01A
depends=Adafruit ILI9341, Adafruit BusIO, SD, Adafruit NeoPixel, Adafruit VS1053 Library, Adafruit BluefruitLE nRF51, Adafruit seesaw Library, Ethernet, Adafruit IO Arduino, FastLED, Adafruit LiquidCrystal, Adafruit SoftServo, TinyWireM, Adafruit AM radio library, WaveHC, Adafruit LED Backpack Library, MAX31850 OneWire, Adafruit VC0706 Serial Camera Library, RTClib, Adafruit SleepyDog Library, Adafruit Thermal Printer Library, Adafruit Zero I2S Library, Adafruit EPD, Adafruit SSD1351 library, Adafruit FONA Library, Adafruit Motor Shield V2 Library, Adafruit NeoMatrix, Adafruit Soundboard library, Adafruit Circuit Playground, ArduinoJson, Adafruit TCS34725, Adafruit Pixie, Adafruit GPS Library, TinyGPS, WiFi101, Adafruit DotStar, Adafruit Si7021 Library, Adafruit WS2801 Library, Mouse, Keyboard, Time, IRremote, Adafruit LSM9DS0 Library, Adafruit Arcada Library, MIDIUSB, PubSubClient, Adafruit LIS2MDL, Adafruit NeoPXL8, Adafruit MCP23017 Arduino Library, Adafruit MLX90640, LiquidCrystal, Adafruit NeoTrellis M4 Library, RGB matrix Panel, Adafruit MLX90614 Library, Adafruit RGB LCD Shield Library, MAX6675 library, Adafruit MP3, Adafruit Keypad, Adafruit Arcada GifDecoder, Keypad, Neosegment, Encoder, Adafruit TiCoServo, Adafruit Trellis Library, FauxmoESP, Adafruit LSM303 Accel, Adafruit LSM303DLH Mag, Adafruit LSM303DLHC, CapacitiveSensor, Adafruit Zero PDM Library, Adafruit DMA neopixel library, elapsedMillis, DST RTC, Adafruit SHARP Memory Display, Adafruit SPIFlash, BSEC Software Library, WiiChuck, Adafruit DPS310, Adafruit AHTX0, RotaryEncoder, Adafruit MCP9808 Library, LSM303, Adafruit Protomatter, Adafruit IS31FL3741 Library, Sensirion I2C SCD4x, Adafruit TestBed, Bounce2, Adafruit AHRS, Adafruit DRV2605 Library, STM32duino VL53L4CD, PicoDVI - Adafruit Fork, Adafruit MMA8451 Library, Adafruit TSC2007, GFX Library for Arduino, Adafruit PyCamera Library, Adafruit ADG72x, Adafruit BNO055, Adafruit SHT4x Library, Adafruit VCNL4200 Library, Adafruit GC9A01A, Adafruit DVI HSTX
43 changes: 32 additions & 11 deletions runcpm-rp2040-dvi-usb/keyboard-copro/keyboard-copro.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include "pio_usb.h"
#include "Adafruit_TinyUSB.h"
#include "pico/stdlib.h"
#include "Adafruit_dvhstx.h"

DVHSTXText3 display(DVHSTX_PINOUT_DEFAULT);

// Pin D+ for host, D- = D+ + 1
#ifndef PIN_USB_HOST_DP
Expand All @@ -28,16 +31,22 @@ Adafruit_USBH_Host USBHost;
SerialPIO pio_serial(1 /* RX of the sibling board */, SerialPIO::NOPIN);

void setup() {
// ensure text generation interrupt takes place on core0
display.begin();
display.println("Hello hstx\n");
}

void loop() {
}

void setup1() {

while(!display) ;
delay(10);
display.println("Hello hstx in setup1\n");
// override tools menu CPU frequency setting
set_sys_clock_khz(120'000, true);
//set_sys_clock_khz(264'000, true);

Serial.begin(115200);
#if 0
while ( !Serial ) delay(10); // wait for native usb
Serial.println("Core1 setup to run TinyUSB host with pio-usb");
Expand All @@ -50,6 +59,9 @@ void setup1() {

pio_usb_configuration_t pio_cfg = PIO_USB_DEFAULT_CONFIG;
pio_cfg.pin_dp = PIN_USB_HOST_DP;
pio_cfg.tx_ch = dma_claim_unused_channel(true);
dma_channel_unclaim(pio_cfg.tx_ch);

USBHost.configure_pio_usb(1, &pio_cfg);

// run host stack on controller (rhport) 1
Expand All @@ -59,6 +71,8 @@ void setup1() {

// this `begin` is a void function, no way to check for failure!
pio_serial.begin(115200);
display.println("end of setup1\n");
display.show_cursor();
}

int old_ascii = -1;
Expand All @@ -70,16 +84,21 @@ const uint32_t initial_repeat_time = 500;
void send_ascii(uint8_t code, uint32_t repeat_time=default_repeat_time) {
old_ascii = code;
repeat_timeout = millis() + repeat_time;
if (code > 32 && code < 127) {
Serial.printf("'%c'\r\n", code);
if (code >= 32 && code < 127) {
display.printf("%c", code);
} else {
Serial.printf("'\\x%02x'\r\n", code);
display.printf("\\x%02x", code);
}
pio_serial.write(code);
}

void loop1()
{
static bool last_serial;
if (!last_serial && Serial) {
last_serial = true;
Serial.println("Hello host serial");
}
uint32_t now = millis();
uint32_t deadline = repeat_timeout - now;
if (old_ascii >= 0 && deadline > INT32_MAX) {
Expand Down Expand Up @@ -166,12 +185,12 @@ bool report_contains(const hid_keyboard_report_t &report, uint8_t key) {

hid_keyboard_report_t old_report;

static bool caps, num;
static uint8_t old_leds;
void process_event(uint8_t dev_addr, uint8_t instance, const hid_keyboard_report_t &report) {
bool alt = report.modifier & 0x44;
bool shift = report.modifier & 0x22;
bool ctrl = report.modifier & 0x11;
bool caps = old_report.reserved & 1;
bool num = old_report.reserved & 2;
uint8_t code = 0;

if (report.keycode[0] == 1 && report.keycode[1] == 1) {
Expand All @@ -188,8 +207,10 @@ void process_event(uint8_t dev_addr, uint8_t instance, const hid_keyboard_report

/* key is newly pressed */
if (keycode == HID_KEY_NUM_LOCK) {
Serial.println("toggle numlock");
num = !num;
} else if (keycode == HID_KEY_CAPS_LOCK) {
Serial.println("toggle capslock");
caps = !caps;
} else {
for (const auto &mapper : keycode_to_ascii) {
Expand Down Expand Up @@ -219,15 +240,15 @@ void process_event(uint8_t dev_addr, uint8_t instance, const hid_keyboard_report
}
}

uint8_t leds = (caps | (num << 1));
if (leds != old_report.reserved) {
uint8_t leds = (caps << 1) | num;
if (leds != old_leds) {
old_leds = leds;
Serial.printf("Send LEDs report %d (dev:instance = %d:%d)\r\n", leds, dev_addr, instance);
// no worky
auto r = tuh_hid_set_report(dev_addr, instance/*idx*/, 0/*report_id*/, HID_REPORT_TYPE_OUTPUT/*report_type*/, &leds, sizeof(leds));
auto r = tuh_hid_set_report(dev_addr, instance/*idx*/, 0/*report_id*/, HID_REPORT_TYPE_OUTPUT/*report_type*/, &old_leds, sizeof(old_leds));
Serial.printf("set_report() -> %d\n", (int)r);
}
old_report = report;
old_report.reserved = leds;
}

// Invoked when received report from device via interrupt endpoint
Expand Down
Empty file.
21 changes: 21 additions & 0 deletions runcpm-rp2350-hstx-usb/runcpm-pico/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Mockba the Borg

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
31 changes: 31 additions & 0 deletions runcpm-rp2350-hstx-usb/runcpm-pico/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--
SPDX-FileCopyrightText: 2023 Jeff Epler for Adafruit Industries

SPDX-License-Identifier: MIT
-->

This is a port of runcpm to the raspberry pi pico.

It is based on:
* [RunCPM](https://github.com/MockbaTheBorg/RunCPM/)
* [RunCPM_RPi_Pico](https://github.com/guidol70/RunCPM_RPi_Pico)

It works on a Raspberry Pi Pico (or Pico W). It uses the internal flash
for storage, and can be mounted as USB storage.

If your Pico is placed on the Pico DV carrier board, you also get a 100x30
character screen to enjoy your CP/M output on!

First, build for your device. You must
* Use the Philhower Pico Core
* In the Tools menu, select
* A flash size option that includes at least 512kB for filesystem
* USB Stack: Adafruit TinyUSB

After it boots the first time, you need to
* Format the flash device on your host computer
* Create the folder "<DEVICE>/A/0"
* Put something useful in that folder, such as [Zork](http://www.retroarchive.org/cpm/games/zork123_80.zip)
* Files must respect the "8.3" naming convention (8 letters filename + 3 letters extension) and be all uppercase
* Safely eject the drive, then reset the emulator.
* Now at the "A0>" prompt you can run "ZORK1".
Loading
Loading