libsidplayfp  2.0.2
Macros | Typedefs | Functions
exSID_ftdiwrap.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define XSFW_EXTERN   extern
 
#define XSFW_PROTODEF(a)   XSFW_EXTERN a ## _p a
 

Typedefs

typedef void *(* xSfw_new_p) (void)
 
typedef void(* xSfw_free_p) (void *ftdi)
 
typedef int(* xSfw_write_data_p) (void *ftdi, const unsigned char *buf, int size)
 
typedef int(* xSfw_read_data_p) (void *ftdi, unsigned char *buf, int size)
 
typedef int(* xSfw_usb_open_desc_p) (void **ftdi, int vid, int pid, const char *desc, const char *serial)
 
typedef int(* xSfw_usb_purge_buffers_p) (void *ftdi)
 
typedef int(* xSfw_usb_close_p) (void *ftdi)
 
typedef char *(* xSfw_get_error_string_p) (void *ftdi)
 

Functions

 XSFW_PROTODEF (xSfw_new)
 Handle allocation callback.
 
 XSFW_PROTODEF (xSfw_free)
 Handle deallocation callback.
 
 XSFW_PROTODEF (xSfw_write_data)
 Data write callback.
 
 XSFW_PROTODEF (xSfw_read_data)
 Data read callback.
 
 XSFW_PROTODEF (xSfw_usb_open_desc)
 Device open callback.
 
 XSFW_PROTODEF (xSfw_usb_purge_buffers)
 Device buffers purge callback.
 
 XSFW_PROTODEF (xSfw_usb_close)
 Device close callback.
 
 XSFW_PROTODEF (xSfw_get_error_string)
 Human readable error string callback.
 
int xSfw_usb_setup (void *ftdi, int baudrate, int latency)
 
int xSfw_dlopen ()
 
void xSfw_dlclose ()
 

Detailed Description

FTDI access wrapper header file.

Typedef Documentation

◆ xSfw_free_p

typedef void(* xSfw_free_p) (void *ftdi)

Free ftdi handle.

◆ xSfw_get_error_string_p

typedef char*(* xSfw_get_error_string_p) (void *ftdi)

Get error string.

Parameters
ftdiftdi handle.
Returns
human-readable error string.
Note
only supported with libftdi.

◆ xSfw_new_p

typedef void*(* xSfw_new_p) (void)

Allocate new ftdi handle.

◆ xSfw_read_data_p

typedef int(* xSfw_read_data_p) (void *ftdi, unsigned char *buf, int size)

Read data from FTDI.

Parameters
ftdiftdi handle.
bufread buffer.
sizenumber of bytes to read.
Returns
number of bytes read or negative error value.
Note
there are performance constrains on the size of the buffer, see documentation.

◆ xSfw_usb_close_p

typedef int(* xSfw_usb_close_p) (void *ftdi)

Close FTDI device.

◆ xSfw_usb_open_desc_p

typedef int(* xSfw_usb_open_desc_p) (void **ftdi, int vid, int pid, const char *desc, const char *serial)

Open device by description.

Parameters
ftdipointer to ftdi handle.
vidtarget vendor id. Ignored by ftd2xx.
pidtarget product id. Ignored by ftd2xx.
descDescription string.
serialtarget product serial. Ignored by ftd2xx.
Returns
0 on success or negative error value.
Warning
This is the only function to use a pointer to ftdi handle, this is rendered necessary because of libftd2xx silly way of doing things.

◆ xSfw_usb_purge_buffers_p

typedef int(* xSfw_usb_purge_buffers_p) (void *ftdi)

Purge FTDI buffers.

◆ xSfw_write_data_p

typedef int(* xSfw_write_data_p) (void *ftdi, const unsigned char *buf, int size)

Write data to FTDI.

Parameters
ftdiftdi handle.
bufwrite buffer.
sizenumber of bytes to write.
Returns
number of bytes written or negative error value.
Note
there are performance constrains on the size of the buffer, see documentation.

Function Documentation

◆ xSfw_dlclose()

void xSfw_dlclose ( )

Release dlopen'd library.

◆ xSfw_dlopen()

int xSfw_dlopen ( )

Attempt to dlopen a known working library to access FTDI chip. Will try libftd2xx first, then libftdi.

Returns
0 on success, -1 on error.

◆ xSfw_usb_setup()

int xSfw_usb_setup ( void *  ftdi,
int  baudrate,
int  latency 
)

Setup FTDI chip to match exSID firmware. Defaults to 8N1, no flow control.

Parameters
ftdiftdi handle
baudrateTarget baudrate
latencyTarget latency
Returns
0 on success, rval on error.