Skip to content

Commit

Permalink
Jeff becker ROM work
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffpiep authored and markjfisher committed Jun 23, 2024
1 parent 8346721 commit 00e6c4a
Show file tree
Hide file tree
Showing 14 changed files with 1,506 additions and 294 deletions.
1 change: 1 addition & 0 deletions include/pinmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "pinmap/iec.h"
#include "pinmap/iec-d32pro.h"
#include "pinmap/coco_devkitc.h"
#include "pinmap/coco_cart.h"
#include "pinmap/coco_s3.h"
#include "pinmap/iec-nugget.h"
#include "pinmap/fujiloaf-rev0.h"
Expand Down
40 changes: 40 additions & 0 deletions include/pinmap/coco_cart.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* FujiNet Hardware Pin Mapping */
#ifdef PINMAP_COCO_CART

/* SD Card - fnFsSD.cpp */
#define PIN_CARD_DETECT GPIO_NUM_12 // fnSystem.h
#define PIN_CARD_DETECT_FIX GPIO_NUM_15 // fnSystem.h
#define PIN_SD_HOST_CS GPIO_NUM_5 // fnFsSD.cpp
#define PIN_SD_HOST_MISO GPIO_NUM_19
#define PIN_SD_HOST_MOSI GPIO_NUM_23
#define PIN_SD_HOST_SCK GPIO_NUM_18

/* UART - fnuart.cpp */
#define PIN_UART0_RX GPIO_NUM_3 // USB Serial
#define PIN_UART0_TX GPIO_NUM_1 // USB Serial
#define PIN_UART1_RX GPIO_NUM_13 // RS232 HDSEL
#define PIN_UART1_TX GPIO_NUM_21 // RS232 DRV2
#define PIN_UART2_RX GPIO_NUM_13
#define PIN_UART2_TX GPIO_NUM_21

/* Buttons - keys.cpp */
#define PIN_BUTTON_A GPIO_NUM_0 // Button 0 on DEVKITC-VE
#define PIN_BUTTON_B GPIO_NUM_NC // No Button B
#define PIN_BUTTON_C GPIO_NUM_14 // Safe reset

/* LEDs - leds.cpp */
#define PIN_LED_WIFI GPIO_NUM_2
#define PIN_LED_BUS GPIO_NUM_12
#define PIN_LED_BT GPIO_NUM_NC // No BT LED

/* Audio Output - samlib.h */
#define PIN_DAC1 GPIO_NUM_25 // not connected

/* Coco */
#define PIN_CASS_MOTOR GPIO_NUM_34 // Second motor pin is tied to +3V
#define PIN_CASS_DATA_IN GPIO_NUM_33
#define PIN_CASS_DATA_OUT GPIO_NUM_26
#define PIN_CD GPIO_NUM_22 // same as atari PROC
#define PIN_EPROM_A14 GPIO_NUM_36 // Used to set the serial baud rate
#define PIN_EPROM_A15 GPIO_NUM_39 // based on the HDB-DOS image selected
#endif /* PINMAP_COCO_DEVKITC */
11 changes: 10 additions & 1 deletion lib/bus/drivewire/drivewire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ static void drivewire_intr_task(void *arg)

systemBus virtualDevice::get_bus() { return DRIVEWIRE; }

void systemBus::op_jeff()
{
fnDwCom.print("FUJINET");
Debug_println("Jeff's op");
}

void systemBus::op_nop()
{
}
Expand Down Expand Up @@ -323,7 +329,10 @@ void systemBus::_drivewire_process_cmd()

