99#include < string>
1010#include < driver/i2c.h>
1111
12- #define CX16_DEVICEID_DISK 0x31
13- #define CX16_DEVICEID_DISK_LAST 0x3F
14-
15- #define CX16_DEVICEID_PRINTER 0x40
16- #define CX16_DEVICEID_PRINTER_LAST 0x43
17-
18- #define CX16_DEVICEID_FN_VOICE 0x43
19-
20- #define CX16_DEVICEID_APETIME 0x45
21-
22- #define CX16_DEVICEID_TYPE3POLL 0x4F
23-
24- #define CX16_DEVICEID_RS232 0x50
25- #define CX16_DEVICEID_RS2323_LAST 0x53
26-
27- #define CX16_DEVICEID_CASSETTE 0x5F
28-
29- #define CX16_DEVICEID_FUJINET 0x70
30- #define CX16_DEVICEID_FN_NETWORK 0x71
31- #define CX16_DEVICEID_FN_NETWORK_LAST 0x78
32-
33- #define CX16_DEVICEID_MIDI 0x99
34-
35- #define CX16_DEVICEID_SIO2BT_NET 0x4E
36- #define CX16_DEVICEID_SIO2BT_SMART 0x45 // Doubles as APETime and "High Score Submission" to URL
37- #define CX16_DEVICEID_APE 0x45
38- #define CX16_DEVICEID_ASPEQT 0x46
39- #define CX16_DEVICEID_PCLINK 0x6F
40-
41- #define CX16_DEVICEID_CPM 0x5A
42-
43- #define I2C_SLAVE_TX_BUF_LEN 255
12+ #define I2C_SLAVE_TX_BUF_LEN 255
4413#define I2C_SLAVE_RX_BUF_LEN 32
4514#define I2C_DEVICE_ID 0x70
4615
4716/* *
4817 * | Address | R/W | Description
4918 * |--- |--- |---
5019 * | 0 | W | Device ID
51- * | 1 | W | Command
52- * | 2 | W | Aux1
53- * | 3 | W | Aux2
20+ * | 1 | W | Command
21+ * | 2 | W | Aux1
22+ * | 3 | W | Aux2
5423 * | 4 | W | Checksum of addresses 0-3
5524 * | 5 | R | (A)CK/(N)ACK
5625 * | 6 | R | (C)OMPLETE/(E)RROR
5726 * | 7 | R/W | Payload Length (LO)
5827 * | 8 | R/W | Payload Length (HI)
59- * | 9 | R/W | Payload Data (auto-increment)
60- *
28+ * | 9 | R/W | Payload Data (auto-increment)
29+ *
6130 * Any write to address 0 will zero out all other addresses.
6231 * Read to address 0 to perform command
63- *
32+ *
6433 * So the sequence to perform a command to the fujinet:
65- *
34+ *
6635 * 1. Write addresses 0-4 for command frame.
6736 * 2. if a write payload is needed, write length lo/hi, then write payload data for # of bytes in length
6837 * 3. READ from address 0 to perform command.
6938 * 4. Check ACK/NAK
7039 * 5. Check COMPLETE/ERROR
71- *
40+ *
7241 * Alternatively, to perform a command from fujinet to the CX16:
73- *
42+ *
7443 * 1. Write addresses 0-4 for the command frame.
7544 * 2. If a read payload is expected, write length lo/hi.
7645 * 3. READ from address 0 to perform command.
@@ -129,7 +98,7 @@ class virtualDevice
12998 /* *
13099 * @brief The passed in command frame, copied.
131100 */
132- cmdFrame_t cmdFrame;
101+ cmdFrame_t cmdFrame;
133102
134103 /* *
135104 * @brief Message queue
@@ -337,7 +306,7 @@ class systemBus
337306 * @param pDevice Pointer to virtualDevice
338307 * @param device_id The ID to assign to virtualDevice
339308 */
340- void addDevice (virtualDevice *pDevice, int device_id);
309+ void addDevice (virtualDevice *pDevice, FujiDeviceID device_id);
341310
342311 /* *
343312 * @brief Remove device from bus
@@ -350,14 +319,14 @@ class systemBus
350319 * @param device_id ID of device to return.
351320 * @return pointer to virtualDevice
352321 */
353- virtualDevice *deviceById (int device_id);
322+ virtualDevice *deviceById (FujiDeviceID device_id);
354323
355324 /* *
356325 * @brief Change ID of a particular virtualDevice
357326 * @param pDevice pointer to virtualDevice
358- * @param device_id new device ID
327+ * @param device_id new device ID
359328 */
360- void changeDeviceId (virtualDevice *pDevice, int device_id);
329+ void changeDeviceId (virtualDevice *pDevice, FujiDeviceID device_id);
361330
362331 /* *
363332 * @brief Are we shutting down?
0 commit comments