int main(void) { // init fifos fifo_init (toRS232FIFO, toRS232Buf, 100); fifo_init (toUSBFIFO, toUSBBuf, 100); USBNCallbackFIFORX1(&FromPC); //USBNCallbackFIFOTX2Ready(&USBtoRS232); sei(); // activate global interrupts UARTInit(); // only for debugging // setup usbstack with your descriptors USBNInit(usbrs232,usbrs232Conf); _USBNAddStringDescriptor(""); //pseudo lang _USBNAddStringDescriptor("Microchip Technology Inc."); //_USBNAddStringDescriptor("abcdefgh"); _USBNAddStringDescriptor("PICkit 2 Microcontroller Programmer "); //_USBNAddStringDescriptor("PICkit 2 Microcontroller Programmer"); //_USBNAddStringDescriptor("ijklmnop"); _USBNAddStringDescriptor("PIC18F2550"); //_USBNAddStringDescriptor("12345678"); _USBNCreateStringField(); USBNInitMC(); // start usb controller USBNStart(); // start device stack while(1); }
int main(void) { int conf, interf; UARTInit(); USBNInit(); // setup your usbn device USBNDeviceVendorID(0x0400); USBNDeviceProductID(0x9876); USBNDeviceBCDDevice(0x0201); char lang[]={0x09,0x04}; _USBNAddStringDescriptor(lang); // language descriptor USBNDeviceManufacture ("vScopeTeam"); USBNDeviceProduct ("vScopeDevice"); USBNDeviceSerialNumber("2006-04-05"); conf = USBNAddConfiguration(); //USBNConfigurationName(conf,"StandardKonfiguration"); USBNConfigurationPower(conf,50); interf = USBNAddInterface(conf,0); USBNAlternateSetting(conf,interf,0); //USBNInterfaceName(conf,interf,"usbstorage"); USBNAddOutEndpoint(conf,interf,1,0x02,BULK,64,0,&SetGetPort); USBNAddInEndpoint(conf,interf,1,0x03,BULK,64,0); /* conf = USBNAddConfiguration(); interf = USBNAddInterface(conf,0); USBNAlternateSetting(conf,interf,1); USBNAddInEndpoint(conf,interf,1,0x02,BULK,64); USBNAddInEndpoint(conf,interf,2,0x03,BULK,8); USBNAddInEndpoint(conf,interf,3,0x04,BULK,64); */ MCUCR |= (1 << ISC01); // fallende flanke GICR |= (1 << INT0); sei(); USBNInitMC(); // start usb chip USBNStart(); DDRB=0xff; PORTB=0x00; while(1); }
int main(void) { int conf, interf; //UARTInit(); USBNInit(); usbprog.long_running=0; DDRA = (1 << PA4); // status led DDRA = (1 << PA7); // switch pin // setup your usbn device USBNDeviceVendorID(0x1786); USBNDeviceProductID(0x0c62); USBNDeviceBCDDevice(0x0007); char lang[]={0x09,0x04}; _USBNAddStringDescriptor(lang); // language descriptor USBNDeviceManufacture ("EmbeddedProjects"); USBNDeviceProduct ("usbprogSkeleton "); conf = USBNAddConfiguration(); USBNConfigurationPower(conf,50); interf = USBNAddInterface(conf,0); USBNAlternateSetting(conf,interf,0); USBNAddInEndpoint(conf,interf,1,0x02,BULK,64,0,&CommandAnswerRest); USBNAddOutEndpoint(conf,interf,1,0x02,BULK,64,0,&Commands); USBNInitMC(); sei(); USBNStart(); //LED_on; int i; for(i=0;i<320;i++) answer[i]=i+2; PORTA &= ~(1<<PA7); //CommandAnswer(320); while(1){ //PORTA |= (1<<PA7); //PORTA &= ~(1<<PA7); } }
int main(void) { int conf, interf; UARTInit(); USBNInit(); DDRA = (1 << DDA4); //PORTA |= (1<<PA4); //on PORTA &= ~(1<<PA4); //off USBNDeviceVendorID(0x1781); //atmel ids USBNDeviceProductID(0x0c62); // atmel ids USBNDeviceBCDDevice(0x0001); char lang[]={0x09,0x04}; _USBNAddStringDescriptor(lang); // language descriptor USBNDeviceManufacture ("B.Sauter"); USBNDeviceProduct ("LEDBLINK"); //0000A0016461 (aktuelle) //0000A0019647 //0000A0000252 conf = USBNAddConfiguration(); USBNConfigurationPower(conf,50); interf = USBNAddInterface(conf,0); USBNAlternateSetting(conf,interf,0); USBNAddInEndpoint(conf,interf,1,0x02,BULK,64,0,NULL); USBNAddOutEndpoint(conf,interf,1,0x02,BULK,64,0,&USBFlash); USBNInitMC(); // start usb chip USBNStart(); sei(); wait_ms(1000); while(1){ PORTA &= ~(1<<PA4); //off wait_ms(100); PORTA |= (1<<PA4); //on wait_ms(100); } }
int main(void) { int conf, interf; UARTInit(); USBNInit(); // setup your usbn device USBNDeviceVendorID(0x0400); USBNDeviceProductID(0x9876); USBNDeviceBCDDevice(0x0201); char lang[]={0x09,0x04}; _USBNAddStringDescriptor(lang); // language descriptor USBNDeviceManufacture ("B.Sauter"); USBNDeviceProduct ("usbflash"); USBNDeviceSerialNumber("2006-04-12"); conf = USBNAddConfiguration(); //USBNConfigurationName(conf,"StandardKonfiguration"); USBNConfigurationPower(conf,50); interf = USBNAddInterface(conf,0); USBNAlternateSetting(conf,interf,0); //USBNInterfaceName(conf,interf,"usbstorage"); USBNAddOutEndpoint(conf,interf,1,0x02,BULK,64,0,&USBFlash); USBNAddInEndpoint(conf,interf,1,0x03,BULK,64,0,NULL); MCUCR |= (1 << ISC01); // fallende flanke GICR |= (1 << INT0); sei(); USBNInitMC(); // start usb chip USBNStart(); while(1); }
int main(void) { usbprog.datatogl = 0; // 1MHz // init fifos // fifo_init (toRS232FIFO, toRS232Buf, 100); // fifo_init (toUSBFIFO, toUSBBuf, 100); USBNCallbackFIFORX1(&USBtoRS232); //USBNCallbackFIFOTX2Ready(&USBtoRS232); sei(); // activate global interrupts // UARTInit(); // only for debugging // setup usbstack with your descriptors USBNInit(usbrs232,usbrs232Conf); USBNInitMC(); // start usb controller USBNStart(); // start device stack // sendUSBString("Hello World!"); while(1){ #if 0 // wenn cpu zeit vorhanden fifos weiterverteilen // usb -> rs232 // rs232 -> usb if( USBBuf_i>2){ USBNWrite(TXC2,FLUSH); USBNWrite(TXD2,toUSBBuf[0]); USBNWrite(TXD2,toUSBBuf[1]); //USBNWrite(TXD2,0x46); //send_toggle(); rs232_send(); USBBuf_i=0; } _delay_ms(1); #endif } }
int main(void) { int conf, interf; UARTInit(); USBNInit(); // setup your usbn device USBNDeviceVendorID(0x0400); USBNDeviceProductID(0x0000); USBNDeviceBCDDevice(0x0000); char lang[]={0x09,0x04}; _USBNAddStringDescriptor(lang); // language descriptor USBNDeviceManufacture ("FH Augsburg"); USBNDeviceProduct ("vScope"); USBNDeviceSerialNumber("www.vscope.de"); conf = USBNAddConfiguration(); USBNConfigurationPower(conf,50); interf = USBNAddInterface(conf,0); USBNAlternateSetting(conf,interf,0); USBNAddOutEndpoint(conf,interf,1,0x02,BULK,64,0,&ParseCommand); USBNAddInEndpoint(conf,interf,1,0x03,BULK,64,0,&TransferISR); USBNInitMC(); // start usb chip USBNStart(); //UARTWrite("waiting for enumaration signal...\r\n"); while(1) { /* send new messages if some available */ } }
int main(void) { int conf, interf; /* set PE as output and to low, other pins to high-Z */ JTAG_PORT_INIT = (1 << PE); JTAG_PORT_WRITE = 0; USBNInit(); usbprog.datatogl = 0; USBNDeviceVendorID(VID); USBNDeviceProductID(PID); USBNDeviceBCDDevice(0x0200); char lang[]={0x09,0x04}; _USBNAddStringDescriptor(lang); // language descriptor USBNDeviceManufacture ("USBprog EmbeddedProjects"); USBNDeviceProduct("usbprogXSVF Xilinx Programmer"); //USBNDeviceSerialNumber("GNU/GPL2"); conf = USBNAddConfiguration(); USBNConfigurationPower(conf,50); interf = USBNAddInterface(conf,0); USBNAlternateSetting(conf,interf,0); USBNAddInEndpoint(conf,interf,1,0x02,BULK,64,0,NULL); USBNAddOutEndpoint(conf,interf,1,0x03,BULK,64,0,&Commands); USBNInitMC(); // start usb chip USBNStart(); sei(); while(1); }
int main(void) { int conf, interf; USBNInit(); usbprog.datatogl = 0; // 1MHz //DDRA = (1 << PA4); USBNDeviceVendorID(0x1781); //atmel ids USBNDeviceProductID(0x0c62); // atmel ids USBNDeviceBCDDevice(0x0200); char lang[]={0x09,0x04}; _USBNAddStringDescriptor(lang); // language descriptor USBNDeviceManufacture("B.Sauter"); USBNDeviceProduct("USB JTAG Interface"); USBNDeviceSerialNumber("GNU/GPL2"); conf = USBNAddConfiguration(); USBNConfigurationPower(conf,50); interf = USBNAddInterface(conf,0); USBNAlternateSetting(conf,interf,0); USBNAddInEndpoint(conf,interf,1,0x02,BULK,64,0,NULL); USBNAddOutEndpoint(conf,interf,1,0x03,BULK,64,0,&Commands); USBNInitMC(); sei(); // start usb chip USBNStart(); while(1); }
int main(void) { // init fifos fifo_init (toRS232FIFO, toRS232Buf, 100); fifo_init (toUSBFIFO, toUSBBuf, 100); USBNCallbackFIFORX1(&USBtoRS232); //USBNCallbackFIFOTX2Ready(&USBtoRS232); sei(); // activate global interrupts UARTInit(); // only for debugging // setup usbstack with your descriptors USBNInit(usbrs232,usbrs232Conf); _USBNAddStringDescriptor(""); //pseudo lang _USBNAddStringDescriptor("FTDI"); _USBNAddStringDescriptor("Dual RS232"); _USBNCreateStringField(); USBNInitMC(); // start usb controller USBNStart(); // start device stack while(1){ #if 0 // wenn cpu zeit vorhanden fifos weiterverteilen // usb -> rs232 // rs232 -> usb USBNWrite(TXC1,FLUSH); USBNWrite(TXD1,0x44); send_toggle(); wait_ms(100); #endif } }
//this is only my debug tool void Terminal(char cmd) { char h,l; unsigned char tmp; int i; struct list_entry *ptr; char *values; switch(cmd) { case 'i': USBNStart(); break; // write to usb register case 'w': //UARTWrite("write to USB reg:"); //USBNDEBUGPRINT("write to USB reg:"); h = UARTGetChar(); l = UARTGetChar(); SendHex(AsciiToHex(h,l)); tmp = AsciiToHex(h,l); UARTWrite("value:"); h = UARTGetChar(); l = UARTGetChar(); SendHex(AsciiToHex(h,l)); //USBNWrite(tmp,AsciiToHex(h,l)); UARTWrite("result:"); SendHex(USBNRead(tmp)); UARTWrite("\r\n"); break; // read from usb register case 'r': UARTWrite("read USB reg:"); h = UARTGetChar(); l = UARTGetChar(); SendHex(AsciiToHex(h,l)); UARTWrite("->"); SendHex(USBNRead(AsciiToHex(h,l))); UARTWrite("\r\n"); break; case 'h': UARTWrite("i usbn init procedure\r\n"); UARTWrite("w write USBN Register <h,l>(address) <h,l> (value) e.g 05 00\r\n"); UARTWrite("r read USBN Register <h,l> e.g. 02 ( RID)\r\n"); UARTWrite("s show all USBN Registers\r\n"); UARTWrite("b send test data from func to host\r\n"); UARTWrite("d show descriptors\r\n"); break; // show all registers case 's': for(i=0;i<=63;i++) { SendHex(i); UARTWrite("->"); SendHex(USBNRead(i)); UARTWrite("\r\n"); } break; case 'd': USBNDebug("\r\nDescriptor List\r\n"); ptr = DescriptorList; while(ptr != NULL) { values = (char*)ptr->data; SendHex(ptr->type); SendHex(ptr->len); SendHex(ptr->conf); SendHex(ptr->interf); USBNDebug(" "); for(i=0;i<ptr->len;i++) SendHex(values[i]); USBNDebug("\r\n"); ptr=ptr->next; } break; case 'b': UARTWrite("send test data from fifo1\r\n"); int j,i; char stat; USBNWrite(TXC1,FLUSH); USBNWrite(TXD1,0x01); for(j=0;j<63;j++) USBNBurstWrite((unsigned char)j); USBNWrite(TXC1,TX_LAST+TX_EN); //USBNWrite(TXC1,TX_LAST+TX_EN+TX_TOGL); break; case 'p': USBNWrite(TXC1,TX_LAST+TX_EN); break; default: UARTWrite("unknown command\r\n"); } }