switch (c)
{
case OP_NOP:
case OP_JEFF:
op_jeff();
break;
case OP_NOP:
op_nop();
break;
case OP_RESET1:
Expand Down
2 changes: 2 additions & 0 deletions lib/bus/drivewire/drivewire.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

/* Operation Codes */
#define OP_NOP 0
#define OP_JEFF 0xA5
#define OP_SERREAD 'C'
#define OP_GETSTAT 'G'
#define OP_SETSTAT 'S'
Expand Down Expand Up @@ -215,6 +216,7 @@ class systemBus
/**
* @brief NOP command (do nothing)
*/
void op_jeff();
void op_nop();
void op_reset();
void op_readex();
Expand Down
2 changes: 2 additions & 0 deletions lib/hardware/fnUART.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ void UARTManager::begin(int baud)
#endif /* BUILD_ADAM */

#ifdef BUILD_COCO
#ifndef PINMAP_COCO_CART
if (_uart_num == 2)
uart_set_line_inverse(_uart_num, UART_SIGNAL_TXD_INV | UART_SIGNAL_RXD_INV);
#endif
#endif /* BUILD_COCO */


Expand Down
5 changes: 2 additions & 3 deletions pico/coco/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ add_executable(main main.c rom.c)
# by default the header is generated into the build dir
# however, alternatively you can choose to generate it somewhere else (in this case in the source tree for check in)
# pico_generate_pio_header(pio_and ${CMAKE_CURRENT_LIST_DIR}/blink.pio OUTPUT_DIR ${CMAKE_CURRENT_LIST_DIR})
# pico_generate_pio_header(main ${CMAKE_CURRENT_LIST_DIR}/rom.pio)
# pico_generate_pio_header(main ${CMAKE_CURRENT_LIST_DIR}/enable.pio)
# pico_generate_pio_header(main ${CMAKE_CURRENT_LIST_DIR}/bank.pio)
pico_generate_pio_header(main ${CMAKE_CURRENT_LIST_DIR}/cococart.pio)
pico_generate_pio_header(main ${CMAKE_CURRENT_LIST_DIR}/uart_tx.pio)
pico_generate_pio_header(main ${CMAKE_CURRENT_LIST_DIR}/uart_rx.pio)

# target_sources(rom PRIVATE rom.c)

Expand Down
103 changes: 103 additions & 0 deletions pico/coco/cococart.pio
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,106 @@
.define public ROMWIDTH 14
.define public DATAWIDTH 8

;.define public BUGPIN 27

;
;
; CoCoAddr - decodes the 0xFFxx address space, pushes LSB to FIFO
;
;

.program cocoaddr
.wrap_target
start:
wait 0 gpio CLKPIN ; wait until new cycle starts
wait 1 gpio CLKPIN ; valid address surely by rising edge
mov osr, ~pins ; put the inverted address into OUT starting with A8
out x, 8 ; put the inverted 8 MSBs (A8-A15) in X to test
jmp x-- start ; A8-A15 != 0xFF to try again (inverted A != 0)
mov osr, pins ; get the bus but not inverted so easier to compare in the firmware
out null, 24 ; remove D0-D7 from OSR
in osr, 8 ; A0-A7 into the input FIFO (via autopush)
.wrap

% c-sdk {
// this is a raw helper function for use by the user which sets up the GPIO inputs
void cocoaddr_program_init(PIO pio, uint sm, uint offset) {
pio_sm_config c = cocoaddr_program_get_default_config(offset);
sm_config_set_in_pins(&c, PINROMADDR + 8); // start at GPIO 16 for the MSB address
sm_config_set_in_shift(&c, false, true, 8); // there are 8 wires to read for the ADDR LSB, shift to the left, autopush
sm_config_set_out_shift(&c, true, false, 32); // shift to the right

// side set for debugging with logic analyzer
// sm_config_set_sideset_pins(&c, BUGPIN);
// pio_gpio_init(pio, BUGPIN);
// pio_sm_set_consecutive_pindirs(pio, sm, BUGPIN, 1, true);

pio_sm_init(pio, sm, offset, &c);
}
%}

;
;
; DataRead
; pico reads 8 bits off the coco data bus
;

.program dataread
.wrap_target
pull ; wait to get triggered
;wait 1 gpio CLKPIN ; wait for rising edge of E - not needed because will only trigger when CLK is high
wait 0 gpio CLKPIN ; wait for next cycle - DATA is valid on falling edge of CLK
in pins 8 ; get the data and push to the FIFO
.wrap

% c-sdk {
// this is a raw helper function for use by the user which sets up the GPIO inputs
void dataread_program_init(PIO pio, uint sm, uint offset) {
pio_sm_config c = dataread_program_get_default_config(offset);
sm_config_set_in_pins(&c, PINROMDATA); // start at GPIO 0 for the DATA byte
sm_config_set_in_shift(&c, false, true, 8); // there are 8 wires to read for the DATA byte, shift to the left, autopush
pio_sm_init(pio, sm, offset, &c);
}
%}

;
;
; datawrite
;
;

.program datawrite
.side_set 3 opt pindirs
.wrap_target
out pins, DATAWIDTH ; output the rom bit value - stalls when no fifo data
wait 1 gpio CLKPIN ; on the clock rising edge
set pindirs 0b11111 side 0b111 ; turn on data output
wait 0 gpio CLKPIN [1] ; on clock falling edge wait data hold time
nop [1] ; complete data hold time
set pindirs 0b00000 side 0b000 ; turn off data output
.wrap

% c-sdk {
// this is a raw helper function for use by the user which sets up the GPIO input and output, and configures the SM to output on a particular pin
void datawrite_program_init(PIO pio, uint sm, uint offset) {
pio_sm_config c = datawrite_program_get_default_config(offset);
// get 8 bit data values through the OSR and output
sm_config_set_out_pins(&c, PINROMDATA, DATAWIDTH);
sm_config_set_out_shift(&c, true, true, DATAWIDTH); // autopull
sm_config_set_set_pins(&c, PINROMDATA, 5);
sm_config_set_sideset_pins(&c, PINROMDATA+5);

// already set up in rom emulator
// set out_pin as a GPIO output connected to this SM
/*
for (int i = 0; i < DATAWIDTH; i++)
pio_gpio_init(pio, PINROMDATA + i);
pio_sm_set_consecutive_pindirs(pio, sm, PINROMDATA, DATAWIDTH, false);
*/

pio_sm_init(pio, sm, offset, &c);
}
%}

;
;
Expand Down Expand Up @@ -96,6 +196,9 @@ void cocowrite_program_init(PIO pio, uint sm, uint offset) {
wait 1 gpio CLKPIN
mov osr, ~null ; enable the outputs
out pindirs, DATAWIDTH
; note: can save 3 PIO instructions by using a set with sideset to switch the 8-bit databus pindirs
; however, that''s a maximum of 8 bits. For larger, use the "mov osr, null; out pindirs" stucture


% c-sdk {
// this is a raw helper function for use by the user which sets up the GPIO input and output, and configures the SM to output on a particular pin
Expand Down
Loading

0 comments on commit 00e6c4a

Please sign in to comment.