| Line 98... | Line 98... | 
      
        | 98 |   | 98 |   | 
      
        | 99 | unsigned int8 status = STATUS_IDLE; | 99 | unsigned int8 status = STATUS_IDLE; | 
      
        | 100 |   | 100 |   | 
      
        | 101 | void main() | 101 | void main() | 
      
        | 102 | { | 102 | { | 
      
        | 103 |   | - |  | 
      
        | - |  | 103 | unsigned int8 data[64]; | 
      
        | 104 | unsigned int8 replyBuf[4]; | 104 | unsigned int8 replyBuf[4]; | 
      
        | 105 | unsigned int8 i=0; | 105 | unsigned int8 i=0; | 
      
        | 106 |   | 106 |   | 
      
        | 107 |    setup_adc_ports(NO_ANALOGS|VSS_VDD); | 107 |    setup_adc_ports(NO_ANALOGS|VSS_VDD); | 
      
        | 108 |    setup_adc(ADC_CLOCK_DIV_2); | 108 |    setup_adc(ADC_CLOCK_DIV_2); | 
      
        | Line 119... | Line 119... | 
      
        | 119 |    printf("MLAB I2C to USB adapter started \n\r "); | 119 |    printf("MLAB I2C to USB adapter started \n\r "); | 
      
        | 120 |   | 120 |   | 
      
        | 121 |          output_high(PIN_B4); | 121 |          output_high(PIN_B4); | 
      
        | 122 |   | 122 |   | 
      
        | 123 |    usb_init(); | 123 |    usb_init(); | 
      
        | - |  | 124 |    usb_wait_for_enumeration();    | 
      
        | - |  | 125 |   | 
      
        | - |  | 126 |   | 
      
        | - |  | 127 |    printf("device enumerated \n\r "); | 
      
        | - |  | 128 |   | 
      
        | - |  | 129 | if(usb_tbe(0)) printf(" endpoint 0 ready \n\r "); | 
      
        | - |  | 130 | else printf(" endpoint 0 disabled \n\r "); | 
      
        | - |  | 131 | if(usb_tbe(1)) printf(" endpoint 1 ready \n\r "); | 
      
        | - |  | 132 | else printf(" endpoint 1 disabled \n\r "); | 
      
        | - |  | 133 | if(usb_tbe(2)) printf(" endpoint 2 ready \n\r "); | 
      
        | - |  | 134 | else printf(" endpoint 2 disabled \n\r "); | 
      
        | - |  | 135 |   | 
      
        | - |  | 136 | if(usb_puts(0,data,64,1000)) printf(" endpoint 0 inicialized \n\r "); | 
      
        | - |  | 137 | else printf("cannot write to endpoint 0 \n\r "); | 
      
        | 124 |   | 138 |   | 
      
        | 125 |    while (TRUE) { | 139 |    while (TRUE) { | 
      
        | 126 |       if (usb_enumerated())  | 140 |       if (usb_enumerated())  | 
      
        | 127 |       { | 141 |       { | 
      
        | 128 |   | 142 |   | 
      
        | Line 174... | Line 188... | 
      
        | 174 |          }*/ | 188 |          }*/ | 
      
        | 175 |   | 189 |   | 
      
        | 176 |          if(usb_kbhit(i)) | 190 |          if(usb_kbhit(i)) | 
      
        | 177 |          { | 191 |          { | 
      
        | 178 |            printf(" data received at endpoint %d \n\r ", i); | 192 |            printf(" data received at endpoint %d \n\r ", i); | 
      
        | - |  | 193 |            usb_gets(i,data,64,1000); | 
      
        | 179 |          } | 194 |          } | 
      
        | 180 |   | 195 |   | 
      
        | 181 |          delay_ms(10); | 196 |          delay_ms(10); | 
      
        | 182 |   | 197 |   | 
      
        | 183 |          output_high(PIN_B4); | 198 |          output_high(PIN_B4); | 
      
        | - |  | 199 |          if( i==1 )i=0; | 
      
        | 184 |          i++; | 200 |          else i=1; | 
      
        | 185 |       } | 201 |       } | 
      
        | 186 |    } | 202 |    } | 
      
        | 187 | } | 203 | } |