![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
IVSC Project
main.cpp@1:82f2ef52759e, 2012-11-14 (annotated)
- Committer:
- kevinkent
- Date:
- Wed Nov 14 20:01:50 2012 +0000
- Revision:
- 1:82f2ef52759e
- Parent:
- 0:960d250e49b2
- Child:
- 2:d0778c36d28d
Added DAC support
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kevinkent | 0:960d250e49b2 | 1 | #include "mbed.h" |
kevinkent | 1:82f2ef52759e | 2 | #include "USBHID.h" |
kevinkent | 1:82f2ef52759e | 3 | #include "DigiPot.h" |
kevinkent | 1:82f2ef52759e | 4 | #include "Max5250.h" |
kevinkent | 1:82f2ef52759e | 5 | #include "Relay.h" |
kevinkent | 0:960d250e49b2 | 6 | |
kevinkent | 1:82f2ef52759e | 7 | Serial pc(USBTX,USBRX); |
kevinkent | 1:82f2ef52759e | 8 | USBHID hid; |
kevinkent | 1:82f2ef52759e | 9 | HID_REPORT recv, xmit; |
kevinkent | 1:82f2ef52759e | 10 | BusOut leds(LED1,LED2,LED3,LED4); |
kevinkent | 1:82f2ef52759e | 11 | |
kevinkent | 1:82f2ef52759e | 12 | |
kevinkent | 1:82f2ef52759e | 13 | int main(void) { |
kevinkent | 1:82f2ef52759e | 14 | int msgtype; |
kevinkent | 1:82f2ef52759e | 15 | leds = 0xf; |
kevinkent | 1:82f2ef52759e | 16 | xmit.length=64; |
kevinkent | 1:82f2ef52759e | 17 | //Fill the report |
kevinkent | 1:82f2ef52759e | 18 | for (int i = 0; i < xmit.length; i++) |
kevinkent | 1:82f2ef52759e | 19 | xmit.data[i] = 0xa5; |
kevinkent | 0:960d250e49b2 | 20 | |
kevinkent | 1:82f2ef52759e | 21 | pc.printf("Resetting to Room Temp\n"); |
kevinkent | 1:82f2ef52759e | 22 | PotReset(); |
kevinkent | 1:82f2ef52759e | 23 | |
kevinkent | 1:82f2ef52759e | 24 | pc.printf("Hello from mbed\n"); |
kevinkent | 1:82f2ef52759e | 25 | |
kevinkent | 1:82f2ef52759e | 26 | DAC_Setup(); |
kevinkent | 1:82f2ef52759e | 27 | pc.printf("DAC Setup Complete\n"); |
kevinkent | 1:82f2ef52759e | 28 | |
kevinkent | 1:82f2ef52759e | 29 | pc.printf("Relays Resetting\n"); |
kevinkent | 1:82f2ef52759e | 30 | Def_Relay(); |
kevinkent | 1:82f2ef52759e | 31 | |
kevinkent | 1:82f2ef52759e | 32 | while (1) { |
kevinkent | 1:82f2ef52759e | 33 | hid.read(&recv); |
kevinkent | 1:82f2ef52759e | 34 | leds = recv.data[0]; |
kevinkent | 1:82f2ef52759e | 35 | msgtype = recv.data[0]; |
kevinkent | 1:82f2ef52759e | 36 | |
kevinkent | 1:82f2ef52759e | 37 | switch (msgtype) { |
kevinkent | 1:82f2ef52759e | 38 | case 0: |
kevinkent | 1:82f2ef52759e | 39 | case 1: |
kevinkent | 1:82f2ef52759e | 40 | case 2: |
kevinkent | 1:82f2ef52759e | 41 | break; |
kevinkent | 1:82f2ef52759e | 42 | case 3: |
kevinkent | 1:82f2ef52759e | 43 | pc.printf("Going to Resistor set\n"); |
kevinkent | 1:82f2ef52759e | 44 | SetResist(recv.data); |
kevinkent | 1:82f2ef52759e | 45 | case 4: |
kevinkent | 1:82f2ef52759e | 46 | pc.printf("Going to DAC set\n"); |
kevinkent | 1:82f2ef52759e | 47 | SetDAC(recv.data); |
kevinkent | 1:82f2ef52759e | 48 | break; |
kevinkent | 1:82f2ef52759e | 49 | case 5: |
kevinkent | 1:82f2ef52759e | 50 | pc.printf("Going to Relay set\n"); |
kevinkent | 1:82f2ef52759e | 51 | Set_Relay(recv.data); |
kevinkent | 1:82f2ef52759e | 52 | break; |
kevinkent | 1:82f2ef52759e | 53 | default: |
kevinkent | 1:82f2ef52759e | 54 | break; |
kevinkent | 1:82f2ef52759e | 55 | } //End switch |
kevinkent | 1:82f2ef52759e | 56 | |
kevinkent | 1:82f2ef52759e | 57 | hid.send(&xmit); |
kevinkent | 1:82f2ef52759e | 58 | } //End while |
kevinkent | 1:82f2ef52759e | 59 | } //End Main |
kevinkent | 1:82f2ef52759e | 60 |