Skip to content

Commit

Permalink
Merge pull request #463 from udo-munk/dev
Browse files Browse the repository at this point in the history
merge dev
  • Loading branch information
udo-munk authored Nov 24, 2024
2 parents 5ccfc6b + b340927 commit ac73c36
Show file tree
Hide file tree
Showing 9 changed files with 228 additions and 130 deletions.
5 changes: 2 additions & 3 deletions picosim/README
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ Now you can build picosim for the Pico RP2040 with these commands:

This machine can be used with Pico and Pico W boards, it is setup
for a Pico board. To setup for a Pico W comment/uncomment the lines
in CMakeLists.txt and change the board type in sim.h. It doesn't
really matter, on a Pico W the CYW43 gets intitialized but is not
used yet.
in CMakeLists.txt. It doesn't really matter, on a Pico W the CYW43
gets intitialized but is not used yet.

To build picosim for the Pico 2 RP2350:

Expand Down
12 changes: 6 additions & 6 deletions picosim/rp2040/disks.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ static spi_t spi = {
.mosi_gpio = SD_SPI_SI,
.miso_gpio = SD_SPI_SO,
#if PICO_RP2040
//.baud_rate = 125 * 1000 * 1000 / 8, /* 15.625 MHz */
//.baud_rate = 125 * 1000 * 1000 / 6, /* 20.833333 MHz */
.baud_rate = 125 * 1000 * 1000 / 4, /* 31.25 MHz */
//.baud_rate = 125 * 1000 * 1000 / 8, /* 15.625 MHz */
//.baud_rate = 125 * 1000 * 1000 / 6, /* 20.833333 MHz */
.baud_rate = 125 * 1000 * 1000 / 4, /* 31.25 MHz */
#endif
#if PICO_RP2350
//.baud_rate = 150 * 1000 * 1000 / 8, // 18.75 MHz
//.baud_rate = 150 * 1000 * 1000 / 6, // 25.00 MHz
.baud_rate = 150 * 1000 * 1000 / 4, // 37.50 MHz
//.baud_rate = 150 * 1000 * 1000 / 8, /* 18.75 MHz */
//.baud_rate = 150 * 1000 * 1000 / 6, /* 25.00 MHz */
.baud_rate = 150 * 1000 * 1000 / 4, /* 37.50 MHz */
#endif
.spi_mode = 3,
.set_drive_strength = true,
Expand Down
15 changes: 6 additions & 9 deletions picosim/rp2040/picosim.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
#include "pico/time.h"
#include "hardware/uart.h"
#include "hardware/watchdog.h"
/* Pico W also needs this */
#if PICO == 1
#ifdef RASPBERRYPI_PICO_W
#include "pico/cyw43_arch.h"
#endif

Expand Down Expand Up @@ -101,12 +100,9 @@ int main(void)
#endif
time_init(); /* initialize FatFS RTC */

#if PICO == 1 /* initialize Pico W hardware */
#ifdef RASPBERRYPI_PICO_W /* initialize Pico W hardware */
if (cyw43_arch_init())
{
printf("CYW43 init failed\n");
return -1;
}
panic("CYW43 init failed\n");
#endif

/* setupt interrupt for break switch */
Expand All @@ -121,14 +117,15 @@ int main(void)
ws2812_program_init(pio, sm, offset, WS2812_PIN, 800000, true);
put_pixel(rgb); /* LED red */

/* when using USB UART wait until it is connected */
/* but also get out if there is input at default UART */
#if LIB_PICO_STDIO_UART
uart_inst_t *my_uart = uart_default;
/* destroy random input from UART after activation */
if (uart_is_readable(my_uart))
getchar();
#endif

/* when using USB UART wait until it is connected */
/* but also get out if there is input at default UART */
#if LIB_PICO_STDIO_USB || LIB_STDIO_MSC_USB
while (!tud_cdc_connected()) {
#if LIB_PICO_STDIO_UART
Expand Down
2 changes: 0 additions & 2 deletions picosim/rp2040/sim.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#ifndef SIM_INC
#define SIM_INC

#define PICO 0 /* board we use, 0 for Pico 1 for Pico W */

#define DEF_CPU Z80 /* default CPU (Z80 or I8080) */
//#define EXCLUDE_I8080 /* we want both CPU's */
#define CPU_SPEED 4 /* CPU speed 0=unlimited */
Expand Down
102 changes: 0 additions & 102 deletions picosim/rp2350/CMakeLists.txt

This file was deleted.

1 change: 1 addition & 0 deletions picosim/rp2350/CMakeLists.txt
102 changes: 102 additions & 0 deletions picosim/rp2350/CMakeLists.txt.arm
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
cmake_minimum_required(VERSION 3.13)

# Set default build type to Release
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release)
endif()

set(PICO_BOARD_HEADER_DIRS ${CMAKE_SOURCE_DIR})

# Set platform, board, and compiler
set(PICO_PLATFORM rp2350-arm-s)
set(PICO_BOARD pico2)
set(PICO_COMPILER pico_arm_cortex_m33_gcc)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

# Pull in SDK (must be before project)
include(pico_sdk_import.cmake)

project(picosim C CXX ASM)

pico_sdk_init()

set(Z80PACK ${CMAKE_SOURCE_DIR}/../../)

add_executable(${PROJECT_NAME}
picosim.c
disks.c
simcfg.c
simio.c
simmem.c
${Z80PACK}/iodevices/rtc80.c
${Z80PACK}/iodevices/sd-fdc.c
${Z80PACK}/z80core/sim8080.c
${Z80PACK}/z80core/simcore.c
${Z80PACK}/z80core/simdis.c
${Z80PACK}/z80core/simglb.c
${Z80PACK}/z80core/simice.c
${Z80PACK}/z80core/simutil.c
${Z80PACK}/z80core/simz80-cb.c
${Z80PACK}/z80core/simz80-dd.c
${Z80PACK}/z80core/simz80-ddcb.c
${Z80PACK}/z80core/simz80-ed.c
${Z80PACK}/z80core/simz80-fd.c
${Z80PACK}/z80core/simz80-fdcb.c
${Z80PACK}/z80core/simz80.c
)

# generate the header file into the source tree
pico_generate_pio_header(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/WS2812.pio)

target_include_directories(${PROJECT_NAME} PUBLIC
${CMAKE_SOURCE_DIR}
${Z80PACK}/iodevices
${Z80PACK}/z80core
)

add_subdirectory(no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src FatFs)
add_subdirectory(stdio_msc_usb)
add_subdirectory(ds3231)

target_compile_definitions(${PROJECT_NAME} PRIVATE
PICO_STACK_SIZE=4096
PICO_CORE1_STACK_SIZE=4096
PICO_HEAP_SIZE=8192
)

# compiler diagnostic options
if (PICO_C_COMPILER_IS_GNU)
target_compile_options(${PROJECT_NAME} PUBLIC -fdiagnostics-color=always)
elseif (PICO_C_COMPILER_IS_CLANG)
target_compile_options(${PROJECT_NAME} PUBLIC -fcolor-diagnostics)
endif ()
target_compile_options(${PROJECT_NAME} PUBLIC -Wall -Wextra)
if (PICO_C_COMPILER_IS_CLANG)
target_compile_options(${PROJECT_NAME} PUBLIC -Weverything)
endif ()
# -Wno-unused-parameter because no-OS-FatFS-SD-SDIO-SPI-RPi-Pico isn't clean
target_compile_options(${PROJECT_NAME} PUBLIC -Wno-unused-parameter)

target_link_libraries(${PROJECT_NAME}
hardware_i2c
pico-ds3231
pico_stdlib
stdio_msc_usb
tinyusb_device
no-OS-FatFS-SD-SDIO-SPI-RPi-Pico
)

pico_add_extra_outputs(${PROJECT_NAME})

target_link_options(${PROJECT_NAME} PRIVATE -Xlinker --print-memory-usage)

pico_set_program_name(${PROJECT_NAME} "z80pack picosim")
pico_set_program_description(${PROJECT_NAME} "z80pack on Raspberry Pi Pico")
pico_set_program_version(${PROJECT_NAME} "1.3")
pico_set_program_url(${PROJECT_NAME} "https://github.com/udo-munk/z80pack")

# enable UART in/out, enable USB in/out
pico_enable_stdio_uart(${PROJECT_NAME} 1)
#pico_enable_stdio_usb(${PROJECT_NAME} 1)
102 changes: 102 additions & 0 deletions picosim/rp2350/CMakeLists.txt.corev
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
cmake_minimum_required(VERSION 3.13)

# Set default build type to Release
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release)
endif()

