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.
main.cpp@0:3a7bf7f211f6, 2011-11-25 (annotated)
- Committer:
- romilly
- Date:
- Fri Nov 25 16:25:53 2011 +0000
- Revision:
- 0:3a7bf7f211f6
First very basic version of the logic analyser; the flashing LEDs are to reassure me that the program in running. They will go soon!
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
romilly | 0:3a7bf7f211f6 | 1 | #include "mbed.h" |
romilly | 0:3a7bf7f211f6 | 2 | #include "USBHID.h" |
romilly | 0:3a7bf7f211f6 | 3 | // Work in progress! Needs the beta version |
romilly | 0:3a7bf7f211f6 | 4 | |
romilly | 0:3a7bf7f211f6 | 5 | //We declare a USBHID device |
romilly | 0:3a7bf7f211f6 | 6 | USBHID hid; |
romilly | 0:3a7bf7f211f6 | 7 | |
romilly | 0:3a7bf7f211f6 | 8 | //This report will contain data to be sent |
romilly | 0:3a7bf7f211f6 | 9 | HID_REPORT send_report; |
romilly | 0:3a7bf7f211f6 | 10 | |
romilly | 0:3a7bf7f211f6 | 11 | // define port |
romilly | 0:3a7bf7f211f6 | 12 | BusIn port(p30, p29, p8, p7, p6, p5, p28, p27); // should be easy to convert to PortIn when available |
romilly | 0:3a7bf7f211f6 | 13 | DigitalOut led1(LED1); |
romilly | 0:3a7bf7f211f6 | 14 | DigitalOut led2(LED2); |
romilly | 0:3a7bf7f211f6 | 15 | DigitalOut led3(LED3); |
romilly | 0:3a7bf7f211f6 | 16 | DigitalOut led4(LED4); |
romilly | 0:3a7bf7f211f6 | 17 | |
romilly | 0:3a7bf7f211f6 | 18 | int main(void) { |
romilly | 0:3a7bf7f211f6 | 19 | //Fill the report |
romilly | 0:3a7bf7f211f6 | 20 | send_report.length = 64; |
romilly | 0:3a7bf7f211f6 | 21 | |
romilly | 0:3a7bf7f211f6 | 22 | while (1) { |
romilly | 0:3a7bf7f211f6 | 23 | //Send the report |
romilly | 0:3a7bf7f211f6 | 24 | send_report.data[0] = port; |
romilly | 0:3a7bf7f211f6 | 25 | hid.send(&send_report); |
romilly | 0:3a7bf7f211f6 | 26 | led1 = 0; |
romilly | 0:3a7bf7f211f6 | 27 | led2 = 0; |
romilly | 0:3a7bf7f211f6 | 28 | led3 = 0; |
romilly | 0:3a7bf7f211f6 | 29 | led4 = 0; |
romilly | 0:3a7bf7f211f6 | 30 | wait(0.1); |
romilly | 0:3a7bf7f211f6 | 31 | led1 = 1; |
romilly | 0:3a7bf7f211f6 | 32 | wait(0.1); |
romilly | 0:3a7bf7f211f6 | 33 | led2 = 1; |
romilly | 0:3a7bf7f211f6 | 34 | wait(0.1); |
romilly | 0:3a7bf7f211f6 | 35 | led3 = 1; |
romilly | 0:3a7bf7f211f6 | 36 | wait(0.1); |
romilly | 0:3a7bf7f211f6 | 37 | led4 = 1; |
romilly | 0:3a7bf7f211f6 | 38 | wait(0.1); |
romilly | 0:3a7bf7f211f6 | 39 | wait(1); |
romilly | 0:3a7bf7f211f6 | 40 | } |
romilly | 0:3a7bf7f211f6 | 41 | } |