libnjb: /usr/obj/ports/libnjb-2.2.7/libnjb-2.2.7/src/usb_io.c File Reference

libnjb 2.2.7

Macros | Functions | Variables
usb_io.c File Reference
`#include <string.h>`
`#include <stdint.h>`
`#include <usb.h>`
`#include "base.h"`
`#include "libnjb.h"`
`#include "ioutil.h"`
`#include "usb_io.h"`
`#include "njb_error.h"`

## Macros
#define | USB_DP_HTD (0x00 << 7) /* host to device */
#define | USB_DP_DTH (0x01 << 7) /* device to host */
#define | USB_FEATURE_HALT 0x00

## Functions
ssize_t | usb_pipe_write (njb_t *njb, void *buf, size_t nbytes)
ssize_t | usb_pipe_read (njb_t *njb, void *buf, size_t nbytes)
int | usb_setup (njb_t *njb, int type, int request, int value, int index, int length, void *data)

## Variables
int | __sub_depth

## Detailed Description

This file contain some USB-specific code that is used by all devices.

## Function Documentation

## § usb_pipe_read()

ssize_t usb_pipe_read | ( | njb_t * | njb,
|  | void * | buf,
|  | size_t | nbytes
| ) |  |

This function reads a chunk of bytes to a buffer from a device's IN endpoint.

Parameters

  njb | the jukebox object to use
  buf | the buffer to store the bytes in
  nbytes | the number of bytes to read in

Returns
  the number of bytes actually read

References DD_USBBLK, DD_USBBLKLIM, njb_struct::dev, njb_debug(), and njb_struct::usb_bulk_in_ep.

Referenced by njb3_get_file_block(), njb_ping(), njb_read_eaxtypes(), and njb_receive_file_block().

## § usb_pipe_write()

ssize_t usb_pipe_write | ( | njb_t * | njb,
|  | void * | buf,
|  | size_t | nbytes
| ) |  |

This function writes a number of bytes from a buffer to a devices OUT endpoint.

Parameters

  njb | the jukebox object to use
  buf | the buffer to send bytes from
  nbytes | the number of bytes to write

Returns
  the number of bytes actually written

References data_dump_ascii(), DD_USBBLK, DD_USBBLKLIM, njb_struct::dev, njb_debug(), and njb_struct::usb_bulk_out_ep.

## § usb_setup()

int usb_setup | ( | njb_t * | njb,
|  | int | type,
|  | int | request,
|  | int | value,
|  | int | index,
|  | int | length,
|  | void * | data
| ) |  |

This function sends a USB SETUP 8-byte command across to endpoint 0 on the device.

References __sub_depth, data_dump(), data_dump_ascii(), DD_USBCTL, njb_struct::dev, and njb_debug().

Referenced by njb_capture(), njb_get_datafile_header(), njb_get_disk_usage(), njb_get_library_counter(), njb_get_playlist_header(), njb_get_track_tag_header(), njb_ping(), njb_read_eaxtypes(), njb_receive_file_block(), njb_set_library_counter(), and njb_verify_last_command().

## Variable Documentation

## § __sub_depth

int __sub_depth

The current subroutine depth for all of libnjb (global)

Referenced by usb_setup().