Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/autobuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
- COCO
- IEC-LOLIN-D32
- IEC-NUGGET
- LYNX
- RS232

steps:
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/platformio.release-LYNX.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[fujinet]
build_platform = BUILD_LYNX
build_bus = comlynx
build_board = fujinet-lynx-prototype

[env:fujinet-lynx-prototype]
platform = espressif32@${fujinet.esp32_platform_version}
platform_packages = ${fujinet.esp32_platform_packages}
board = fujinet-v1
build_type = debug
build_flags =
${env.build_flags}
-D PINMAP_LYNX
16 changes: 16 additions & 0 deletions include/fujiDeviceID.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
#ifndef FUJI_DEVICES_H
#define FUJI_DEVICES_H

#if defined(BUILD_ADAM) || defined(BUILD_LYNX)
enum fujiDeviceID_t {
FUJI_DEVICEID_FUJINET = 0x0F,

FUJI_DEVICEID_KEYBOARD = 0x01,
FUJI_DEVICEID_PRINTER = 0x02,
FUJI_DEVICEID_DISK = 0x04,
FUJI_DEVICEID_DISK2 = 0x05,
FUJI_DEVICEID_DISK3 = 0x06,
FUJI_DEVICEID_DISK4 = 0x07,
FUJI_DEVICEID_TAPE = 0x08,
FUJI_DEVICEID_NETWORK_TEMP = 0x09,
FUJI_DEVICEID_NETWORK = 0x0E,
};
#else
enum fujiDeviceID_t {
FUJI_DEVICEID_FUJINET = 0x70,

Expand All @@ -23,5 +38,6 @@ enum fujiDeviceID_t {
FUJI_DEVICEID_NETWORK_LAST = 0x78,
FUJI_DEVICEID_MIDI = 0x99,
};
#endif /* BUILD_ADAM || BUILD_LYNX */

#endif /* FUJI_DEVICES_H */
50 changes: 26 additions & 24 deletions lib/bus/comlynx/comlynx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ uint8_t comlynx_checksum(uint8_t *buf, unsigned short len)
void virtualDevice::comlynx_send(uint8_t b)
{
Debug_printf("comlynx_send_buffer: %X\n", b);

// Wait for idle only when in UDPStream mode
if (SYSTEM_BUS._udpDev->udpstreamActive)
SYSTEM_BUS.wait_for_idle();

// Write the byte
SYSTEM_BUS.write(b);
SYSTEM_BUS.flush();
Expand All @@ -94,7 +94,7 @@ void virtualDevice::comlynx_send(uint8_t b)

void virtualDevice::comlynx_send_buffer(uint8_t *buf, unsigned short len)
{

//buf[len] = '\0';
//Debug_printf("comlynx_send_buffer: %d %s\n", len, buf); // causes out of bounds write in disk routines

Expand All @@ -104,7 +104,7 @@ void virtualDevice::comlynx_send_buffer(uint8_t *buf, unsigned short len)
// Wait for idle only when in UDPStream mode
if (SYSTEM_BUS._udpDev->udpstreamActive)
SYSTEM_BUS.wait_for_idle();

SYSTEM_BUS.write(buf, len);
SYSTEM_BUS.read(buf, len);
}
Expand All @@ -116,7 +116,7 @@ bool virtualDevice::comlynx_recv_ck()

while (SYSTEM_BUS.available() <= 0)
fnSystem.yield();

// get checksum
recv_ck = SYSTEM_BUS.read();

Expand Down Expand Up @@ -203,7 +203,7 @@ unsigned short virtualDevice::comlynx_recv_buffer(uint8_t *buf, unsigned short l
unsigned short b;

b = SYSTEM_BUS.read(buf, len);

// Add to receive buffer
memcpy(&recvbuffer[recvbuffer_len], buf, len);
recvbuffer_len += len;
Expand Down Expand Up @@ -321,7 +321,7 @@ void systemBus::_comlynx_process_cmd()
b = SYSTEM_BUS.read();
d = b & 0x0F;


// Find device ID and pass control to it
if (_daisyChain.count(d) < 1)
{
Expand All @@ -331,12 +331,12 @@ void systemBus::_comlynx_process_cmd()
#ifdef DEBUG
if ((b & 0xF0) == (MN_ACK<<4))
Debug_println("Lynx sent ACK");
else {
else {
Debug_println("---");
Debug_printf("comlynx_process_cmd: dev:%X cmd:%X\n", d, (b & 0xF0)>>4);
}
#endif
#endif

// turn on Comlynx Indicator LED
fnLedManager.set(eLed::LED_BUS, true);
_daisyChain[d]->comlynx_process(b);
Expand Down Expand Up @@ -382,7 +382,7 @@ void systemBus::setup()
_port.begin(ChannelConfig()
.deviceID(FN_UART_BUS)
.baud(COMLYNX_BAUDRATE)
.parity(UART_PARITY_ODD)
.parity(UART_PARITY_ODD)
);
}

Expand All @@ -396,29 +396,31 @@ void systemBus::shutdown()
Debug_printf("All devices shut down.\n");
}

void systemBus::addDevice(virtualDevice *pDevice, uint8_t device_id)
void systemBus::addDevice(virtualDevice *pDevice, fujiDeviceID_t device_id)
{
Debug_printf("Adding device: %02X\n", device_id);
pDevice->_devnum = device_id;
_daisyChain[device_id] = pDevice;

switch (device_id)
{
case 0x02:
case FUJI_DEVICEID_PRINTER:
_printerDev = (lynxPrinter *)pDevice;
break;
case 0x0f:
case FUJI_DEVICEID_FUJINET:
_fujiDev = (lynxFuji *)pDevice;
break;
default:
break;
}
}

bool systemBus::deviceExists(uint8_t device_id)
bool systemBus::deviceExists(fujiDeviceID_t device_id)
{
return _daisyChain.find(device_id) != _daisyChain.end();
}

bool systemBus::deviceEnabled(uint8_t device_id)
bool systemBus::deviceEnabled(fujiDeviceID_t device_id)
{
if (deviceExists(device_id))
return _daisyChain[device_id]->device_active;
Expand All @@ -430,7 +432,7 @@ void systemBus::remDevice(virtualDevice *pDevice)
{
}

void systemBus::remDevice(uint8_t device_id)
void systemBus::remDevice(fujiDeviceID_t device_id)
{
if (deviceExists(device_id))
{
Expand All @@ -443,7 +445,7 @@ int systemBus::numDevices()
return _daisyChain.size();
}

void systemBus::changeDeviceId(virtualDevice *p, uint8_t device_id)
void systemBus::changeDeviceId(virtualDevice *p, fujiDeviceID_t device_id)
{
for (auto devicep : _daisyChain)
{
Expand All @@ -452,7 +454,7 @@ void systemBus::changeDeviceId(virtualDevice *p, uint8_t device_id)
}
}

virtualDevice *systemBus::deviceById(uint8_t device_id)
virtualDevice *systemBus::deviceById(fujiDeviceID_t device_id)
{
for (auto devicep : _daisyChain)
{
Expand All @@ -468,15 +470,15 @@ void systemBus::reset()
devicep.second->reset();
}

void systemBus::enableDevice(uint8_t device_id)
void systemBus::enableDevice(fujiDeviceID_t device_id)
{
Debug_printf("Enabling Comlynx Device %d\n", device_id);

if (_daisyChain.find(device_id) != _daisyChain.end())
_daisyChain[device_id]->device_active = true;
}

void systemBus::disableDevice(uint8_t device_id)
void systemBus::disableDevice(fujiDeviceID_t device_id)
{
Debug_printf("Disabling Comlynx Device %d\n", device_id);

Expand Down Expand Up @@ -545,7 +547,7 @@ void systemBus::setRedeyeMode(bool enable)
void systemBus::setRedeyeGameRemap(uint32_t remap)
{
Debug_printf("setRedeyeGameRemap, %d\n", remap);

// handle pure updstream games
if ((remap >> 8) == 0xE1) {
_udpDev->redeye_mode = false; // turn off redeye
Expand All @@ -555,7 +557,7 @@ void systemBus::setRedeyeGameRemap(uint32_t remap)

// handle redeye game that need remapping
if (remap != 0xFFFF) {
_udpDev->remap_game_id = true;
_udpDev->remap_game_id = true;
_udpDev->new_game_id = remap;
}
else {
Expand All @@ -569,7 +571,7 @@ void systemBus::setRedeyeGameRemap(uint32_t remap)
{
Debug_printf("setComlynxIdleTime, %d\n", idle_time);

SYSTEM_BUS.comlynx_idle_time = idle_time;
SYSTEM_BUS.comlynx_idle_time = idle_time;
}*/

#endif /* BUILD_LYNX */
12 changes: 3 additions & 9 deletions lib/bus/comlynx/comlynx.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#include "UARTChannel.h"
#include "fujiDeviceID.h"
#include <freertos/FreeRTOS.h>
#include <freertos/queue.h>

Expand All @@ -31,13 +32,6 @@
#define NM_SEND 0x0B // response.data (send)
#define NM_NACK 0x0C // response.control (nack)

#define COMLYNX_DEVICE_ID_KEYBOARD 0x01
#define COMLYNX_DEVICE_ID_PRINTER 0x02
#define COMLYNX_DEVICEID_DISK 0x04
#define COMLYNX_DEVICE_TAPE 0x08
#define COMLYNX_DEVICE_NETWORK 0x0E
#define COMLYNX_DEVICE_FUJINET 0x0F

#define COMLYNX_RESET_DEBOUNCE_PERIOD 100 // in ms

union cmdFrame_t
Expand Down Expand Up @@ -161,7 +155,7 @@ class virtualDevice
/**
* @brief Device Number: 0-15
*/
uint8_t _devnum;
fujiDeviceID_t _devnum;

virtual void shutdown() {}

Expand Down Expand Up @@ -233,7 +227,7 @@ class virtualDevice
* @brief return the device number (0-15) of this device
* @return the device # (0-15) of this device
*/
uint8_t id() { return _devnum; }
fujiDeviceID_t id() { return _devnum; }


};
Expand Down
Loading