From e5638680299fee7c6f466708f93c59e2f6305754 Mon Sep 17 00:00:00 2001 From: Chris Osborn Date: Sat, 18 Oct 2025 11:16:22 -0700 Subject: [PATCH] systemBus-ize rs232 --- .github/workflows/autobuild.yml | 10 +++++++++- .github/workflows/release.yml | 11 ++++++++++- lib/bus/rs232/rs232.cpp | 6 +++--- lib/bus/rs232/rs232.h | 2 +- lib/device/rs232/fuji.cpp | 34 ++++++++++++++++----------------- lib/device/rs232/modem.cpp | 12 ++++++------ lib/device/rs232/rs232cpm.cpp | 2 +- lib/hardware/fnUART.cpp | 2 +- 8 files changed, 47 insertions(+), 32 deletions(-) diff --git a/.github/workflows/autobuild.yml b/.github/workflows/autobuild.yml index 7496fafa9..8e48da85c 100644 --- a/.github/workflows/autobuild.yml +++ b/.github/workflows/autobuild.yml @@ -20,7 +20,15 @@ jobs: runs-on: "ubuntu-latest" strategy: matrix: - target-platform: [ATARI, ATARI-esp32-s3-wroom-1-n16r8, ADAM, APPLE, IEC-LOLIN-D32, IEC-NUGGET, COCO] + target-platform: + - ADAM + - APPLE + - ATARI + - ATARI-esp32-s3-wroom-1-n16r8 + - COCO + - IEC-LOLIN-D32 + - IEC-NUGGET + - RS232 steps: - name: Checkout Source diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b8f2fc6f6..639d27103 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,16 @@ jobs: runs-on: "ubuntu-latest" strategy: matrix: - target-platform: [ATARI, ATARI-8mb, ADAM, APPLE, COCO, IEC-LOLIN-D32, MASTERIES-REVAB, MASTERIES-REVA-SPIFIX, RS232] + target-platform: + - ADAM + - APPLE + - ATARI + - ATARI-8mb + - COCO + - IEC-LOLIN-D32 + - MASTERIES-REVA-SPIFIX + - MASTERIES-REVAB + - RS232 env: TAG_NAME: ${{ github.event.inputs.tag || github.ref_name }} diff --git a/lib/bus/rs232/rs232.cpp b/lib/bus/rs232/rs232.cpp index e651bdbd0..1741ef261 100755 --- a/lib/bus/rs232/rs232.cpp +++ b/lib/bus/rs232/rs232.cpp @@ -154,7 +154,7 @@ void virtualDevice::rs232_error() void virtualDevice::rs232_high_speed() { Debug_print("rs232 HRS232 INDEX\n"); - uint8_t hsd = RS232.getHighSpeedIndex(); + uint8_t hsd = SYSTEM_BUS.getHighSpeedIndex(); bus_to_computer((uint8_t *)&hsd, 1, false); } @@ -265,7 +265,7 @@ void systemBus::service() { _cpmDev->rs232_handle_cpm(); return; // break! - } + } // Go process a command frame if the RS232 CMD line is asserted if (fnSystem.digital_read(PIN_RS232_DTR) == DIGI_LOW) @@ -321,7 +321,7 @@ void systemBus::setup() fnSystem.set_pin_mode(PIN_RS232_DSR,gpio_mode_t::GPIO_MODE_OUTPUT); fnSystem.digital_write(PIN_RS232_DSR,DIGI_LOW); - + // Create a message queue qRs232Messages = xQueueCreate(4, sizeof(rs232_message_t)); diff --git a/lib/bus/rs232/rs232.h b/lib/bus/rs232/rs232.h index 07319e887..7e94e3430 100755 --- a/lib/bus/rs232/rs232.h +++ b/lib/bus/rs232/rs232.h @@ -144,7 +144,7 @@ class virtualDevice virtual void rs232_status() = 0; /** - * @brief All RS232 devices repeatedly call this routine to fan out to other methods for each command. + * @brief All RS232 devices repeatedly call this routine to fan out to other methods for each command. * This is typcially implemented as a switch() statement. */ virtual void rs232_process(cmdFrame_t *cmd_ptr) = 0; diff --git a/lib/device/rs232/fuji.cpp b/lib/device/rs232/fuji.cpp index 443440c6e..e94c45cbf 100755 --- a/lib/device/rs232/fuji.cpp +++ b/lib/device/rs232/fuji.cpp @@ -90,22 +90,22 @@ void rs232Fuji::rs232_status() if (cmdFrame.aux == STATUS_MOUNT_TIME) { - // Return drive slot mount status: 0 if unmounted, otherwise time when mounted + // Return drive slot mount status: 0 if unmounted, otherwise time when mounted time_t mount_status[MAX_DISK_DEVICES]; - int idx; + int idx; - for (idx = 0; idx < MAX_DISK_DEVICES; idx++) - mount_status[idx] = _fnDisks[idx].disk_dev.mount_time; + for (idx = 0; idx < MAX_DISK_DEVICES; idx++) + mount_status[idx] = _fnDisks[idx].disk_dev.mount_time; - bus_to_computer((uint8_t *) mount_status, sizeof(mount_status), false); + bus_to_computer((uint8_t *) mount_status, sizeof(mount_status), false); } else { - char ret[4] = {0}; + char ret[4] = {0}; - Debug_printf("Status for what? %08lx\n", cmdFrame.aux); - bus_to_computer((uint8_t *)ret, sizeof(ret), false); + Debug_printf("Status for what? %08lx\n", cmdFrame.aux); + bus_to_computer((uint8_t *)ret, sizeof(ret), false); } return; } @@ -749,11 +749,11 @@ void rs232Fuji::image_rotate() { int swap = _fnDisks[n - 1].disk_dev.id(); Debug_printf("setting slot %d to ID %hx\n", n, swap); - _rs232_bus->changeDeviceId(&_fnDisks[n].disk_dev, swap); + SYSTEM_BUS.changeDeviceId(&_fnDisks[n].disk_dev, swap); } // The first slot gets the device ID of the last slot - _rs232_bus->changeDeviceId(&_fnDisks[0].disk_dev, last_id); + SYSTEM_BUS.changeDeviceId(&_fnDisks[0].disk_dev, last_id); // Say whatever disk is in D1: if (Config.get_general_rotation_sounds()) @@ -1392,11 +1392,11 @@ void rs232Fuji::rs232_set_rs232_external_clock() if (speed == 0) { - RS232.setUltraHigh(false, 0); + SYSTEM_BUS.setUltraHigh(false, 0); } else { - RS232.setUltraHigh(true, baudRate); + SYSTEM_BUS.setUltraHigh(true, baudRate); } rs232_complete(); @@ -1454,16 +1454,14 @@ void rs232Fuji::rs232_enable_udpstream() rs232_complete(); // Start the UDP Stream - RS232.setUDPHost(host, port); + SYSTEM_BUS.setUDPHost(host, port); } } // Initializes base settings and adds our devices to the RS232 bus -void rs232Fuji::setup(systemBus *rs232bus) +void rs232Fuji::setup() { // set up Fuji device - _rs232_bus = rs232bus; - _populate_slots_from_config(); insert_boot_device(Config.get_general_boot_mode()); @@ -1476,10 +1474,10 @@ void rs232Fuji::setup(systemBus *rs232bus) // Add our devices to the RS232 bus for (int i = 0; i < MAX_DISK_DEVICES; i++) - _rs232_bus->addDevice(&_fnDisks[i].disk_dev, RS232_DEVICEID_DISK + i); + SYSTEM_BUS.addDevice(&_fnDisks[i].disk_dev, RS232_DEVICEID_DISK + i); for (int i = 0; i < MAX_NETWORK_DEVICES; i++) - _rs232_bus->addDevice(&rs232NetDevs[i], RS232_DEVICEID_FN_NETWORK + i); + SYSTEM_BUS.addDevice(&rs232NetDevs[i], RS232_DEVICEID_FN_NETWORK + i); } diff --git a/lib/device/rs232/modem.cpp b/lib/device/rs232/modem.cpp index fcfa5e770..e351bd7b1 100755 --- a/lib/device/rs232/modem.cpp +++ b/lib/device/rs232/modem.cpp @@ -193,7 +193,7 @@ void rs232Modem::rs232_poll_1() Send back RS232 command for booting. This is a 12 uint8_t + chk block that is meant to be written to the RS232 parameter block starting at DDEVIC ($0300). - The boot block MUST start at $0500. There are both BASIC-based and cart-based + The boot block MUST start at $0500. There are both BASIC-based and cart-based loaders that use JSR $0506 to run the loader. */ @@ -427,7 +427,7 @@ void rs232Modem::rs232_control() tcpClient.stop(); // Hang up if DTR drops. CRX = false; cmdMode = true; - + if (listenPort > 0) { // tcpServer.stop(); @@ -1476,8 +1476,8 @@ void rs232Modem::modemCommand() break; case AT_CPM: modemActive = false; - RS232.getCPM()->init_cpm(modemBaud); - RS232.getCPM()->cpmActive = true; + SYSTEM_BUS.getCPM()->init_cpm(modemBaud); + SYSTEM_BUS.getCPM()->cpmActive = true; break; case AT_PHONEBOOKLIST: at_handle_pblist(); @@ -1679,7 +1679,7 @@ void rs232Modem::rs232_handle_modem() // Read from serial, the amount available up to // maximum size of the buffer int rs232BytesRead = fnUartBUS.readBytes(&txBuf[0], //RS232_UART.readBytes(&txBuf[0], - (rs232BytesAvail > TX_BUF_SIZE) ? TX_BUF_SIZE : rs232BytesAvail); + (rs232BytesAvail > TX_BUF_SIZE) ? TX_BUF_SIZE : rs232BytesAvail); // Disconnect if going to AT mode with "+++" sequence for (int i = 0; i < (int)rs232BytesRead; i++) @@ -1747,7 +1747,7 @@ void rs232Modem::rs232_handle_modem() Debug_println("Going back to command mode"); at_cmd_println("OK"); - + cmdMode = true; plusCount = 0; diff --git a/lib/device/rs232/rs232cpm.cpp b/lib/device/rs232/rs232cpm.cpp index c64043cf6..1844b3442 100755 --- a/lib/device/rs232/rs232cpm.cpp +++ b/lib/device/rs232/rs232cpm.cpp @@ -58,7 +58,7 @@ void rs232CPM::rs232_handle_cpm() void rs232CPM::init_cpm(int baud) { - fnUartBUS.set_baudrate(baud); + SYSTEM_BUS.setBaudrate(baud); Status = Debug = 0; Break = Step = -1; RAM = (uint8_t *)malloc(MEMSIZE); diff --git a/lib/hardware/fnUART.cpp b/lib/hardware/fnUART.cpp index 1e6879562..1c82b5bf7 100644 --- a/lib/hardware/fnUART.cpp +++ b/lib/hardware/fnUART.cpp @@ -122,7 +122,7 @@ void UARTManager::begin(int baud) // If using an older Rev0 or Rev00 board, you will need to pull PIN_EPROM_A14 (IO36) up to 3.3V or 5V via a 10K // resistor to have it default to the previous default of 57600 baud otherwise they will both read as low and you // will get 38400 baud. - + fnSystem.set_pin_mode(PIN_EPROM_A14, gpio_mode_t::GPIO_MODE_INPUT, SystemManager::pull_updown_t::PULL_NONE); fnSystem.set_pin_mode(PIN_EPROM_A15, gpio_mode_t::GPIO_MODE_INPUT, SystemManager::pull_updown_t::PULL_NONE);