libexsid  2.1
exSID_ftdiwrap.c File Reference

exSID USB FTDI access wrapper More...

#include "exSID_defs.h"
#include <stdio.h>
#include "exSID_ftdiwrap.h"
Include dependency graph for exSID_ftdiwrap.c:

Go to the source code of this file.

Macros

#define XSFW_WRAPDECL
 
#define EXSID_INTERFACES   "libftdi, libftd2xx"
 
#define _xSfw_dlopen(filename)   dlopen(filename, RTLD_NOW|RTLD_LOCAL)
 
#define _xSfw_dlsym(handle, symbol)   dlsym(handle, symbol)
 
#define _xSfw_dlclose(handle)   dlclose(handle)
 
#define _xSfw_dlerror()   dlerror()
 
#define _xSfw_clear_dlerror()   dlerror()
 
#define _xSfw_free_errstr(str)   /* nothing */
 
#define XSFW_DLSYM(a, b)
 

Enumerations

enum  libtype_t { XS_LIBNONE, XS_LIBFTDI, XS_LIBFTD2XX }
 Flag to signal which of the supported libraries is in use. More...
 

Functions

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

Detailed Description

exSID USB FTDI access wrapper

Author
Thibaut VARENE
Date
2016
Note
Primary target is libftdi (cleaner API), adaptations are made for others.

Definition in file exSID_ftdiwrap.c.

Macro Definition Documentation

#define _xSfw_clear_dlerror ( )    dlerror()

Definition at line 86 of file exSID_ftdiwrap.c.

Referenced by xSfw_dlopen().

#define _xSfw_dlclose (   handle)    dlclose(handle)

Definition at line 84 of file exSID_ftdiwrap.c.

Referenced by xSfw_dlclose().

#define _xSfw_dlerror ( )    dlerror()

Definition at line 85 of file exSID_ftdiwrap.c.

#define _xSfw_dlopen (   filename)    dlopen(filename, RTLD_NOW|RTLD_LOCAL)

Definition at line 82 of file exSID_ftdiwrap.c.

Referenced by xSfw_dlopen().

#define _xSfw_dlsym (   handle,
  symbol 
)    dlsym(handle, symbol)

Definition at line 83 of file exSID_ftdiwrap.c.

#define _xSfw_free_errstr (   str)    /* nothing */

Definition at line 87 of file exSID_ftdiwrap.c.

Referenced by xSfw_dlopen().

#define EXSID_INTERFACES   "libftdi, libftd2xx"

Definition at line 57 of file exSID_ftdiwrap.c.

Referenced by xSfw_dlopen().

#define XSFW_DLSYM (   a,
 
)
Value:
*(void **)(&a) = _xSfw_dlsym(dlhandle, b); \
if (a == NULL) { \
dlerrorstr = _xSfw_dlerror(); \
goto dlfail; \
}
#define _xSfw_dlerror()
#define _xSfw_dlsym(handle, symbol)

Referenced by xSfw_dlopen().

#define XSFW_WRAPDECL

Definition at line 54 of file exSID_ftdiwrap.c.

Enumeration Type Documentation

enum libtype_t

Flag to signal which of the supported libraries is in use.

Enumerator
XS_LIBNONE 
XS_LIBFTDI 
XS_LIBFTD2XX 

Definition at line 92 of file exSID_ftdiwrap.c.

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().