- Main Page
- Classes
- Files
- Related Pages

- File List
- File Members

# usbcontrol.c File Reference

`#include "type.h"`
`#include "usbdebug.h"`
`#include "usbstruct.h"`
`#include "usbapi.h"`

Include dependency graph for usbcontrol.c:

## Defines

#define | MAX_CONTROL_SIZE 128
#define | MAX_REQ_HANDLERS 4

## Functions

void | USBHandleControlTransfer (U8 bEP, U8 bEPStat)
void | USBRegisterRequestHandler (int iType, TFnHandleRequest *pfnHandler, U8 *pbDataStore)

## Detailed Description

Control transfer handler.

This module handles control transfers and is normally installed on the endpoint 0 callback.

Control transfers can be of the following type: 0 Standard; 1 Class; 2 Vendor; 3 Reserved.

A callback can be installed for each of these control transfers using USBRegisterRequestHandler. When an OUT request arrives, data is collected in the data store provided with the USBRegisterRequestHandler call. When the transfer is done, the callback is called. When an IN request arrives, the callback is called immediately to either put the control transfer data in the data store, or to get a pointer to control transfer data. The data is then packetised and sent to the host.

## Define Documentation

#define MAX_CONTROL_SIZE 128

maximum total size of control transfer data

#define MAX_REQ_HANDLERS 4

standard, class, vendor, reserved

## Function Documentation

void USBHandleControlTransfer | ( | U8 | bEP,
|  | U8 | bEPStat |
| ) |  |  |

Handles IN/OUT transfers on EP0

Parameters:

  `[in]` | bEP | Endpoint address
  `[in]` | bEPStat | Endpoint status

void USBRegisterRequestHandler | ( | int | iType,
|  | TFnHandleRequest * | pfnHandler,
|  | U8 * | pbDataStore |
| ) |  |  |

Registers a callback for handling requests

Parameters:

  `[in]` | iType | Type of request, e.g. REQTYPE_TYPE_STANDARD
  `[in]` | *pfnHandler | Callback function pointer
  `[in]` | *pbDataStore | Data storage area for this type of request