The front end of a simple logic analyzer, which will capture a set of input values and send them over the USB HID interface to a PC for analysis and display.

Dependencies:  

main.cpp

Committer:
romilly
Date:
2011-11-25
Revision:
0:3a7bf7f211f6

File content as of revision 0:3a7bf7f211f6:

#include "mbed.h"
#include "USBHID.h"
// Work in progress! Needs the beta version

//We declare a USBHID device
USBHID hid;

//This report will contain data to be sent
HID_REPORT send_report;

// define port
BusIn     port(p30, p29, p8, p7, p6, p5, p28, p27);   // should be easy to convert to PortIn when available
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);

int main(void) {
    //Fill the report
    send_report.length = 64;
    
    while (1) {
        //Send the report
        send_report.data[0] = port;
        hid.send(&send_report);
        led1 = 0;
        led2 = 0;
        led3 = 0;
        led4 = 0;
        wait(0.1);
        led1 = 1;
        wait(0.1);
        led2 = 1;
        wait(0.1);
        led3 = 1;
        wait(0.1);
        led4 = 1;
        wait(0.1);
        wait(1);
    }
}