├── .gitignore ├── flash-rp2040 ├── picosim.md5 ├── picosim.uf2 └── picosim.info ├── libs ├── no-OS-FatFS-SD-SDIO-SPI-RPi-Pico │ ├── examples │ │ ├── simple │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── CMakeLists.txt │ │ │ ├── main.c │ │ │ └── hw_config.c │ │ ├── unix_like │ │ │ ├── .gitignore │ │ │ └── CMakeLists.txt │ │ ├── block_device │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── main.c │ │ │ ├── hw_config.c │ │ │ └── CMakeLists.txt │ │ ├── command_line │ │ │ ├── .gitignore │ │ │ ├── include │ │ │ │ ├── command.h │ │ │ │ └── tests.h │ │ │ └── config │ │ │ │ ├── maker_pi_pico.hw_config.c │ │ │ │ ├── thing_plus.hw_config.c │ │ │ │ └── exp_mod_A_SPI.hw_config.c │ │ ├── dynamic_config │ │ │ ├── .gitignore │ │ │ └── CMakeLists.txt │ │ ├── simple_sdio │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ └── CMakeLists.txt │ │ ├── stdio_buffering │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── hw_config.c │ │ │ └── CMakeLists.txt │ │ ├── usb_mass_storage │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── CMakeLists.txt │ │ │ ├── include │ │ │ │ └── tusb_config.h │ │ │ └── main.c │ │ └── PlatformIO │ │ │ ├── bench2 │ │ │ ├── .gitignore │ │ │ ├── test │ │ │ │ └── README │ │ │ ├── lib │ │ │ │ └── README │ │ │ ├── include │ │ │ │ └── README │ │ │ └── platformio.ini │ │ │ ├── hw_debug │ │ │ ├── .gitignore │ │ │ ├── add_aon.py │ │ │ └── platformio.ini │ │ │ ├── one_SDIO │ │ │ ├── .gitignore │ │ │ ├── platformio.ini │ │ │ └── include │ │ │ │ └── README │ │ │ ├── one_SPI.C │ │ │ ├── .gitignore │ │ │ ├── platformio.ini │ │ │ └── include │ │ │ │ └── README │ │ │ ├── data_logger │ │ │ ├── .gitignore │ │ │ ├── include │ │ │ │ └── README │ │ │ └── platformio.ini │ │ │ ├── one_SPI.C++ │ │ │ ├── .gitignore │ │ │ ├── include │ │ │ │ └── README │ │ │ └── platformio.ini │ │ │ ├── one_SPI_one_SDIO │ │ │ ├── .gitignore │ │ │ ├── platformio.ini │ │ │ └── include │ │ │ │ └── README │ │ │ └── one_SPI_one_SDIO.dir_ops │ │ │ ├── .gitignore │ │ │ ├── platformio.ini │ │ │ └── include │ │ │ └── README │ ├── .gitignore │ ├── src │ │ ├── sd_driver │ │ │ ├── dma_interrupts.h │ │ │ ├── SPI │ │ │ │ ├── sd_card_spi.h │ │ │ │ └── sd_spi.c │ │ │ └── sd_timeouts.c │ │ ├── include │ │ │ ├── file_stream.h │ │ │ ├── sd_timeouts.h │ │ │ ├── my_rtc.h │ │ │ ├── f_util.h │ │ │ ├── hw_config.h │ │ │ ├── delays.h │ │ │ ├── crc.h │ │ │ ├── ff_stdio.h │ │ │ └── util.h │ │ ├── ff15 │ │ │ ├── source │ │ │ │ ├── 00readme.txt │ │ │ │ └── diskio.h │ │ │ ├── documents │ │ │ │ └── res │ │ │ │ │ ├── app1.c │ │ │ │ │ ├── app5.c │ │ │ │ │ ├── app6.c │ │ │ │ │ └── app2.c │ │ │ └── LICENSE.txt │ │ ├── ZuluSCSI-firmware │ │ │ └── LICENSE │ │ ├── src │ │ │ ├── util.c │ │ │ └── FatFsSd.cpp │ │ ├── SdFat │ │ │ └── LICENSE.md │ │ ├── CMakeLists.txt │ │ └── mbed-os │ │ │ └── README.md │ └── include │ │ ├── FatFsSd_C.h │ │ └── FsLib │ │ ├── FsNew.cpp │ │ ├── FsLib.h │ │ ├── FsNew.h │ │ ├── FsFormatter.h │ │ └── FsVolume.cpp ├── pico-ds3231 │ ├── .gitignore │ ├── lib │ │ └── CMakeLists.txt │ ├── examples │ │ ├── set_time │ │ │ ├── CMakeLists.txt │ │ │ └── set_time.c │ │ ├── hello_ds3231 │ │ │ ├── CMakeLists.txt │ │ │ └── hello_ds3231.c │ │ └── read_temperature │ │ │ ├── CMakeLists.txt │ │ │ └── read_temperature.c │ ├── LICENSE │ └── README.md └── stdio_msc_usb │ ├── README.txt │ ├── CMakeLists.txt │ └── include │ └── tusb_config.h ├── flash-rp2350-arm-s ├── picosim.md5 ├── picosim.uf2 └── picosim.info ├── flash-rp2350-riscv ├── picosim.md5 ├── picosim.uf2 └── picosim.info ├── disks ├── comms.dsk ├── cpm22.dsk ├── cpm3-1.dsk ├── cpm3-2.dsk ├── cpm3gen.dsk ├── dazzler.dsk ├── empty.dsk ├── fig80.dsk ├── mpm-1.dsk ├── mpm-2.dsk ├── ucsd1.dsk ├── ucsd2.dsk ├── ucsdint.dsk ├── ucsdgame.dsk └── README ├── resources ├── MPM.png ├── RTC.jpg ├── 8080-CPU.png ├── micro80.jpg ├── terminal.jpg └── usb-ser.jpg ├── srccpm2 ├── cpm.bin ├── Makefile └── boot.asm ├── srccpm3 ├── ccp.bin ├── cpmldr.bin ├── Makefile └── boot.asm ├── srcmpm ├── mpmldr.bin ├── Makefile ├── boot.asm └── putsys.c ├── srcsim ├── debug.h ├── fonts │ ├── CMakeLists.txt │ └── Makefile ├── picosim.h ├── dazzler.h ├── bootrom.c ├── rebuildflash.sh ├── simcfg.h ├── simio.h ├── lcd_dev.h ├── simport.h ├── gpio.h ├── lcd.h ├── debug.c ├── disks.h ├── simmem.c ├── sim.h └── uart_tx.pio ├── src-examples ├── tb.bin ├── blink.bin ├── life.bin ├── bas4k32.bin ├── bas8k40.bin ├── kscope.bin ├── micro80.bin ├── serial.bin ├── bas16k40.bin ├── test8080.bin ├── blink.asm ├── Makefile ├── README ├── serial.asm ├── blink.lis └── kscope.asm ├── .gitattributes ├── roms ├── Makefile ├── bootrom.asm └── bootrom.lis ├── .editorconfig ├── cpmtools ├── swlcd.asm └── Makefile ├── srcucsd-iv ├── Makefile └── putsys.c └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /flash-rp2040/picosim.md5: -------------------------------------------------------------------------------- 1 | f2a15857ae88b4bd9ca011d8132949f6 picosim.uf2 2 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/simple/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/unix_like/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /flash-rp2350-arm-s/picosim.md5: -------------------------------------------------------------------------------- 1 | fc201aca4df91bcea970eaa4dd853f8c picosim.uf2 2 | -------------------------------------------------------------------------------- /flash-rp2350-riscv/picosim.md5: -------------------------------------------------------------------------------- 1 | dc93f06b172e4e7767e884f13b1dcf0f picosim.uf2 2 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/block_device/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/command_line/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/dynamic_config/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/simple_sdio/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/stdio_buffering/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /disks/comms.dsk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/disks/comms.dsk -------------------------------------------------------------------------------- /disks/cpm22.dsk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/disks/cpm22.dsk -------------------------------------------------------------------------------- /disks/cpm3-1.dsk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/disks/cpm3-1.dsk -------------------------------------------------------------------------------- /disks/cpm3-2.dsk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/disks/cpm3-2.dsk -------------------------------------------------------------------------------- /disks/cpm3gen.dsk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/disks/cpm3gen.dsk -------------------------------------------------------------------------------- /disks/dazzler.dsk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/disks/dazzler.dsk -------------------------------------------------------------------------------- /disks/empty.dsk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/disks/empty.dsk -------------------------------------------------------------------------------- /disks/fig80.dsk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/disks/fig80.dsk -------------------------------------------------------------------------------- /disks/mpm-1.dsk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/disks/mpm-1.dsk -------------------------------------------------------------------------------- /disks/mpm-2.dsk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/disks/mpm-2.dsk -------------------------------------------------------------------------------- /disks/ucsd1.dsk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/disks/ucsd1.dsk -------------------------------------------------------------------------------- /disks/ucsd2.dsk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/disks/ucsd2.dsk -------------------------------------------------------------------------------- /disks/ucsdint.dsk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/disks/ucsdint.dsk -------------------------------------------------------------------------------- /resources/MPM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/resources/MPM.png -------------------------------------------------------------------------------- /resources/RTC.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/resources/RTC.jpg -------------------------------------------------------------------------------- /srccpm2/cpm.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/srccpm2/cpm.bin -------------------------------------------------------------------------------- /srccpm3/ccp.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/srccpm3/ccp.bin -------------------------------------------------------------------------------- /srcmpm/mpmldr.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/srcmpm/mpmldr.bin -------------------------------------------------------------------------------- /srcsim/debug.h: -------------------------------------------------------------------------------- 1 | extern void debug_init(void); 2 | extern void debug_puts(const char *s); 3 | -------------------------------------------------------------------------------- /disks/ucsdgame.dsk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/disks/ucsdgame.dsk -------------------------------------------------------------------------------- /src-examples/tb.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/src-examples/tb.bin -------------------------------------------------------------------------------- /srccpm3/cpmldr.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/srccpm3/cpmldr.bin -------------------------------------------------------------------------------- /resources/8080-CPU.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/resources/8080-CPU.png -------------------------------------------------------------------------------- /resources/micro80.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/resources/micro80.jpg -------------------------------------------------------------------------------- /resources/terminal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/resources/terminal.jpg -------------------------------------------------------------------------------- /resources/usb-ser.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/resources/usb-ser.jpg -------------------------------------------------------------------------------- /src-examples/blink.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/src-examples/blink.bin -------------------------------------------------------------------------------- /src-examples/life.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/src-examples/life.bin -------------------------------------------------------------------------------- /flash-rp2040/picosim.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/flash-rp2040/picosim.uf2 -------------------------------------------------------------------------------- /src-examples/bas4k32.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/src-examples/bas4k32.bin -------------------------------------------------------------------------------- /src-examples/bas8k40.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/src-examples/bas8k40.bin -------------------------------------------------------------------------------- /src-examples/kscope.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/src-examples/kscope.bin -------------------------------------------------------------------------------- /src-examples/micro80.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/src-examples/micro80.bin -------------------------------------------------------------------------------- /src-examples/serial.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/src-examples/serial.bin -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/usb_mass_storage/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | build/ 3 | *.swp 4 | -------------------------------------------------------------------------------- /libs/pico-ds3231/.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | **/.history 3 | **/build/* 4 | *.swp 5 | html 6 | docs 7 | datasheets 8 | -------------------------------------------------------------------------------- /src-examples/bas16k40.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/src-examples/bas16k40.bin -------------------------------------------------------------------------------- /src-examples/test8080.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/src-examples/test8080.bin -------------------------------------------------------------------------------- /flash-rp2350-arm-s/picosim.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/flash-rp2350-arm-s/picosim.uf2 -------------------------------------------------------------------------------- /flash-rp2350-riscv/picosim.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udo-munk/RP2xxx-GEEK-80/HEAD/flash-rp2350-riscv/picosim.uf2 -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/bench2/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode/.browse.c_cpp.db* 3 | .vscode/c_cpp_properties.json 4 | .vscode/launch.json 5 | .vscode/ipch 6 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/hw_debug/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode/.browse.c_cpp.db* 3 | .vscode/c_cpp_properties.json 4 | .vscode/launch.json 5 | .vscode/ipch 6 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/one_SDIO/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode/.browse.c_cpp.db* 3 | .vscode/c_cpp_properties.json 4 | .vscode/launch.json 5 | .vscode/ipch 6 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/one_SPI.C/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode/.browse.c_cpp.db* 3 | .vscode/c_cpp_properties.json 4 | .vscode/launch.json 5 | .vscode/ipch 6 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/data_logger/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode/.browse.c_cpp.db* 3 | .vscode/c_cpp_properties.json 4 | .vscode/launch.json 5 | .vscode/ipch 6 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/one_SPI.C++/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode/.browse.c_cpp.db* 3 | .vscode/c_cpp_properties.json 4 | .vscode/launch.json 5 | .vscode/ipch 6 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/one_SPI_one_SDIO/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode/.browse.c_cpp.db* 3 | .vscode/c_cpp_properties.json 4 | .vscode/launch.json 5 | .vscode/ipch 6 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/one_SPI_one_SDIO.dir_ops/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode/.browse.c_cpp.db* 3 | .vscode/c_cpp_properties.json 4 | .vscode/launch.json 5 | .vscode/ipch 6 | -------------------------------------------------------------------------------- /srcsim/fonts/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(fonts INTERFACE) 2 | 3 | target_sources(fonts INTERFACE 4 | font12.c 5 | font14.c 6 | font16.c 7 | font18.c 8 | font20.c 9 | font22.c 10 | font24.c 11 | font28.c 12 | font32.c 13 | ) 14 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | # Don't show diffs for binary files and don't do end-of-line conversion 4 | *.bin -diff -text 5 | *.dsk -diff -text 6 | *.png -diff -text 7 | *.jpg -diff -text 8 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/.gitignore: -------------------------------------------------------------------------------- 1 | **/build 2 | **/cppcheck_project-cppcheck-build-dir 3 | *.html 4 | *.png 5 | *.zip 6 | *.xlsx 7 | *.bak 8 | **/.vscode 9 | *.tar.gz 10 | PlatformIO.notes.txt 11 | examples/command_line/cppcheck_project.cppcheck 12 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/sd_driver/dma_interrupts.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "pico.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | void dma_irq_add_handler(const uint num, bool exclusive); 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | -------------------------------------------------------------------------------- /srcsim/picosim.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Z80SIM - a Z80-CPU simulator 3 | * 4 | * Copyright (C) 2024 by Udo Munk & Thomas Eberhardt 5 | */ 6 | 7 | #ifndef PICOSIM_INC 8 | #define PICOSIM_INC 9 | 10 | extern int speed, initial_lcd; 11 | 12 | extern float read_onboard_temp(void); 13 | 14 | #endif /* !PICOSIM_INC */ 15 | -------------------------------------------------------------------------------- /roms/Makefile: -------------------------------------------------------------------------------- 1 | Z80ASMDIR = ../../z80pack/z80asm 2 | Z80ASM = $(Z80ASMDIR)/z80asm 3 | Z80ASMFLAGS = -l -T -sn -p0 4 | 5 | all: ../srcsim/bootrom.c 6 | 7 | ../srcsim/bootrom.c: bootrom.asm $(Z80ASM) 8 | $(Z80ASM) $(Z80ASMFLAGS) -fc -o../srcsim/bootrom.c $< 9 | 10 | $(Z80ASM): FORCE 11 | $(MAKE) -C $(Z80ASMDIR) 12 | 13 | FORCE: 14 | 15 | .PHONY: all FORCE 16 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://editorconfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | [*] 7 | end_of_line = lf 8 | insert_final_newline = true 9 | charset = utf-8 10 | 11 | [{Makefile,*.{asm,c,cpp,h,mac}}] 12 | indent_style = tab 13 | indent_size = 8 14 | trim_trailing_whitespace = true 15 | 16 | [*.md] 17 | indent_style = tab 18 | indent_size = 8 19 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/command_line/include/command.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | // 5 | #include "pico/stdlib.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | extern bool logger_enabled; 12 | extern const uint32_t period; 13 | extern absolute_time_t next_log_time; 14 | 15 | void process_stdio(int cRxedChar); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /libs/pico-ds3231/lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(pico-ds3231 INTERFACE) 2 | 3 | target_include_directories(pico-ds3231 4 | INTERFACE 5 | ${CMAKE_CURRENT_LIST_DIR}/include 6 | ) 7 | 8 | target_link_libraries(pico-ds3231 9 | INTERFACE 10 | hardware_i2c 11 | ) 12 | 13 | target_sources(pico-ds3231 14 | INTERFACE 15 | ${CMAKE_CURRENT_LIST_DIR}/ds3231.c 16 | ${CMAKE_CURRENT_LIST_DIR}/include/ds3231.h 17 | ) 18 | -------------------------------------------------------------------------------- /srcsim/dazzler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Emulation of Cromemco Dazzler on the RP2040/RP2350-GEEK LCD 3 | * 4 | * Copyright (C) 2015-2019 by Udo Munk 5 | * Copyright (C) 2024 by Thomas Eberhardt 6 | */ 7 | 8 | #ifndef DAZZLER_INC 9 | #define DAZZLER_INC 10 | 11 | #include "sim.h" 12 | #include "simdefs.h" 13 | 14 | extern void dazzler_ctl_out(BYTE data), dazzler_format_out(BYTE data); 15 | extern BYTE dazzler_flags_in(void); 16 | 17 | #endif /* !DAZZLER_INC */ 18 | -------------------------------------------------------------------------------- /srcsim/bootrom.c: -------------------------------------------------------------------------------- 1 | // build from source file bootrom.asm 2 | unsigned char code[MEMSIZE] = { 3 | 0xf3, 0xaf, 0x32, 0x00, 0xf0, 0x32, 0x02, 0xf0, 0x32, 0x03, 0xf0, 0x3e, 4 | 0x01, 0x32, 0x01, 0xf0, 0x3e, 0x10, 0xd3, 0x04, 0x3e, 0x00, 0xd3, 0x04, 5 | 0x3e, 0xf0, 0xd3, 0x04, 0x3e, 0x20, 0xd3, 0x04, 0xdb, 0x04, 0xb7, 0xca, 6 | 0x00, 0x00, 0xfe, 0x02, 0xca, 0x00, 0x00, 0x76 7 | }; 8 | unsigned short code_length = 44; 9 | unsigned short code_load_addr = 0xff00; 10 | -------------------------------------------------------------------------------- /srcsim/rebuildflash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Rebuild all flash images on Linux (needs picotool) 3 | for i in rp2040 rp2350-arm-s rp2350-riscv 4 | do 5 | rm -rf build 6 | mkdir build 7 | cd build 8 | cmake -D PICO_PLATFORM=$i -G "Unix Makefiles" .. 9 | make -j 10 | FLASHDIR=../../flash-$i 11 | rm -rf $FLASHDIR 12 | mkdir $FLASHDIR 13 | cp picosim.uf2 $FLASHDIR 14 | md5sum picosim.uf2 >$FLASHDIR/picosim.md5 15 | picotool info -a picosim.uf2 >$FLASHDIR/picosim.info 16 | cd .. 17 | done 18 | rm -rf build 19 | -------------------------------------------------------------------------------- /cpmtools/swlcd.asm: -------------------------------------------------------------------------------- 1 | ; Switch to next LCD status display tool 2 | ; 3 | ; Copyright (C) 2024 by Thomas Eberhardt 4 | ; 5 | title 'Switch to next LCD status display tool' 6 | 7 | .8080 8 | aseg 9 | org 100h 10 | 11 | hwctl equ 0a0h 12 | hwunlk equ 0aah 13 | lcdnext equ 8 14 | 15 | in hwctl ; check if hardware control port is unlocked 16 | ora a 17 | jz unlckd 18 | mvi a,hwunlk ; unlock hardware control port 19 | out hwctl 20 | unlckd: mvi a,lcdnext ; switch to next LCD status display 21 | out hwctl 22 | ret 23 | 24 | end 25 | -------------------------------------------------------------------------------- /srcsim/simcfg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Z80SIM - a Z80-CPU simulator 3 | * 4 | * Copyright (C) 2024 by Udo Munk & Thomas Eberhardt 5 | * 6 | * This module configures the machine appropriate for the 7 | * Z80/8080 software we want to run on it. 8 | * 9 | * History: 10 | * 23-APR-2024 dummy, no configuration implemented yet 11 | * 12-MAY-2024 implemented configuration dialog 12 | * 28-MAY-2024 implemented mount/unmount of disk images 13 | */ 14 | 15 | #ifndef SIMCFG_INC 16 | #define SIMCFG_INC 17 | 18 | extern void config(void); 19 | 20 | #endif /* !SIMCFG_INC */ 21 | -------------------------------------------------------------------------------- /srcsim/simio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Z80SIM - a Z80-CPU simulator 3 | * 4 | * Copyright (C) 2024-2025 by Udo Munk & Thomas Eberhardt 5 | */ 6 | 7 | #ifndef SIMIO_INC 8 | #define SIMIO_INC 9 | 10 | #include "sim.h" 11 | #include "simdefs.h" 12 | 13 | #define IO_DATA_UNUSED 0xff /* data returned on unused ports */ 14 | 15 | extern BYTE fp_value; 16 | extern int cons_data_bits; 17 | 18 | extern in_func_t *const port_in[256]; 19 | extern out_func_t *const port_out[256]; 20 | 21 | extern void init_io(void); 22 | extern void exit_io(void); 23 | 24 | #endif /* !SIMIO_INC */ 25 | -------------------------------------------------------------------------------- /srcsim/lcd_dev.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Functions for communicating with the RP2040/RP2350-GEEK LCD 3 | * (based on Waveshare example code) 4 | * 5 | * Copyright (C) 2024 by Thomas Eberhardt 6 | */ 7 | 8 | #ifndef LCD_DEV_INC 9 | #define LCD_DEV_INC 10 | 11 | #include 12 | 13 | #include "draw.h" 14 | 15 | extern void lcd_dev_init(uint8_t backlight); 16 | extern void lcd_dev_exit(void); 17 | extern void lcd_dev_backlight(uint8_t value); 18 | extern void lcd_dev_rotation(bool rotated); 19 | extern void lcd_dev_send_pixmap(draw_pixmap_t *pixmap); 20 | 21 | #endif /* !LCD_DEV_INC */ 22 | -------------------------------------------------------------------------------- /cpmtools/Makefile: -------------------------------------------------------------------------------- 1 | Z80ASMDIR = ../../z80pack/z80asm 2 | Z80ASM = $(Z80ASMDIR)/z80asm 3 | Z80ASMFLAGS = -8 -l -T -sn -p0 4 | 5 | all: swlcd.com xmodem29.com 6 | 7 | swlcd.com: swlcd.asm $(Z80ASM) 8 | $(Z80ASM) $(Z80ASMFLAGS) -fb -o$@ $< 9 | 10 | xmodem29.com: xmodem29.asm $(Z80ASM) 11 | $(Z80ASM) $(Z80ASMFLAGS) -fb -o$@ $< 12 | 13 | $(Z80ASM): FORCE 14 | $(MAKE) -C $(Z80ASMDIR) 15 | 16 | FORCE: 17 | 18 | install: 19 | 20 | uninstall: 21 | 22 | clean: 23 | rm -f swlcd.com swlcd.lis xmodem29.com xmodem29.lis 24 | 25 | distclean: clean 26 | 27 | .PHONY: all FORCE install uninstall clean distclean 28 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/command_line/include/tests.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | int lliot(size_t pnum); 9 | void ls(const char *dir); 10 | void simple(); 11 | void bench(char const* logdrv); 12 | void big_file_test(const char *const pathname, size_t size, 13 | uint32_t seed); 14 | void vCreateAndVerifyExampleFiles(const char *pcMountPath); 15 | void vStdioWithCWDTest(const char *pcMountPath); 16 | bool process_logger(); 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /srcsim/simport.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Z80SIM - a Z80-CPU simulator 3 | * 4 | * Copyright (C) 2024-2025 Thomas Eberhardt 5 | */ 6 | 7 | #ifndef SIMPORT_INC 8 | #define SIMPORT_INC 9 | 10 | #include "pico/time.h" 11 | 12 | #include "sim.h" 13 | #include "simdefs.h" 14 | 15 | static inline void sleep_for_us(unsigned long time) { sleep_us(time); } 16 | static inline void sleep_for_ms(unsigned time) { sleep_ms(time); } 17 | 18 | static inline uint64_t get_clock_us(void) 19 | { 20 | return to_us_since_boot(get_absolute_time()); 21 | } 22 | 23 | extern bool get_cmdline(char *buf, int len); 24 | 25 | #endif /* !SIMPORT_INC */ 26 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/include/file_stream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * file_stream.h 3 | * 4 | * Wraps a FreeRTOS+FAT FF_FILE in a standard I/O stream FILE 5 | * to take advantage of the buffering provided by the standard I/O library 6 | * for a tremendous speedup of random-sized writes (e.g., fprintf output). 7 | * 8 | * Created on: Jun 20, 2024 9 | * Author: carlk 10 | */ 11 | 12 | #pragma once 13 | 14 | #include 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | FILE *open_file_stream( const char *pcFile, const char *pcMode ); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/bench2/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PlatformIO Test Runner and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PlatformIO Unit Testing: 11 | - https://docs.platformio.org/en/latest/advanced/unit-testing/index.html 12 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/include/sd_timeouts.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | typedef struct { 7 | uint32_t sd_command; 8 | unsigned sd_command_retries; 9 | unsigned sd_lock; 10 | unsigned sd_spi_read; 11 | unsigned sd_spi_write; 12 | unsigned sd_spi_write_read; 13 | unsigned spi_lock; 14 | unsigned rp2040_sdio_command_R1; 15 | unsigned rp2040_sdio_command_R2; 16 | unsigned rp2040_sdio_command_R3; 17 | unsigned rp2040_sdio_rx_poll; 18 | unsigned rp2040_sdio_tx_poll; 19 | unsigned sd_sdio_begin; 20 | unsigned sd_sdio_stopTransmission; 21 | } sd_timeouts_t; 22 | 23 | extern sd_timeouts_t sd_timeouts; 24 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/stdio_buffering/README.md: -------------------------------------------------------------------------------- 1 | # stdio_buffering 2 | 3 | This example illustrates the speedup that can be provided by taking advantage of the 4 | C library's Standard Input/Output (stdio) buffering. 5 | 6 | Typical output: 7 | ``` 8 | Hello, world! 9 | Time without buffering: 7840 ms 10 | Time with buffering: 3207 ms 11 | Goodbye, world! 12 | ``` 13 | showing a speedup of greater than 2X. 14 | 15 | If you have a record-oriented application, 16 | and the records are multiples of 512 bytes in size, 17 | you might not see a significant speedup. 18 | However, if, for example, you are writing text files with 19 | no fixed record length, the speedup can be great. 20 | -------------------------------------------------------------------------------- /srccpm3/Makefile: -------------------------------------------------------------------------------- 1 | CSTDS = -std=c99 -D_DEFAULT_SOURCE # -D_XOPEN_SOURCE=700L 2 | CWARNS= -Wall -Wextra -Wwrite-strings 3 | CFLAGS= -O $(CSTDS) $(CWARNS) 4 | LDFLAGS= -s 5 | 6 | Z80ASMDIR = ../../z80pack/z80asm 7 | Z80ASM = $(Z80ASMDIR)/z80asm 8 | Z80ASMFLAGS = -8 -l -T -sn -p0 9 | 10 | all: putsys boot.bin 11 | 12 | putsys: putsys.c 13 | $(CC) $(CFLAGS) $(LDFLAGS) -o putsys putsys.c 14 | 15 | boot.bin: boot.asm $(Z80ASM) 16 | $(Z80ASM) $(Z80ASMFLAGS) -fb $< 17 | 18 | $(Z80ASM): FORCE 19 | $(MAKE) -C $(Z80ASMDIR) 20 | 21 | FORCE: 22 | 23 | install: 24 | 25 | uninstall: 26 | 27 | clean: 28 | rm -f putsys boot.bin boot.lis 29 | 30 | distclean: clean 31 | 32 | .PHONY: all FORCE install uninstall clean distclean 33 | -------------------------------------------------------------------------------- /srcmpm/Makefile: -------------------------------------------------------------------------------- 1 | CSTDS = -std=c99 -D_DEFAULT_SOURCE # -D_XOPEN_SOURCE=700L 2 | CWARNS= -Wall -Wextra -Wwrite-strings 3 | CFLAGS= -O $(CSTDS) $(CWARNS) 4 | LDFLAGS= -s 5 | 6 | Z80ASMDIR = ../../z80pack/z80asm 7 | Z80ASM = $(Z80ASMDIR)/z80asm 8 | Z80ASMFLAGS = -l -T -sn -p0 9 | 10 | all: putsys boot.bin 11 | 12 | putsys: putsys.c 13 | $(CC) $(CFLAGS) $(LDFLAGS) -o putsys putsys.c 14 | 15 | boot.bin: boot.asm $(Z80ASM) 16 | $(Z80ASM) $(Z80ASMFLAGS) -fb $< 17 | 18 | $(Z80ASM): FORCE 19 | $(MAKE) -C $(Z80ASMDIR) 20 | 21 | FORCE: 22 | 23 | install: 24 | 25 | uninstall: 26 | 27 | clean: 28 | rm -f putsys boot.bin boot.lis 29 | 30 | distclean: clean 31 | 32 | .PHONY: all FORCE install uninstall clean distclean 33 | -------------------------------------------------------------------------------- /src-examples/blink.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Example program for the Pico Z80 3 | ; Blink a LED for a bit 4 | ; 5 | ; Udo Munk, April 2024 6 | ; 7 | 8 | 9 | ORG 0000H ; starting at memory location 0 10 | 11 | LED EQU 0 ; LED port 12 | 13 | DI ; disable interrupts 14 | LD SP,STACK ; setup stack in upper memory 15 | 16 | LD B,20 ; blink LED 20 times 17 | L1: LD A,1 ; switch LED on 18 | OUT (LED),A 19 | LD HL,0 ; wait a bit 20 | L2: DEC HL 21 | LD A,H 22 | OR L 23 | JR NZ,L2 24 | LD A,0 ; switch LED off 25 | OUT (LED),A 26 | LD HL,0 ; wait a bit 27 | L3: DEC HL 28 | LD A,H 29 | OR L 30 | JR NZ,L3 31 | DJNZ L1 ; again if not done 32 | HALT ; done, halt CPU 33 | 34 | DS 20 ; space for the stack 35 | STACK: 36 | 37 | END ; of program 38 | -------------------------------------------------------------------------------- /libs/pico-ds3231/examples/set_time/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | set(CMAKE_C_STANDARD 11) 4 | set(CMAKE_CXX_STANDARD 17) 5 | 6 | include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake) 7 | 8 | add_subdirectory(../../lib ds3231) 9 | 10 | project(set_time C CXX ASM) 11 | 12 | pico_sdk_init() 13 | 14 | add_executable(${PROJECT_NAME} ${PROJECT_NAME}.c) 15 | pico_set_program_name(${PROJECT_NAME} ${PROJECT_NAME}) 16 | pico_set_program_version(${PROJECT_NAME} "0.1") 17 | 18 | pico_enable_stdio_uart(${PROJECT_NAME} 0) 19 | pico_enable_stdio_usb(${PROJECT_NAME} 1) 20 | 21 | target_link_libraries( 22 | ${PROJECT_NAME} 23 | pico_stdlib 24 | hardware_i2c 25 | pico-ds3231 26 | ) 27 | 28 | pico_add_extra_outputs(${PROJECT_NAME}) 29 | -------------------------------------------------------------------------------- /libs/pico-ds3231/examples/hello_ds3231/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | set(CMAKE_C_STANDARD 11) 4 | set(CMAKE_CXX_STANDARD 17) 5 | 6 | include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake) 7 | 8 | add_subdirectory(../../lib ds3231) 9 | 10 | project(hello_ds3231 C CXX ASM) 11 | 12 | pico_sdk_init() 13 | 14 | add_executable(${PROJECT_NAME} ${PROJECT_NAME}.c) 15 | pico_set_program_name(${PROJECT_NAME} ${PROJECT_NAME}) 16 | pico_set_program_version(${PROJECT_NAME} "0.1") 17 | 18 | pico_enable_stdio_uart(${PROJECT_NAME} 0) 19 | pico_enable_stdio_usb(${PROJECT_NAME} 1) 20 | 21 | target_link_libraries( 22 | ${PROJECT_NAME} 23 | pico_stdlib 24 | hardware_i2c 25 | pico-ds3231 26 | ) 27 | 28 | pico_add_extra_outputs(${PROJECT_NAME}) 29 | -------------------------------------------------------------------------------- /libs/pico-ds3231/examples/read_temperature/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | set(CMAKE_C_STANDARD 11) 4 | set(CMAKE_CXX_STANDARD 17) 5 | 6 | include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake) 7 | 8 | add_subdirectory(../../lib ds3231) 9 | 10 | project(read_temperature C CXX ASM) 11 | 12 | pico_sdk_init() 13 | 14 | add_executable(${PROJECT_NAME} ${PROJECT_NAME}.c) 15 | pico_set_program_name(${PROJECT_NAME} ${PROJECT_NAME}) 16 | pico_set_program_version(${PROJECT_NAME} "0.1") 17 | 18 | pico_enable_stdio_uart(${PROJECT_NAME} 0) 19 | pico_enable_stdio_usb(${PROJECT_NAME} 1) 20 | 21 | target_link_libraries( 22 | ${PROJECT_NAME} 23 | pico_stdlib 24 | hardware_i2c 25 | pico-ds3231 26 | ) 27 | 28 | pico_add_extra_outputs(${PROJECT_NAME}) 29 | -------------------------------------------------------------------------------- /srcucsd-iv/Makefile: -------------------------------------------------------------------------------- 1 | CSTDS = -std=c99 -D_DEFAULT_SOURCE # -D_XOPEN_SOURCE=700L 2 | CWARNS= -Wall -Wextra -Wwrite-strings 3 | CFLAGS= -O $(CSTDS) $(CWARNS) 4 | LDFLAGS= -s 5 | 6 | Z80ASMDIR = ../../z80pack/z80asm 7 | Z80ASM = $(Z80ASMDIR)/z80asm 8 | Z80ASMFLAGS = -l -T -sn -p0 9 | 10 | all: putsys boot.bin bios.bin 11 | 12 | putsys: putsys.c 13 | $(CC) $(CFLAGS) $(LDFLAGS) -o putsys putsys.c 14 | 15 | boot.bin: boot.asm $(Z80ASM) 16 | $(Z80ASM) $(Z80ASMFLAGS) -fb $< 17 | 18 | bios.bin: bios.asm 19 | $(Z80ASM) $(Z80ASMFLAGS) -fb $< 20 | 21 | $(Z80ASM): FORCE 22 | $(MAKE) -C $(Z80ASMDIR) 23 | 24 | FORCE: 25 | 26 | install: 27 | 28 | uninstall: 29 | 30 | clean: 31 | rm -f putsys boot.bin boot.lis bios.bin bios.lis 32 | 33 | distclean: clean 34 | 35 | .PHONY: all FORCE install uninstall clean distclean 36 | -------------------------------------------------------------------------------- /srcsim/gpio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Z80SIM - a Z80-CPU simulator 3 | * 4 | * Copyright (C) 2025 by Thomas Eberhardt & Udo Munk 5 | */ 6 | 7 | #ifndef GPIO_INC 8 | #define GPIO_INC 9 | 10 | /* 11 | * Additional hardware defines that are not in the board files 12 | */ 13 | 14 | #ifndef WAVESHARE_I2CADC_I2C 15 | #define WAVESHARE_I2CADC_I2C 0 16 | #endif 17 | #ifndef WAVESHARE_I2CADC_SDA_PIN 18 | #define WAVESHARE_I2CADC_SDA_PIN 28 19 | #endif 20 | #ifndef WAVESHARE_I2CADC_SCL_PIN 21 | #define WAVESHARE_I2CADC_SCL_PIN 29 22 | #endif 23 | 24 | #ifndef WAVESHARE_DEBUG_TX_PIN 25 | #define WAVESHARE_DEBUG_TX_PIN 2 26 | #endif 27 | 28 | #ifndef WAVESHARE_LCD_WIDTH 29 | #define WAVESHARE_LCD_WIDTH 240 30 | #endif 31 | #ifndef WAVESHARE_LCD_HEIGHT 32 | #define WAVESHARE_LCD_HEIGHT 135 33 | #endif 34 | 35 | #endif /* !GPIO_INC */ 36 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/simple/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Simple Example for an SPI-attached SD card 4 | 5 | ### Overview 6 | 7 | This program is a simple demonstration of writing to an SD card using the [FatFs API](http://elm-chan.org/fsw/ff/00index_e.html). 8 | It initializes the standard input/output, mounts an SD card, writes to a file, and then unmounts the SD card. 9 | 10 | ### Features 11 | 12 | * Mounts an SD card 13 | * Opens a file in append mode and writes a message 14 | * Closes the file and unmounts the SD card 15 | * Prints success and failure messages to the STDIO console 16 | 17 | ### Requirements 18 | * You will need to 19 | [customize](https://github.com/carlk3/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico#customizing-for-the-hardware-configuration) 20 | the `hw_config.c` file to match your hardware. 21 | -------------------------------------------------------------------------------- /srccpm2/Makefile: -------------------------------------------------------------------------------- 1 | CSTDS = -std=c99 -D_DEFAULT_SOURCE # -D_XOPEN_SOURCE=700L 2 | CWARNS= -Wall -Wextra -Wwrite-strings 3 | CFLAGS= -O $(CSTDS) $(CWARNS) 4 | LDFLAGS= -s 5 | 6 | Z80ASMDIR = ../../z80pack/z80asm 7 | Z80ASM = $(Z80ASMDIR)/z80asm 8 | Z80ASMFLAGS = -8 -l -T -sn -p0 9 | 10 | all: putsys bios.bin boot.bin 11 | 12 | putsys: putsys.c 13 | $(CC) $(CFLAGS) $(LDFLAGS) -o putsys putsys.c 14 | 15 | bios.bin: bios.asm $(Z80ASM) 16 | $(Z80ASM) $(Z80ASMFLAGS) -fb -x $< 17 | 18 | boot.bin: boot.asm $(Z80ASM) 19 | $(Z80ASM) $(Z80ASMFLAGS) -fb $< 20 | 21 | $(Z80ASM): FORCE 22 | $(MAKE) -C $(Z80ASMDIR) 23 | 24 | FORCE: 25 | 26 | install: 27 | 28 | uninstall: 29 | 30 | clean: 31 | rm -f putsys bios.bin bios.lis boot.bin boot.lis 32 | 33 | distclean: clean 34 | 35 | .PHONY: all FORCE install uninstall clean distclean 36 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/one_SPI.C/platformio.ini: -------------------------------------------------------------------------------- 1 | 2 | [env:pico2] 3 | platform = https://github.com/maxgerhardt/platform-raspberrypi.git 4 | board = rpipico2 5 | framework = arduino 6 | debug_tool = cmsis-dap 7 | upload_protocol = cmsis-dap 8 | lib_deps = no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 9 | lib_extra_dirs = ../../../.. 10 | platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#master 11 | 12 | [env:pico] 13 | platform = https://github.com/maxgerhardt/platform-raspberrypi.git 14 | board = rpipico 15 | framework = arduino 16 | debug_tool = cmsis-dap 17 | upload_protocol = cmsis-dap 18 | lib_deps = no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 19 | lib_extra_dirs = ../../../.. 20 | platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#master 21 | -------------------------------------------------------------------------------- /flash-rp2040/picosim.info: -------------------------------------------------------------------------------- 1 | File picosim.uf2 family ID 'rp2040': 2 | 3 | Program Information 4 | name: z80pack picosim 5 | version: 1.8 6 | web site: https://github.com/udo-munk/RP2xxx-GEEK-80 7 | description: z80pack on Waveshare RP2040-GEEK 8 | features: USB stdin / stdout 9 | binary start: 0x10000000 10 | binary end: 0x100556d0 11 | 12 | Fixed Pin Information 13 | 2: DEBUG TX 14 | 4: UART TX 15 | 5: UART RX 16 | 28: DS3231 I2C SDA 17 | 29: DS3231 I2C SCL 18 | 19 | Build Information 20 | sdk version: 2.1.1 21 | pico_board: waveshare_rp2040_geek 22 | boot2_name: boot2_w25q080 23 | build date: Jun 9 2025 24 | build attributes: Release 25 | 26 | Metadata Blocks 27 | none 28 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/include/my_rtc.h: -------------------------------------------------------------------------------- 1 | /* my_rtc.h 2 | Copyright 2021 Carl John Kugler III 3 | 4 | Licensed under the Apache License, Version 2.0 (the License); you may not use 5 | this file except in compliance with the License. You may obtain a copy of the 6 | License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | */ 14 | #pragma once 15 | 16 | #include 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | extern time_t epochtime; 23 | void time_init(); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/simple_sdio/README.md: -------------------------------------------------------------------------------- 1 | # Simple Example for an SDIO-attached SD card 2 | 3 | ### Overview 4 | 5 | This program is a simple demonstration of writing to an SD card using the [FatFs API](http://elm-chan.org/fsw/ff/00index_e.html). 6 | It initializes the standard input/output and real-time clock, mounts an SD card, writes to a file, and then unmounts the SD card. 7 | 8 | ### Features 9 | 10 | * Mounts an SD card 11 | * Opens a file in append mode and writes a message 12 | * Closes the file and unmounts the SD card 13 | * Prints success and failure messages to the STDIO console 14 | 15 | ### Requirements 16 | * You will need to 17 | [customize](https://github.com/carlk3/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico#customizing-for-the-hardware-configuration) 18 | the hardware configuration in the `main.c` file to match your hardware. 19 | * PICO_SDK_PATH must be set in the Cmake: Configure Environment 20 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/ff15/source/00readme.txt: -------------------------------------------------------------------------------- 1 | FatFs Module Source Files R0.15 2 | 3 | 4 | FILES 5 | 6 | 00readme.txt This file. 7 | 00history.txt Revision history. 8 | ff.c FatFs module. 9 | ffconf.h Configuration file of FatFs module. 10 | ff.h Common include file for FatFs and application module. 11 | diskio.h Common include file for FatFs and disk I/O module. 12 | diskio.c An example of glue function to attach existing disk I/O module to FatFs. 13 | ffunicode.c Optional Unicode utility functions. 14 | ffsystem.c An example of optional O/S related functions. 15 | 16 | 17 | Low level disk I/O module is not included in this archive because the FatFs 18 | module is only a generic file system layer and it does not depend on any specific 19 | storage device. You need to provide a low level disk I/O module written to 20 | control the storage device that attached to the target system. 21 | 22 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/usb_mass_storage/README.md: -------------------------------------------------------------------------------- 1 | # USB Mass Storage on Pico SD Card 2 | 3 | This example turns your Pico into something like an SD card USB dongle. 4 | You can mount the Pico's SD card on a desktop PC by connecting the Pico's USB port to the computer's USB port. 5 | 6 | It is derived from 7 | [lib/tinyusb/examples/device/cdc_msc](https://github.com/hathach/tinyusb/tree/4232642899362fa5e9cf0dc59bad6f1f6d32c563/examples/device/cdc_msc). 8 | It uses the [Block Device API](https://github.com/carlk3/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/tree/main?tab=readme-ov-file#block-device-api). 9 | 10 | ## Requirements 11 | * You will need to 12 | [customize](https://github.com/carlk3/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico#customizing-for-the-hardware-configuration) 13 | the `hw_config.c` file to match your hardware. 14 | 15 | ## Build 16 | Follow the instructions in [Getting started with Raspberry Pi Pico-series](https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf). 17 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/sd_driver/SPI/sd_card_spi.h: -------------------------------------------------------------------------------- 1 | /* sd_card_spi.h 2 | Copyright 2021 Carl John Kugler III 3 | 4 | Licensed under the Apache License, Version 2.0 (the License); you may not use 5 | this file except in compliance with the License. You may obtain a copy of the 6 | License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | */ 14 | 15 | #pragma once 16 | 17 | #include "sd_card.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | void sd_spi_ctor(sd_card_t *sd_card_p); // Constructor for sd_card_t 24 | uint32_t sd_go_idle_state(sd_card_t *sd_card_p); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | /* [] END OF FILE */ 30 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/hw_debug/add_aon.py: -------------------------------------------------------------------------------- 1 | Import("env") 2 | from os.path import join 3 | platform = env.PioPlatform() 4 | FRAMEWORK_DIR = platform.get_package_dir("framework-arduinopico") 5 | board = env.BoardConfig() 6 | chip = board.get("build.mcu") 7 | 8 | env.Append(CPPPATH=[ 9 | join(FRAMEWORK_DIR, "pico-sdk", "src", "rp2_common", "pico_aon_timer", "include") 10 | ]) 11 | env.BuildSources( 12 | join("$BUILD_DIR", "PicoAON"), 13 | join(FRAMEWORK_DIR, "pico-sdk", "src", "rp2_common", "pico_aon_timer") 14 | ) 15 | 16 | if chip == "rp2350": 17 | # pico-sdk/src/rp2_common/hardware_powman/include/hardware/powman.h 18 | env.Append(CPPPATH=[ 19 | join(FRAMEWORK_DIR, "pico-sdk", "src", "rp2_common", "hardware_powman", "include") 20 | ]) 21 | # pico-sdk/src/rp2_common/hardware_powman 22 | env.BuildSources( 23 | join("$BUILD_DIR", "Powman"), 24 | join(FRAMEWORK_DIR, "pico-sdk", "src", "rp2_common", "hardware_powman") 25 | ) 26 | -------------------------------------------------------------------------------- /libs/stdio_msc_usb/README.txt: -------------------------------------------------------------------------------- 1 | This library allows USB mass storage access together with USB CDC 2 | stdio. Intended to be used together with 3 | https://github.com/carlk3/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico . 4 | 5 | Based on pico-sdk/src/rp2_common/pico_stdio_usb and 6 | pico-sdk/lib/tinyusb/examples/device/cdc_msc . 7 | 8 | See CMakeLists.txt, picosim.c, and simcfg.c in srcsim to see how to 9 | use this. 10 | 11 | Basically: 12 | 13 | Add with "add_subdirectory" and "target_link_libraries(tinyusb_device 14 | stdio_msc_usb)" to CMakeLists.txt. Remove "pico_enable_stdio_usb". 15 | 16 | Call "tusb_init()" and "stdio_msc_usb_init()" in "main()". Activate 17 | the mass storage access with "stdio_msc_usb_do_msc()". This will wait 18 | until the medium is ejected by the host OS. 19 | 20 | This is done this way, because the FatFS library needs exclusive 21 | access to the storage medium. So USB access can only be activated in 22 | the configuration menu to allow copying of files and disk images 23 | to/from the host OS. 24 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/sd_driver/sd_timeouts.c: -------------------------------------------------------------------------------- 1 | 2 | #include "sd_timeouts.h" 3 | 4 | sd_timeouts_t sd_timeouts __attribute__((weak)) = { 5 | .sd_command = 2000, // Timeout in ms for response 6 | .sd_command_retries = 3, // Times SPI cmd is retried when there is no response 7 | .sd_lock = 8000, // Timeout in ms for response 8 | .sd_spi_read = 1000, // Timeout in ms for response 9 | .sd_spi_write = 1000, // Timeout in ms for response 10 | .sd_spi_write_read = 1000, // Timeout in ms for response 11 | .spi_lock = 4000, // Timeout in ms for response 12 | .rp2040_sdio_command_R1 = 10, // Timeout in ms for response 13 | .rp2040_sdio_command_R2 = 2, // Timeout in ms for response 14 | .rp2040_sdio_command_R3 = 2, // Timeout in ms for response 15 | .rp2040_sdio_rx_poll = 1000, // Timeout in ms for response 16 | .rp2040_sdio_tx_poll = 5000, // Timeout in ms for response 17 | .sd_sdio_begin = 1000, // Timeout in ms for response 18 | .sd_sdio_stopTransmission = 200, // Timeout in ms for response 19 | }; 20 | -------------------------------------------------------------------------------- /src-examples/Makefile: -------------------------------------------------------------------------------- 1 | Z80ASMDIR = ../../z80pack/z80asm 2 | Z80ASM = $(Z80ASMDIR)/z80asm 3 | Z80ASMFLAGS = -fb -l -T -sn -p0 4 | 5 | all: kscope.bin life.bin blink.bin micro80.bin serial.bin tb.bin test8080.bin 6 | 7 | kscope.bin: kscope.asm $(Z80ASM) 8 | $(Z80ASM) $(Z80ASMFLAGS) -8 $< 9 | 10 | life.bin: life.asm $(Z80ASM) 11 | $(Z80ASM) $(Z80ASMFLAGS) -8 $< 12 | 13 | blink.bin: blink.asm $(Z80ASM) 14 | $(Z80ASM) $(Z80ASMFLAGS) $< 15 | 16 | micro80.bin: micro80.asm $(Z80ASM) 17 | $(Z80ASM) $(Z80ASMFLAGS) -8 $< 18 | 19 | serial.bin: serial.asm $(Z80ASM) 20 | $(Z80ASM) $(Z80ASMFLAGS) $< 21 | 22 | tb.bin: tb.asm $(Z80ASM) 23 | $(Z80ASM) $(Z80ASMFLAGS) -8 -x $< 24 | 25 | test8080.bin: test8080.asm $(Z80ASM) 26 | $(Z80ASM) $(Z80ASMFLAGS) -8 -dONCPM=0 $< 27 | 28 | $(Z80ASM): FORCE 29 | $(MAKE) -C $(Z80ASMDIR) 30 | 31 | FORCE: 32 | 33 | install: 34 | 35 | uninstall: 36 | 37 | clean: 38 | rm -f kscope.bin life.bin blink.bin micro80.bin serial.bin tb.bin \ 39 | test8080.bin 40 | 41 | distclean: clean 42 | 43 | .PHONY: all FORCE install uninstall clean distclean 44 | -------------------------------------------------------------------------------- /roms/bootrom.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; boot ROM for z80pack machines using SD-FDC 3 | ; use 8080 instructions only, so that it runs 4 | ; on all our CPU's 5 | ; 6 | ; Copyright (C) 2024 by Udo Munk 7 | ; 8 | ORG 0FF00H ;ROM in upper most memory page 9 | ; 10 | ; I/O ports 11 | ; 12 | FDC EQU 4 ;FDC port 13 | ; 14 | FDCMD EQU 0F000H ;command bytes for the FDC 15 | ; 16 | DI ;disable interrupts 17 | ; 18 | XOR A ;zero A 19 | LD (FDCMD),A ;track 0 20 | LD (FDCMD+2),A ;DMA address low 21 | LD (FDCMD+3),A ;DMA address high 22 | LD A,1 ;sector 1 23 | LD (FDCMD+1),A 24 | ; 25 | LD A,10H ;setup command for FDC 26 | OUT (FDC),A 27 | LD A,FDCMD AND 0FFH 28 | OUT (FDC),A 29 | LD A,FDCMD SHR 8 30 | OUT (FDC),A 31 | ; 32 | LD A,20H ;read sector 1 on track 0 from drive 0 33 | OUT (FDC),A 34 | IN A,(FDC) ;get FDC result 35 | OR A ;zero ? 36 | JP Z,0 ;if yes jump to boot code loaded @ 0 37 | ; 38 | CP 2 ;some problem, lets see, no disk in drive? 39 | JP Z,0 ;yes, so hopefully they loaded some code 40 | HALT ;if not there is some serious problem 41 | ; 42 | END ;of ROM 43 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/include/FatFsSd_C.h: -------------------------------------------------------------------------------- 1 | /* FatFsSd_C.h 2 | Copyright 2023 Carl John Kugler III 3 | 4 | Licensed under the Apache License, Version 2.0 (the License); you may not use 5 | this file except in compliance with the License. You may obtain a copy of the 6 | License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | */ 14 | #pragma once 15 | 16 | #include "../src/ff15/source/ff.h" 17 | // 18 | #include "../src/ff15/source/diskio.h" /* Declarations of disk functions */ 19 | #include "../src/include/f_util.h" 20 | #include "../src/include/my_rtc.h" 21 | #include "../src/sd_driver/sd_card.h" 22 | #include "../src/sd_driver/SDIO/rp2040_sdio.h" 23 | #include "../src/sd_driver/SPI/my_spi.h" 24 | #include "../src/include/hw_config.h" 25 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/ZuluSCSI-firmware/LICENSE: -------------------------------------------------------------------------------- 1 | Software 2 | ----- 3 | 4 | ZuluSCSI™ - Copyright (c) 2022 Rabbit Hole Computing™ 5 | 6 | ZuluSCSI™ is based on both SCSI2SD V6 and BlueSCSI codebases, 7 | and licensed under the GPL version 3 or any later version. 8 | 9 | https://www.gnu.org/licenses/gpl-3.0.html 10 | ---- 11 | SCSI2SD code is Copyright (C) 2016-2022 Michael McMaster. 12 | BlueSCSI code is Copyright (C) 2021 Eric Helgeson. 13 | 14 | This program is free software: you can redistribute it and/or modify 15 | it under the terms of the GNU General Public License as published by 16 | the Free Software Foundation, either version 3 of the License, or 17 | (at your option) any later version. 18 | 19 | This program is distributed in the hope that it will be useful, 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | GNU General Public License for more details. 23 | 24 | You should have received a copy of the GNU General Public License 25 | along with this program. If not, see . 26 | -------------------------------------------------------------------------------- /srcsim/lcd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Functions for using the RP2040/RP2350-GEEK LCD from the emulation 3 | * 4 | * Copyright (C) 2024-2025 by Udo Munk & Thomas Eberhardt 5 | */ 6 | 7 | #ifndef LCD_INC 8 | #define LCD_INC 9 | 10 | #include "sim.h" 11 | #include "simdefs.h" 12 | 13 | #include "lcd_dev.h" 14 | #include "draw.h" 15 | 16 | #define LCD_STATUS_CURRENT 0 17 | #define LCD_STATUS_REGISTERS 1 18 | #define LCD_STATUS_PANEL 2 19 | #define LCD_STATUS_DRIVES 3 20 | #define LCD_STATUS_PORTS 4 21 | #define LCD_STATUS_MEMORY 5 22 | 23 | typedef void (*lcd_func_t)(bool first); 24 | 25 | extern uint16_t led_color; /* call lcd_update_led() after changing this */ 26 | 27 | extern void lcd_init(void), lcd_exit(void); 28 | extern void lcd_brightness(int brightness); 29 | extern void lcd_set_rotation(bool rotated); 30 | extern void lcd_update_led(void); 31 | extern void lcd_custom_disp(lcd_func_t draw_func); 32 | extern void lcd_status_disp(int which); 33 | extern void lcd_status_next(void); 34 | extern void lcd_update_drive(int drive, int track, int sector, WORD addr, 35 | bool rdwr, bool active); 36 | 37 | #endif /* !LCD_INC */ 38 | -------------------------------------------------------------------------------- /libs/stdio_msc_usb/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_library(stdio_msc_usb) 2 | 3 | target_include_directories(stdio_msc_usb_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 4 | 5 | target_sources(stdio_msc_usb INTERFACE 6 | ${CMAKE_CURRENT_LIST_DIR}/msc_usb.c 7 | ${CMAKE_CURRENT_LIST_DIR}/reset_interface.c 8 | ${CMAKE_CURRENT_LIST_DIR}/stdio_msc_usb.c 9 | ${CMAKE_CURRENT_LIST_DIR}/stdio_msc_usb_descriptors.c 10 | ) 11 | 12 | pico_mirrored_target_link_libraries(stdio_msc_usb INTERFACE 13 | pico_stdio 14 | pico_time 15 | pico_unique_id 16 | pico_usb_reset_interface 17 | ) 18 | target_link_libraries(stdio_msc_usb INTERFACE 19 | tinyusb_device 20 | ) 21 | # PICO_CMAKE_CONFIG: STDIO_MSC_USB_CONNECT_WAIT_TIMEOUT_MS, Maximum number of milliseconds to wait during initialization for a CDC connection from the host (negative means indefinite) during initialization, type=int, default=0, group=stdio_msc_usb 22 | if (STDIO_MSC_USB_CONNECT_WAIT_TIMEOUT_MS) 23 | target_compile_definitions(stdio_msc_usb INTERFACE 24 | STDIO_MSC_USB_CONNECT_WAIT_TIMEOUT_MS=${STDIO_MSC_USB_CONNECT_WAIT_TIMEOUT_MS} 25 | ) 26 | endif() 27 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/include/f_util.h: -------------------------------------------------------------------------------- 1 | /* f_util.h 2 | Copyright 2021 Carl John Kugler III 3 | 4 | Licensed under the Apache License, Version 2.0 (the License); you may not use 5 | this file except in compliance with the License. You may obtain a copy of the 6 | License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | */ 14 | #pragma once 15 | #include "ff.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | const char *FRESULT_str(FRESULT i); 22 | FRESULT delete_node ( 23 | TCHAR* path, /* Path name buffer with the sub-directory to delete */ 24 | UINT sz_buff, /* Size of path name buffer (items) */ 25 | FILINFO* fno /* Name read buffer */ 26 | ); 27 | 28 | void ls(const char *dir); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024-2025 Udo Munk & Thomas Eberhardt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/src/util.c: -------------------------------------------------------------------------------- 1 | /* 2 | * util.c 3 | * 4 | * Created on: Apr 12, 2022 5 | * Author: carlk 6 | */ 7 | #include 8 | #include 9 | #include 10 | #include 11 | // 12 | #include "util.h" 13 | 14 | int gcd(int a,int b) { 15 | int R; 16 | while ((a % b) > 0) { 17 | R = a % b; 18 | a = b; 19 | b = R; 20 | } 21 | return b; 22 | } 23 | 24 | char const* uint8_binary_str(uint8_t number) { 25 | static char b[sizeof number * 8 + 1]; 26 | 27 | memset(b, 0, sizeof b); 28 | for (size_t i = 0; i < sizeof number * 8; ++i) { 29 | unsigned int mask = 1 << i; 30 | if (number & mask) 31 | b[sizeof number * 8 - 1 - i] = '1'; 32 | else 33 | b[sizeof number * 8 - 1 - i] = '0'; 34 | } 35 | return b; 36 | } 37 | char const* uint_binary_str(unsigned int number) { 38 | static char b[sizeof number * 8 + 1]; 39 | 40 | memset(b, 0, sizeof b); 41 | for (size_t i = 0; i < sizeof number * 8; ++i) { 42 | unsigned int mask = 1 << i; 43 | if (number & mask) 44 | b[sizeof number * 8 - 1 - i] = '1'; 45 | else 46 | b[sizeof number * 8 - 1 - i] = '0'; 47 | } 48 | return b; 49 | } 50 | -------------------------------------------------------------------------------- /srcsim/fonts/Makefile: -------------------------------------------------------------------------------- 1 | PROJECT = terminus-font 2 | VERSION = 4.49.1 3 | SFDIR = $(PROJECT)-$(basename $(VERSION)) 4 | SRCDIR = $(PROJECT)-$(VERSION) 5 | SRCFILE = $(SRCDIR).tar.gz 6 | URL = https://downloads.sourceforge.net/project/$(PROJECT)/$(SFDIR)/$(SRCFILE) 7 | 8 | CFLAGS = -O -Wall -Wextra 9 | 10 | all: 11 | @echo "If you really want to regenerate the fonts use \"make fonts\"" 12 | 13 | fonts: bdf2c $(SRCFILE) 14 | @echo "Generating font*.c and OFL.TXT files..." 15 | @set -e; tar -x -f $(SRCFILE); \ 16 | cd $(SRCDIR); \ 17 | patch -s -p1 -i alt/td1.diff; \ 18 | ../bdf2c ter-u12n.bdf > ../font12.c; \ 19 | ../bdf2c ter-u14b.bdf > ../font14.c; \ 20 | ../bdf2c ter-u16b.bdf > ../font16.c; \ 21 | ../bdf2c ter-u18b.bdf > ../font18.c; \ 22 | ../bdf2c ter-u20b.bdf > ../font20.c; \ 23 | ../bdf2c ter-u22b.bdf > ../font22.c; \ 24 | ../bdf2c ter-u24b.bdf > ../font24.c; \ 25 | ../bdf2c ter-u28b.bdf > ../font28.c; \ 26 | ../bdf2c ter-u32b.bdf > ../font32.c; \ 27 | tr -d '\r' < OFL.TXT > ../OFL.TXT; \ 28 | cd ..; \ 29 | rm -rf $(SRCDIR) 30 | 31 | bdf2c: bdf2c.c 32 | 33 | $(SRCFILE): 34 | curl -LO $(URL) 35 | 36 | clean: 37 | rm -f bdf2c $(SRCFILE) 38 | 39 | .PHONY: all fonts clean 40 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/SdFat/LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2011..2020 Bill Greiman 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/one_SPI_one_SDIO/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:pico] 2 | platform = https://github.com/maxgerhardt/platform-raspberrypi.git 3 | board = pico 4 | framework = arduino 5 | board_build.core = earlephilhower 6 | platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#master 7 | debug_tool = cmsis-dap 8 | upload_protocol = cmsis-dap 9 | monitor_port = COM8 10 | monitor_speed = 115200 11 | 12 | ; build_flags = 13 | 14 | ; Normal way: 15 | ; lib_deps = 16 | ; carlk3/no-OS-FatFS-SD-SPI-RPi-Pico@^1.0.2 17 | 18 | ; Get the latest straight from github: 19 | ; lib_deps = https://github.com/carlk3/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico.git 20 | 21 | ; Use local copy: 22 | lib_deps = no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 23 | lib_extra_dirs = ../../../.. 24 | 25 | [env:pico2] 26 | platform = https://github.com/maxgerhardt/platform-raspberrypi.git 27 | board = rpipico2 28 | framework = arduino 29 | platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#master 30 | debug_tool = cmsis-dap 31 | upload_protocol = cmsis-dap 32 | lib_deps = no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 33 | lib_extra_dirs = ../../../.. 34 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/hw_debug/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:pico] 2 | platform = https://github.com/maxgerhardt/platform-raspberrypi.git 3 | board = pico 4 | framework = arduino 5 | board_build.core = earlephilhower 6 | debug_tool = cmsis-dap 7 | upload_protocol = cmsis-dap 8 | 9 | build_flags = 10 | -D USE_DBG_PRINTF # Debug output 11 | -D PICO_USE_STACK_GUARDS=1 12 | 13 | ; Normal way: 14 | ; lib_deps = 15 | ; carlk3/no-OS-FatFS-SD-SPI-RPi-Pico@^1.0.2 16 | 17 | ; Get the latest straight from github: 18 | ; lib_deps = https://github.com/carlk3/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico.git 19 | 20 | ; Use local copy: 21 | lib_deps = no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 22 | lib_extra_dirs = ../../../.. 23 | platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#master 24 | 25 | [env:pico2] 26 | platform = https://github.com/maxgerhardt/platform-raspberrypi.git 27 | board = rpipico2 28 | framework = arduino 29 | debug_tool = cmsis-dap 30 | upload_protocol = cmsis-dap 31 | lib_deps = no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 32 | lib_extra_dirs = ../../../.. 33 | platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#master 34 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/block_device/README.md: -------------------------------------------------------------------------------- 1 | # block_device 2 | 3 | **WARNING**: Any filesystem format on the target drive will be destroyed! 4 | You can format the card to replace the filesystem, 5 | but you will lose any preexisting data. 6 | 7 | This example illustrates the direct use of the block device API. The API implements the *Media Access Interface* described in [FatFs - Generic FAT Filesystem Module](http://elm-chan.org/fsw/ff/00index_e.html) (also see *Required Functions* in [FatFs Module Application Note](http://elm-chan.org/fsw/ff/doc/appnote.html)). 8 | The declarations are in `src/ff15/source/diskio.h`. 9 | 10 | If you don't require a filesystem on an SD card, 11 | or if you want to use a different filesystem, 12 | you can operate at the block device level. 13 | At the block device interface, the SD card appears to contain a long sequence of 14 | numbered blocks of 512 bytes each. I.e., the smallest addressable unit is a block of 512 bytes. 15 | The address of a block is its "logical block address" (LBA). 16 | Blocks can be addressed by their LBA and read and written individually or as sequences with a starting address and length. 17 | 18 | This example can use SPI or SDIO attached SD cards. 19 | -------------------------------------------------------------------------------- /flash-rp2350-arm-s/picosim.info: -------------------------------------------------------------------------------- 1 | File picosim.uf2 family ID 'rp2350-arm-s': 2 | 3 | Program Information 4 | name: z80pack picosim 5 | version: 1.8 6 | web site: https://github.com/udo-munk/RP2xxx-GEEK-80 7 | description: z80pack on Waveshare RP2350-GEEK 8 | features: USB stdin / stdout 9 | binary start: 0x10000000 10 | binary end: 0x10051238 11 | target chip: RP2350 12 | image type: ARM Secure 13 | 14 | Fixed Pin Information 15 | 2: DEBUG TX 16 | 4: UART TX 17 | 5: UART RX 18 | 28: DS3231 I2C SDA 19 | 29: DS3231 I2C SCL 20 | 21 | Build Information 22 | sdk version: 2.1.1 23 | pico_board: waveshare_rp2350_geek 24 | boot2_name: boot2_w25q080 25 | build date: Jun 9 2025 26 | build attributes: Release 27 | 28 | Metadata Block 1 29 | address: 0x10000138 30 | next block address: 0x10051224 31 | block type: image def 32 | target chip: RP2350 33 | image type: ARM Secure 34 | 35 | Metadata Block 2 36 | address: 0x10051224 37 | next block address: 0x10000138 38 | block type: ignored 39 | -------------------------------------------------------------------------------- /srcsim/debug.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Z80SIM - a Z80-CPU simulator 3 | * 4 | * Copyright (C) 2025 by Udo Munk 5 | * 6 | * This module implements a TX UART on the DEBUG port, GP 2 is TX, 7 | * and stdio compatible functions debug_* to print on this port. 8 | * 9 | * History: 10 | * 06-JUN-2025 first implementation 11 | */ 12 | 13 | #include "pico/stdlib.h" 14 | #include "hardware/pio.h" 15 | #include "uart_tx.pio.h" 16 | 17 | #include "gpio.h" 18 | #include "debug.h" 19 | 20 | #define SERIAL_BAUD 115200 /* baud rate we use */ 21 | 22 | /* PIO and sm we use */ 23 | static PIO pio = pio1; 24 | static uint sm; 25 | 26 | /* 27 | * initialialize TX UART using PIO 28 | * must be called before output to the port 29 | */ 30 | void debug_init(void) 31 | { 32 | /* get next unused one */ 33 | sm = pio_claim_unused_sm(pio, true); 34 | 35 | /* setup the GPIO as TX UART */ 36 | uint offset = pio_add_program(pio, &uart_tx_program); 37 | uart_tx_program_init(pio, sm, offset, WAVESHARE_DEBUG_TX_PIN, SERIAL_BAUD); 38 | } 39 | 40 | /* 41 | * print string to debug port followed by CR/LF, so works same as stdio puts 42 | */ 43 | void debug_puts(const char *s) 44 | { 45 | uart_tx_program_puts(pio, sm, s); 46 | uart_tx_program_putc(pio, sm, '\r'); 47 | uart_tx_program_putc(pio, sm, '\n'); 48 | } 49 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/bench2/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /flash-rp2350-riscv/picosim.info: -------------------------------------------------------------------------------- 1 | File picosim.uf2 family ID 'rp2350-riscv': 2 | 3 | Program Information 4 | name: z80pack picosim 5 | version: 1.8 6 | web site: https://github.com/udo-munk/RP2xxx-GEEK-80 7 | description: z80pack on Waveshare RP2350-GEEK 8 | features: USB stdin / stdout 9 | binary start: 0x10000000 10 | binary end: 0x1005dd48 11 | target chip: RP2350 12 | image type: RISC-V 13 | 14 | Fixed Pin Information 15 | 2: DEBUG TX 16 | 4: UART TX 17 | 5: UART RX 18 | 28: DS3231 I2C SDA 19 | 29: DS3231 I2C SCL 20 | 21 | Build Information 22 | sdk version: 2.1.1 23 | pico_board: waveshare_rp2350_geek 24 | boot2_name: boot2_w25q080 25 | build date: Jun 9 2025 26 | build attributes: Release 27 | 28 | Metadata Block 1 29 | address: 0x10000014 30 | next block address: 0x1005dd34 31 | block type: image def 32 | target chip: RP2350 33 | image type: RISC-V 34 | entry point: EP 0x10000036, SP 0x20082000 35 | 36 | Metadata Block 2 37 | address: 0x1005dd34 38 | next block address: 0x10000014 39 | block type: ignored 40 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/one_SPI_one_SDIO.dir_ops/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:pico] 2 | platform = https://github.com/maxgerhardt/platform-raspberrypi.git 3 | board = pico 4 | framework = arduino 5 | board_build.core = earlephilhower 6 | platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#master 7 | debug_tool = cmsis-dap 8 | upload_protocol = cmsis-dap 9 | monitor_port = COM8 10 | monitor_speed = 115200 11 | 12 | ; build_unflags = -fno-exceptions 13 | ; build_flags = -fexceptions 14 | 15 | build_flags = "-Wno-psabi" 16 | ; "-D USE_DBG_PRINTF" 17 | 18 | ; Normal way: 19 | ; lib_deps = 20 | ; carlk3/no-OS-FatFS-SD-SPI-RPi-Pico@^1.0.2 21 | 22 | ; Get the latest straight from github: 23 | ; lib_deps = https://github.com/carlk3/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico.git 24 | 25 | ; Use local copy: 26 | lib_deps = no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 27 | lib_extra_dirs = ../../../.. 28 | 29 | [env:pico2] 30 | platform = https://github.com/maxgerhardt/platform-raspberrypi.git 31 | board = rpipico2 32 | framework = arduino 33 | platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#master 34 | debug_tool = cmsis-dap 35 | upload_protocol = cmsis-dap 36 | lib_deps = no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 37 | lib_extra_dirs = ../../../.. 38 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/ff15/documents/res/app1.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------/ 2 | / Open or create a file in append mode 3 | / (This function was sperseded by FA_OPEN_APPEND flag at FatFs R0.12a) 4 | /------------------------------------------------------------*/ 5 | 6 | FRESULT open_append ( 7 | FIL* fp, /* [OUT] File object to create */ 8 | const char* path /* [IN] File name to be opened */ 9 | ) 10 | { 11 | FRESULT fr; 12 | 13 | /* Opens an existing file. If not exist, creates a new file. */ 14 | fr = f_open(fp, path, FA_WRITE | FA_OPEN_ALWAYS); 15 | if (fr == FR_OK) { 16 | /* Seek to end of the file to append data */ 17 | fr = f_lseek(fp, f_size(fp)); 18 | if (fr != FR_OK) 19 | f_close(fp); 20 | } 21 | return fr; 22 | } 23 | 24 | 25 | int main (void) 26 | { 27 | FRESULT fr; 28 | FATFS fs; 29 | FIL fil; 30 | 31 | /* Open or create a log file and ready to append */ 32 | f_mount(&fs, "", 0); 33 | fr = open_append(&fil, "logfile.txt"); 34 | if (fr != FR_OK) return 1; 35 | 36 | /* Append a line */ 37 | f_printf(&fil, "%02u/%02u/%u, %2u:%02u\n", Mday, Mon, Year, Hour, Min); 38 | 39 | /* Close the file */ 40 | f_close(&fil); 41 | 42 | return 0; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/one_SDIO/platformio.ini: -------------------------------------------------------------------------------- 1 | ; See https://arduino-pico.readthedocs.io/en/latest/platformio.html 2 | 3 | [env:pico] 4 | platform = https://github.com/maxgerhardt/platform-raspberrypi.git 5 | ; platform = raspberrypi 6 | board = pico 7 | framework = arduino 8 | board_build.core = earlephilhower 9 | platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#master 10 | debug_tool = cmsis-dap 11 | upload_protocol = cmsis-dap 12 | monitor_port = COM8 13 | monitor_speed = 115200 14 | 15 | build_flags = 16 | -D USE_DBG_PRINTF 17 | 18 | ; Normal way: 19 | ; lib_deps = 20 | ; carlk3/no-OS-FatFS-SD-SPI-RPi-Pico@^1.0.2 21 | 22 | ; Get the latest straight from github: 23 | ; lib_deps = https://github.com/carlk3/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico.git 24 | ; Use local copy: 25 | lib_deps = no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 26 | lib_extra_dirs = ../../../.. 27 | 28 | [env:pico2] 29 | platform = https://github.com/maxgerhardt/platform-raspberrypi.git 30 | board = rpipico2 31 | framework = arduino 32 | board_build.core = earlephilhower 33 | platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#master 34 | debug_tool = cmsis-dap 35 | upload_protocol = cmsis-dap 36 | lib_deps = no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 37 | lib_extra_dirs = ../../../.. 38 | -------------------------------------------------------------------------------- /srcsim/disks.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Z80SIM - a Z80-CPU simulator 3 | * 4 | * Copyright (C) 2024-2025 by Udo Munk & Thomas Eberhardt 5 | * 6 | * This module implements the disks drives and low level 7 | * access functions for MicroSD, needed by the FDC. 8 | * 9 | * History: 10 | * 29-JUN-2024 split of from memsim.c and picosim.c 11 | * 26-APR-2025 use a define for filename lenght 12 | */ 13 | 14 | #ifndef DISKS_INC 15 | #define DISKS_INC 16 | 17 | #include "sim.h" 18 | #include "simdefs.h" 19 | 20 | #include "ff.h" 21 | 22 | #define NUMDISK 4 /* number of disk drives */ 23 | #define FNLEN 8 /* length of filename without extension */ 24 | #define DISKLEN 9 + FNLEN + 4 /* path length for disk drives /DISKS80/filename.DSK */ 25 | /* also used for code files /CODE80/filename.BIN */ 26 | 27 | extern FIL sd_file; 28 | extern FRESULT sd_res; 29 | extern char disks[NUMDISK][DISKLEN+1]; 30 | 31 | extern void init_disks(void), exit_disks(void); 32 | extern void list_files(const char *dir, const char *ext); 33 | extern bool load_file(const char *name); 34 | extern void check_disks(void); 35 | extern void mount_disk(int drive, const char *name); 36 | 37 | extern BYTE read_sec(int drive, int track, int sector, WORD addr); 38 | extern BYTE write_sec(int drive, int track, int sector, WORD addr); 39 | extern void get_fdccmd(BYTE *cmd, WORD addr); 40 | 41 | #endif /* !DISK_INC */ 42 | -------------------------------------------------------------------------------- /srccpm3/boot.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; CP/M 3 boot-loader for z80pack machines using SD-FDC 3 | ; 4 | ; Copyright (C) 2024 by Udo Munk 5 | ; 6 | ; History: 7 | ; 30-JUN-2024 first public release 8 | ; 9 | ORG 0 ; memory base of boot 10 | ; 11 | BOOT EQU 0100H ; cpmldr runs at 0100H 12 | SECTS EQU 25 ; # of sectors to load 13 | ; 14 | ; I/O ports 15 | ; 16 | FDC EQU 4 ;FDC port 17 | ; 18 | DI ;disable interrupts 19 | LXI SP,0FFH ;some space for stack 20 | MVI A,10H ;setup command for FDC 21 | OUT FDC 22 | MVI A,CMD AND 0FFH 23 | OUT FDC 24 | MVI A,CMD SHR 8 25 | OUT FDC 26 | LXI B,2 ;B=track 0, C=sector 2 27 | MVI D,SECTS ;D=# sectors to load 28 | ; 29 | ; load the next sector 30 | ; 31 | LSECT MVI A,20H ;tell FDC to read sector on drive 0 32 | OUT FDC 33 | IN FDC ;get result from FDC 34 | ORA A 35 | JZ BOOT1 36 | HLT ;read error, halt CPU 37 | BOOT1 DCR D ;SECTS=SECTS-1 38 | JZ BOOT ;all done, head for cpmldr 39 | INR C ;sector = sector + 1 40 | MOV A,C 41 | STA CMD+1 ;save sector 42 | PUSH D 43 | LHLD CMD+2 ;get DMA address 44 | LXI D,80H ;and increase it by 128 45 | DAD D 46 | POP D 47 | SHLD CMD+2 ;set new dma address 48 | JMP LSECT ;for next sector 49 | ; 50 | ; command bytes for the FDC 51 | CMD DB 00H ;track 0 52 | DB 02H ;sector 2 53 | DB BOOT AND 0FFH ;DMA address low 54 | DB BOOT SHR 8 ;DMA address high 55 | 56 | END ;of boot loader 57 | -------------------------------------------------------------------------------- /srcsim/simmem.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Z80SIM - a Z80-CPU simulator 3 | * 4 | * Copyright (C) 2024 by Udo Munk 5 | * Copyright (C) 2025 by Thomas Eberhardt 6 | * 7 | * This module implements the memory for the Z80/8080 CPU. 8 | * 9 | * History: 10 | * 23-APR-2024 derived from z80sim 11 | * 09-JUN-2024 implemented boot ROM 12 | * 28-JUN-2024 added second memory bank 13 | * 29-JUN-2024 implemented banked memory 14 | * 12-MAR-2025 added more memory banks for RP2350 15 | */ 16 | 17 | #include 18 | 19 | #include "sim.h" 20 | #include "simdefs.h" 21 | #include "simmem.h" 22 | 23 | /* 64KB bank 0 + common segment */ 24 | BYTE __aligned(4) bnk0[65536]; 25 | /* NUMSEG memory banks of size SEGSIZ */ 26 | BYTE __aligned(4) bnks[NUMSEG][SEGSIZ]; 27 | /* selected bank */ 28 | BYTE selbnk, *curbnk; 29 | 30 | /* boot ROM code */ 31 | #define MEMSIZE 256 32 | #include "bootrom.c" 33 | 34 | void init_memory(void) 35 | { 36 | register int i, j; 37 | 38 | /* copy boot ROM into write protected top memory page */ 39 | for (i = 0; i < MEMSIZE; i++) 40 | bnk0[0xff00 + i] = code[i]; 41 | 42 | /* trash memory like in a real machine after power on */ 43 | for (i = 0; i < 0xff00; i++) 44 | bnk0[i] = rand() % 256; 45 | for (j = 0; j < NUMSEG; j++) { 46 | curbnk = bnks[j]; 47 | for (i = 0; i < SEGSIZ; i++) 48 | curbnk[i] = rand() % 256; 49 | } 50 | 51 | selbnk = 0; 52 | } 53 | 54 | void reset_memory(void) 55 | { 56 | selbnk = 0; 57 | } 58 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/include/FsLib/FsNew.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2022 Bill Greiman 3 | * This file is part of the SdFat library for SD memory cards. 4 | * 5 | * MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #include "FsNew.h" 26 | void* operator new(size_t size, newalign_t* ptr) { 27 | (void)size; 28 | return ptr; 29 | } 30 | -------------------------------------------------------------------------------- /src-examples/README: -------------------------------------------------------------------------------- 1 | This directory contains Z80/8080 code examples for the Pico Z80. 2 | I have assembled the sources with z80asm from z80pack, but you 3 | can use any Z80/8080 assembler of course. 4 | 5 | With z80pack z80sim examples like these can be debugged under 6 | control of an In Circuit Emulator (debug probe), the serial 7 | port implemented in the latest release is identical. 8 | You also can attach the ICE to this machine for debugging, 9 | see sim.h for compiling options. 10 | 11 | Copy the "example".bin files into a directory CODE80 on MicroSD card. 12 | 13 | The examples are: 14 | serial.bin - shows how to do serial I/O 15 | blink.bin - blink a LED with Z80 port output 16 | 17 | test8080.bin - Kelly Smith 8080 CPU test program 18 | tb.bin - 8080 TINY BASIC 19 | kscope.bin - Kaleidoscope (uses Dazzler graphics) 20 | micro80.bin - 8080 Microchess (uses Dazzler graphics) 21 | life.bin - The Game of Life (uses Dazzler graphics) 22 | bas4k32.bin - MITS Altair BASIC 4K V3.2, runs on 8080 only! fp sw = 0 23 | bas8k40.bin - MITS Altair BASIC 8K V4.0, runs on 8080 only! fp sw = 22 24 | bas16k40.bin - Extended MITS Altair BASIC 16K V4.0 fp sw = 22 25 | this version starts on a Z80 but won't work correct 26 | 27 | "fp sw" = front panel switches 28 | 29 | Set the front panel switches with the "p - Port 255 value" menu 30 | command, or with "p fe" in the ICE (yes, port 254, which is a mirror 31 | of port 255 to allow setting the switches, since writing to port 255 32 | will set the port LEDs on the front panel display). 33 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/include/FsLib/FsLib.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2022 Bill Greiman 3 | * This file is part of the SdFat library for SD memory cards. 4 | * 5 | * MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef FsLib_h 26 | #define FsLib_h 27 | /** 28 | * \file 29 | * \brief FsLib include file. 30 | */ 31 | #include "FsVolume.h" 32 | #include "FsFile.h" 33 | #include "FsFormatter.h" 34 | #endif // FsLib_h 35 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/ff15/documents/res/app5.c: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------/ 2 | / Test if the file is contiguous / 3 | /----------------------------------------------------------------------*/ 4 | 5 | FRESULT test_contiguous_file ( 6 | FIL* fp, /* [IN] Open file object to be checked */ 7 | int* cont /* [OUT] 1:Contiguous, 0:Fragmented or zero-length */ 8 | ) 9 | { 10 | DWORD clst, clsz, step; 11 | FSIZE_t fsz; 12 | FRESULT fr; 13 | 14 | 15 | *cont = 0; 16 | fr = f_rewind(fp); /* Validates and prepares the file */ 17 | if (fr != FR_OK) return fr; 18 | 19 | #if FF_MAX_SS == FF_MIN_SS 20 | clsz = (DWORD)fp->obj.fs->csize * FF_MAX_SS; /* Cluster size */ 21 | #else 22 | clsz = (DWORD)fp->obj.fs->csize * fp->obj.fs->ssize; 23 | #endif 24 | fsz = f_size(fp); 25 | if (fsz > 0) { 26 | clst = fp->obj.sclust - 1; /* A cluster leading the first cluster for first test */ 27 | while (fsz) { 28 | step = (fsz >= clsz) ? clsz : (DWORD)fsz; 29 | fr = f_lseek(fp, f_tell(fp) + step); /* Advances file pointer a cluster */ 30 | if (fr != FR_OK) return fr; 31 | if (clst + 1 != fp->clust) break; /* Is not the cluster next to previous one? */ 32 | clst = fp->clust; fsz -= step; /* Get current cluster for next test */ 33 | } 34 | if (fsz == 0) *cont = 1; /* All done without fail? */ 35 | } 36 | 37 | return FR_OK; 38 | } 39 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/include/hw_config.h: -------------------------------------------------------------------------------- 1 | /* hw_config.h 2 | Copyright 2021 Carl John Kugler III 3 | 4 | Licensed under the Apache License, Version 2.0 (the License); you may not use 5 | this file except in compliance with the License. You may obtain a copy of the 6 | License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | */ 14 | #pragma once 15 | 16 | #include 17 | 18 | #include "sd_card.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /* FatFS supports up to 10 logical drives. By default, each logical 25 | drive is associated with the physical drive in same drive number. */ 26 | 27 | /* Return the number of physical drives (SD card sockets) in the configuration */ 28 | size_t sd_get_num(); 29 | 30 | /* Return a pointer to the SD card "object" at the given physical drive number. 31 | (See http://elm-chan.org/fsw/ff/doc/filename.html#vol.) 32 | Parameter `num` must be less than sd_get_num(). */ 33 | sd_card_t* sd_get_by_num(size_t num); 34 | 35 | /* See http://elm-chan.org/fsw/ff/doc/config.html#str_volume_id */ 36 | #if FF_STR_VOLUME_ID 37 | extern const char* VolumeStr[FF_VOLUMES]; /* User defined volume ID */ 38 | #endif 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | /* [] END OF FILE */ 45 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/bench2/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/one_SDIO/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/data_logger/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/one_SPI.C++/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/one_SPI.C/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/one_SPI_one_SDIO/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/one_SPI.C++/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [env:pico] 12 | platform = https://github.com/maxgerhardt/platform-raspberrypi.git 13 | board = pico 14 | framework = arduino 15 | board_build.core = earlephilhower 16 | platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#master 17 | debug_tool = cmsis-dap 18 | upload_protocol = cmsis-dap 19 | monitor_port = COM8 20 | monitor_speed = 115200 21 | 22 | build_flags = "-Wno-psabi" 23 | "-D USE_DBG_PRINTF" 24 | 25 | ; Normal way: 26 | ; lib_deps = 27 | ; carlk3/no-OS-FatFS-SD-SPI-RPi-Pico@^1.0.2 28 | 29 | ; Get the latest straight from github: 30 | ; lib_deps = https://github.com/carlk3/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico.git 31 | 32 | ; Use local copy: 33 | lib_deps = no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 34 | lib_extra_dirs = ../../../.. 35 | 36 | [env:pico2] 37 | platform = https://github.com/maxgerhardt/platform-raspberrypi.git 38 | board = rpipico2 39 | framework = arduino 40 | platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#master 41 | debug_tool = cmsis-dap 42 | upload_protocol = cmsis-dap 43 | lib_deps = no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 44 | lib_extra_dirs = ../../../.. 45 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/one_SPI_one_SDIO.dir_ops/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /srcsim/sim.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Z80SIM - a Z80-CPU simulator 3 | * 4 | * Copyright (C) 2024-2025 by Udo Munk & Thomas Eberhardt 5 | * 6 | * This is the configuration for a Waveshare RP2040/RP2350-GEEK board 7 | */ 8 | 9 | #ifndef SIM_INC 10 | #define SIM_INC 11 | 12 | #define DEF_CPU Z80 /* default CPU (Z80 or I8080) */ 13 | //#define EXCLUDE_I8080 /* we want both CPU's */ 14 | #define CPU_SPEED 4 /* CPU speed 0=unlimited */ 15 | /*#define ALT_I8080*/ /* use alt. 8080 sim. primarily optimized for size */ 16 | /*#define ALT_Z80*/ /* use alt. Z80 sim. primarily optimized for size */ 17 | #define UNDOC_INST /* compile undocumented instrs. (required by ALT_*) */ 18 | #ifndef EXCLUDE_Z80 19 | /*#define FAST_BLOCK*/ /* much faster but not accurate Z80 block instr. */ 20 | #endif 21 | #define SIMPLEPANEL /* this machine has a simple frontpanel */ 22 | #define IOPANEL /* this machine has an I/O port panel */ 23 | 24 | /*#define WANT_ICE*/ /* attach ICE to headless machine */ 25 | #ifdef WANT_ICE 26 | #define BAREMETAL /* disable ICE commands that require a full OS */ 27 | #define WANT_TIM /* count t-states */ 28 | #define HISIZE 100 /* number of entries in history */ 29 | #define SBSIZE 4 /* number of software breakpoints */ 30 | #define WANT_HB /* hardware breakpoint */ 31 | #endif 32 | 33 | #if PICO_RP2040 34 | #define MODEL "RP2040-GEEK" 35 | #else 36 | #define MODEL "RP2350-GEEK" 37 | #endif 38 | 39 | #define USR_COM "Waveshare " MODEL " Z80/8080 emulator" 40 | #define USR_REL "1.8" 41 | #define USR_CPR "Copyright (C) 2024-2025 by Udo Munk & Thomas Eberhardt" 42 | 43 | #ifndef PRIu64 44 | #define PRIu64 "llu" 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /libs/pico-ds3231/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2023, Antonio González 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/data_logger/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [env:pico] 12 | platform = https://github.com/maxgerhardt/platform-raspberrypi.git 13 | board = pico 14 | framework = arduino 15 | board_build.core = earlephilhower 16 | debug_tool = cmsis-dap 17 | upload_protocol = cmsis-dap 18 | monitor_port = COM8 19 | monitor_speed = 115200 20 | 21 | build_flags = 22 | "-Wno-psabi" 23 | -D USE_DBG_PRINTF ; Debug output 24 | 25 | ; Normal way: 26 | ; lib_deps = 27 | ; carlk3/no-OS-FatFS-SD-SPI-RPi-Pico@^1.0.2 28 | 29 | ; Get the latest straight from github: 30 | ; lib_deps = https://github.com/carlk3/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico.git 31 | 32 | ; Use local copy: 33 | lib_deps = no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 34 | lib_extra_dirs = ../../../.. 35 | platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#master 36 | 37 | [env:pico2] 38 | platform = https://github.com/maxgerhardt/platform-raspberrypi.git 39 | board = rpipico2 40 | framework = arduino 41 | debug_tool = cmsis-dap 42 | upload_protocol = cmsis-dap 43 | lib_deps = no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 44 | lib_extra_dirs = ../../../.. 45 | platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#master 46 | -------------------------------------------------------------------------------- /libs/pico-ds3231/README.md: -------------------------------------------------------------------------------- 1 | # pico-ds3231 2 | 3 | A C library for using the DS3231 real-time clock with the Raspberry Pi 4 | Pico. 5 | 6 | The DS3231 ([product website][analog]) is a real-time clock (RTC) with 7 | integrated crystal oscillator. It also features two 2 alarms and a 8 | battery-backup input. 9 | 10 | There are breakout boards that use this RTC, notably Adafruit's DS3231 11 | Precision RTC breakout board ([cat.num. 3013][ada3013]). 12 | 13 | [analog]: https://www.analog.com/en/products/ds3231.html 14 | [ada3013]: https://www.adafruit.com/product/3013 15 | 16 | 17 | ## Pin description 18 | 19 | | DS3231 Pin | Description 20 | |------------|------------ 21 | | 32 kHz | Oscillator output. Leave unconnected if not used 22 | | Vin | Power supply, requires decoupling capacitor (0.1 to 1 uF) 23 | | ~INT/SQW | Square wave or interrupt output. Leave unconnected if not used 24 | | ~RST | Active-low reset 25 | | GND | Ground 26 | | VBAT | Backup power supply input. If not used connect to ground 27 | | SDA | Serial data input/output 28 | | SCL | Serial data clock 29 | 30 | 31 | ## Wiring 32 | 33 | The DS3231 RTC operates with an I2C interface. Thus, all it requires is 34 | connections to SDA, SCL, Vin, and GND pins in the Pico, e.g. 35 | 36 | | RTC | Pico 37 | |-----|--------- 38 | | Vin | 3V3(OUT) 39 | | SDA | GP4 40 | | SCL | GP5 41 | | GDN | GND 42 | 43 | 44 | ## Using the library 45 | 46 | See examples. 47 | 48 | ### To do 49 | 50 | These are additional functions that are available in the DS3231 but have 51 | not yet been implemented in this library: 52 | 53 | * Alarms/alarm interrupts 54 | * Enabling/setting freq of square-wave output 55 | -------------------------------------------------------------------------------- /srccpm2/boot.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; CP/M 2.2 boot-loader for z80pack machines using SD-FDC 3 | ; 4 | ; Copyright (C) 2024 by Udo Munk 5 | ; 6 | ORG 0 ;mem base of boot 7 | ; 8 | MSIZE EQU 64 ;mem size in kbytes 9 | ; 10 | BIAS EQU (MSIZE-20)*1024 ;offset from 20k system 11 | CCP EQU 3400H+BIAS ;base of the ccp 12 | CPMB EQU BIAS+3400H ;start of CP/M 13 | BOOTE EQU CPMB+1600H ;cold boot entry point 14 | SECTS EQU 51 ;# of sectors to load (26 * 2 - 1) 15 | ; 16 | ; I/O ports 17 | ; 18 | FDC EQU 4 ;FDC port 19 | ; 20 | DI ;disable interrupts 21 | LXI SP,0FFH ;some space for stack 22 | MVI A,10H ;setup command for FDC 23 | OUT FDC 24 | MVI A,CMD AND 0FFH 25 | OUT FDC 26 | MVI A,CMD SHR 8 27 | OUT FDC 28 | LXI B,2 ;B=track 0, C=sector 2 29 | MVI D,SECTS ;D=# sectors to load 30 | ; 31 | ; load the next sector 32 | ; 33 | LSECT MVI A,20H ;tell FDC to read sector on drive 0 34 | OUT FDC 35 | IN FDC ;get result from FDC 36 | ORA A 37 | JZ BOOT1 38 | HLT ;read error, halt CPU 39 | BOOT1 DCR D ;SECTS=SECTS-1 40 | JZ BOOTE ;go to CP/M if all sectors done 41 | INR C ;sector = sector + 1 42 | MOV A,C 43 | CPI 27 ;last sector of track? 44 | JC BOOT2 ;no, do next sector 45 | MVI C,1 ;sector = 1 46 | INR B ;track = track + 1 47 | BOOT2 MOV A,B ;setup command 48 | STA CMD+0 ;save track 49 | MOV A,C 50 | STA CMD+1 ;save sector 51 | PUSH D 52 | LHLD CMD+2 ;get DMA address 53 | LXI D,80H ;and increase it by 128 54 | DAD D 55 | POP D 56 | SHLD CMD+2 ;set new dma address 57 | JMP LSECT ;for next sector 58 | ; 59 | ; command bytes for the FDC 60 | CMD DB 00H ;track 0 61 | DB 02H ;sector 2 62 | DB CPMB AND 0FFH ;DMA address low 63 | DB CPMB SHR 8 ;DMA address high 64 | 65 | END ;of boot loader 66 | -------------------------------------------------------------------------------- /src-examples/serial.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Example program for the Pico Z80 3 | ; Do some serial I/O. 4 | ; 5 | ; Udo Munk, April 2024 6 | ; 7 | ORG 0000H ; starting at memory location 0 8 | 9 | CR EQU 13 ; carriage return 10 | LF EQU 10 ; line feed 11 | 12 | ; 13 | ; ports defined are for the first USB console, change to 7 and 8 14 | ; for communication over the serial UART 15 | ; 16 | TTYSTA EQU 0 ; tty status port 17 | TTYDAT EQU 1 ; tty data port 18 | 19 | DI ; disable interrupts 20 | LD SP,STACK ; setup stack in upper memory 21 | 22 | ; print instructions 23 | LD HL,TEXT ; HL points to text to send 24 | LOOP: LD A,(HL) ; get next character into A 25 | OR A ; is it 0 termination? 26 | JR Z,ECHO ; if yes done 27 | CALL OUTCH ; output character to tty 28 | INC HL ; point to next character 29 | JR LOOP ; and again 30 | 31 | ; now echo what is typed 32 | ECHO: IN A,(TTYSTA) ; get tty status 33 | RRCA 34 | JR C,ECHO ; wait if not ready 35 | IN A,(TTYDAT) ; get character from tty into A 36 | CALL OUTCH ; echo it 37 | CP 'X' ; is it a X? 38 | JR Z,DONE ; done if so 39 | CP CR ; is it a carriage return? 40 | JR NZ,ECHO ; no, go on 41 | LD A,LF ; else also send line feed 42 | CALL OUTCH 43 | JR ECHO ; repeat 44 | 45 | DONE: HALT ; done 46 | 47 | ; output character in A to tty 48 | OUTCH: PUSH AF ; save character in A 49 | OUTCH1: IN A,(TTYSTA) ; get tty status 50 | RLCA 51 | JR C,OUTCH1 ; wait if not ready 52 | POP AF ; get character back into A 53 | OUT (TTYDAT),A ; send character to tty 54 | RET 55 | 56 | TEXT: DEFM "Hello from the Z80 CPU" 57 | DEFB CR,LF 58 | DEFM "I will echo what you type, type X if done" 59 | DEFB CR,LF,0 60 | 61 | DS 20 ; space for the stack 62 | STACK: 63 | 64 | END ; of program 65 | -------------------------------------------------------------------------------- /libs/pico-ds3231/examples/read_temperature/read_temperature.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Antonio González 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | #include "pico/stdlib.h" 9 | #include "hardware/i2c.h" 10 | 11 | #include "ds3231.h" 12 | 13 | 14 | /* 15 | This example shows how to read the temperature register in the DS3231 16 | */ 17 | 18 | // Modify these definitions as required, to match your wiring 19 | #define DS3231_I2C_PORT i2c1 20 | #define DS3231_I2C_SDA_PIN 2 21 | #define DS3231_I2C_SCL_PIN 3 22 | 23 | int main() { 24 | stdio_init_all(); 25 | 26 | // Variable for the temperature value. 27 | float temperature; 28 | 29 | // Create a real-time clock structure and initiate this. 30 | struct ds3231_rtc rtc; 31 | ds3231_init(DS3231_I2C_PORT, DS3231_I2C_SDA_PIN, 32 | DS3231_I2C_SCL_PIN, &rtc); 33 | 34 | // A datetime structure holds date and time values. 35 | ds3231_datetime_t dt; 36 | 37 | // This is a character array that will be used for storing a string 38 | // representation of the date and time. 39 | uint8_t dt_str[25]; 40 | 41 | // Sleep for a few seconds while the user opens the terminal. 42 | sleep_ms(3000); 43 | 44 | while (1) { 45 | // Read the date and time from the DS3231 RTC. 46 | ds3231_get_datetime(&dt, &rtc); 47 | 48 | // Convert the dt structure to a string and print this. 49 | ds3231_ctime(dt_str, sizeof(dt_str), &dt); 50 | puts(dt_str); 51 | 52 | // Read the temperature register and print 53 | ds3231_get_temperature(&temperature, &rtc); 54 | printf("Temperature: %0.2f C\n", temperature); 55 | 56 | // Sleep for a while. Note that the temperature register is only 57 | // updated every 64 seconds. Thus, reading this value more often 58 | // than this does not make much sense. 59 | sleep_ms(65000); 60 | } 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/ff15/LICENSE.txt: -------------------------------------------------------------------------------- 1 | FatFs License 2 | 3 | FatFs has being developped as a personal project of the author, ChaN. It is free from the code anyone else wrote at current release. Following code block shows a copy of the FatFs license document that heading the source files. 4 | 5 | /*----------------------------------------------------------------------------/ 6 | / FatFs - Generic FAT Filesystem Module Rx.xx / 7 | /-----------------------------------------------------------------------------/ 8 | / 9 | / Copyright (C) 20xx, ChaN, all right reserved. 10 | / 11 | / FatFs module is an open source software. Redistribution and use of FatFs in 12 | / source and binary forms, with or without modification, are permitted provided 13 | / that the following condition is met: 14 | / 15 | / 1. Redistributions of source code must retain the above copyright notice, 16 | / this condition and the following disclaimer. 17 | / 18 | / This software is provided by the copyright holder and contributors "AS IS" 19 | / and any warranties related to this software are DISCLAIMED. 20 | / The copyright owner or contributors be NOT LIABLE for any damages caused 21 | / by use of this software. 22 | /----------------------------------------------------------------------------*/ 23 | 24 | Therefore FatFs license is one of the BSD-style licenses, but there is a significant feature. FatFs is mainly intended for embedded systems. In order to extend the usability for commercial products, the redistributions of FatFs in binary form, such as embedded code, binary library and any forms without source code, do not need to include about FatFs in the documentations. This is equivalent to the 1-clause BSD license. Of course FatFs is compatible with the most of open source software licenses include GNU GPL. When you redistribute the FatFs source code with changes or create a fork, the license can also be changed to GNU GPL, BSD-style license or any open source software license that not conflict with FatFs license. 25 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/simple_sdio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # == DO NEVER EDIT THE NEXT LINES for Raspberry Pi Pico VS Code Extension to work == 2 | if(WIN32) 3 | set(USERHOME $ENV{USERPROFILE}) 4 | else() 5 | set(USERHOME $ENV{HOME}) 6 | endif() 7 | set(sdkVersion 2.0.0) 8 | set(toolchainVersion 13_2_Rel1) 9 | set(picotoolVersion 2.0.0) 10 | set(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake) 11 | if (EXISTS ${picoVscode}) 12 | include(${picoVscode}) 13 | endif() 14 | # ==================================================================================== 15 | # Generated Cmake Pico project file 16 | 17 | cmake_minimum_required(VERSION 3.5) 18 | 19 | set(PICO_BOARD pico CACHE STRING "Board type") 20 | 21 | # Pull in Pico SDK (must be before project) 22 | include(pico_sdk_import.cmake) 23 | 24 | project(simple_sdio C CXX ASM) 25 | 26 | # Initialise the Raspberry Pi Pico SDK 27 | pico_sdk_init() 28 | 29 | add_subdirectory(../../src build) 30 | 31 | # Add executable. Default name is the project name, version 0.1 32 | add_executable(simple_sdio main.c) 33 | 34 | # Can leave these off for silent mode: 35 | # add_compile_definitions(USE_PRINTF USE_DBG_PRINTF) 36 | add_compile_definitions(USE_PRINTF) 37 | 38 | # Add the standard library and FatFS/SPI to the build 39 | target_link_libraries(simple_sdio 40 | pico_stdlib 41 | no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 42 | ) 43 | 44 | pico_set_program_name(simple_sdio "simple_sdio") 45 | pico_set_program_version(simple_sdio "0.1") 46 | 47 | # Choose source and destination for standard input and output: 48 | # See 4.1. Serial input and output on Raspberry Pi Pico in Getting started with Raspberry Pi Pico (https://datasheets.raspberrypi.org/pico/getting-started-with-pico.pdf) 49 | # and 2.7.1. Standard Input/Output (stdio) Support in Raspberry Pi Pico C/C++ SDK (https://datasheets.raspberrypi.org/pico/raspberry-pi-pico-c-sdk.pdf): 50 | pico_enable_stdio_uart(simple_sdio 1) 51 | pico_enable_stdio_usb(simple_sdio 1) 52 | 53 | pico_add_extra_outputs(simple_sdio) 54 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/simple/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # == DO NEVER EDIT THE NEXT LINES for Raspberry Pi Pico VS Code Extension to work == 2 | if(WIN32) 3 | set(USERHOME $ENV{USERPROFILE}) 4 | else() 5 | set(USERHOME $ENV{HOME}) 6 | endif() 7 | set(sdkVersion 2.0.0) 8 | set(toolchainVersion 13_2_Rel1) 9 | set(picotoolVersion 2.0.0) 10 | set(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake) 11 | if (EXISTS ${picoVscode}) 12 | include(${picoVscode}) 13 | endif() 14 | # ==================================================================================== 15 | cmake_minimum_required(VERSION 3.5) 16 | 17 | set(PICO_BOARD pico2 CACHE STRING "Board type") 18 | 19 | # Pull in Pico SDK (must be before project) 20 | include(pico_sdk_import.cmake) 21 | 22 | project(simple_example C CXX ASM) 23 | 24 | # Initialise the Raspberry Pi Pico SDK 25 | pico_sdk_init() 26 | 27 | add_subdirectory(../../src build) 28 | 29 | # Add executable. Default name is the project name, version 0.1 30 | add_executable(simple_example 31 | main.c 32 | hw_config.c 33 | ) 34 | # Can leave these off for silent mode: 35 | # add_compile_definitions(USE_PRINTF USE_DBG_PRINTF) 36 | add_compile_definitions(USE_PRINTF) 37 | 38 | # Add the standard library and FatFS/SPI to the build 39 | target_link_libraries(simple_example 40 | pico_stdlib 41 | no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 42 | ) 43 | 44 | pico_set_program_name(simple_example "simple_example") 45 | pico_set_program_version(simple_example "0.1") 46 | 47 | # Choose source and destination for standard input and output: 48 | # See 4.1. Serial input and output on Raspberry Pi Pico in Getting started with Raspberry Pi Pico (https://datasheets.raspberrypi.org/pico/getting-started-with-pico.pdf) 49 | # and 2.7.1. Standard Input/Output (stdio) Support in Raspberry Pi Pico C/C++ SDK (https://datasheets.raspberrypi.org/pico/raspberry-pi-pico-c-sdk.pdf): 50 | pico_enable_stdio_uart(simple_example 1) 51 | pico_enable_stdio_usb(simple_example 1) 52 | 53 | pico_add_extra_outputs(simple_example) 54 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/usb_mass_storage/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # == DO NEVER EDIT THE NEXT LINES for Raspberry Pi Pico VS Code Extension to work == 2 | if(WIN32) 3 | set(USERHOME $ENV{USERPROFILE}) 4 | else() 5 | set(USERHOME $ENV{HOME}) 6 | endif() 7 | set(sdkVersion 2.0.0) 8 | set(toolchainVersion 13_2_Rel1) 9 | set(picotoolVersion 2.0.0) 10 | set(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake) 11 | if (EXISTS ${picoVscode}) 12 | include(${picoVscode}) 13 | endif() 14 | # ==================================================================================== 15 | cmake_minimum_required(VERSION 3.13...3.27) 16 | 17 | set(PICO_BOARD pico CACHE STRING "Board type") 18 | 19 | set(PROGRAM_NAME sd-usb) 20 | 21 | # Pull in Pico SDK (must be before project) 22 | include(pico_sdk_import.cmake) 23 | 24 | project(${PROGRAM_NAME}) 25 | 26 | pico_sdk_init() 27 | 28 | add_subdirectory(../../src build) 29 | 30 | add_executable(${PROGRAM_NAME} 31 | hw_config.c 32 | main.c 33 | msc_disk.c 34 | usb_descriptors.c 35 | ) 36 | target_link_libraries(${PROGRAM_NAME} PRIVATE 37 | no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 38 | pico_stdlib 39 | tinyusb_additions 40 | tinyusb_board 41 | tinyusb_device 42 | ) 43 | 44 | target_include_directories(${PROGRAM_NAME} PRIVATE 45 | ${CMAKE_CURRENT_LIST_DIR}/include 46 | ) 47 | 48 | # https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf 49 | target_compile_definitions(${PROGRAM_NAME} PUBLIC 50 | PARAM_ASSERTIONS_ENABLE_ALL=1 51 | PICO_MALLOC_PANIC=1 52 | PICO_USE_STACK_GUARDS=1 53 | 54 | USE_PRINTF 55 | USE_DBG_PRINTF 56 | ) 57 | 58 | #target_compile_options(${PROGRAM_NAME} PRIVATE -Werror -Wall -Wextra -Wnull-dereference) 59 | target_compile_options(${PROGRAM_NAME} PUBLIC 60 | -Wall 61 | -Wextra 62 | -Wshadow 63 | -Wstack-usage=2048 64 | -fanalyzer 65 | ) 66 | 67 | target_link_options(${PROGRAM_NAME} PRIVATE -Wl,--print-memory-usage) 68 | 69 | pico_enable_stdio_usb(${PROGRAM_NAME} 1) 70 | pico_add_extra_outputs(${PROGRAM_NAME}) 71 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/include/FsLib/FsNew.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2022 Bill Greiman 3 | * This file is part of the SdFat library for SD memory cards. 4 | * 5 | * MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef FsNew_h 26 | #define FsNew_h 27 | #include 28 | #include 29 | 30 | /** 32-bit alignment */ 31 | typedef uint32_t newalign_t; 32 | 33 | /** Size required for exFAT or FAT class. */ 34 | #define FS_SIZE(etype, ftype) \ 35 | (sizeof(ftype) < sizeof(etype) ? sizeof(etype) : sizeof(ftype)) 36 | 37 | /** Dimension of aligned area. */ 38 | #define NEW_ALIGN_DIM(n) \ 39 | (((size_t)(n) + sizeof(newalign_t) - 1U)/sizeof(newalign_t)) 40 | 41 | /** Dimension of aligned area for etype or ftype class. */ 42 | #define FS_ALIGN_DIM(etype, ftype) NEW_ALIGN_DIM(FS_SIZE(etype, ftype)) 43 | 44 | /** Custom new placement operator */ 45 | void* operator new(size_t size, newalign_t* ptr); 46 | #endif // FsNew_h 47 | -------------------------------------------------------------------------------- /src-examples/blink.lis: -------------------------------------------------------------------------------- 1 | Z80/8080-Macro-Assembler Release 2.1 2 | 3 | LOC OBJECT CODE LINE STMT SOURCE CODE 4 | 1 1 ; 5 | 2 2 ; Example program for the Pico Z80 6 | 3 3 ; Blink a LED for a bit 7 | 4 4 ; 8 | 5 5 ; Udo Munk, April 2024 9 | 6 6 ; 10 | 7 7 11 | 8 8 12 | 9 9 ORG 0000H ; starting at memory location 0 13 | 10 10 14 | 0000 = 11 11 LED EQU 0 ; LED port 15 | 12 12 16 | 0000 f3 13 13 DI ; disable interrupts 17 | 0001 31 35 00 14 14 LD SP,STACK ; setup stack in upper memory 18 | 15 15 19 | 0004 06 14 16 16 LD B,20 ; blink LED 20 times 20 | 0006 3e 01 17 17 L1: LD A,1 ; switch LED on 21 | 0008 d3 00 18 18 OUT (LED),A 22 | 000a 21 00 00 19 19 LD HL,0 ; wait a bit 23 | 000d 2b 20 20 L2: DEC HL 24 | 000e 7c 21 21 LD A,H 25 | 000f b5 22 22 OR L 26 | 0010 20 fb 23 23 JR NZ,L2 27 | 0012 3e 00 24 24 LD A,0 ; switch LED off 28 | 0014 d3 00 25 25 OUT (LED),A 29 | 0016 21 00 00 26 26 LD HL,0 ; wait a bit 30 | 0019 2b 27 27 L3: DEC HL 31 | 001a 7c 28 28 LD A,H 32 | 001b b5 29 29 OR L 33 | 001c 20 fb 30 30 JR NZ,L3 34 | 001e 10 e6 31 31 DJNZ L1 ; again if not done 35 | 0020 76 32 32 HALT ; done, halt CPU 36 | 33 33 37 | 0021 34 34 DS 20 ; space for the stack 38 | 0035 35 35 STACK: 39 | 36 36 40 | 0035 37 37 END ; of program 41 | 42 | Symbol table 43 | 44 | L1 0006 L2 000d L3 0019 LED 0000 STACK 0035 45 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(no-OS-FatFS-SD-SDIO-SPI-RPi-Pico INTERFACE) 2 | 3 | pico_generate_pio_header(no-OS-FatFS-SD-SDIO-SPI-RPi-Pico ${CMAKE_CURRENT_LIST_DIR}/sd_driver/SDIO/rp2040_sdio.pio) 4 | 5 | target_compile_definitions(no-OS-FatFS-SD-SDIO-SPI-RPi-Pico INTERFACE 6 | PICO_MAX_SHARED_IRQ_HANDLERS=8u 7 | ) 8 | # target_compile_options(no-OS-FatFS-SD-SDIO-SPI-RPi-Pico INTERFACE -ffile-prefix-map=${CMAKE_CURRENT_LIST_DIR}=) 9 | 10 | target_sources(no-OS-FatFS-SD-SDIO-SPI-RPi-Pico INTERFACE 11 | ${CMAKE_CURRENT_LIST_DIR}/ff15/source/ff.c 12 | ${CMAKE_CURRENT_LIST_DIR}/ff15/source/ffsystem.c 13 | ${CMAKE_CURRENT_LIST_DIR}/ff15/source/ffunicode.c 14 | ${CMAKE_CURRENT_LIST_DIR}/sd_driver/dma_interrupts.c 15 | ${CMAKE_CURRENT_LIST_DIR}/sd_driver/sd_card.c 16 | ${CMAKE_CURRENT_LIST_DIR}/sd_driver/sd_timeouts.c 17 | ${CMAKE_CURRENT_LIST_DIR}/sd_driver/SDIO/rp2040_sdio.c 18 | ${CMAKE_CURRENT_LIST_DIR}/sd_driver/SDIO/sd_card_sdio.c 19 | ${CMAKE_CURRENT_LIST_DIR}/sd_driver/SPI/my_spi.c 20 | ${CMAKE_CURRENT_LIST_DIR}/sd_driver/SPI/sd_card_spi.c 21 | ${CMAKE_CURRENT_LIST_DIR}/sd_driver/SPI/sd_spi.c 22 | ${CMAKE_CURRENT_LIST_DIR}/src/crash.c 23 | ${CMAKE_CURRENT_LIST_DIR}/src/crc.c 24 | ${CMAKE_CURRENT_LIST_DIR}/src/f_util.c 25 | ${CMAKE_CURRENT_LIST_DIR}/src/ff_stdio.c 26 | ${CMAKE_CURRENT_LIST_DIR}/src/file_stream.c 27 | ${CMAKE_CURRENT_LIST_DIR}/src/glue.c 28 | ${CMAKE_CURRENT_LIST_DIR}/src/my_debug.c 29 | ${CMAKE_CURRENT_LIST_DIR}/src/my_rtc.c 30 | ${CMAKE_CURRENT_LIST_DIR}/src/util.c 31 | ) 32 | target_include_directories(no-OS-FatFS-SD-SDIO-SPI-RPi-Pico INTERFACE 33 | ff15/source 34 | sd_driver 35 | include 36 | ) 37 | 38 | if(PICO_RISCV) 39 | set(HWDEP_LIBS hardware_watchdog) 40 | else() 41 | set(HWDEP_LIBS cmsis_core) 42 | endif() 43 | 44 | target_link_libraries(no-OS-FatFS-SD-SDIO-SPI-RPi-Pico INTERFACE 45 | hardware_dma 46 | hardware_pio 47 | hardware_spi 48 | hardware_sync 49 | pico_aon_timer 50 | pico_stdlib 51 | ${HWDEP_LIBS} 52 | ) 53 | -------------------------------------------------------------------------------- /src-examples/kscope.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; CROMEMCO DAZZLER KALEIDOSCOPE 3 | ; WRITTEN BY LI-CHEN WANG 4 | ; 5 | 6 | ORG 0 7 | 8 | DI 9 | LXI SP,0100H 10 | MVI A,081H 11 | OUT 14 12 | MVI A,030H 13 | OUT 15 14 | L0B IN 0 15 | RRC 16 | JC NOKEY 17 | HLT 18 | NOKEY MOV A,B 19 | RRC 20 | RRC 21 | ANA D 22 | ADD C 23 | MOV C,A 24 | RRC 25 | RRC 26 | ANA D 27 | MOV L,A 28 | MOV A,B 29 | SUB L 30 | MOV B,A 31 | PUSH B 32 | PUSH D 33 | PUSH H 34 | LXI D,0 35 | MOV A,H 36 | ANI 01FH 37 | RAR 38 | JC L2B 39 | MOV E,A 40 | RLC 41 | RLC 42 | RLC 43 | RLC 44 | MOV D,A 45 | L2B MVI H,08H 46 | CALL L5D 47 | MOV A,B 48 | CMA 49 | MOV B,A 50 | MVI H,06H 51 | CALL L5D 52 | MOV A,C 53 | CMA 54 | MOV C,A 55 | MVI H,02H 56 | CALL L5D 57 | MOV A,B 58 | CMA 59 | MOV B,A 60 | MVI H,04H 61 | CALL L5D 62 | POP H 63 | POP D 64 | POP B 65 | DCR E 66 | JNZ L0B 67 | INR B 68 | INR C 69 | MVI E,03FH 70 | DCR H 71 | JNZ L0B 72 | INR D 73 | MVI H,01FH 74 | JMP L0B 75 | L5D MOV A,C 76 | ANI 0F8H 77 | RAL 78 | MOV L,A 79 | MOV A,H 80 | ACI 00H 81 | MOV H,A 82 | MOV A,B 83 | ANI 0F8H 84 | RAR 85 | RAR 86 | RAR 87 | RAR 88 | PUSH PSW 89 | ADD L 90 | MOV L,A 91 | POP PSW 92 | MOV A,M 93 | JC L7A 94 | ANI 0F0H 95 | ADD E 96 | MOV M,A 97 | RET 98 | L7A ANI 0FH 99 | ADD D 100 | MOV M,A 101 | RET 102 | 103 | END 104 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/command_line/config/maker_pi_pico.hw_config.c: -------------------------------------------------------------------------------- 1 | /* hw_config.c 2 | Copyright 2021 Carl John Kugler III 3 | 4 | Licensed under the Apache License, Version 2.0 (the License); you may not use 5 | this file except in compliance with the License. You may obtain a copy of the 6 | License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | */ 14 | /* 15 | 16 | This file should be tailored to match the hardware design. 17 | See 18 | https://github.com/carlk3/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/tree/main#customizing-for-the-hardware-configuration 19 | 20 | */ 21 | 22 | #include "hw_config.h" 23 | 24 | // Hardware Configuration of SPI "objects" 25 | // Note: multiple SD cards can be driven by one SPI if they use different slave 26 | // selects. 27 | static spi_t spi = { // One for each RP2040 SPI component used 28 | .hw_inst = spi1, // SPI component 29 | .miso_gpio = 12, // GPIO number (not pin number) 30 | .mosi_gpio = 11, 31 | .sck_gpio = 10, 32 | .baud_rate = 12500 * 1000, 33 | //.baud_rate = 25 * 1000 * 1000, // Actual frequency: 20833333. 34 | }; 35 | /* SPI Interfaces */ 36 | static sd_spi_if_t spi_if = { 37 | .spi = &spi, // Pointer to the SPI driving this card 38 | .ss_gpio = 15 // The SPI slave select GPIO for this SD card 39 | }; 40 | 41 | // Hardware Configuration of the SD Card "objects" 42 | static sd_card_t sd_card = { 43 | .type = SD_IF_SPI, 44 | .spi_if_p = &spi_if, // Pointer to the SPI interface driving this card 45 | }; 46 | 47 | /* ********************************************************************** */ 48 | 49 | size_t sd_get_num() { return 1; } 50 | 51 | sd_card_t *sd_get_by_num(size_t num) { 52 | if (0 == num) { 53 | return &sd_card; 54 | } else { 55 | return NULL; 56 | } 57 | } 58 | 59 | /* [] END OF FILE */ 60 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/PlatformIO/bench2/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [env:pico] 12 | ; platform = raspberrypi 13 | ; board = pico 14 | ; framework = arduino 15 | 16 | platform = https://github.com/maxgerhardt/platform-raspberrypi.git 17 | board = pico 18 | framework = arduino 19 | board_build.core = earlephilhower 20 | debug_tool = cmsis-dap 21 | upload_protocol = cmsis-dap 22 | 23 | build_type = release 24 | 25 | build_flags = 26 | "-Wno-psabi" 27 | -D PICO_STACK_SIZE=0x400 28 | -D __HEAP_SIZE=0x400 29 | -D PICO_USE_STACK_GUARDS=1 30 | -D USE_DBG_PRINTF 31 | 32 | ; Normal way: 33 | ; lib_deps = 34 | ; carlk3/no-OS-FatFS-SD-SPI-RPi-Pico@^1.0.2 35 | 36 | ; Get the latest straight from github: 37 | ; lib_deps = https://github.com/carlk3/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico.git 38 | 39 | ; Use local copy: 40 | lib_deps = no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 41 | lib_extra_dirs = ../../../.. 42 | platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#master 43 | 44 | ; lib_ldf_mode = deep+ 45 | 46 | [env:picow] 47 | platform = https://github.com/maxgerhardt/platform-raspberrypi.git 48 | board = rpipicow 49 | framework = arduino 50 | debug_tool = cmsis-dap 51 | upload_protocol = cmsis-dap 52 | lib_deps = no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 53 | lib_extra_dirs = ../../../.. 54 | platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#master 55 | 56 | [env:pico2] 57 | platform = https://github.com/maxgerhardt/platform-raspberrypi.git 58 | board = rpipico2 59 | framework = arduino 60 | debug_tool = cmsis-dap 61 | upload_protocol = cmsis-dap 62 | lib_deps = no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 63 | lib_extra_dirs = ../../../.. 64 | platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#master 65 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/ff15/documents/res/app6.c: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------*/ 2 | /* Raw Read/Write Throughput Checker */ 3 | /*---------------------------------------------------------------------*/ 4 | 5 | #include 6 | #include 7 | #include "diskio.h" 8 | #include "ff.h" 9 | 10 | 11 | int test_raw_speed ( 12 | BYTE pdrv, /* Physical drive number */ 13 | DWORD lba, /* Start LBA for read/write test */ 14 | DWORD len, /* Number of bytes to read/write (must be multiple of sz_buff) */ 15 | void* buff, /* Read/write buffer */ 16 | UINT sz_buff /* Size of read/write buffer (must be multiple of FF_MAX_SS) */ 17 | ) 18 | { 19 | WORD ss; 20 | DWORD ofs, tmr; 21 | 22 | 23 | #if FF_MIN_SS != FF_MAX_SS 24 | if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &ss) != RES_OK) { 25 | printf("\ndisk_ioctl() failed.\n"); 26 | return 0; 27 | } 28 | #else 29 | ss = FF_MAX_SS; 30 | #endif 31 | 32 | printf("Starting raw write test at sector %lu in %u bytes of data chunks...", lba, sz_buff); 33 | tmr = systimer(); 34 | for (ofs = 0; ofs < len / ss; ofs += sz_buff / ss) { 35 | if (disk_write(pdrv, buff, lba + ofs, sz_buff / ss) != RES_OK) { 36 | printf("\ndisk_write() failed.\n"); 37 | return 0; 38 | } 39 | } 40 | if (disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) { 41 | printf("\ndisk_ioctl() failed.\n"); 42 | return 0; 43 | } 44 | tmr = systimer() - tmr; 45 | printf("\n%lu bytes written and it took %lu timer ticks.\n", len, tmr); 46 | 47 | printf("Starting raw read test at sector %lu in %u bytes of data chunks...", lba, sz_buff); 48 | tmr = systimer(); 49 | for (ofs = 0; ofs < len / ss; ofs += sz_buff / ss) { 50 | if (disk_read(pdrv, buff, lba + ofs, sz_buff / ss) != RES_OK) { 51 | printf("\ndisk_read() failed.\n"); 52 | return 0; 53 | } 54 | } 55 | tmr = systimer() - tmr; 56 | printf("\n%lu bytes read and it took %lu timer ticks.\n", len, tmr); 57 | 58 | printf("Test completed.\n"); 59 | return 1; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/include/delays.h: -------------------------------------------------------------------------------- 1 | /* 2 | * delays.h 3 | * 4 | * Created on: Apr 25, 2022 5 | * Author: carlk 6 | */ 7 | /* Using millis() or micros() for timeouts 8 | 9 | For example, 10 | 11 | uint32_t start = millis(); 12 | do { 13 | // ... 14 | } 15 | } while (millis() - start < TIMEOUT); 16 | 17 | There is no problem if the millis() counter wraps, 18 | due to the properties of unsigned integer modulo arithmetic. 19 | 20 | "A computation involving unsigned operands can never overflow, 21 | because a result that cannot be represented by the resulting 22 | unsigned integer type is reduced modulo the number that is 23 | one greater than the largest value that can be represented 24 | by the resulting type." 25 | -- ISO/IEC 9899:1999 (E) §6.2.5/9 26 | 27 | In other words, a uint32_t will wrap at 0 and UINT_MAX. 28 | 29 | So, for example, 30 | 0x00000000 - 0xFFFFFFFF = 0x00000001 31 | 32 | Remember that an unsigned integer will never be negative! 33 | 34 | Be careful with comparisons. In the example above, 35 | if 0x00000000 is the result of the counter wrapping, 36 | and 0xFFFFFFFF is the start timestamp, a comparison like 37 | 38 | millis() - start < TIMEOUT 39 | 40 | is OK, but the following code is problematic if, say, the first call 41 | to millis() returns 0xFFFFFFF0 and the second 42 | call to millis() returns 0xFFFFFFFF: 43 | 44 | uint32_t end = millis() + 100; // end = 0x00000054 45 | while (millis() < end) // while (0xFFFFFFFF < 0x00000054) 46 | 47 | */ 48 | 49 | #pragma once 50 | 51 | #include 52 | // 53 | #include "pico.h" 54 | #include "pico/stdlib.h" 55 | 56 | #ifdef __cplusplus 57 | extern "C" { 58 | #endif 59 | 60 | static inline uint32_t millis() { 61 | __compiler_memory_barrier(); 62 | return time_us_64() / 1000; 63 | __compiler_memory_barrier(); 64 | } 65 | 66 | static inline void delay_ms(uint32_t ulTime_ms) { 67 | sleep_ms(ulTime_ms); 68 | } 69 | 70 | static inline uint64_t micros() { 71 | __compiler_memory_barrier(); 72 | return to_us_since_boot(get_absolute_time()); 73 | __compiler_memory_barrier(); 74 | } 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | /* [] END OF FILE */ 80 | -------------------------------------------------------------------------------- /srcmpm/boot.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; MP/M 2 boot-loader for z80pack machines using SD-FDC 3 | ; 4 | ; Copyright (C) 1989-2024 by Udo Munk 5 | ; Copyright (C) 2025 by Thomas Eberhardt 6 | ; 7 | ; History: 8 | ; 12-MAR-2025 first public release based on cpmsim/srcmpm and RP2xxx/srccpm3 9 | ; 10 | ORG 0 ;mem base of boot 11 | ; 12 | BOOT EQU 0100H ;cpmldr runs at 0100H 13 | SECTS EQU 51 ;# of sectors to load (26 * 2 - 1) 14 | ; 15 | ; I/O ports 16 | ; 17 | CONDAT EQU 1 ;console data port 18 | FDC EQU 4 ;FDC 19 | ; 20 | JP COLD 21 | ; 22 | ERRMSG: DEFM 'BOOT: error booting' 23 | DEFB 13,10,0 24 | ; 25 | ; begin the load operation 26 | ; 27 | COLD: LD A,10H ;setup command for FDC 28 | OUT (FDC),A 29 | LD A,CMD AND 0FFH 30 | OUT (FDC),A 31 | LD A,CMD SHR 8 32 | OUT (FDC),A 33 | LD BC,2 ;b=track 0, c=sector 2 34 | LD D,SECTS ;d=# sectors to load 35 | ; 36 | ; load the next sector 37 | ; 38 | LSECT LD A,20H ;tell FDC to read sector on drive 0 39 | OUT (FDC),A 40 | IN A,(FDC) ;get status of FDC 41 | OR A ;read successful ? 42 | JP Z,CONT ;yes, continue 43 | LD HL,ERRMSG ;no, print error 44 | PRTMSG: LD A,(HL) 45 | OR A 46 | JP Z,STOP 47 | OUT (CONDAT),A 48 | INC HL 49 | JP PRTMSG 50 | STOP: DI 51 | HALT ;and halt cpu 52 | ; 53 | CONT: 54 | ;go to next sector if load is incomplete 55 | DEC D ;sects=sects-1 56 | JP Z,BOOT ;head for the bios 57 | 58 | ; 59 | ; more sectors to load 60 | ; 61 | ; we aren't using a stack, so use as scratch register 62 | ; to hold the load address increment 63 | ; 64 | LD HL,(CMD+2) ;get DMA address 65 | LD SP,128 ;128 bytes per sector 66 | ADD HL,SP ; = + 128 67 | LD (CMD+2),HL ;set new DMA address 68 | ; 69 | INC C ;sector = sector + 1 70 | LD A,C 71 | LD (CMD+1),A ;save sector 72 | CP 27 ;last sector of track ? 73 | JP C,LSECT ;no, go read another 74 | ; 75 | ; end of track, increment to next track 76 | ; 77 | LD C,1 ;sector = 1 78 | LD A,C 79 | LD (CMD+1),A ;save sector 80 | INC B ;track = track + 1 81 | LD A,B 82 | LD (CMD),A ;save track 83 | JP LSECT ;for another group 84 | ; 85 | ; command bytes for the FDC 86 | ; 87 | CMD DEFB 00H ;track 0 88 | DEFB 02H ;sector 2 89 | DEFB BOOT AND 0FFH ;DMA address low 90 | DEFB BOOT SHR 8 ;DMA address high 91 | ; 92 | END ;of boot loader 93 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/usb_mass_storage/include/tusb_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 5 | * Copyright (c) 2020 Damien P. George 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | */ 26 | 27 | #pragma once 28 | 29 | //#include "stdio_usb.h" 30 | 31 | #define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE) 32 | 33 | #define CFG_TUD_CDC (1) 34 | #define CFG_TUD_CDC_RX_BUFSIZE (256) 35 | #define CFG_TUD_CDC_TX_BUFSIZE (256) 36 | 37 | #define CFG_TUD_MSC (1) 38 | #define CFG_TUD_MSC_EP_BUFSIZE (4096) 39 | 40 | // We use a vendor specific interface but with our own driver 41 | // Vendor driver only used for Microsoft OS 2.0 descriptor 42 | #if !PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_MS_OS_20_DESCRIPTOR 43 | #define CFG_TUD_VENDOR (0) 44 | #else 45 | #define CFG_TUD_VENDOR (1) 46 | #define CFG_TUD_VENDOR_RX_BUFSIZE (256) 47 | #define CFG_TUD_VENDOR_TX_BUFSIZE (256) 48 | #endif 49 | 50 | // RHPort number used for device can be defined by board.mk, default to port 0 51 | #ifndef BOARD_TUD_RHPORT 52 | #define BOARD_TUD_RHPORT 0 53 | #endif 54 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/command_line/config/thing_plus.hw_config.c: -------------------------------------------------------------------------------- 1 | /* hw_config.c 2 | Copyright 2021 Carl John Kugler III 3 | 4 | Licensed under the Apache License, Version 2.0 (the License); you may not use 5 | this file except in compliance with the License. You may obtain a copy of the 6 | License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | */ 14 | /* 15 | 16 | This file should be tailored to match the hardware design. 17 | 18 | See 19 | https://github.com/carlk3/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/tree/main#customizing-for-the-hardware-configuration 20 | 21 | */ 22 | 23 | #include "hw_config.h" 24 | 25 | /* Hardware Configuration of SPI "object" */ 26 | static spi_t spi = { 27 | .hw_inst = spi1, // SPI component 28 | .miso_gpio = 12, // GPIO number (not pin number) 29 | .mosi_gpio = 15, 30 | .sck_gpio = 14, 31 | .set_drive_strength = true, 32 | .mosi_gpio_drive_strength = GPIO_DRIVE_STRENGTH_2MA, 33 | .sck_gpio_drive_strength = GPIO_DRIVE_STRENGTH_2MA, 34 | 35 | .baud_rate = 25 * 1000 * 1000, // Actual frequency: 20833333. 36 | }; 37 | 38 | /* SPI Interface */ 39 | static sd_spi_if_t spi_if = { 40 | .spi = &spi, // Pointer to the SPI driving this card 41 | .ss_gpio = 9, // The SPI slave select GPIO for this SD card 42 | .set_drive_strength = true, 43 | .ss_gpio_drive_strength = GPIO_DRIVE_STRENGTH_2MA 44 | }; 45 | 46 | /* Hardware Configuration of the SD Card "objects" */ 47 | static sd_card_t sd_card = { 48 | .type = SD_IF_SPI, 49 | .spi_if_p = &spi_if, // Pointer to the SPI interface driving this card 50 | }; 51 | 52 | /* ********************************************************************** */ 53 | 54 | size_t sd_get_num() { return 1; } 55 | 56 | sd_card_t *sd_get_by_num(size_t num) { 57 | if (num < sd_get_num()) { 58 | return &sd_card; 59 | } else { 60 | return NULL; 61 | } 62 | } 63 | 64 | /* [] END OF FILE */ 65 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/simple/main.c: -------------------------------------------------------------------------------- 1 | /* main.c 2 | Copyright 2021 Carl John Kugler III 3 | 4 | Licensed under the Apache License, Version 2.0 (the License); you may not use 5 | this file except in compliance with the License. You may obtain a copy of the 6 | License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | */ 14 | 15 | #include 16 | // 17 | #include "pico/stdlib.h" 18 | // 19 | #include "hw_config.h" 20 | #include "f_util.h" 21 | #include "ff.h" 22 | 23 | /** 24 | * @file main.c 25 | * @brief Minimal example of writing to a file on SD card 26 | * @details 27 | * This program demonstrates the following: 28 | * - Initialization of the stdio 29 | * - Mounting and unmounting the SD card 30 | * - Opening a file and writing to it 31 | * - Closing a file and unmounting the SD card 32 | */ 33 | 34 | int main() { 35 | // Initialize stdio 36 | stdio_init_all(); 37 | 38 | puts("Hello, world!"); 39 | 40 | // See FatFs - Generic FAT Filesystem Module, "Application Interface", 41 | // http://elm-chan.org/fsw/ff/00index_e.html 42 | FATFS fs; 43 | FRESULT fr = f_mount(&fs, "", 1); 44 | if (FR_OK != fr) { 45 | panic("f_mount error: %s (%d)\n", FRESULT_str(fr), fr); 46 | } 47 | 48 | // Open a file and write to it 49 | FIL fil; 50 | const char* const filename = "filename.txt"; 51 | fr = f_open(&fil, filename, FA_OPEN_APPEND | FA_WRITE); 52 | if (FR_OK != fr && FR_EXIST != fr) { 53 | panic("f_open(%s) error: %s (%d)\n", filename, FRESULT_str(fr), fr); 54 | } 55 | if (f_printf(&fil, "Hello, world!\n") < 0) { 56 | printf("f_printf failed\n"); 57 | } 58 | 59 | // Close the file 60 | fr = f_close(&fil); 61 | if (FR_OK != fr) { 62 | printf("f_close error: %s (%d)\n", FRESULT_str(fr), fr); 63 | } 64 | 65 | // Unmount the SD card 66 | f_unmount(""); 67 | 68 | puts("Goodbye, world!"); 69 | for (;;); 70 | } 71 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/include/FsLib/FsFormatter.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2022 Bill Greiman 3 | * This file is part of the SdFat library for SD memory cards. 4 | * 5 | * MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef FsFormatter_h 26 | #define FsFormatter_h 27 | #include "FatLib/FatLib.h" 28 | #include "ExFatLib/ExFatLib.h" 29 | /** 30 | * \class FsFormatter 31 | * \brief Format a exFAT/FAT volume. 32 | */ 33 | class FsFormatter { 34 | public: 35 | /** 36 | * Format a FAT volume. 37 | * 38 | * \param[in] dev Block device for volume. 39 | * \param[in] secBuffer buffer for writing to volume. 40 | * \param[in] pr Print device for progress output. 41 | * 42 | * \return true for success or false for failure. 43 | */ 44 | bool format(FsBlockDevice* dev, uint8_t* secBuffer, print_t* pr = nullptr) { 45 | uint32_t sectorCount = dev->sectorCount(); 46 | if (sectorCount == 0) { 47 | return false; 48 | } 49 | return sectorCount <= 67108864 ? 50 | m_fFmt.format(dev, secBuffer, pr) : 51 | m_xFmt.format(dev, secBuffer, pr); 52 | } 53 | private: 54 | FatFormatter m_fFmt; 55 | ExFatFormatter m_xFmt; 56 | }; 57 | #endif // FsFormatter_h 58 | -------------------------------------------------------------------------------- /srcsim/uart_tx.pio: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | ; 4 | ; SPDX-License-Identifier: BSD-3-Clause 5 | ; 6 | .pio_version 0 // only requires PIO version 0 7 | 8 | .program uart_tx 9 | .side_set 1 opt 10 | 11 | ; An 8n1 UART transmit program. 12 | ; OUT pin 0 and side-set pin 0 are both mapped to UART TX pin. 13 | 14 | pull side 1 [7] ; Assert stop bit, or stall with line in idle state 15 | set x, 7 side 0 [7] ; Preload bit counter, assert start bit for 8 clocks 16 | bitloop: ; This loop will run 8 times (8n1 UART) 17 | out pins, 1 ; Shift 1 bit from OSR to the first OUT pin 18 | jmp x-- bitloop [6] ; Each loop iteration is 8 cycles. 19 | 20 | 21 | % c-sdk { 22 | #include "hardware/clocks.h" 23 | 24 | static inline void uart_tx_program_init(PIO pio, uint sm, uint offset, uint pin_tx, uint baud) { 25 | // Tell PIO to initially drive output-high on the selected pin, then map PIO 26 | // onto that pin with the IO muxes. 27 | pio_sm_set_pins_with_mask64(pio, sm, 1ull << pin_tx, 1ull << pin_tx); 28 | pio_sm_set_pindirs_with_mask64(pio, sm, 1ull << pin_tx, 1ull << pin_tx); 29 | pio_gpio_init(pio, pin_tx); 30 | 31 | pio_sm_config c = uart_tx_program_get_default_config(offset); 32 | 33 | // OUT shifts to right, no autopull 34 | sm_config_set_out_shift(&c, true, false, 32); 35 | 36 | // We are mapping both OUT and side-set to the same pin, because sometimes 37 | // we need to assert user data onto the pin (with OUT) and sometimes 38 | // assert constant values (start/stop bit) 39 | sm_config_set_out_pins(&c, pin_tx, 1); 40 | sm_config_set_sideset_pins(&c, pin_tx); 41 | 42 | // We only need TX, so get an 8-deep FIFO! 43 | sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX); 44 | 45 | // SM transmits 1 bit per 8 execution cycles. 46 | float div = (float)clock_get_hz(clk_sys) / (8 * baud); 47 | sm_config_set_clkdiv(&c, div); 48 | 49 | pio_sm_init(pio, sm, offset, &c); 50 | pio_sm_set_enabled(pio, sm, true); 51 | } 52 | 53 | static inline void uart_tx_program_putc(PIO pio, uint sm, char c) { 54 | pio_sm_put_blocking(pio, sm, (uint32_t)c); 55 | } 56 | 57 | static inline void uart_tx_program_puts(PIO pio, uint sm, const char *s) { 58 | while (*s) 59 | uart_tx_program_putc(pio, sm, *s++); 60 | } 61 | 62 | %} 63 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/block_device/main.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file main.c 3 | * 4 | * \brief Example program demonstrating how to use the low-level disk I/O 5 | * functions provided by the SD driver. 6 | * 7 | * This program writes two blocks of data, reads the blocks back, 8 | * and verifies that the data matches what was written. 9 | * 10 | * \note This program will destroy any existing filesystem on the SD card. 11 | * 12 | * \author Carl John Kugler III 13 | * 14 | * \copyright Copyright 2024 Carl John Kugler III 15 | * \license Apache License, Version 2.0 16 | * 17 | * WARNING: Any filesystem format on the target drive will be destroyed! 18 | */ 19 | 20 | // 21 | #include 22 | #include 23 | #include 24 | // 25 | #include "pico/stdlib.h" 26 | // 27 | #include "diskio.h" /* Declarations of disk functions */ 28 | 29 | #ifdef NDEBUG 30 | # warning "This test relies on asserts to verify test results!" 31 | #endif 32 | 33 | int main() { 34 | stdio_init_all(); 35 | 36 | puts("Hello, world!"); 37 | 38 | // Physical drive number 39 | BYTE const pdrv = 0; 40 | 41 | // Initialize the disk subsystem 42 | DSTATUS ds = disk_initialize(pdrv); 43 | assert(0 == (ds & STA_NOINIT)); 44 | 45 | // Get the number of sectors on the drive 46 | DWORD sz_drv = 0; 47 | DRESULT dr = disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_drv); 48 | assert(RES_OK == dr); 49 | 50 | // Create a type for a 512-byte block 51 | typedef char block_t[512]; 52 | 53 | // Define a couple of blocks 54 | block_t blocks[2]; 55 | 56 | // Initialize the blocks 57 | snprintf(blocks[0], sizeof blocks[0], "Hello"); 58 | snprintf(blocks[1], sizeof blocks[1], "World!"); 59 | 60 | LBA_t const lba = 0; // Arbitrary 61 | assert(lba + count_of(blocks) < sz_drv); 62 | 63 | // Write the blocks 64 | dr = disk_write(pdrv, (BYTE*)blocks[lba], lba, count_of(blocks)); 65 | assert(RES_OK == dr); 66 | 67 | // Sync the disk 68 | dr = disk_ioctl(pdrv, CTRL_SYNC, 0); 69 | assert(RES_OK == dr); 70 | 71 | memset(blocks, 0xA5, sizeof blocks); 72 | 73 | // Read the blocks 74 | dr = disk_read(pdrv, (BYTE*)blocks[lba], lba, count_of(blocks)); 75 | assert(RES_OK == dr); 76 | 77 | // Verify the data 78 | assert(0 == strcmp(blocks[0], "Hello")); 79 | assert(0 == strcmp(blocks[1], "World!")); 80 | 81 | puts("Goodbye, world!"); 82 | 83 | for (;;) __breakpoint(); 84 | } 85 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/block_device/hw_config.c: -------------------------------------------------------------------------------- 1 | 2 | /* hw_config.c 3 | Copyright 2021 Carl John Kugler III 4 | 5 | Licensed under the Apache License, Version 2.0 (the License); you may not use 6 | this file except in compliance with the License. You may obtain a copy of the 7 | License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | Unless required by applicable law or agreed to in writing, software distributed 11 | under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR 12 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | specific language governing permissions and limitations under the License. 14 | */ 15 | /* 16 | This file should be tailored to match the hardware design. 17 | 18 | See 19 | https://github.com/carlk3/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/tree/main#customizing-for-the-hardware-configuration 20 | */ 21 | 22 | #include "hw_config.h" 23 | 24 | /* Configuration of RP2040 hardware SPI object */ 25 | static spi_t spi = { 26 | .hw_inst = spi0, // RP2040 SPI component 27 | .sck_gpio = 2, // GPIO number (not Pico pin number) 28 | .mosi_gpio = 3, 29 | .miso_gpio = 4, 30 | .baud_rate = 12 * 1000 * 1000 // Actual frequency: 10416666. 31 | }; 32 | 33 | /* SPI Interface */ 34 | static sd_spi_if_t spi_if = { 35 | .spi = &spi, // Pointer to the SPI driving this card 36 | .ss_gpio = 7 // The SPI slave select GPIO for this SD card 37 | }; 38 | 39 | /* Configuration of the SD Card socket object */ 40 | static sd_card_t sd_card = { 41 | .type = SD_IF_SPI, 42 | .spi_if_p = &spi_if // Pointer to the SPI interface driving this card 43 | }; 44 | 45 | /* ********************************************************************** */ 46 | 47 | size_t sd_get_num() { return 1; } 48 | 49 | /** 50 | * Return a pointer to an sd_card_t object associated with the given physical 51 | * drive number. 52 | * 53 | * \param[in] num The physical drive number. 54 | * 55 | * \return A pointer to an sd_card_t object associated with the given physical 56 | * drive number, or NULL if the physical drive number is invalid. 57 | */ 58 | sd_card_t *sd_get_by_num(size_t num) { 59 | if (0 == num) { 60 | // The physical drive number is valid. Return a pointer to the 61 | // associated sd_card_t object. 62 | return &sd_card; 63 | } else { 64 | // The physical drive number is invalid. Return NULL. 65 | return NULL; 66 | } 67 | } 68 | 69 | /* [] END OF FILE */ 70 | -------------------------------------------------------------------------------- /srcmpm/putsys.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Write the MP/M 2 system files to system tracks of drive A 3 | * 4 | * Copyright (C) 2006-2016 by Udo Munk 5 | * Copyright (C) 2024 by Thomas Eberhardt 6 | * 7 | * History: 8 | * 08-DEC-2006 cloned from the version for CP/M 3 9 | * 03-APR-2016 disk drive name drivea.dsk 10 | * 27-APR-2024 improve error handling 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | /*#define DISK "../disks/drivea.dsk"*/ 21 | #define DISK "../disks/mpm-1.dsk" 22 | /* 23 | * This program writes the MP/M 2 OS from the following files 24 | * onto the system tracks of the boot disk (DISK): 25 | * 26 | * boot loader boot.bin 27 | * mpmldr mpmldr.bin 28 | */ 29 | int main(void) 30 | { 31 | unsigned char sector[128]; 32 | int fd, drivea; 33 | ssize_t n; 34 | 35 | /* open drive A for writing */ 36 | if ((drivea = open(DISK, O_WRONLY)) == -1) { 37 | perror(DISK); 38 | exit(EXIT_FAILURE); 39 | } 40 | 41 | /* open boot loader (boot.bin) for reading */ 42 | if ((fd = open("boot.bin", O_RDONLY)) == -1) { 43 | perror("boot.bin"); 44 | exit(EXIT_FAILURE); 45 | } 46 | /* read boot loader */ 47 | memset((char *) sector, 0, 128); 48 | if (read(fd, (char *) sector, 128) == -1) { 49 | perror("boot.bin"); 50 | exit(EXIT_FAILURE); 51 | } 52 | /* and write it to disk in drive A */ 53 | if ((n = write(drivea, (char *) sector, 128)) != 128) { 54 | fprintf(stderr, DISK ": %s\n", 55 | n == -1 ? strerror(errno) : "short write"); 56 | exit(EXIT_FAILURE); 57 | } 58 | close(fd); 59 | 60 | /* open MP/M 2 mpmldr file (mpmldr.bin) for reading */ 61 | if ((fd = open("mpmldr.bin", O_RDONLY)) == -1) { 62 | perror("mpmldr.bin"); 63 | exit(EXIT_FAILURE); 64 | } 65 | /* read from mpmldr.bin and write to disk in drive A */ 66 | while ((n = read(fd, (char *) sector, 128)) == 128) 67 | if ((n = write(drivea, (char *) sector, 128)) != 128) { 68 | fprintf(stderr, DISK ": %s\n", 69 | n == -1 ? strerror(errno) : "short write"); 70 | exit(EXIT_FAILURE); 71 | } 72 | if (n == -1) { 73 | perror("mpmldr.bin"); 74 | exit(EXIT_FAILURE); 75 | } else if (n > 0) { 76 | memset((char *) §or[n], 0, 128 - n); 77 | if ((n = write(drivea, (char *) sector, 128)) != 128) { 78 | fprintf(stderr, DISK ": %s\n", 79 | n == -1 ? strerror(errno) : "short write"); 80 | exit(EXIT_FAILURE); 81 | } 82 | } 83 | close(fd); 84 | 85 | close(drivea); 86 | return EXIT_SUCCESS; 87 | } 88 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/simple/hw_config.c: -------------------------------------------------------------------------------- 1 | 2 | /* hw_config.c 3 | Copyright 2021 Carl John Kugler III 4 | 5 | Licensed under the Apache License, Version 2.0 (the License); you may not use 6 | this file except in compliance with the License. You may obtain a copy of the 7 | License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | Unless required by applicable law or agreed to in writing, software distributed 11 | under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR 12 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | specific language governing permissions and limitations under the License. 14 | */ 15 | 16 | /* 17 | This file should be tailored to match the hardware design. 18 | 19 | See 20 | https://github.com/carlk3/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/tree/main#customizing-for-the-hardware-configuration 21 | */ 22 | 23 | #include "hw_config.h" 24 | 25 | /* Configuration of hardware SPI object */ 26 | static spi_t spi = { 27 | .hw_inst = spi0, // SPI component 28 | .sck_gpio = 2, // GPIO number (not Pico pin number) 29 | .mosi_gpio = 3, 30 | .miso_gpio = 4, 31 | //.baud_rate = 125 * 1000 * 1000 / 8 // 15625000 Hz 32 | //.baud_rate = 125 * 1000 * 1000 / 6 // 20833333 Hz 33 | .baud_rate = 125 * 1000 * 1000 / 4 // 31250000 Hz 34 | //.baud_rate = 125 * 1000 * 1000 / 2 // 62500000 Hz 35 | }; 36 | 37 | /* SPI Interface */ 38 | static sd_spi_if_t spi_if = { 39 | .spi = &spi, // Pointer to the SPI driving this card 40 | .ss_gpio = 7 // The SPI slave select GPIO for this SD card 41 | }; 42 | 43 | /* Configuration of the SD Card socket object */ 44 | static sd_card_t sd_card = { 45 | .type = SD_IF_SPI, 46 | .spi_if_p = &spi_if // Pointer to the SPI interface driving this card 47 | }; 48 | 49 | /* ********************************************************************** */ 50 | 51 | size_t sd_get_num() { return 1; } 52 | 53 | /** 54 | * @brief Get a pointer to an SD card object by its number. 55 | * 56 | * @param[in] num The number of the SD card to get. 57 | * 58 | * @return A pointer to the SD card object, or @c NULL if the number is invalid. 59 | */ 60 | sd_card_t *sd_get_by_num(size_t num) { 61 | if (0 == num) { 62 | // The number 0 is a valid SD card number. 63 | // Return a pointer to the sd_card object. 64 | return &sd_card; 65 | } else { 66 | // The number is invalid. Return @c NULL. 67 | return NULL; 68 | } 69 | } 70 | 71 | /* [] END OF FILE */ 72 | -------------------------------------------------------------------------------- /roms/bootrom.lis: -------------------------------------------------------------------------------- 1 | Z80/8080-Macro-Assembler Release 2.1 2 | 3 | LOC OBJECT CODE LINE STMT SOURCE CODE 4 | 1 1 ; 5 | 2 2 ; boot ROM for z80pack machines using SD-FDC 6 | 3 3 ; use 8080 instructions only, so that it runs 7 | 4 4 ; on all our CPU's 8 | 5 5 ; 9 | 6 6 ; Copyright (C) 2024 by Udo Munk 10 | 7 7 ; 11 | 8 8 ORG 0FF00H ;ROM in upper most memory page 12 | 9 9 ; 13 | 10 10 ; I/O ports 14 | 11 11 ; 15 | 0004 = 12 12 FDC EQU 4 ;FDC port 16 | 13 13 ; 17 | f000 = 14 14 FDCMD EQU 0F000H ;command bytes for the FDC 18 | 15 15 ; 19 | ff00 f3 16 16 DI ;disable interrupts 20 | 17 17 ; 21 | ff01 af 18 18 XOR A ;zero A 22 | ff02 32 00 f0 19 19 LD (FDCMD),A ;track 0 23 | ff05 32 02 f0 20 20 LD (FDCMD+2),A ;DMA address low 24 | ff08 32 03 f0 21 21 LD (FDCMD+3),A ;DMA address high 25 | ff0b 3e 01 22 22 LD A,1 ;sector 1 26 | ff0d 32 01 f0 23 23 LD (FDCMD+1),A 27 | 24 24 ; 28 | ff10 3e 10 25 25 LD A,10H ;setup command for FDC 29 | ff12 d3 04 26 26 OUT (FDC),A 30 | ff14 3e 00 27 27 LD A,FDCMD AND 0FFH 31 | ff16 d3 04 28 28 OUT (FDC),A 32 | ff18 3e f0 29 29 LD A,FDCMD SHR 8 33 | ff1a d3 04 30 30 OUT (FDC),A 34 | 31 31 ; 35 | ff1c 3e 20 32 32 LD A,20H ;read sector 1 on track 0 from drive 0 36 | ff1e d3 04 33 33 OUT (FDC),A 37 | ff20 db 04 34 34 IN A,(FDC) ;get FDC result 38 | ff22 b7 35 35 OR A ;zero ? 39 | ff23 ca 00 00 36 36 JP Z,0 ;if yes jump to boot code loaded @ 0 40 | 37 37 ; 41 | ff26 fe 02 38 38 CP 2 ;some problem, lets see, no disk in drive? 42 | ff28 ca 00 00 39 39 JP Z,0 ;yes, so hopefully they loaded some code 43 | ff2b 76 40 40 HALT ;if not there is some serious problem 44 | 41 41 ; 45 | ff2c 42 42 END ;of ROM 46 | 47 | Symbol table 48 | 49 | FDC 0004 FDCMD f000 50 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/ff15/documents/res/app2.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------/ 2 | / Delete a sub-directory even if it contains any file 3 | /-------------------------------------------------------------/ 4 | / The delete_node() function is for R0.12+. 5 | / It works regardless of FF_FS_RPATH. 6 | */ 7 | 8 | 9 | FRESULT delete_node ( 10 | TCHAR* path, /* Path name buffer with the sub-directory to delete */ 11 | UINT sz_buff, /* Size of path name buffer (items) */ 12 | FILINFO* fno /* Name read buffer */ 13 | ) 14 | { 15 | UINT i, j; 16 | FRESULT fr; 17 | DIR dir; 18 | 19 | 20 | fr = f_opendir(&dir, path); /* Open the sub-directory to make it empty */ 21 | if (fr != FR_OK) return fr; 22 | 23 | for (i = 0; path[i]; i++) ; /* Get current path length */ 24 | path[i++] = _T('/'); 25 | 26 | for (;;) { 27 | fr = f_readdir(&dir, fno); /* Get a directory item */ 28 | if (fr != FR_OK || !fno->fname[0]) break; /* End of directory? */ 29 | j = 0; 30 | do { /* Make a path name */ 31 | if (i + j >= sz_buff) { /* Buffer over flow? */ 32 | fr = 100; break; /* Fails with 100 when buffer overflow */ 33 | } 34 | path[i + j] = fno->fname[j]; 35 | } while (fno->fname[j++]); 36 | if (fno->fattrib & AM_DIR) { /* Item is a sub-directory */ 37 | fr = delete_node(path, sz_buff, fno); 38 | } else { /* Item is a file */ 39 | fr = f_unlink(path); 40 | } 41 | if (fr != FR_OK) break; 42 | } 43 | 44 | path[--i] = 0; /* Restore the path name */ 45 | f_closedir(&dir); 46 | 47 | if (fr == FR_OK) fr = f_unlink(path); /* Delete the empty sub-directory */ 48 | return fr; 49 | } 50 | 51 | 52 | 53 | 54 | int main (void) /* How to use */ 55 | { 56 | FRESULT fr; 57 | FATFS fs; 58 | TCHAR buff[256]; 59 | FILINFO fno; 60 | 61 | 62 | f_mount(&fs, _T("5:"), 0); 63 | 64 | /* Directory to be deleted */ 65 | _tcscpy(buff, _T("5:dir")); 66 | 67 | /* Delete the directory */ 68 | fr = delete_node(buff, sizeof buff / sizeof buff[0], &fno); 69 | 70 | /* Check the result */ 71 | if (fr) { 72 | _tprintf(_T("Failed to delete the directory. (%u)\n"), fr); 73 | return fr; 74 | } else { 75 | _tprintf(_T("The directory and the contents have successfully been deleted.\n"), buff); 76 | return 0; 77 | } 78 | } 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/stdio_buffering/hw_config.c: -------------------------------------------------------------------------------- 1 | 2 | /* hw_config.c 3 | Copyright 2021 Carl John Kugler III 4 | 5 | Licensed under the Apache License, Version 2.0 (the License); you may not use 6 | this file except in compliance with the License. You may obtain a copy of the 7 | License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | Unless required by applicable law or agreed to in writing, software distributed 11 | under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR 12 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | specific language governing permissions and limitations under the License. 14 | */ 15 | 16 | /* 17 | This file should be tailored to match the hardware design. 18 | 19 | See 20 | https://github.com/carlk3/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/tree/main#customizing-for-the-hardware-configuration 21 | */ 22 | 23 | #include "hw_config.h" 24 | 25 | /* Configuration of hardware SPI object */ 26 | static spi_t spi = { 27 | .hw_inst = spi0, // SPI component 28 | .sck_gpio = 2, // GPIO number (not Pico pin number) 29 | .mosi_gpio = 3, 30 | .miso_gpio = 4, 31 | //.baud_rate = 125 * 1000 * 1000 / 8 // 15625000 Hz 32 | //.baud_rate = 125 * 1000 * 1000 / 6 // 20833333 Hz 33 | .baud_rate = 125 * 1000 * 1000 / 4 // 31250000 Hz 34 | //.baud_rate = 125 * 1000 * 1000 / 2 // 62500000 Hz 35 | }; 36 | 37 | /* SPI Interface */ 38 | static sd_spi_if_t spi_if = { 39 | .spi = &spi, // Pointer to the SPI driving this card 40 | .ss_gpio = 7 // The SPI slave select GPIO for this SD card 41 | }; 42 | 43 | /* Configuration of the SD Card socket object */ 44 | static sd_card_t sd_card = { 45 | .type = SD_IF_SPI, 46 | .spi_if_p = &spi_if // Pointer to the SPI interface driving this card 47 | }; 48 | 49 | /* ********************************************************************** */ 50 | 51 | size_t sd_get_num() { return 1; } 52 | 53 | /** 54 | * @brief Get a pointer to an SD card object by its number. 55 | * 56 | * @param[in] num The number of the SD card to get. 57 | * 58 | * @return A pointer to the SD card object, or @c NULL if the number is invalid. 59 | */ 60 | sd_card_t *sd_get_by_num(size_t num) { 61 | if (0 == num) { 62 | // The number 0 is a valid SD card number. 63 | // Return a pointer to the sd_card object. 64 | return &sd_card; 65 | } else { 66 | // The number is invalid. Return @c NULL. 67 | return NULL; 68 | } 69 | } 70 | 71 | /* [] END OF FILE */ 72 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/dynamic_config/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # == DO NEVER EDIT THE NEXT LINES for Raspberry Pi Pico VS Code Extension to work == 2 | if(WIN32) 3 | set(USERHOME $ENV{USERPROFILE}) 4 | else() 5 | set(USERHOME $ENV{HOME}) 6 | endif() 7 | set(sdkVersion 2.0.0) 8 | set(toolchainVersion 13_2_Rel1) 9 | set(picotoolVersion 2.0.0) 10 | set(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake) 11 | if (EXISTS ${picoVscode}) 12 | include(${picoVscode}) 13 | endif() 14 | # ==================================================================================== 15 | # Generated Cmake Pico project file 16 | 17 | cmake_minimum_required(VERSION 3.5) 18 | 19 | set(PICO_BOARD pico2 CACHE STRING "Board type") 20 | 21 | # Pull in Pico SDK (must be before project) 22 | include(pico_sdk_import.cmake) 23 | 24 | project(dynamic_config_example C CXX ASM) 25 | 26 | # Initialise the Raspberry Pi Pico SDK 27 | pico_sdk_init() 28 | 29 | add_subdirectory(../../src build) 30 | 31 | # Add executable. Default name is the project name, version 0.1 32 | add_executable(dynamic_config_example 33 | main.cpp 34 | ) 35 | 36 | target_compile_options(dynamic_config_example PUBLIC 37 | -Wall 38 | -Wextra 39 | -Wshadow 40 | -Wstack-usage=2048 41 | -fanalyzer 42 | ) 43 | 44 | add_compile_definitions( 45 | PARAM_ASSERTIONS_ENABLE_ALL=1 46 | PICO_MALLOC_PANIC=1 47 | PICO_USE_STACK_GUARDS=1 48 | 49 | # This program is useless without standard input and output. 50 | USE_PRINTF 51 | #USE_DBG_PRINTF 52 | ) 53 | 54 | 55 | 56 | set_property(TARGET dynamic_config_example APPEND_STRING PROPERTY LINK_FLAGS 57 | "-Wl,--print-memory-usage" 58 | ) 59 | 60 | pico_set_program_name(dynamic_config_example "dynamic_config_example") 61 | pico_set_program_version(dynamic_config_example "0.1") 62 | 63 | # Choose source and destination for standard input and output: 64 | # See 4.1. Serial input and output on Raspberry Pi Pico in Getting started with Raspberry Pi Pico (https://datasheets.raspberrypi.org/pico/getting-started-with-pico.pdf) 65 | # and 2.7.1. Standard Input/Output (stdio) Support in Raspberry Pi Pico C/C++ SDK (https://datasheets.raspberrypi.org/pico/raspberry-pi-pico-c-sdk.pdf): 66 | pico_enable_stdio_uart(dynamic_config_example 1) 67 | pico_enable_stdio_usb(dynamic_config_example 1) 68 | 69 | # Add the standard library and FatFS/SPI to the build 70 | target_link_libraries(dynamic_config_example 71 | pico_stdlib 72 | no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 73 | ) 74 | 75 | pico_add_extra_outputs(dynamic_config_example) 76 | -------------------------------------------------------------------------------- /disks/README: -------------------------------------------------------------------------------- 1 | On your MicroSD card create a directory DISKS80 and copy the *.dsk files 2 | into it. When you run the picosim machine and you want to boot an OS, 3 | put a bootable disk image into drive 0. The disk images are: 4 | 5 | cpm22.dsk - Yeah well, good old CP/M 2.2 for 8080 (bootable) 6 | cpm3gen.dsk - used to bring up CP/M 3 on CP/M 2.2 (NOT bootable) 7 | cpm3-1.dsk - CP/M 3 system disk 1 for 8080 (bootable) 8 | cpm3-2.dsk - CP/M 3 system disk 2 for 8080 (NOT bootable) 9 | mpm-1.dsk - MP/M II system disk 1 for Z80 and RP2350 only (bootable) 10 | mpm-2.dsk - MP/M II system disk 2 for Z80 and RP2350 only (NOT bootable) 11 | empty.dsk - empty CP/M disk, we often need one (NOT bootable) 12 | comms.dsk - CP/M communication programs adapted to this machine (NOT bootable) 13 | dazzler.dsk - CP/M programs for Cromemco Dazzler (NOT bootable) 14 | 15 | fig80.dsk - FIG Forth for the 8080, versions 1.1 and 1.3 (bootable) 16 | fig80scr.dsk - Forth block device with source screens for editor, 8080 17 | assembler, tools. Use with FIG Forth only, other OS's 18 | likely will corrupt the disk. 19 | 20 | ucsd1.dsk - UCSD p-System system disk 1 for 8080 (bootable) 21 | ucsd2.dsk - UCSD p-System system disk 2 for 8080 (NOT bootable) 22 | ucsdint.dsk - UCSD p-System interpreter, used to reconfigure system 23 | (NOT bootable) 24 | ucsdgame.dsk - UCSD p-System games with sources (NOT bootable) 25 | 26 | 27 | The disk images are in IBM 3740 format, the diskdef for cpmtools is: 28 | 29 | diskdef ibm-3740 30 | seclen 128 31 | tracks 77 32 | sectrk 26 33 | blocksize 1024 34 | maxdir 64 35 | skew 6 36 | boottrk 2 37 | os 2.2 38 | end 39 | 40 | 41 | Additional notes: 42 | 43 | MP/M: 44 | If you boot the MP/M II disk, it will boot CP/M 2.2 and to start MP/M use 45 | the command mpmldr. One can make MP/M bootable directly by writing boot 46 | code and mpmldr to the system tracks, the MP/M documentation explains 47 | how to do this. You can use the putsys program provided in srcmpm to do it. 48 | However, for developers a system booting into CP/M first is much 49 | more handy, because you need CP/M to assemble a modified BIOS and sysgen 50 | MP/M. Also it is possible to run MP/M under control of some debugger like 51 | DDT or SID from CP/M, to find some problem, see manuals. 52 | 53 | Forth: 54 | Also FIG Forth will boot into CP/M 2.2 and then you run it from there. 55 | Almost all implementations for 8080/Z80 use CP/M as host OS, because 56 | then it runs on every system with a working CP/M. Native Forth versions 57 | must match the hardware exactly and won't work on a slightly different 58 | system, without porting work. 59 | -------------------------------------------------------------------------------- /libs/pico-ds3231/examples/set_time/set_time.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Antonio González 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | #include "pico/stdlib.h" 9 | #include "hardware/i2c.h" 10 | 11 | #include "ds3231.h" 12 | 13 | 14 | /* Set the time on the DS3231. 15 | 16 | This helps set the time in the DS3231 real-time clock. If the device has 17 | a battery backup then it should only be necessary to do this once. 18 | 19 | The steps involved are: 20 | 21 | (1) After connecting the clock tot the Pico, update the relevant I2C 22 | definitions below. 23 | 24 | (2) Enter date and time values below, see the ds3231_datetime_t 25 | structure. Set a time a few minutes in the future. 26 | 27 | (3) Compile this code and upload to the Pico. 28 | 29 | (4) Open a terminal (e.g. `picocom /dev/ttyACM0`) 30 | 31 | (5) Look at a watch or clock: as soon as the time matches the one 32 | entered below, press `enter`. At that point the date/time will be 33 | uploaded to the DS3231 and this will start ticking. 34 | */ 35 | 36 | #define DS3231_I2C_PORT i2c1 37 | #define DS3231_I2C_SDA_PIN 2 38 | #define DS3231_I2C_SCL_PIN 3 39 | 40 | #define ASCII_ENTER 0x0D 41 | 42 | 43 | int main() { 44 | stdio_init_all(); 45 | 46 | struct ds3231_rtc rtc; 47 | 48 | ds3231_init(DS3231_I2C_PORT, DS3231_I2C_SDA_PIN, 49 | DS3231_I2C_SCL_PIN, &rtc); 50 | 51 | // Set a date and time here to a few minutes the future. 52 | ds3231_datetime_t dt = { 53 | .year = 2023, // Year (2000-2099) 54 | .month = 12, // Month (1-12, 1=January) 55 | .day = 11, // Day (1-31) 56 | .hour = 16, // Hour, 24-h format (0-23) 57 | .minutes = 03, // Minutes (0-59) 58 | .seconds = 00, // Seconds (0-59) 59 | .dotw = 1 // Day of the week (1-7, 1=Monday) 60 | }; 61 | 62 | char c; 63 | uint8_t dt_str[25]; 64 | 65 | // Wait for a few seconds for the user to open a terminal, then 66 | // wait for the user to press enter. 67 | sleep_ms(3000); 68 | ds3231_ctime(dt_str, sizeof(dt_str), &dt); 69 | printf("Press enter at %s\n"); 70 | while(1) { 71 | c = getchar(); 72 | if (c == ASCII_ENTER) { 73 | // Set the date and time as soon as enter is pressed. 74 | ds3231_set_datetime(&dt, &rtc); 75 | puts("Time set."); 76 | break; 77 | } 78 | } 79 | 80 | while (1) { 81 | ds3231_get_datetime(&dt, &rtc); 82 | ds3231_ctime(dt_str, sizeof(dt_str), &dt); 83 | puts(dt_str); 84 | sleep_ms(10000); 85 | } 86 | return 0; 87 | } -------------------------------------------------------------------------------- /libs/pico-ds3231/examples/hello_ds3231/hello_ds3231.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Antonio González 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | #include "pico/stdlib.h" 9 | #include "hardware/i2c.h" 10 | 11 | #include "ds3231.h" 12 | 13 | /* 14 | This example illustrates the basic functionality of this library, namely 15 | setting the date and time and then reading these back. See comments 16 | below for more details. 17 | */ 18 | 19 | // Modify these definitions as required, to match connections. 20 | #define DS3231_I2C_PORT i2c1 21 | #define DS3231_I2C_SDA_PIN 2 22 | #define DS3231_I2C_SCL_PIN 3 23 | 24 | int main() { 25 | stdio_init_all(); 26 | 27 | // Create a real-time clock structure and initiate this. 28 | struct ds3231_rtc rtc; 29 | ds3231_init(DS3231_I2C_PORT, DS3231_I2C_SDA_PIN, 30 | DS3231_I2C_SCL_PIN, &rtc); 31 | 32 | // A `ds3231_datetime_t` structure holds date and time values. It is 33 | // used first to set the initial (user-defined) date/time. After 34 | // these initial values are set, then this same structure will be 35 | // updated by the ds3231 functions as needed with the most current 36 | // time and date values. 37 | ds3231_datetime_t dt = { 38 | .year = 2023, // Year (2000-2099) 39 | .month = 12, // Month (1-12, 1=January, 12=December) 40 | .day = 12, // Day (1-31) 41 | .hour = 14, // Hour, in 24-h format (0-23) 42 | .minutes = 30, // Minutes (0-59) 43 | .seconds = 00, // Seconds (0-59) 44 | .dotw = 2, // Day of the week (1-7, 1=Monday, 7=Sunday) 45 | }; 46 | 47 | // This will use the above information to set the date and time. 48 | ds3231_set_datetime(&dt, &rtc); 49 | 50 | // This is a character array that will be used for storing a string 51 | // representation of the date and time. 52 | uint8_t dt_str[25]; 53 | 54 | while (1) { 55 | // Read the date and time from the DS3231 RTC. 56 | ds3231_get_datetime(&dt, &rtc); 57 | 58 | // Convert the dt structure to a string and print this. 59 | ds3231_ctime(dt_str, sizeof(dt_str), &dt); 60 | puts(dt_str); 61 | 62 | // These related functions are also available; they similarly 63 | // take a character array and convert time and/or date to 64 | // string: 65 | // 66 | // ds3231_isoformat(dt_str, sizeof(dt_str), &dt); 67 | // ds3231_str_date(dt_str, sizeof(dt_str), &dt); 68 | // ds3231_str_time(dt_str, sizeof(dt_str), &dt); 69 | 70 | // Sleep for a few seconds. 71 | sleep_ms(10000); 72 | } 73 | return 0; 74 | } 75 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/stdio_buffering/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # == DO NOT EDIT THE FOLLOWING LINES for the Raspberry Pi Pico VS Code Extension to work == 2 | if(WIN32) 3 | set(USERHOME $ENV{USERPROFILE}) 4 | else() 5 | set(USERHOME $ENV{HOME}) 6 | endif() 7 | set(sdkVersion 2.1.0) 8 | set(toolchainVersion 13_3_Rel1) 9 | set(picotoolVersion 2.1.0) 10 | set(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake) 11 | if (EXISTS ${picoVscode}) 12 | include(${picoVscode}) 13 | endif() 14 | # ==================================================================================== 15 | # Generated Cmake Pico project file 16 | 17 | cmake_minimum_required(VERSION 3.5) 18 | 19 | set(PICO_BOARD pico2 CACHE STRING "Board type") 20 | 21 | # Pull in Pico SDK (must be before project) 22 | include(pico_sdk_import.cmake) 23 | 24 | project(stdiobuf C CXX ASM) 25 | 26 | # Initialise the Raspberry Pi Pico SDK 27 | pico_sdk_init() 28 | 29 | add_subdirectory(../../src build) 30 | 31 | # Add executable. Default name is the project name, version 0.1 32 | add_executable(stdiobuf 33 | main.cpp 34 | hw_config.c 35 | ) 36 | 37 | target_include_directories(stdiobuf PUBLIC 38 | include/ 39 | ) 40 | 41 | target_compile_options(stdiobuf PUBLIC 42 | -Wall 43 | -Wextra 44 | -Wshadow 45 | -Wstack-usage=2048 46 | -fanalyzer 47 | ) 48 | 49 | # https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf 50 | target_compile_definitions(stdiobuf PUBLIC 51 | PICO_STACK_SIZE=0x1000 52 | 53 | PARAM_ASSERTIONS_ENABLE_ALL=1 54 | PICO_MALLOC_PANIC=1 55 | PICO_USE_STACK_GUARDS=1 56 | 57 | # This program is useless without standard input and output. 58 | USE_PRINTF 59 | USE_DBG_PRINTF 60 | ) 61 | 62 | # Disable CRC checking for SPI-attached cards. 63 | # add_compile_definitions(SD_CRC_ENABLED=0) 64 | 65 | 66 | set_property(TARGET stdiobuf APPEND_STRING PROPERTY LINK_FLAGS 67 | "-Wl,--print-memory-usage" 68 | ) 69 | 70 | pico_set_program_name(stdiobuf "stdiobuf") 71 | pico_set_program_version(stdiobuf "0.1") 72 | 73 | # See 4.1. Serial input and output on Raspberry Pi Pico in Getting started with Raspberry Pi Pico (https://datasheets.raspberrypi.org/pico/getting-started-with-pico.pdf) 74 | # and 2.7.1. Standard Input/Output (stdio) Support in Raspberry Pi Pico C/C++ SDK (https://datasheets.raspberrypi.org/pico/raspberry-pi-pico-c-sdk.pdf): 75 | # pico_enable_stdio_uart(stdiobuf 1) 76 | pico_enable_stdio_usb(stdiobuf 1) 77 | 78 | 79 | # Add the standard library to the build 80 | target_link_libraries(stdiobuf 81 | pico_stdlib 82 | no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 83 | ) 84 | 85 | pico_add_extra_outputs(stdiobuf) 86 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/src/FatFsSd.cpp: -------------------------------------------------------------------------------- 1 | /* FatFsSd.cpp 2 | Copyright 2023 Carl John Kugler III 3 | 4 | Licensed under the Apache License, Version 2.0 (the License); you may not use 5 | this file except in compliance with the License. You may obtain a copy of the 6 | License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | */ 14 | 15 | #include "FatFsSd.h" 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | using namespace FatFsNs; 22 | 23 | /* 24 | See FatFs - Generic FAT Filesystem Module, "Application Interface", 25 | http://elm-chan.org/fsw/ff/00index_e.html 26 | */ 27 | 28 | std::vector FatFs::SdCards; 29 | 30 | /* Put a formatted string to the file */ 31 | int File::printf(const TCHAR* format, ...) { 32 | va_list arg; 33 | va_start(arg, format); 34 | char temp[64]; 35 | char* buffer = temp; 36 | size_t len = vsnprintf(temp, sizeof(temp), format, arg); 37 | va_end(arg); 38 | if (len > sizeof(temp) - 1) { 39 | buffer = new char[len + 1]; 40 | if (!buffer) { 41 | return 0; 42 | } 43 | va_start(arg, format); 44 | int vrc = vsnprintf(buffer, len + 1, format, arg); 45 | // Notice that only when this returned value is non-negative and less than n, 46 | // the string has been completely written. 47 | assert(vrc >= 0 && vrc < len + 1); 48 | va_end(arg); 49 | } 50 | UINT bw; 51 | FRESULT fr = f_write(&fil, buffer, len, &bw); 52 | int rc = bw; 53 | if (FR_OK != fr) { 54 | rc = -1; 55 | } 56 | if (buffer != temp) { 57 | delete[] buffer; 58 | } 59 | return rc; 60 | } 61 | 62 | bool FatFs::begin() { 63 | if (!sd_init_driver()) 64 | return false; 65 | for (size_t i = 0; i < sd_get_num(); ++i) { 66 | sd_card_t* sd_card_p = sd_get_by_num(i); 67 | if (!sd_card_p) return false; 68 | // See http://elm-chan.org/fsw/ff/doc/dstat.html 69 | int dstatus = sd_card_p->init(sd_card_p); 70 | if (dstatus & STA_NOINIT) return false; 71 | } 72 | return true; 73 | } 74 | 75 | size_t __attribute__((weak)) sd_get_num() { 76 | return FatFs::SdCard_get_num(); 77 | } 78 | sd_card_t * __attribute__((weak)) sd_get_by_num(size_t num) { 79 | return (FatFs::SdCard_get_by_num(num)->m_sd_card_p); 80 | } 81 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/include/crc.h: -------------------------------------------------------------------------------- 1 | /* crc.h 2 | Copyright 2021 Carl John Kugler III 3 | 4 | Licensed under the Apache License, Version 2.0 (the License); you may not use 5 | this file except in compliance with the License. You may obtain a copy of the 6 | License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | */ 14 | /* Derived from: 15 | * SD/MMC File System Library 16 | * Copyright (c) 2016 Neil Thiessen 17 | * 18 | * Licensed under the Apache License, Version 2.0 (the "License"); 19 | * you may not use this file except in compliance with the License. 20 | * You may obtain a copy of the License at 21 | * 22 | * http://www.apache.org/licenses/LICENSE-2.0 23 | * 24 | * Unless required by applicable law or agreed to in writing, software 25 | * distributed under the License is distributed on an "AS IS" BASIS, 26 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 | * See the License for the specific language governing permissions and 28 | * limitations under the License. 29 | */ 30 | 31 | #ifndef SD_CRC_H 32 | #define SD_CRC_H 33 | 34 | #include 35 | #include 36 | 37 | /** 38 | * @brief Calculate the CRC7 checksum for the specified data block. 39 | * 40 | * This function calculates the CRC7 checksum for the specified data block 41 | * using the lookup table defined in the m_Crc7Table array. 42 | * 43 | * @param data The data block to be checked. 44 | * @param length The length of the data block in bytes. 45 | * @return The calculated checksum. 46 | */ 47 | __attribute__((optimize("Ofast"))) 48 | static inline char crc7(uint8_t const *data, int const length) { 49 | extern const char m_Crc7Table[]; 50 | char crc = 0; 51 | for (int i = 0; i < length; i++) { 52 | crc = m_Crc7Table[(crc << 1) ^ data[i]]; 53 | } 54 | 55 | //Return the calculated checksum 56 | return crc; 57 | } 58 | 59 | /** 60 | * @brief Calculate the CRC16 checksum for the specified data block. 61 | * 62 | * This function calculates the CRC16 checksum for the specified data block 63 | * using the lookup table defined in the m_Crc7Table array. 64 | * 65 | * @param data The data block to be checked. 66 | * @param length The length of the data block in bytes. 67 | * @return The calculated checksum. 68 | */ 69 | uint16_t crc16(uint8_t const *data, int const length); 70 | 71 | #endif 72 | 73 | /* [] END OF FILE */ 74 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/sd_driver/SPI/sd_spi.c: -------------------------------------------------------------------------------- 1 | /* sd_spi.c 2 | Copyright 2021 Carl John Kugler III 3 | 4 | Licensed under the Apache License, Version 2.0 (the License); you may not use 5 | this file except in compliance with the License. You may obtain a copy of the 6 | License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | */ 14 | 15 | /* Standard includes. */ 16 | #include 17 | #include 18 | #include 19 | // 20 | #include "hardware/gpio.h" 21 | // 22 | #include "my_debug.h" 23 | #include "delays.h" 24 | #include "my_spi.h" 25 | // 26 | #if !defined(USE_DBG_PRINTF) || defined(NDEBUG) 27 | # pragma GCC diagnostic ignored "-Wunused-variable" 28 | #endif 29 | // 30 | #include "sd_spi.h" 31 | 32 | // #define TRACE_PRINTF(fmt, args...) 33 | // #define TRACE_PRINTF printf 34 | 35 | void sd_spi_go_high_frequency(sd_card_t *sd_card_p) { 36 | uint actual = spi_set_baudrate(sd_card_p->spi_if_p->spi->hw_inst, sd_card_p->spi_if_p->spi->baud_rate); 37 | DBG_PRINTF("%s: Actual frequency: %lu\n", __FUNCTION__, (long)actual); 38 | } 39 | void sd_spi_go_low_frequency(sd_card_t *sd_card_p) { 40 | uint actual = spi_set_baudrate(sd_card_p->spi_if_p->spi->hw_inst, 400 * 1000); // Actual frequency: 398089 41 | DBG_PRINTF("%s: Actual frequency: %lu\n", __FUNCTION__, (long)actual); 42 | } 43 | 44 | /* 45 | After power up, the host starts the clock and sends the initializing sequence on the CMD line. 46 | This sequence is a contiguous stream of logical ‘1’s. The sequence length is the maximum of 1msec, 47 | 74 clocks or the supply-ramp-uptime; the additional 10 clocks 48 | (over the 64 clocks after what the card should be ready for communication) is 49 | provided to eliminate power-up synchronization problems. 50 | */ 51 | void sd_spi_send_initializing_sequence(sd_card_t *sd_card_p) { 52 | if ((uint)-1 == sd_card_p->spi_if_p->ss_gpio) return; 53 | bool old_ss = gpio_get(sd_card_p->spi_if_p->ss_gpio); 54 | // Set DI and CS high and apply 74 or more clock pulses to SCLK: 55 | gpio_put(sd_card_p->spi_if_p->ss_gpio, 1); 56 | uint8_t ones[10]; 57 | memset(ones, 0xFF, sizeof ones); 58 | uint32_t start = millis(); 59 | do { 60 | spi_transfer(sd_card_p->spi_if_p->spi, ones, NULL, sizeof ones); 61 | } while (millis() - start < 1); 62 | gpio_put(sd_card_p->spi_if_p->ss_gpio, old_ss); 63 | } 64 | 65 | /* [] END OF FILE */ 66 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/block_device/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # == DO NEVER EDIT THE NEXT LINES for Raspberry Pi Pico VS Code Extension to work == 2 | if(WIN32) 3 | set(USERHOME $ENV{USERPROFILE}) 4 | else() 5 | set(USERHOME $ENV{HOME}) 6 | endif() 7 | set(sdkVersion 2.0.0) 8 | set(toolchainVersion 13_2_Rel1) 9 | set(picotoolVersion 2.0.0) 10 | set(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake) 11 | if (EXISTS ${picoVscode}) 12 | include(${picoVscode}) 13 | endif() 14 | # ==================================================================================== 15 | cmake_minimum_required(VERSION 3.5) 16 | 17 | set(PICO_BOARD pico CACHE STRING "Board type") 18 | 19 | # Pull in Pico SDK (must be before project) 20 | include(pico_sdk_import.cmake) 21 | 22 | project(blkdev C CXX ASM) 23 | 24 | # add_compile_options(-Os) # Optimize for size (place before pico_sdk_init) 25 | 26 | # Initialise the Pico SDK 27 | pico_sdk_init() 28 | 29 | add_subdirectory(../../src build) 30 | 31 | # Add executable. Default name is the project name, version 0.1 32 | add_executable(blkdev 33 | main.c 34 | hw_config.c 35 | ) 36 | 37 | # Add the standard library to the build 38 | target_link_libraries(blkdev 39 | pico_stdlib 40 | no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 41 | ) 42 | 43 | # https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf 44 | target_compile_definitions(blkdev PUBLIC 45 | PARAM_ASSERTIONS_ENABLE_ALL=1 46 | PICO_MALLOC_PANIC=1 47 | PICO_USE_STACK_GUARDS=1 48 | 49 | USE_PRINTF 50 | #USE_DBG_PRINTF 51 | ) 52 | 53 | target_compile_options(blkdev PUBLIC 54 | -Wall 55 | -Wextra 56 | -Wshadow 57 | -Wstack-usage=2048 58 | -fanalyzer 59 | ) 60 | 61 | # Disable CRC checking for SPI-attached cards. 62 | # add_compile_definitions(SD_CRC_ENABLED=0) 63 | 64 | # Use Pico's LED to show drive activity. 65 | # Ensure that PICO_DEFAULT_LED_PIN is set correctly. 66 | # Note that Pico W uses GPIO 25 for SPI communication to the CYW43439. 67 | # add_compile_definitions(USE_LED=1) 68 | 69 | set_property(TARGET blkdev APPEND_STRING PROPERTY LINK_FLAGS 70 | "-Wl,--print-memory-usage" 71 | ) 72 | 73 | pico_set_program_name(blkdev "blkdev") 74 | pico_set_program_version(blkdev "0.1") 75 | 76 | # See 4.1. Serial input and output on Raspberry Pi Pico in Getting started with Raspberry Pi Pico (https://datasheets.raspberrypi.org/pico/getting-started-with-pico.pdf) 77 | # and 2.7.1. Standard Input/Output (stdio) Support in Raspberry Pi Pico C/C++ SDK (https://datasheets.raspberrypi.org/pico/raspberry-pi-pico-c-sdk.pdf): 78 | # pico_enable_stdio_uart(blkdev 1) 79 | pico_enable_stdio_usb(blkdev 1) 80 | 81 | target_link_libraries(blkdev 82 | no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 83 | ) 84 | 85 | pico_add_extra_outputs(blkdev) 86 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/unix_like/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # == DO NEVER EDIT THE NEXT LINES for Raspberry Pi Pico VS Code Extension to work == 2 | if(WIN32) 3 | set(USERHOME $ENV{USERPROFILE}) 4 | else() 5 | set(USERHOME $ENV{HOME}) 6 | endif() 7 | set(sdkVersion 2.0.0) 8 | set(toolchainVersion 13_2_Rel1) 9 | set(picotoolVersion 2.0.0) 10 | set(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake) 11 | if (EXISTS ${picoVscode}) 12 | include(${picoVscode}) 13 | endif() 14 | # ==================================================================================== 15 | 16 | cmake_minimum_required(VERSION 3.5) 17 | 18 | set(PICO_BOARD pico CACHE STRING "Board type") 19 | 20 | # Pull in Pico SDK (must be before project) 21 | include(pico_sdk_import.cmake) 22 | 23 | project(unix_like C CXX ASM) 24 | 25 | # Initialise the Raspberry Pi Pico SDK 26 | pico_sdk_init() 27 | 28 | add_subdirectory(../../src build) 29 | 30 | # Add executable. Default name is the project name, version 0.1 31 | add_executable(unix_like 32 | main.c 33 | hw_config.c 34 | ) 35 | 36 | target_compile_options(unix_like PUBLIC 37 | -Wall 38 | -Wextra 39 | -Wshadow 40 | -Wstack-usage=2048 41 | -fanalyzer 42 | ) 43 | 44 | # https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf 45 | target_compile_definitions(unix_like PUBLIC 46 | PICO_STACK_SIZE=0x1000 47 | 48 | PARAM_ASSERTIONS_ENABLE_ALL=1 49 | PICO_MALLOC_PANIC=1 50 | PICO_USE_STACK_GUARDS=1 51 | 52 | # This program is useless without standard input and output. 53 | USE_PRINTF 54 | USE_DBG_PRINTF 55 | ) 56 | 57 | # Disable CRC checking for SPI-attached cards. 58 | # add_compile_definitions(SD_CRC_ENABLED=0) 59 | 60 | 61 | set_property(TARGET unix_like APPEND_STRING PROPERTY LINK_FLAGS 62 | "-Wl,--print-memory-usage" 63 | ) 64 | 65 | pico_set_program_name(unix_like "unix_like") 66 | pico_set_program_version(unix_like "0.1") 67 | 68 | # Choose source and destination for standard input and output: 69 | # See 4.1. Serial input and output on Raspberry Pi Pico in Getting started with Raspberry Pi Pico (https://datasheets.raspberrypi.org/pico/getting-started-with-pico.pdf) 70 | # and 2.7.1. Standard Input/Output (stdio) Support in Raspberry Pi Pico C/C++ SDK (https://datasheets.raspberrypi.org/pico/raspberry-pi-pico-c-sdk.pdf): 71 | pico_enable_stdio_uart(unix_like 1) 72 | pico_enable_stdio_usb(unix_like 1) 73 | 74 | # Add the standard library and FatFS/SPI to the build 75 | target_link_libraries(unix_like 76 | pico_stdlib 77 | no-OS-FatFS-SD-SDIO-SPI-RPi-Pico 78 | ) 79 | 80 | # NOTE: for this to work, src\ff15\source\ffconf.h must be removed or renamed. 81 | target_include_directories(no-OS-FatFS-SD-SDIO-SPI-RPi-Pico BEFORE INTERFACE 82 | ${CMAKE_CURRENT_LIST_DIR}/include 83 | ) 84 | 85 | pico_add_extra_outputs(unix_like) 86 | -------------------------------------------------------------------------------- /libs/stdio_msc_usb/include/tusb_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 5 | * Copyright (c) 2020 Damien P. George 6 | * Copyright (c) 2024-2025 Thomas Eberhardt 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 | 28 | #ifndef _STDIO_MSC_USB_TUSB_CONFIG_H 29 | #define _STDIO_MSC_USB_TUSB_CONFIG_H 30 | 31 | #include "stdio_msc_usb.h" 32 | 33 | #define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE) 34 | 35 | #if STDIO_MSC_USB_DISABLE_STDIO 36 | #define CFG_TUD_CDC (2) 37 | #define STDIO_MSC_USB_CONSOLE2_ITF 0 38 | #define STDIO_MSC_USB_PRINTER_ITF 1 39 | #else 40 | #define CFG_TUD_CDC (3) 41 | #define STDIO_MSC_USB_CONSOLE_ITF 0 42 | #define STDIO_MSC_USB_CONSOLE2_ITF 1 43 | #define STDIO_MSC_USB_PRINTER_ITF 2 44 | #endif 45 | 46 | // CDC FIFO size of TX and RX 47 | #ifndef CFG_TUD_CDC_RX_BUFSIZE 48 | #define CFG_TUD_CDC_RX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64) 49 | #endif 50 | #ifndef CFG_TUD_CDC_TX_BUFSIZE 51 | #define CFG_TUD_CDC_TX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64) 52 | #endif 53 | 54 | // CDC Endpoint transfer buffer size, more is faster 55 | #ifndef CFG_TUD_CDC_EP_BUFSIZE 56 | #define CFG_TUD_CDC_EP_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64) 57 | #endif 58 | 59 | #define CFG_TUD_MSC (1) 60 | #define CFG_TUD_MSC_EP_BUFSIZE (4096) 61 | 62 | // We use a vendor specific interface but with our own driver 63 | // Vendor driver only used for Microsoft OS 2.0 descriptor 64 | #if !STDIO_MSC_USB_RESET_INTERFACE_SUPPORT_MS_OS_20_DESCRIPTOR 65 | #define CFG_TUD_VENDOR (0) 66 | #else 67 | #define CFG_TUD_VENDOR (1) 68 | #define CFG_TUD_VENDOR_RX_BUFSIZE (256) 69 | #define CFG_TUD_VENDOR_TX_BUFSIZE (256) 70 | #endif 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/include/FsLib/FsVolume.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2022 Bill Greiman 3 | * This file is part of the SdFat library for SD memory cards. 4 | * 5 | * MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #include "FsLib.h" 26 | FsVolume* FsVolume::m_cwv = nullptr; 27 | //------------------------------------------------------------------------------ 28 | bool FsVolume::begin(FsBlockDevice* blockDev, bool setCwv, 29 | uint8_t part, uint32_t volStart) { 30 | m_blockDev = blockDev; 31 | m_fVol = nullptr; 32 | m_xVol = new (m_volMem) ExFatVolume; 33 | if (m_xVol && m_xVol->begin(m_blockDev, false, part, volStart)) { 34 | goto done; 35 | } 36 | m_xVol = nullptr; 37 | m_fVol = new (m_volMem) FatVolume; 38 | if (m_fVol && m_fVol->begin(m_blockDev, false, part, volStart)) { 39 | goto done; 40 | } 41 | m_fVol = nullptr; 42 | return false; 43 | 44 | done: 45 | if (setCwv || !m_cwv) { 46 | m_cwv = this; 47 | } 48 | return true; 49 | } 50 | //------------------------------------------------------------------------------ 51 | bool FsVolume::ls(print_t* pr, const char* path, uint8_t flags) { 52 | FsBaseFile dir; 53 | return dir.open(this, path, O_RDONLY) && dir.ls(pr, flags); 54 | } 55 | //------------------------------------------------------------------------------ 56 | FsFile FsVolume::open(const char *path, oflag_t oflag) { 57 | FsFile tmpFile; 58 | tmpFile.open(this, path, oflag); 59 | return tmpFile; 60 | } 61 | #if ENABLE_ARDUINO_STRING 62 | //------------------------------------------------------------------------------ 63 | FsFile FsVolume::open(const String &path, oflag_t oflag) { 64 | return open(path.c_str(), oflag ); 65 | } 66 | #endif // ENABLE_ARDUINO_STRING 67 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/mbed-os/README.md: -------------------------------------------------------------------------------- 1 | [![Mbed OS][mbed-os-logo]][mbed-os-link] 2 | 3 | [![Build status master][mbed-master-svg]][mbed-master] 4 | [![Tools coverage status][mbed-coveralls-tools-svg]][mbed-coveralls-tools] 5 | 6 | [mbed-os-logo]: logo.png 7 | [mbed-os-link]: https://www.mbed.com/en/platform/mbed-os/ 8 | [mbed-master]: https://github.com/ARMmbed/mbed-os/actions/workflows/basic_checks.yml 9 | [mbed-master-svg]: https://github.com/ARMmbed/mbed-os/actions/workflows/basic_checks.yml/badge.svg 10 | [mbed-coveralls-tools]: https://coveralls.io/github/ARMmbed/mbed-os?branch=master 11 | [mbed-coveralls-tools-svg]: https://coveralls.io/repos/github/ARMmbed/mbed-os/badge.svg?branch=master 12 | 13 | Arm Mbed OS is an open source embedded operating system designed specifically for the "things" in the Internet of Things. It includes all the features you need to develop a connected product based on an Arm Cortex-M microcontroller, including security, connectivity, an RTOS and drivers for sensors and I/O devices. 14 | 15 | Mbed OS provides a platform that includes: 16 | 17 | - Security foundations. 18 | - Cloud management services. 19 | - Drivers for sensors, I/O devices and connectivity. 20 | 21 | ## Release notes 22 | The [release notes](https://os.mbed.com/releases) detail the current release. You can also find information about previous versions. 23 | 24 | ## License and contributions 25 | 26 | The software is provided under the [Apache-2.0 license](LICENSE-apache-2.0.txt). Contributions to this project are accepted under the same license. Please see [contributing.md](CONTRIBUTING.md) for more information. 27 | 28 | This project contains code from other projects. The original license text is included in those source files. They must comply with our [license guide](https://os.mbed.com/docs/mbed-os/latest/contributing/license.html). 29 | 30 | Folders containing files under different permissive license than Apache 2.0 are listed in the [LICENSE](LICENSE.md) file. 31 | 32 | ## Getting started for developers 33 | 34 | We have a [developer website](https://os.mbed.com) for asking questions, engaging with others, finding information on boards and components, using an online IDE and compiler, reading the documentation and learning about what's new and what's coming next in Mbed OS. 35 | 36 | ## Getting started for contributors 37 | 38 | We also have a [contributing and publishing guide](https://os.mbed.com/contributing/) that covers licensing, contributor agreements and style guidelines. 39 | 40 | ## Documentation 41 | 42 | For more information about Mbed OS, please see [our published documentation](https://os.mbed.com/docs/latest). It includes Doxygen for our APIs, step-by-step tutorials, porting information and background reference materials about our architecture and tools. 43 | 44 | To contribute to this documentation, please see the [mbed-os-5-docs repository](https://github.com/ARMmbed/mbed-os-5-docs). 45 | 46 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/include/ff_stdio.h: -------------------------------------------------------------------------------- 1 | /* ff_stdio.h 2 | Copyright 2021 Carl John Kugler III 3 | 4 | Licensed under the Apache License, Version 2.0 (the License); you may not use 5 | this file except in compliance with the License. You may obtain a copy of the 6 | License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | */ 14 | // For compatibility with FreeRTOS+FAT API 15 | #include 16 | #include 17 | #include 18 | #include 19 | // 20 | #include "ff.h" 21 | // 22 | #include "my_debug.h" 23 | 24 | #define BaseType_t int 25 | #define FF_FILE FIL 26 | 27 | #define ff_rewind f_rewind 28 | #define pvPortMalloc malloc 29 | #define vPortFree free 30 | #define ffconfigMAX_FILENAME 250 31 | #define configASSERT myASSERT 32 | #define FF_PRINTF printf 33 | #define pdFREERTOS_ERRNO_NONE 0 34 | #define FF_EOF (-1) 35 | #define FF_SEEK_SET 0 36 | #define FF_SEEK_CUR 1 37 | #define FF_SEEK_END 2 38 | #define pdFALSE 0 39 | #define pdTRUE 1 40 | #define ff_filelength f_size 41 | #define ff_feof f_eof 42 | 43 | typedef struct FF_STAT { 44 | uint32_t st_size; /* Size of the object in number of bytes. */ 45 | // uint16_t st_mode; /* The mode (attribute bits) of this 46 | // file or directory. */ 47 | } FF_Stat_t; 48 | 49 | typedef struct { 50 | DIR dir; 51 | FILINFO fileinfo; 52 | const char *pcFileName; 53 | uint32_t ulFileSize; 54 | //uint8_t ucAttributes; 55 | } FF_FindData_t; 56 | 57 | FF_FILE *ff_fopen(const char *pcFile, const char *pcMode); 58 | int ff_fclose(FF_FILE *pxStream); 59 | int ff_stat(const char *pcFileName, FF_Stat_t *pxStatBuffer); 60 | size_t ff_fwrite(const void *pvBuffer, size_t xSize, size_t xItems, 61 | FF_FILE *pxStream); 62 | size_t ff_fread(void *pvBuffer, size_t xSize, size_t xItems, FF_FILE *pxStream); 63 | int ff_chdir(const char *pcDirectoryName); 64 | char *ff_getcwd(char *pcBuffer, size_t xBufferLength); 65 | int ff_mkdir(const char *pcPath); 66 | int ff_fputc(int iChar, FF_FILE *pxStream); 67 | int ff_fgetc(FF_FILE *pxStream); 68 | int ff_rmdir(const char *pcDirectory); 69 | int ff_remove(const char *pcPath); 70 | long ff_ftell(FF_FILE *pxStream); 71 | int ff_fseek(FF_FILE *pxStream, int iOffset, int iWhence); 72 | int ff_findfirst(const char *pcDirectory, FF_FindData_t *pxFindData); 73 | int ff_findnext( FF_FindData_t *pxFindData ); 74 | FF_FILE *ff_truncate( const char * pcFileName, long lTruncateSize ); 75 | int ff_seteof( FF_FILE *pxStream ); 76 | int ff_rename( const char *pcOldName, const char *pcNewName, int bDeleteIfExists ); 77 | char *ff_fgets(char *pcBuffer, size_t xCount, FF_FILE *pxStream); 78 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/ff15/source/diskio.h: -------------------------------------------------------------------------------- 1 | /*-----------------------------------------------------------------------/ 2 | / Low level disk interface modlue include file (C)ChaN, 2019 / 3 | /-----------------------------------------------------------------------*/ 4 | 5 | #ifndef _DISKIO_DEFINED 6 | #define _DISKIO_DEFINED 7 | 8 | #include "ff.h" 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /* Status of Disk Functions */ 15 | typedef BYTE DSTATUS; 16 | 17 | /* Results of Disk Functions */ 18 | typedef enum { 19 | RES_OK = 0, /* 0: Successful */ 20 | RES_ERROR, /* 1: R/W Error */ 21 | RES_WRPRT, /* 2: Write Protected */ 22 | RES_NOTRDY, /* 3: Not Ready */ 23 | RES_PARERR /* 4: Invalid Parameter */ 24 | } DRESULT; 25 | 26 | 27 | /*---------------------------------------*/ 28 | /* Prototypes for disk control functions */ 29 | 30 | 31 | DSTATUS disk_initialize (BYTE pdrv); 32 | DSTATUS disk_status (BYTE pdrv); 33 | DRESULT disk_read (BYTE pdrv, BYTE* buff, LBA_t sector, UINT count); 34 | DRESULT disk_write (BYTE pdrv, const BYTE* buff, LBA_t sector, UINT count); 35 | DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); 36 | 37 | 38 | /* Disk Status Bits (DSTATUS) */ 39 | 40 | #define STA_NOINIT 0x01 /* Drive not initialized */ 41 | #define STA_NODISK 0x02 /* No medium in the drive */ 42 | #define STA_PROTECT 0x04 /* Write protected */ 43 | 44 | 45 | /* Command code for disk_ioctrl fucntion */ 46 | 47 | /* Generic command (Used by FatFs) */ 48 | #define CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */ 49 | #define GET_SECTOR_COUNT 1 /* Get media size (needed at FF_USE_MKFS == 1) */ 50 | #define GET_SECTOR_SIZE 2 /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */ 51 | #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at FF_USE_MKFS == 1) */ 52 | #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */ 53 | 54 | /* Generic command (Not used by FatFs) */ 55 | #define CTRL_POWER 5 /* Get/Set power status */ 56 | #define CTRL_LOCK 6 /* Lock/Unlock media removal */ 57 | #define CTRL_EJECT 7 /* Eject media */ 58 | #define CTRL_FORMAT 8 /* Create physical format on the media */ 59 | 60 | /* MMC/SDC specific ioctl command */ 61 | #define MMC_GET_TYPE 10 /* Get card type */ 62 | #define MMC_GET_CSD 11 /* Get CSD */ 63 | #define MMC_GET_CID 12 /* Get CID */ 64 | #define MMC_GET_OCR 13 /* Get OCR */ 65 | #define MMC_GET_SDSTAT 14 /* Get SD status */ 66 | #define ISDIO_READ 55 /* Read data form SD iSDIO register */ 67 | #define ISDIO_WRITE 56 /* Write data to SD iSDIO register */ 68 | #define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */ 69 | 70 | /* ATA/CF specific ioctl command */ 71 | #define ATA_GET_REV 20 /* Get F/W revision */ 72 | #define ATA_GET_MODEL 21 /* Get model name */ 73 | #define ATA_GET_SN 22 /* Get serial number */ 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /srcucsd-iv/putsys.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Write the UCSD pSystem IV boot and BIOS code to system tracks of drive A 3 | * 4 | * Copyright (C) 2008-2016 by Udo Munk 5 | * Copyright (C) 2024 by Thomas Eberhardt 6 | * 7 | * History: 8 | * 12-AUG-2008 initial version 9 | * 03-APR-2016 disk drive name drivea.dsk 10 | * 27-APR-2024 improve error handling 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | //#define DISK "../disks/drivea.dsk" 21 | #define DISK "../disks/ucsd1.dsk" 22 | 23 | /* 24 | * This program writes the UCSD boot code from the following files 25 | * onto the system tracks of the boot disk (DISK): 26 | * 27 | * boot loader boot.bin 28 | * BIOS bios.bin 29 | */ 30 | int main(void) 31 | { 32 | unsigned char sector[128]; 33 | register int i; 34 | int fd, drivea; 35 | ssize_t n; 36 | off_t o; 37 | 38 | /* open drive A for writing */ 39 | if ((drivea = open(DISK, O_WRONLY)) == -1) { 40 | perror(DISK); 41 | exit(EXIT_FAILURE); 42 | } 43 | 44 | /* open boot loader (boot.bin) for reading */ 45 | if ((fd = open("boot.bin", O_RDONLY)) == -1) { 46 | perror("boot.bin"); 47 | exit(EXIT_FAILURE); 48 | } 49 | /* read boot loader */ 50 | memset((char *) sector, 0, 128); 51 | if (read(fd, (char *) sector, 128) == -1) { 52 | perror("boot.bin"); 53 | exit(EXIT_FAILURE); 54 | } 55 | /* and write it to disk in drive A */ 56 | if ((n = write(drivea, (char *) sector, 128)) != 128) { 57 | fprintf(stderr, DISK ": %s\n", 58 | n == -1 ? strerror(errno) : "short write"); 59 | exit(EXIT_FAILURE); 60 | } 61 | close(fd); 62 | 63 | /* seek to sector 19 on drive A */ 64 | if ((o = lseek(drivea, 18 * 128L, SEEK_SET)) != 18 * 128L) { 65 | fprintf(stderr, DISK ": %s\n", 66 | o == -1 ? strerror(errno) : "short file"); 67 | exit(EXIT_FAILURE); 68 | } 69 | 70 | /* open BIOS (bios.bin) for reading */ 71 | if ((fd = open("bios.bin", O_RDONLY)) == -1) { 72 | perror("bios.bin"); 73 | exit(EXIT_FAILURE); 74 | } 75 | /* read BIOS from bios.bin and write it to disk in drive A */ 76 | i = 0; 77 | while ((n = read(fd, (char *) sector, 128)) == 128) { 78 | if ((n = write(drivea, (char *) sector, 128)) != 128) { 79 | fprintf(stderr, DISK ": %s\n", 80 | n == -1 ? strerror(errno) : "short write"); 81 | exit(EXIT_FAILURE); 82 | } 83 | i++; 84 | if (i == 8) { 85 | fputs(DISK ": out of space (8 sectors written)", 86 | stderr); 87 | exit(EXIT_FAILURE); 88 | } 89 | } 90 | if (n == -1) { 91 | perror("bios.bin"); 92 | exit(EXIT_FAILURE); 93 | } else if (n > 0) { 94 | memset((char *) §or[n], 0, 128 - n); 95 | if ((n = write(drivea, (char *) sector, 128)) != 128) { 96 | fprintf(stderr, DISK ": %s\n", 97 | n == -1 ? strerror(errno) : "short write"); 98 | exit(EXIT_FAILURE); 99 | } 100 | } 101 | close(fd); 102 | 103 | close(drivea); 104 | return EXIT_SUCCESS; 105 | } 106 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src/include/util.h: -------------------------------------------------------------------------------- 1 | /* util.h 2 | Copyright 2021 Carl John Kugler III 3 | 4 | Licensed under the Apache License, Version 2.0 (the License); you may not use 5 | this file except in compliance with the License. You may obtain a copy of the 6 | License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | */ 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | #include 20 | // 21 | #include "my_debug.h" 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | 28 | // Greatest Common Divisor: Euclidian Algorithm 29 | // https://www.freecodecamp.org/news/euclidian-gcd-algorithm-greatest-common-divisor/ 30 | int gcd(int a,int b); 31 | 32 | typedef int (*printer_t)(const char* format, ...); 33 | 34 | // works with negative index 35 | static inline int wrap_ix(int index, int n) 36 | { 37 | return ((index % n) + n) % n; 38 | } 39 | // Calculate arr indices with wrap around (+ and -) 40 | static inline int mod_floor(int a, int n) { 41 | return ((a % n) + n) % n; 42 | } 43 | 44 | __attribute__((always_inline)) static inline uint32_t calculate_checksum(uint32_t const *p, size_t const size){ 45 | uint32_t checksum = 0; 46 | for (uint32_t i = 0; i < (size/sizeof(uint32_t))-1; i++){ 47 | checksum ^= *p; 48 | p++; 49 | } 50 | return checksum; 51 | } 52 | 53 | static inline void ext_str(size_t const data_sz, 54 | uint8_t const data[], 55 | size_t const msb, 56 | size_t const lsb, 57 | size_t const buf_sz, 58 | char buf[]) { 59 | memset(buf, 0, buf_sz); 60 | size_t size = (1 + msb - lsb) / 8; // bytes 61 | size_t byte = (data_sz - 1) - (msb / 8); 62 | for (uint32_t i = 0; i < size; i++) { 63 | myASSERT(i < buf_sz); 64 | myASSERT(byte < data_sz); 65 | buf[i] = data[byte++]; 66 | } 67 | } 68 | 69 | static inline uint32_t ext_bits(size_t n_src_bytes, unsigned char const *data, int msb, int lsb) { 70 | uint32_t bits = 0; 71 | uint32_t size = 1 + msb - lsb; 72 | for (uint32_t i = 0; i < size; i++) { 73 | uint32_t position = lsb + i; 74 | uint32_t byte = (n_src_bytes - 1) - (position >> 3); 75 | uint32_t bit = position & 0x7; 76 | uint32_t value = (data[byte] >> bit) & 1; 77 | bits |= value << i; 78 | } 79 | return bits; 80 | } 81 | static inline uint32_t ext_bits16(unsigned char const *data, int msb, int lsb) { 82 | return ext_bits(16, data, msb, lsb); 83 | } 84 | 85 | char const* uint8_binary_str(uint8_t number); 86 | char const* uint_binary_str(unsigned int number); 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | /* [] END OF FILE */ 92 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/command_line/config/exp_mod_A_SPI.hw_config.c: -------------------------------------------------------------------------------- 1 | 2 | /* hw_config.c 3 | Copyright 2021 Carl John Kugler III 4 | 5 | Licensed under the Apache License, Version 2.0 (the License); you may not use 6 | this file except in compliance with the License. You may obtain a copy of the 7 | License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | Unless required by applicable law or agreed to in writing, software distributed 11 | under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR 12 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | specific language governing permissions and limitations under the License. 14 | */ 15 | 16 | /* 17 | This file should be tailored to match the hardware design. 18 | 19 | See 20 | https://github.com/carlk3/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/tree/main#customizing-for-the-hardware-configuration 21 | 22 | */ 23 | 24 | /* Hardware configuration for Expansion Module Type A 25 | See https://oshwlab.com/carlk3/rpi-pico-sd-card-expansion-module-1 26 | */ 27 | 28 | #include "hw_config.h" 29 | 30 | // Hardware Configuration of SPI "object" 31 | // One for each RP2040 SPI component used 32 | static spi_t spi = { 33 | .hw_inst = spi0, // SPI component 34 | .sck_gpio = 2, // GPIO number (not Pico pin number) 35 | .mosi_gpio = 3, 36 | .miso_gpio = 4, 37 | .set_drive_strength = true, 38 | .mosi_gpio_drive_strength = GPIO_DRIVE_STRENGTH_4MA, 39 | .sck_gpio_drive_strength = GPIO_DRIVE_STRENGTH_2MA, 40 | .spi_mode = 3, 41 | //.baud_rate = 125 * 1000 * 1000 / 8 // 15625000 Hz 42 | //.baud_rate = 125 * 1000 * 1000 / 6 // 20833333 Hz 43 | .baud_rate = 125 * 1000 * 1000 / 4 // 31250000 Hz 44 | //.baud_rate = 125 * 1000 * 1000 / 2 // 62500000 Hz 45 | }; 46 | 47 | /* SPI Interface */ 48 | static sd_spi_if_t spi_if = { 49 | .spi = &spi, // Pointer to the SPI driving this card 50 | .ss_gpio = 7 // The SPI slave select GPIO for this SD card 51 | }; 52 | 53 | /* Configuration of the SD Card socket object */ 54 | static sd_card_t sd_card = { 55 | .type = SD_IF_SPI, 56 | .spi_if_p = &spi_if, // Pointer to the SPI interface driving this card 57 | 58 | // SD Card detect: 59 | .use_card_detect = true, 60 | .card_detect_gpio = 9, 61 | .card_detected_true = 0 // What the GPIO read returns when a card is present. 62 | }; 63 | 64 | /* ********************************************************************** */ 65 | 66 | size_t sd_get_num() { return 1; } 67 | 68 | /** 69 | * @brief Get a pointer to an SD card object by its number. 70 | * 71 | * @param[in] num The number of the SD card to get. 72 | * 73 | * @return A pointer to the SD card object, or @c NULL if the number is invalid. 74 | */ 75 | sd_card_t *sd_get_by_num(size_t num) { 76 | if (0 == num) { 77 | // The number 0 is a valid SD card number. 78 | // Return a pointer to the sd_card object. 79 | return &sd_card; 80 | } else { 81 | // The number is invalid. Return @c NULL. 82 | return NULL; 83 | } 84 | } 85 | 86 | /* [] END OF FILE */ 87 | -------------------------------------------------------------------------------- /libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/examples/usb_mass_storage/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Driver for Raspberry Pi Pico SD card block device 3 | */ 4 | /* 5 | * Modifications copyright 2024 Carl John Kugler III 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the License); you may not use 8 | * this file except in compliance with the License. You may obtain a copy of the 9 | * License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software distributed 14 | * under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR 15 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations under the License. 17 | */ 18 | /* 19 | * The MIT License (MIT) 20 | * 21 | * Copyright (c) 2019 Ha Thach (tinyusb.org) 22 | * 23 | * Permission is hereby granted, free of charge, to any person obtaining a copy 24 | * of this software and associated documentation files (the "Software"), to deal 25 | * in the Software without restriction, including without limitation the rights 26 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 27 | * copies of the Software, and to permit persons to whom the Software is 28 | * furnished to do so, subject to the following conditions: 29 | * 30 | * The above copyright notice and this permission notice shall be included in 31 | * all copies or substantial portions of the Software. 32 | * 33 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 34 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 35 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 36 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 37 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 38 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 39 | * THE SOFTWARE. 40 | * 41 | */ 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | /** 49 | * @file main.c 50 | * @brief Entry point for the Raspberry Pi Pico TinyUSB CDC ACM and MSC 51 | * example. 52 | * 53 | * This example implements a CDC ACM device and a Mass Storage device. 54 | * The CDC ACM device enumerates as a serial port and can be used to 55 | * transfer data to and from the board. The Mass Storage device enumerates 56 | * as a USB drive and can be used to transfer files to and from the board. 57 | * 58 | * The example uses the TinyUSB library for USB communication and the 59 | * Raspberry Pi Pico SDK for hardware access. 60 | */ 61 | int main(void) { 62 | // Initialize the board 63 | board_init(); 64 | 65 | // Clear Screen 66 | printf("\033[2J\033[H"); 67 | 68 | // Initialize TinyUSB 69 | tud_init(BOARD_TUD_RHPORT); 70 | 71 | // Initialize the standard I/O streams 72 | stdio_init_all(); 73 | 74 | // Run the TinyUSB task loop 75 | while (true) { 76 | tud_task(); 77 | } 78 | } 79 | --------------------------------------------------------------------------------