set(PICO_BOARD_HEADER_DIRS ${CMAKE_SOURCE_DIR})

# Set platform, board, and compiler
set(PICO_PLATFORM rp2350-riscv)
set(PICO_BOARD pico2)
set(PICO_COMPILER pico_riscv_gcc)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

# Pull in SDK (must be before project)
include(pico_sdk_import.cmake)

project(picosim C CXX ASM)

pico_sdk_init()

set(Z80PACK ${CMAKE_SOURCE_DIR}/../../)

add_executable(${PROJECT_NAME}
picosim.c
disks.c
simcfg.c
simio.c
simmem.c
${Z80PACK}/iodevices/rtc80.c
${Z80PACK}/iodevices/sd-fdc.c
${Z80PACK}/z80core/sim8080.c
${Z80PACK}/z80core/simcore.c
${Z80PACK}/z80core/simdis.c
${Z80PACK}/z80core/simglb.c
${Z80PACK}/z80core/simice.c
${Z80PACK}/z80core/simutil.c
${Z80PACK}/z80core/simz80-cb.c
${Z80PACK}/z80core/simz80-dd.c
${Z80PACK}/z80core/simz80-ddcb.c
${Z80PACK}/z80core/simz80-ed.c
${Z80PACK}/z80core/simz80-fd.c
${Z80PACK}/z80core/simz80-fdcb.c
${Z80PACK}/z80core/simz80.c
)

