Guest User

Untitled

a guest
Nov 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.25 KB | None | 0 0
  1. /** Main program entry point. This routine contains the overall program flow, including initial
  2.  *  setup of all components and the main program loop.
  3.  */
  4. int main(void)
  5. {
  6.     SetupHardware();
  7.  
  8.     /* Create a regular blocking character stream for the interface so that it can be used with the stdio.h functions */
  9.     CDC_Device_CreateBlockingStream(&VirtualSerial_CDC_Interface, &USBSerialStream);
  10.  
  11.     sei();
  12.  
  13.  
  14.  
  15.     DDRB = 0; //input
  16.     DDRD = 0; //input
  17.     PORTB = 0xFF; //on
  18.     PORTD = 0;    //off
  19.  
  20.  
  21.     for (;;)
  22.     {
  23.         while(fgetc(&USBSerialStream) != 'x');  //wait for x
  24.  
  25.         DDRB = gethex();
  26.         DDRD = gethex();
  27.  
  28.         CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
  29.         USB_USBTask();
  30.     }
  31.  
  32.  
  33.  
  34. /* V1
  35.     DDRB = 0xFF; //output
  36.     DDRD = 0xFF;
  37.     PORTB = 0; //off
  38.     PORTD = 0;
  39.  
  40.  
  41.     for (;;)
  42.     {
  43.         while(fgetc(&USBSerialStream) != 'x');  //wait for x
  44.  
  45.         PORTB = gethex();
  46.         PORTD = gethex();
  47.  
  48.         CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
  49.         USB_USBTask();
  50.     }*/
  51.  
  52. /*
  53.     //OLD code
  54.     for (;;)
  55.     {
  56.         switch(fgetc(&USBSerialStream)) {
  57.         case 'a': PORTD |= (1<<2); break;
  58.         case 'b': PORTD &= ~(1<<2); break;
  59.         case 'c': PORTD |= (1<<3);  break;
  60.         case 'd': PORTD &= ~(1<<3);  break;
  61.         }
  62.         CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
  63.         USB_USBTask();
  64.     }*/
  65. }
Add Comment
Please, Sign In to add comment