Skip to content

Commit 7b40efe

Browse files
committed
[lynx] Fix problems with compiling
1 parent d7fd2d2 commit 7b40efe

File tree

9 files changed

+147
-114
lines changed

9 files changed

+147
-114
lines changed

.github/workflows/autobuild.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
- COCO
2929
- IEC-LOLIN-D32
3030
- IEC-NUGGET
31+
- LYNX
3132
- RS232
3233

3334
steps:
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[fujinet]
2+
build_platform = BUILD_LYNX
3+
build_bus = comlynx
4+
build_board = fujinet-lynx-prototype
5+
6+
[env:fujinet-lynx-prototype]
7+
platform = espressif32@${fujinet.esp32_platform_version}
8+
platform_packages = ${fujinet.esp32_platform_packages}
9+
board = fujinet-v1
10+
build_type = debug
11+
build_flags =
12+
${env.build_flags}
13+
-D PINMAP_LYNX

include/fujiDeviceID.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
#ifndef FUJI_DEVICES_H
22
#define FUJI_DEVICES_H
33

4+
#if defined(BUILD_ADAM) || defined(BUILD_LYNX)
5+
enum fujiDeviceID_t {
6+
FUJI_DEVICEID_FUJINET = 0x0F,
7+
8+
FUJI_DEVICEID_KEYBOARD = 0x01,
9+
FUJI_DEVICEID_PRINTER = 0x02,
10+
FUJI_DEVICEID_DISK = 0x04,
11+
FUJI_DEVICEID_DISK2 = 0x05,
12+
FUJI_DEVICEID_DISK3 = 0x06,
13+
FUJI_DEVICEID_DISK4 = 0x07,
14+
FUJI_DEVICEID_TAPE = 0x08,
15+
FUJI_DEVICEID_NETWORK_TEMP = 0x09,
16+
FUJI_DEVICEID_NETWORK = 0x0E,
17+
};
18+
#else
419
enum fujiDeviceID_t {
520
FUJI_DEVICEID_FUJINET = 0x70,
621

@@ -23,5 +38,6 @@ enum fujiDeviceID_t {
2338
FUJI_DEVICEID_NETWORK_LAST = 0x78,
2439
FUJI_DEVICEID_MIDI = 0x99,
2540
};
41+
#endif /* BUILD_ADAM || BUILD_LYNX */
2642

2743
#endif /* FUJI_DEVICES_H */

lib/bus/comlynx/comlynx.cpp

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ uint8_t comlynx_checksum(uint8_t *buf, unsigned short len)
8181
void virtualDevice::comlynx_send(uint8_t b)
8282
{
8383
Debug_printf("comlynx_send_buffer: %X\n", b);
84-
84+
8585
// Wait for idle only when in UDPStream mode
8686
if (SYSTEM_BUS._udpDev->udpstreamActive)
8787
SYSTEM_BUS.wait_for_idle();
88-
88+
8989
// Write the byte
9090
SYSTEM_BUS.write(b);
9191
SYSTEM_BUS.flush();
@@ -94,7 +94,7 @@ void virtualDevice::comlynx_send(uint8_t b)
9494

9595
void virtualDevice::comlynx_send_buffer(uint8_t *buf, unsigned short len)
9696
{
97-
97+
9898
//buf[len] = '\0';
9999
//Debug_printf("comlynx_send_buffer: %d %s\n", len, buf); // causes out of bounds write in disk routines
100100

@@ -104,7 +104,7 @@ void virtualDevice::comlynx_send_buffer(uint8_t *buf, unsigned short len)
104104
// Wait for idle only when in UDPStream mode
105105
if (SYSTEM_BUS._udpDev->udpstreamActive)
106106
SYSTEM_BUS.wait_for_idle();
107-
107+
108108
SYSTEM_BUS.write(buf, len);
109109
SYSTEM_BUS.read(buf, len);
110110
}
@@ -116,7 +116,7 @@ bool virtualDevice::comlynx_recv_ck()
116116

117117
while (SYSTEM_BUS.available() <= 0)
118118
fnSystem.yield();
119-
119+
120120
// get checksum
121121
recv_ck = SYSTEM_BUS.read();
122122

@@ -203,7 +203,7 @@ unsigned short virtualDevice::comlynx_recv_buffer(uint8_t *buf, unsigned short l
203203
unsigned short b;
204204

205205
b = SYSTEM_BUS.read(buf, len);
206-
206+
207207
// Add to receive buffer
208208
memcpy(&recvbuffer[recvbuffer_len], buf, len);
209209
recvbuffer_len += len;
@@ -321,7 +321,7 @@ void systemBus::_comlynx_process_cmd()
321321
b = SYSTEM_BUS.read();
322322
d = b & 0x0F;
323323

324-
324+
325325
// Find device ID and pass control to it
326326
if (_daisyChain.count(d) < 1)
327327
{
@@ -331,12 +331,12 @@ void systemBus::_comlynx_process_cmd()
331331
#ifdef DEBUG
332332
if ((b & 0xF0) == (MN_ACK<<4))
333333
Debug_println("Lynx sent ACK");
334-
else {
334+
else {
335335
Debug_println("---");
336336
Debug_printf("comlynx_process_cmd: dev:%X cmd:%X\n", d, (b & 0xF0)>>4);
337337
}
338-
#endif
339-
338+
#endif
339+
340340
// turn on Comlynx Indicator LED
341341
fnLedManager.set(eLed::LED_BUS, true);
342342
_daisyChain[d]->comlynx_process(b);
@@ -382,7 +382,7 @@ void systemBus::setup()
382382
_port.begin(ChannelConfig()
383383
.deviceID(FN_UART_BUS)
384384
.baud(COMLYNX_BAUDRATE)
385-
.parity(UART_PARITY_ODD)
385+
.parity(UART_PARITY_ODD)
386386
);
387387
}
388388

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

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

405405
switch (device_id)
406406
{
407-
case 0x02:
407+
case FUJI_DEVICEID_PRINTER:
408408
_printerDev = (lynxPrinter *)pDevice;
409409
break;
410-
case 0x0f:
410+
case FUJI_DEVICEID_FUJINET:
411411
_fujiDev = (lynxFuji *)pDevice;
412412
break;
413+
default:
414+
break;
413415
}
414416
}
415417

416-
bool systemBus::deviceExists(uint8_t device_id)
418+
bool systemBus::deviceExists(fujiDeviceID_t device_id)
417419
{
418420
return _daisyChain.find(device_id) != _daisyChain.end();
419421
}
420422

421-
bool systemBus::deviceEnabled(uint8_t device_id)
423+
bool systemBus::deviceEnabled(fujiDeviceID_t device_id)
422424
{
423425
if (deviceExists(device_id))
424426
return _daisyChain[device_id]->device_active;
@@ -430,7 +432,7 @@ void systemBus::remDevice(virtualDevice *pDevice)
430432
{
431433
}
432434

433-
void systemBus::remDevice(uint8_t device_id)
435+
void systemBus::remDevice(fujiDeviceID_t device_id)
434436
{
435437
if (deviceExists(device_id))
436438
{
@@ -443,7 +445,7 @@ int systemBus::numDevices()
443445
return _daisyChain.size();
444446
}
445447

446-
void systemBus::changeDeviceId(virtualDevice *p, uint8_t device_id)
448+
void systemBus::changeDeviceId(virtualDevice *p, fujiDeviceID_t device_id)
447449
{
448450
for (auto devicep : _daisyChain)
449451
{
@@ -452,7 +454,7 @@ void systemBus::changeDeviceId(virtualDevice *p, uint8_t device_id)
452454
}
453455
}
454456

455-
virtualDevice *systemBus::deviceById(uint8_t device_id)
457+
virtualDevice *systemBus::deviceById(fujiDeviceID_t device_id)
456458
{
457459
for (auto devicep : _daisyChain)
458460
{
@@ -468,15 +470,15 @@ void systemBus::reset()
468470
devicep.second->reset();
469471
}
470472

471-
void systemBus::enableDevice(uint8_t device_id)
473+
void systemBus::enableDevice(fujiDeviceID_t device_id)
472474
{
473475
Debug_printf("Enabling Comlynx Device %d\n", device_id);
474476

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

479-
void systemBus::disableDevice(uint8_t device_id)
481+
void systemBus::disableDevice(fujiDeviceID_t device_id)
480482
{
481483
Debug_printf("Disabling Comlynx Device %d\n", device_id);
482484

@@ -545,7 +547,7 @@ void systemBus::setRedeyeMode(bool enable)
545547
void systemBus::setRedeyeGameRemap(uint32_t remap)
546548
{
547549
Debug_printf("setRedeyeGameRemap, %d\n", remap);
548-
550+
549551
// handle pure updstream games
550552
if ((remap >> 8) == 0xE1) {
551553
_udpDev->redeye_mode = false; // turn off redeye
@@ -555,7 +557,7 @@ void systemBus::setRedeyeGameRemap(uint32_t remap)
555557

556558
// handle redeye game that need remapping
557559
if (remap != 0xFFFF) {
558-
_udpDev->remap_game_id = true;
560+
_udpDev->remap_game_id = true;
559561
_udpDev->new_game_id = remap;
560562
}
561563
else {
@@ -569,7 +571,7 @@ void systemBus::setRedeyeGameRemap(uint32_t remap)
569571
{
570572
Debug_printf("setComlynxIdleTime, %d\n", idle_time);
571573
572-
SYSTEM_BUS.comlynx_idle_time = idle_time;
574+
SYSTEM_BUS.comlynx_idle_time = idle_time;
573575
}*/
574576

575577
#endif /* BUILD_LYNX */

lib/bus/comlynx/comlynx.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include "UARTChannel.h"
9+
#include "fujiDeviceID.h"
910
#include <freertos/FreeRTOS.h>
1011
#include <freertos/queue.h>
1112

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

34-
#define COMLYNX_DEVICE_ID_KEYBOARD 0x01
35-
#define COMLYNX_DEVICE_ID_PRINTER 0x02
36-
#define COMLYNX_DEVICEID_DISK 0x04
37-
#define COMLYNX_DEVICE_TAPE 0x08
38-
#define COMLYNX_DEVICE_NETWORK 0x0E
39-
#define COMLYNX_DEVICE_FUJINET 0x0F
40-
4135
#define COMLYNX_RESET_DEBOUNCE_PERIOD 100 // in ms
4236

4337
union cmdFrame_t
@@ -161,7 +155,7 @@ class virtualDevice
161155
/**
162156
* @brief Device Number: 0-15
163157
*/
164-
uint8_t _devnum;
158+
fujiDeviceID_t _devnum;
165159

166160
virtual void shutdown() {}
167161

@@ -233,7 +227,7 @@ class virtualDevice
233227
* @brief return the device number (0-15) of this device
234228
* @return the device # (0-15) of this device
235229
*/
236-
uint8_t id() { return _devnum; }
230+
fujiDeviceID_t id() { return _devnum; }
237231

238232

239233
};

0 commit comments

Comments
 (0)