BIOS Reference - USB Functions

From NanoComputerWiki

Jump to: navigation, search

USB Module Functions

NanoComputer BIOS Reference

USB Module

Note: This information may be out of date. For the latest information always check the header files shipped with the NanoComputer SDK.

Last update: Oct 31 2008

// --------------------------------------------------
//  Defines
// --------------------------------------------------
    #define USB_FIXEDPACKET_BUFFERSIZE              0x41
    #define USB_FIXEDPACKET_SIZE                    0x40

    #define E_USB_DATASTREAM_BAD_DATA_PACKET        -200    // FF38
    #define E_USB_DATASTREAM_BAD_SEND_PACKET        -201    // FF37


// --------------------------------------------------
//  Globals
// --------------------------------------------------
    char* _pUSB_BIOS_GLOBAL_STR_BUFFER = NULL;


// --------------------------------------------------
//  Public Function Prototypes
// --------------------------------------------------
    /**
     *  Ends USB communications.
     *
     *  Status - [in] Status code to send at end of the USB communications
     *
     *  This must be called before application terminates
     *
     *  Returns E_OK on success, other error in failure.
     **/
    char USB_End(char Status);

    /**
     *  Sends a formatted string using the USB.  Maxmimum length of the string 0x80 bytes
     *
     *  sFormat - [in] See printf documentation
     *  ...     - [in] See printf documentation
     *
     *  Returns E_OK on success, other error in failure.
     **/
    char USB_Printf(const char* sFormat, ...);

    /**
     *  Receives data from the USB
     *
     *  pBuf           - [in]  Buffer to write the data into
     *  BufSize        - [in]  Size of the buffer pBuf
     *  pBytesReceived - [out] The number of bytes actually received, may be less then BufSize
     *
     *  Returns E_OK on success, other error in failure.
     **/
    char USB_Receive(unsigned char* pBuf, unsigned short BufSize, unsigned short* pBytesReceived);

    /**
     *  Resets USB communications.
     *
     *  This should be called from within an application to change the maximum input packet size.
     *
     *  MaxInPacketSize - [in] Maximum size of an incoming packet.
     *
     *  Returns E_OK on success, other error in failure.
     **/
    char USB_Reset(unsigned short MaxInPacketSize);

    /**
     *  Sends data using the USB
     *
     *  pBuf           - [in]  Buffer containing data to send
     *  BufSize        - [in]  Size of the buffer pBuf
     *
     *  Returns E_OK on success, other error in failure.
     **/
    char USB_Send(unsigned char* pBuf, unsigned short BufSize);

    /**
     *  Sends and Receives data using the USB
     *
     *  pInBuf         - [in]  Pointer to buffer where received data will be placed
     *  InBufSize      - [in]  Size of the pInBuf
     *  pBytesReceived - [out] The number of bytes received from the PC, may be less then InBufSize.  Can be NULL if don't care.
     *  pOutBuf        - [in]  Pointer to buffer of data to be sent to PC
     *  OutBufSize     - [in]  Number of bytes to send to PC
     *
     *  Returns E_OK on success, other error in failure.
     **/
    char USB_SendReceive(unsigned char* pInBuf, unsigned short InBufSize, unsigned short* pBytesReceived, unsigned char* pOutBuf, unsigned short OutBufSize);

    /**
     *  Starts USB communications.
     *
     *  This must be called before application uses the USB
     *
     *  MaxInPacketSize - [in] Maximum size of an incoming packet.
     *
     *  Returns E_OK on success, other error in failure.
     **/
    char USB_Start(unsigned short MaxInPacketSize);

Navigation

Click on any of the links below to navigate to a new page
Personal tools