usb.h File Reference

The header file describes the usb interface. More...

Go to the source code of this file.

Data Structures

struct  HAL_UsbEndPointDescptr_t

Typedefs

typedef void(*) TransferCallback_t (void *pArg, uint8_t status, uint16_t transferred, uint16_t remaining)

Functions

END_PACK void HAL_RegisterRequestHandler (void(*f)(uint8_t *req))
 Registers user's request handler.
void HAL_RegisterEndOfBusResetHandler (void(*f)(void))
 Registers user's end of bus reset handler.
void HAL_RegisterResumeHandler (void(*f)(void))
 Registers user's resume handler.
void HAL_RegisterSuspendHandler (void(*f)(void))
 Registers user's suspend handler.
void HAL_ConfigureEndpoint (HAL_UsbEndPointDescptr_t *descriptor)
 Configures an endpoint according to its Endpoint Descriptor.
uint8_t HAL_UsbWrite (uint8_t eptnum, void *data, uint32_t size, TransferCallback_t callback, void *argument)
 Sends data through a USB endpoint. Sets up the transfer descriptor, writes one or two data payloads (depending on the number of FIFO bank for the endpoint) and then starts the actual transfer. The operation is complete when all the data has been sent.
uint8_t HAL_UsbRead (uint8_t eptnum, void *data, uint32_t size, TransferCallback_t callback, void *argument)
 Reads incoming data on an USB endpoint This methods sets the transfer descriptor and activate the endpoint interrupt. The actual transfer is then carried out by the endpoint interrupt handler. The Read operation finishes either when the buffer is full, or a short packet (inferior to endpoint maximum size) is received.
void HAL_Halt (uint8_t eptnum)
 Sets the HALT feature on the given endpoint (if not already in this state).
void HAL_Unhalt (uint8_t eptnum)
 Clears the Halt feature on the given endpoint.
uint8_t HAL_IsHalted (uint8_t eptnum)
 Returns the current Halt status of an endpoint.
uint8_t HAL_Stall (uint8_t eptnum)
 Causes the given endpoint to acknowledge the next packet it receives with a STALL handshake.
void HAL_SetAddress (uint8_t *address)
 Sets the device address to the given value.
void HAL_SetConfiguration (uint8_t cfgnum)
 Sets the current device configuration.
void HAL_UsbInit (uint8_t *reqMem)
 Initializes the USB driver. This function must be called before host bus reset and after pull up is connected to D+. After pull up was connected to D+ host resets device with 100ms delay.
uint8_t HAL_GetState (void)
 Returns the current state of the USB device.


Detailed Description

The header file describes the usb interface.

Author:
Atmel Corporation: http://www.atmel.com
Support email: avr@atmel.com
Copyright (c) 2008 , Atmel Corporation. All rights reserved. Licensed under Atmel's Limited License Agreement (BitCloudTM).

Definition in file usb.h.


Typedef Documentation

typedef void(* ) TransferCallback_t(void *pArg, uint8_t status, uint16_t transferred, uint16_t remaining)

Definition at line 38 of file usb.h.


Function Documentation

END_PACK void HAL_RegisterRequestHandler ( void(*)(uint8_t *req)  f  ) 

Registers user's request handler.

Parameters:
[in] f - pointer to user's callback

void HAL_RegisterEndOfBusResetHandler ( void(*)(void)  f  ) 

Registers user's end of bus reset handler.

Parameters:
[in] f - pointer to user's callback

void HAL_RegisterResumeHandler ( void(*)(void)  f  ) 

Registers user's resume handler.

Parameters:
[in] f - pointer to user's callback

void HAL_RegisterSuspendHandler ( void(*)(void)  f  ) 

Registers user's suspend handler.

Parameters:
[in] f - pointer to user's callback

void HAL_ConfigureEndpoint ( HAL_UsbEndPointDescptr_t descriptor  ) 

Configures an endpoint according to its Endpoint Descriptor.

Parameters:
[in] descriptor - Pointer to an Endpoint descriptor.

uint8_t HAL_UsbWrite ( uint8_t  eptnum,
void *  data,
uint32_t  size,
TransferCallback_t  callback,
void *  argument 
)

Sends data through a USB endpoint. Sets up the transfer descriptor, writes one or two data payloads (depending on the number of FIFO bank for the endpoint) and then starts the actual transfer. The operation is complete when all the data has been sent.

If the size of the buffer is greater than the size of the endpoint (or twice the size if the endpoint has two FIFO banks), then the buffer must be kept allocated until the transfer is finished*. This means that it is not possible to declare it on the stack (i.e. as a local variable of a function which returns after starting a transfer).

Parameters:
[in] eptnum - Endpoint number.
[in] data - Pointer to a buffer with the data to send.
[in] size - Size of the data buffer.
[in] callback - Optional callback function to invoke when the transfer is complete.
[in] argument - Optional argument to the callback function.
Returns:
STATUS_SUCCESS if the transfer has been started; otherwise, the corresponding error status code.

uint8_t HAL_UsbRead ( uint8_t  eptnum,
void *  data,
uint32_t  size,
TransferCallback_t  callback,
void *  argument 
)

Reads incoming data on an USB endpoint This methods sets the transfer descriptor and activate the endpoint interrupt. The actual transfer is then carried out by the endpoint interrupt handler. The Read operation finishes either when the buffer is full, or a short packet (inferior to endpoint maximum size) is received.

The buffer must be kept allocated until the transfer is finished*.

Parameters:
[in] eptnum - Endpoint number.
[in] data - Pointer to a data buffer.
[in] size - Size of the data buffer in bytes.
[in] callback - Optional end-of-transfer callback function.
[in] argument - Optional argument to the callback function.
Returns:
STATUS_SUCCESS if the read operation has been started; otherwise, the corresponding error code.

void HAL_Halt ( uint8_t  eptnum  ) 

Sets the HALT feature on the given endpoint (if not already in this state).

Parameters:
[in] eptnum - Endpoint number.

void HAL_Unhalt ( uint8_t  eptnum  ) 

Clears the Halt feature on the given endpoint.

Parameters:
[in] eptnum - Endpoint number.

uint8_t HAL_IsHalted ( uint8_t  eptnum  ) 

Returns the current Halt status of an endpoint.

Parameters:
[in] eptnum - Endpoint number.
Returns:
1 - if the endpoint is currently halted; 0 - otherwise.

uint8_t HAL_Stall ( uint8_t  eptnum  ) 

Causes the given endpoint to acknowledge the next packet it receives with a STALL handshake.

Parameters:
[in] eptnum - Endpoint number.
Returns:
STATUS_SUCCESS or STATUS_BUSY.

void HAL_SetAddress ( uint8_t *  address  ) 

Sets the device address to the given value.

Parameters:
[in] address - New device address.

void HAL_SetConfiguration ( uint8_t  cfgnum  ) 

Sets the current device configuration.

Parameters:
[in] cfgnum - Configuration number to set.

void HAL_UsbInit ( uint8_t *  reqMem  ) 

Initializes the USB driver. This function must be called before host bus reset and after pull up is connected to D+. After pull up was connected to D+ host resets device with 100ms delay.

Parameters:
[in] reqMem - Memory for usb request. Memory is allocated by user.

uint8_t HAL_GetState ( void   ) 

Returns the current state of the USB device.

Returns:
Device current state.


Generated on Mon Feb 16 17:53:40 2009 for BitCloud Stack Documentation by  doxygen 1.5.1-p1