void main(void) { WORD counter=0; SETCPUFREQ(CLK_12M); // enable timer 0 and timer 1 to be 16 bit counters TMOD = 0x11; // enable timer 2 to also be a 16 bit counter T2CON = 0; RCAP2L = 0; // reload values for t2 RCAP2H = 0; EA=1; // enable interrupts ENABLE_TIMER0(); ENABLE_TIMER1(); ENABLE_TIMER2(); TR0=1; // start t0 TR1=1; // start t1 TR2=1; // start t2 // and blink d5 while (TRUE) { ++counter; if (!counter) { d5 = !d5; if (d5) { d5off(); } else { d5on(); } } } }
void main(void) { SETCPUFREQ(CLK_48M); // if this image is loaded to as iic to // the eeprom // the C2 bit will turn this on // turn it back off so the device can // handle usb requests USBCS &= ~bmRENUM; EA=1; // enable interrupts sio0_init(57600); // timer 0 setup TL1=TH1=0; // start at 0 ET1=1; // timer 1 interrupts TR1=1; // start timer 1 d5off(); // end init while (1) { char r=getchar(); putchar(r); } }
void main_init() { REVCTL = bmNOAUTOARM | bmSKIPCOMMIT; SYNCDELAY; SETCPUFREQ(CLK_48M); SYNCDELAY; printf("main_init\r\n"); ep_init(); gpif_stuff_init(); fpga_init(); /* timer2 */ CKCON &= ~(1<<5); T2CON = (1<<2); /* run timer 2 in auto reload mode */ }
void main() { BOOL on=FALSE; unsigned int size=0; LED6 = 0; REVCTL=0; // not using advanced endpoint controls on=0; lcount=0; got_sud=FALSE; icount=0; gotbuf=FALSE; bytes=0; // renumerate RENUMERATE_UNCOND(); SETCPUFREQ(CLK_48M); sio0_init(57600); USE_USB_INTS(); ENABLE_SUDAV(); ENABLE_SOF(); ENABLE_HISPEED(); ENABLE_USBRESET(); // only valid endpoints are 2/6 EP2CFG = 0xA2; // 10100010 SYNCDELAY(); EP6CFG = 0xE2; // 11100010 SYNCDELAY(); EP1INCFG &= ~bmVALID; SYNCDELAY(); EP1OUTCFG &= ~bmVALID; SYNCDELAY(); EP4CFG &= ~bmVALID; SYNCDELAY(); EP8CFG &= ~bmVALID; SYNCDELAY(); // arm ep2 EP2BCL = 0x80; // write once SYNCDELAY(); EP2BCL = 0x80; // do it again EA=1; // global interrupt enable OEB |= 0x01; // set PB0 as output LED6 = 0; eeprom_write_local(LG_PROM, 0, IIC_SIZE, fx2_c0); while(TRUE) { if ( got_sud ) { printf ( "Handle setupdata\n" ); handle_setupdata(); got_sud=FALSE; } if ( !(EP2468STAT & bmEP2EMPTY) ) { // EP2 received data if ( !(EP2468STAT & bmEP6FULL) ) { // wait for at least one // empty buffer WORD i; bytes = MAKEWORD(EP2BCH,EP2BCL); for (i=0;i<bytes;++i) { EP6FIFOBUF[i] = 0x00; // arm ep6 out EP6BCH=MSB(bytes); SYNCDELAY(); EP6BCL=LSB(bytes); REARM(); // re-arm ep2 } } } //delay(40); if (LED6) {LED6 = 0;} else {LED6 =1;} } }
void main() { REVCTL=0; // not using advanced endpoint controls d2off(); on=0; lcount=0; got_sud=FALSE; icount=0; gotbuf=FALSE; bytes=0; // renumerate RENUMERATE_UNCOND(); SETCPUFREQ(CLK_48M); SETIF48MHZ(); sio0_init(57600); USE_USB_INTS(); ENABLE_SUDAV(); ENABLE_SOF(); ENABLE_HISPEED(); ENABLE_USBRESET(); // only valid endpoints are 2/6 EP2CFG = 0xA2; // 10100010 SYNCDELAY; EP6CFG = 0xE2; // 11100010 SYNCDELAY; EP1INCFG &= ~bmVALID; SYNCDELAY; EP1OUTCFG &= ~bmVALID; SYNCDELAY; EP4CFG &= ~bmVALID; SYNCDELAY; EP8CFG &= ~bmVALID; SYNCDELAY; // arm ep2 EP2BCL = 0x80; // write once SYNCDELAY; EP2BCL = 0x80; // do it again // make it so we enumberate EA=1; // global interrupt enable printf ( "Done initializing stuff\n" ); d3off(); while(TRUE) { if ( got_sud ) { printf ( "Handle setupdata\n" ); handle_setupdata(); got_sud=FALSE; } if ( !(EP2468STAT & bmEP2EMPTY) ) { printf ( "ep2 out received data\n" ); if ( !(EP2468STAT & bmEP6FULL) ) { // wait for at least one empty in buffer WORD i; printf ( "Sending data to ep6 in\n"); bytes = MAKEWORD(EP2BCH,EP2BCL); for (i=0;i<bytes;++i) EP6FIFOBUF[i] = EP2FIFOBUF[i]; // can copy whole string w/ autoptr instead. // or copy directly from one buf to another // ARM ep6 out EP6BCH=MSB(bytes); SYNCDELAY; EP6BCL=LSB(bytes); REARM(); // ep2 //printf ( "Re-Armed ep2\n" ); } } } }