libsidplayfp 2.16.1
src/USBSIDInterface.h
1/*
2 * USBSID-Pico is a RPi Pico (RP2040/RP2350) based board for interfacing one
3 * or two MOS SID chips and/or hardware SID emulators over (WEB)USB with your
4 * computer, phone or ASID supporting player.
5 *
6 * USBSIDInterface.h
7 * This file is part of USBSID-Pico (https://github.com/LouDnl/USBSID-Pico-driver)
8 * File author: LouD
9 *
10 * Copyright (c) 2024-2025 LouD
11 *
12 * This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, version 2.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 *
24 */
25
26#ifndef _USBSID_INTERFACE_H_
27#define _USBSID_INTERFACE_H_
28
29#include <stdint.h>
30#include <stddef.h>
31#include <stdbool.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37 /* USBSID Interface for use in STD C applications */
38 typedef void * USBSIDitf;
39 USBSIDitf create_USBSID(void);
40 int init_USBSID(USBSIDitf, bool start_threaded, bool with_cycles);
41 void close_USBSID(USBSIDitf);
42 void pause_USBSID(USBSIDitf);
43 void reset_USBSID(USBSIDitf);
44 void resetallregisters_USBSID(USBSIDitf);
45 void clearbus_USBSID(USBSIDitf);
46 void mute_USBSID(USBSIDitf);
47 void unmute_USBSID(USBSIDitf);
48 void setclockrate_USBSID(USBSIDitf, long clockrate_cycles, bool suspend_sids);
49 long getclockrate_USBSID(USBSIDitf);
50 long getrefreshrate_USBSID(USBSIDitf);
51 long getrasterrate_USBSID(USBSIDitf);
52 int getnumsids_USBSID(USBSIDitf);
53 int getfmoplsid_USBSID(USBSIDitf);
54 int getpcbversion_USBSID(USBSIDitf);
55 void setstereo_USBSID(USBSIDitf, int state);
56 void togglestereo_USBSID(USBSIDitf);
57
58 /* Helpers */
59 bool initialised_USBSID(USBSIDitf);
60 bool available_USBSID(USBSIDitf);
61 bool portisopen_USBSID(USBSIDitf);
62 // int found_USBSID(USBSIDitf);
63
64 /* Synchronous direct */
65 void writesingle_USBSID(USBSIDitf, unsigned char *buff, int len);
66 unsigned char readsingle_USBSID(USBSIDitf, uint8_t reg);
67
68 /* Asynchronous direct */
69 void writebuffer_USBSID(USBSIDitf, unsigned char *buff, int len);
70 void write_USBSID(USBSIDitf, uint8_t reg, uint8_t val);
71 void writecycled_USBSID(USBSIDitf, uint8_t reg, uint8_t val, uint16_t cycles);
72 unsigned char read_USBSID(USBSIDitf p, uint8_t reg);
73
74 /* Asynchronous thread */
75 void writering_USBSID(USBSIDitf, uint8_t reg, uint8_t val);
76 void writeringcycled_USBSID(USBSIDitf, uint8_t reg, uint8_t val, uint16_t cycles);
77
78 /* Thread buffer */
79 void enablethread_USBSID(USBSIDitf);
80 void disablethread_USBSID(USBSIDitf);
81 void setflush_USBSID(USBSIDitf);
82 void flush_USBSID(USBSIDitf);
83 void restartringbuffer_USBSID(USBSIDitf);
84 void setbuffsize_USBSID(USBSIDitf, int size);
85 void setdiffsize_USBSID(USBSIDitf, int size);
86
87 /* Thread utils */
88 void restartthread_USBSID(USBSIDitf, bool with_cycles);
89
90 /* Timing and cycles */
91 int_fast64_t waitforcycle_USBSID(USBSIDitf, uint_fast64_t cycles);
92
93#ifdef __cplusplus
94}
95#endif
96
97#endif /* _USBSID_INTERFACE_H_ */