# generate the header file into the source tree
pico_generate_pio_header(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/WS2812.pio)

target_include_directories(${PROJECT_NAME} PUBLIC
${CMAKE_SOURCE_DIR}
${Z80PACK}/iodevices
${Z80PACK}/z80core
)

add_subdirectory(no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src FatFs)
add_subdirectory(stdio_msc_usb)
add_subdirectory(ds3231)

target_compile_definitions(${PROJECT_NAME} PRIVATE
PICO_STACK_SIZE=4096
PICO_CORE1_STACK_SIZE=4096
PICO_HEAP_SIZE=8192
)

# compiler diagnostic options
if (PICO_C_COMPILER_IS_GNU)
target_compile_options(${PROJECT_NAME} PUBLIC -fdiagnostics-color=always)
elseif (PICO_C_COMPILER_IS_CLANG)
target_compile_options(${PROJECT_NAME} PUBLIC -fcolor-diagnostics)
endif ()
target_compile_options(${PROJECT_NAME} PUBLIC -Wall -Wextra)
if (PICO_C_COMPILER_IS_CLANG)
target_compile_options(${PROJECT_NAME} PUBLIC -Weverything)
endif ()
# -Wno-unused-parameter because no-OS-FatFS-SD-SDIO-SPI-RPi-Pico isn't clean
target_compile_options(${PROJECT_NAME} PUBLIC -Wno-unused-parameter)

target_link_libraries(${PROJECT_NAME}
hardware_i2c
pico-ds3231
pico_stdlib
stdio_msc_usb
tinyusb_device
no-OS-FatFS-SD-SDIO-SPI-RPi-Pico
)

pico_add_extra_outputs(${PROJECT_NAME})

target_link_options(${PROJECT_NAME} PRIVATE -Xlinker --print-memory-usage)

pico_set_program_name(${PROJECT_NAME} "z80pack picosim")
pico_set_program_description(${PROJECT_NAME} "z80pack on Raspberry Pi Pico")
pico_set_program_version(${PROJECT_NAME} "1.3")
pico_set_program_url(${PROJECT_NAME} "https://github.com/udo-munk/z80pack")

# enable UART in/out, enable USB in/out
pico_enable_stdio_uart(${PROJECT_NAME} 1)
#pico_enable_stdio_usb(${PROJECT_NAME} 1)
Loading

0 comments on commit ac73c36

Please sign in to comment.