OpenCBM
Macros | Functions
xu1541.c File Reference

libusb based xu1541 access routines More...

#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "opencbm.h"
#include "arch.h"
#include "dynlibusb.h"
#include "getpluginaddress.h"
#include "xu1541.h"

Go to the source code of this file.

Macros

#define TIMEOUT_DELAY   25000
 timeout value, used mainly after errors More...
 

Functions

int xu1541_init (void)
 initialise the xu1541 device More...
 
void xu1541_close (void)
 close the xu1541 device More...
 
int xu1541_ioctl (unsigned int cmd, unsigned int addr, unsigned int secaddr)
 perform an ioctl on the xu1541 More...
 
int xu1541_write (const unsigned char *data, size_t len)
 write data to the xu1541 device More...
 
int xu1541_read (unsigned char *data, size_t len)
 read data from the xu1541 device More...
 
int xu1541_special_write (int mode, const unsigned char *data, size_t size)
 "special" write data to the xu1541 device More...
 
int xu1541_special_read (int mode, unsigned char *data, size_t size)
 "special" read data from the xu1541 device More...
 

Detailed Description

libusb based xu1541 access routines



Author
Till Harbaum

Definition in file xu1541.c.

Macro Definition Documentation

#define TIMEOUT_DELAY   25000

timeout value, used mainly after errors

Todo:
What is the exact purpose of this?

Definition at line 37 of file xu1541.c.

Referenced by xu1541_ioctl(), xu1541_read(), and xu1541_write().

Function Documentation

void xu1541_close ( void  )

close the xu1541 device

Remarks
This function releases the interface and closes the xu1541 handle.

Definition at line 243 of file xu1541.c.

Referenced by opencbm_plugin_driver_close().

int xu1541_init ( void  )

initialise the xu1541 device

This function tries to find and identify the xu1541 device.

Returns
0 on success, -1 on error.
Remarks
On success, xu1541_handle contains a valid handle to the xu1541 device. In this case, the device configuration has been set and the interface been claimed.
Bug:
On some error types, this function might return error, but might has opened the xu1541_handle. In this case, the handle is leaked, as xu1541_close() is not to be called.

Definition at line 132 of file xu1541.c.

Referenced by opencbm_plugin_driver_open().

int xu1541_ioctl ( unsigned int  cmd,
unsigned int  addr,
unsigned int  secaddr 
)

perform an ioctl on the xu1541

Parameters
cmdThe IOCTL number
addrThe (IEC) device to use
secaddrThe (IEC) secondary address to use
Returns
Depends upon the IOCTL.
Todo:
Rework for cleaner structure. Currently, this is a mess!

Definition at line 270 of file xu1541.c.

References TIMEOUT_DELAY.

Referenced by opencbm_plugin_clear_eoi(), opencbm_plugin_close(), opencbm_plugin_get_eoi(), opencbm_plugin_iec_poll(), opencbm_plugin_iec_release(), opencbm_plugin_iec_set(), opencbm_plugin_iec_setrelease(), opencbm_plugin_iec_wait(), opencbm_plugin_listen(), opencbm_plugin_open(), opencbm_plugin_pp_read(), opencbm_plugin_pp_write(), opencbm_plugin_reset(), opencbm_plugin_talk(), opencbm_plugin_unlisten(), and opencbm_plugin_untalk().

int xu1541_read ( unsigned char *  data,
size_t  len 
)

read data from the xu1541 device

Parameters
dataPointer to a buffer which will contain the data read from the xu1541
lenThe number of bytes to read from the xu1541
Returns
The number of bytes read

Definition at line 461 of file xu1541.c.

References TIMEOUT_DELAY.

Referenced by opencbm_plugin_raw_read().

int xu1541_special_read ( int  mode,
unsigned char *  data,
size_t  size 
)

"special" read data from the xu1541 device

Todo:
What is so special?
Parameters
mode
Todo:
???
Parameters
dataPointer to a buffer which will contain the data read from the xu1541
sizeThe number of bytes to read from the xu1541
Returns
The number of bytes read

Definition at line 636 of file xu1541.c.

Referenced by opencbm_plugin_pp_cc_read_n(), opencbm_plugin_pp_dc_read_n(), opencbm_plugin_s1_read_n(), and opencbm_plugin_s2_read_n().

int xu1541_special_write ( int  mode,
const unsigned char *  data,
size_t  size 
)

"special" write data to the xu1541 device

Todo:
What is so special?
Parameters
mode
Todo:
???
Parameters
dataPointer to buffer which contains the data to be written to the xu1541
sizeThe length of the data buffer to be written to the xu1541
Returns
The number of bytes written
Remarks
current all special mode are able to work asynchronously. this means that we can just handle them in the device at the same time as the USB transfers.

Definition at line 588 of file xu1541.c.

Referenced by opencbm_plugin_pp_cc_write_n(), opencbm_plugin_pp_dc_write_n(), opencbm_plugin_s1_write_n(), and opencbm_plugin_s2_write_n().

int xu1541_write ( const unsigned char *  data,
size_t  len 
)

write data to the xu1541 device

Parameters
dataPointer to buffer which contains the data to be written to the xu1541
lenThe length of the data buffer to be written to the xu1541
Returns
The number of bytes written

Definition at line 379 of file xu1541.c.

References TIMEOUT_DELAY.

Referenced by opencbm_plugin_raw_write().