libexsid  2.1
exSID_ftdiwrap.h File Reference

FTDI access wrapper header file. More...

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)
 Allocate new ftdi handle. More...
 
typedef void(* xSfw_free_p) (void *ftdi)
 Free ftdi handle. More...
 
typedef int(* xSfw_write_data_p) (void *ftdi, const unsigned char *buf, int size)
 Write data to FTDI. More...
 
typedef int(* xSfw_read_data_p) (void *ftdi, unsigned char *buf, int size)
 Read data from FTDI. More...
 
typedef int(* xSfw_usb_open_desc_p) (void **ftdi, int vid, int pid, const char *desc, const char *serial)
 Open device by description. More...
 
typedef int(* xSfw_usb_purge_buffers_p) (void *ftdi)
 Purge FTDI buffers. More...
 
typedef int(* xSfw_usb_close_p) (void *ftdi)
 Close FTDI device. More...
 
typedef char *(* xSfw_get_error_string_p) (void *ftdi)
 Get error string. More...
 

Functions

int xSfw_usb_setup (void *ftdi, int baudrate, int latency)
 Setup FTDI chip to match exSID firmware. More...
 
int xSfw_dlopen ()
 Attempt to dlopen a known working library to access FTDI chip. More...
 
void xSfw_dlclose ()
 Release dlopen'd library. More...
 

Variables

xSfw_new_p xSfw_new
 Handle allocation callback. More...
 
xSfw_free_p xSfw_free
 Handle deallocation callback. More...
 
xSfw_write_data_p xSfw_write_data
 Data write callback. More...
 
xSfw_read_data_p xSfw_read_data
 Data read callback. More...
 
xSfw_usb_open_desc_p xSfw_usb_open_desc
 Device open callback. More...
 
xSfw_usb_close_p xSfw_usb_close
 Device close callback. More...
 
xSfw_get_error_string_p xSfw_get_error_string
 Human readable error string callback. More...
 

Detailed Description

FTDI access wrapper header file.

Definition in file exSID_ftdiwrap.h.

Macro Definition Documentation

#define XSFW_EXTERN   extern

Definition at line 71 of file exSID_ftdiwrap.h.

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

Definition at line 76 of file exSID_ftdiwrap.h.

Typedef Documentation

typedef void(* xSfw_free_p) (void *ftdi)

Free ftdi handle.

Definition at line 21 of file exSID_ftdiwrap.h.

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.

Definition at line 68 of file exSID_ftdiwrap.h.

typedef void*(* xSfw_new_p) (void)

Allocate new ftdi handle.

Definition at line 18 of file exSID_ftdiwrap.h.

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.

Definition at line 41 of file exSID_ftdiwrap.h.

typedef int(* xSfw_usb_close_p) (void *ftdi)

Close FTDI device.

Definition at line 60 of file exSID_ftdiwrap.h.

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.

Definition at line 54 of file exSID_ftdiwrap.h.

typedef int(* xSfw_usb_purge_buffers_p) (void *ftdi)

Purge FTDI buffers.

Definition at line 57 of file exSID_ftdiwrap.h.

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.

Definition at line 31 of file exSID_ftdiwrap.h.

Function Documentation

void xSfw_dlclose ( )

Release dlopen'd library.

Definition at line 335 of file exSID_ftdiwrap.c.

References _xSfw_dlclose.

Referenced by exSID_exit(), and 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.

Definition at line 175 of file exSID_ftdiwrap.c.

References _xSfw_clear_dlerror, _xSfw_dlopen, _xSfw_free_errstr, EXSID_INTERFACES, XS_LIBFTD2XX, XS_LIBFTDI, xsdbg, xSfw_dlclose(), XSFW_DLSYM, xSfw_free, xSfw_get_error_string, xSfw_new, xSfw_read_data, xSfw_usb_close, xSfw_usb_open_desc, and xSfw_write_data.

Referenced by exSID_init().

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.

Definition at line 267 of file exSID_ftdiwrap.c.

References XS_LIBFTD2XX, XS_LIBFTDI, and xsdbg.

Referenced by exSID_init().

Variable Documentation

xSfw_free_p xSfw_free

Handle deallocation callback.

Referenced by exSID_exit(), exSID_free(), exSID_init(), and xSfw_dlopen().

xSfw_get_error_string_p xSfw_get_error_string

Human readable error string callback.

Referenced by exSID_exit(), exSID_init(), and xSfw_dlopen().

xSfw_new_p xSfw_new

Handle allocation callback.

Referenced by exSID_init(), and xSfw_dlopen().

xSfw_read_data_p xSfw_read_data

Data read callback.

Referenced by xSfw_dlopen().

xSfw_usb_close_p xSfw_usb_close

Device close callback.

Referenced by exSID_exit(), and xSfw_dlopen().

xSfw_usb_open_desc_p xSfw_usb_open_desc

Device open callback.

Referenced by exSID_init(), and xSfw_dlopen().

xSfw_write_data_p xSfw_write_data

Data write callback.

Referenced by xSfw_dlopen().