ADC Niose test Connect four analog signals to your MBED. and then run the Windows app. The four traces are displayed on an oscilloscope like display. I have used a USB HID DEVICE link, so connections to D+, D- are required. The MBED code is otherwise quite basic, So you can modify it to your own test needs. Additionaly, there is a 16 bit count value, in my MBED code Mainly to test if MSB & LSB are correct.

Dependencies:   mbed

HID/USBDevice.h

Committer:
ceri
Date:
2011-11-19
Revision:
0:cbe01b678bd4

File content as of revision 0:cbe01b678bd4:

/* USBDevice.h */
/* Generic USB device */
/* Copyright (c) 2011 ARM Limited. All rights reserved. */

#ifndef USBDEVICE_H
#define USBDEVICE_H

#include "mbed.h"
#include "USBDevice_Types.h"
#include "USBBusInterface.h"



class USBDevice: public USBHAL
{
public:
    USBDevice(uint16_t vendor_id, uint16_t product_id, uint16_t product_release);
    
    /**
    * Check if the device is configured
    *
    * @returns true if configured, false otherwise
    */
    bool configured(void);
    
    /**
    * Connect a device
    */
    void connect(void);
    
    /**
    * Disconnect a device
    */
    void disconnect(void);
    
    /**
    * Add an endpoint
    *
    * @param endpoint endpoint which will be added
    * @param maxPacket Maximum size of a packet which can be sent for this endpoint
    * @returns true if successful, false otherwise
    */
    bool addEndpoint(uint8_t endpoint, uint32_t maxPacket);

    /**
    * Start a reading on a certain endpoint.
    * You can access the result of the reading by USBDevice_read
    *
    * @param endpoint endpoint which will be read
    * @param maxSize the maximum length that can be read
    * @return true if successful
    */
    bool readStart(uint8_t endpoint, uint16_t maxSize);
    
    /**
    * Read a certain endpoint. Before calling this function, USBUSBDevice_readStart
    * must be called.
    *
    * Warning: blocking
    *
    * @param endpoint endpoint which will be read
    * @param buffer buffer will be filled with the data received
    * @param size the number of bytes read will be stored in *size
    * @param maxSize the maximum length that can be read
    * @returns true if successful
    */
    bool read(uint8_t endpoint, uint8_t * buffer, uint16_t * size, uint16_t maxSize);
    
    /**
    * Read a certain endpoint.
    *
    * Warning: non blocking
    *
    * @param endpoint endpoint which will be read
    * @param buffer buffer will be filled with the data received (if data are available) 
    * @param size the number of bytes read will be stored in *size
    * @param maxSize the maximum length that can be read
    * @returns true if successful
    */
    bool readNB(uint8_t endpoint, uint8_t * buffer, uint16_t * size, uint16_t maxSize);
    
    /**
    * Write a certain endpoint.
    *
    * Warning: blocking
    *
    * @param endpoint endpoint to write
    * @param buffer data contained in buffer will be write
    * @param size the number of bytes to write
    * @param maxSize the maximum length that can be written on this endpoint
    */
    bool write(uint8_t endpoint, uint8_t * buffer, uint16_t size, uint16_t maxSize);
    bool writeNB(uint8_t endpoint, uint8_t * buffer, uint16_t size, uint16_t maxSize);

    
    /**
    * Called by USBDevice layer on bus reset. Warning: Called in ISR context
    *
    * May be used to reset state
    */
    virtual void USBCallback_busReset(void) {};
    
    /**
    * Called by USBDevice on Endpoint0 request. Warning: Called in ISR context
    * This is used to handle extensions to standard requests
    * and class specific requests
    *
    * @returns true if class handles this request
    */
    virtual bool USBCallback_request() { return false; };   
    
    /**
    * Called by USBDevice on Endpoint0 request completion
    * if the 'notify' flag has been set to true. Warning: Called in ISR context
    *
    * In this case it is used to indicate that a HID report has
    * been received from the host on endpoint 0
    */
    virtual void USBCallback_requestCompleted() {};
    
    /**
    * Called by USBDevice layer. Set configuration of the device.
    * For instance, you can add all endpoints that you need on this function.
    *
    * @param configuration Number of the configuration
    */
    virtual bool USBCallback_setConfiguration(uint8_t configuration) { return false; };

    /**
    * Get device descriptor. Warning: this method has to store the length of the report descriptor in reportLength.
    *
    * @returns pointer to the device descriptor
    */
    virtual uint8_t * deviceDesc();
    
    /**
    * Get configuration descriptor
    *
    * @returns pointer to the configuration descriptor
    */
    virtual uint8_t * configurationDesc(){return NULL;};
    
    /**
    * Get string lang id descriptor
    *
    * @return pointer to the string lang id descriptor
    */
    virtual uint8_t * stringLangidDesc();
    
    /**
    * Get string manufacturer descriptor
    *
    * @returns pointer to the string manufacturer descriptor
    */
    virtual uint8_t * stringImanufacturerDesc();
    
    /**
    * Get string product descriptor
    *
    * @returns pointer to the string product descriptor
    */
    virtual uint8_t * stringIproductDesc();
    
    /**
    * Get string serial descriptor
    *
    * @returns pointer to the string serial descriptor
    */
    virtual uint8_t * stringIserialDesc();
    
    /**
    * Get string configuration descriptor
    *
    * @returns pointer to the string configuration descriptor
    */
    virtual uint8_t * stringIConfigurationDesc();
    
    /**
    * Get string interface descriptor
    *
    * @returns pointer to the string interface descriptor
    */
    virtual uint8_t * stringIinterfaceDesc();
    
    /**
    * Get the length of the report descriptor
    *
    * @returns length of the report descriptor
    */
    virtual uint16_t reportDescLength() { return 0; };
    


protected:
    virtual void busReset(void);
    virtual void EP0setupCallback(void);
    virtual void EP0out(void);
    virtual void EP0in(void);
    virtual void SOF(int frameNumber);
    virtual void connectStateChanged(unsigned int connected);
    virtual void suspendStateChanged(unsigned int suspended);
    uint8_t * findDescriptor(uint8_t descriptorType);
    CONTROL_TRANSFER * getTransferPtr(void);
    
    uint16_t VENDOR_ID;
    uint16_t PRODUCT_ID;
    uint16_t PRODUCT_RELEASE;

private:
    bool addRateFeedbackEndpoint(uint8_t endpoint, uint32_t maxPacket);
    bool requestGetDescriptor(void);
    bool controlOut(void);
    bool controlIn(void);
    bool requestSetAddress(void);
    bool requestSetConfiguration(void);
    bool requestSetFeature(void);
    bool requestClearFeature(void);
    bool requestGetStatus(void);
    bool requestSetup(void);
    bool controlSetup(void);
    void decodeSetupPacket(uint8_t *data, SETUP_PACKET *packet);
    bool requestGetConfiguration(void);
    bool requestGetInterface(void);
    bool requestSetInterface(void);

    CONTROL_TRANSFER transfer;
    USB_DEVICE device;
};


#endif