void ADCSetFreeRunning(BOOL freeRun) { if (freeRun) { SETPIN(ADCSRA, ADATE); ADCSRB &= ~(1 << ADTS2) & ~(1 << ADTS1) & ~(1 << ADTS0); } else { CLEARPIN(ADCSRA, ADATE); } }
/* central command parser */ void Commands(char *buf) { //usbprog.datatogl = 1; // 1MHz int i; switch(buf[0]) { case PORT_DIRECTION: set_direction((uint8_t)buf[1]); //answer[0] = PORT_DIRECTION; //answer[1] = 0x00; //CommandAnswer(2); break; case PORT_SET: set_port((uint8_t)buf[1]); //answer[0] = PORT_SET; //answer[1] = 0x00; //CommandAnswer(2); break; case PORT_GET: answer[0] = PORT_GET; answer[1] = get_port(); CommandAnswer(2); break; case PORT_SETPIN: set_bit((uint8_t)buf[1],(uint8_t)buf[2]); //answer[0] = PORT_SETPIN; //answer[1] = 0x00; //CommandAnswer(2); break; case PORT_GETBIT: answer[0] = PORT_GETBIT; answer[1] = (char)get_bit((uint8_t)buf[1]); CommandAnswer(2); break; case WRITE_TDI: write_tdi(buf,((uint8_t)buf[1]*256)+(uint8_t)buf[2]); // size = numbers of byte not bits!!! round up #if 1 // tck 0 tms 0 tdi 0 CLEARPIN(PIN_WRITE,TCK); // clk CLEARPIN(PIN_WRITE,TDI); // tdi CLEARPIN(PIN_WRITE,TMS); // tms // tck 1 tms 0 tdi 0 SETPIN(PIN_WRITE,TCK); // clk #endif //answer[0] = WRITE_TDI; //answer[1] = 0x00; //CommandAnswer(2); break; case WRITE_TMS: write_tms((uint8_t)buf[1]); //answer[0] = WRITE_TDI; //answer[1] = 0x00; //CommandAnswer(2); break; case READ_TDO: read_tdo(buf,((uint8_t)buf[1]*256)+(uint8_t)buf[2]); // size = numbers of byte not bits!!! round up #if 1 // tck 0 tms 0 tdi 0 CLEARPIN(PIN_WRITE,TCK); // clk CLEARPIN(PIN_WRITE,TDI); // tdi CLEARPIN(PIN_WRITE,TMS); // tms // tck 1 tms 0 tdi 0 SETPIN(PIN_WRITE,TCK); // clk #endif for(i=0;i<64;i++) answer[i]=buf[i]; CommandAnswer(64); break; case WRITE_AND_READ: write_and_read(buf,((uint8_t)buf[1]*256)+(uint8_t)buf[2]); // size = numbers of byte not bits!!! round up #if 0 // tck 0 tms 0 tdi 0 CLEARPIN(PIN_WRITE,TCK); // clk CLEARPIN(PIN_WRITE,TDI); // tdi CLEARPIN(PIN_WRITE,TMS); // tms // tck 1 tms 0 tdi 0 SETPIN(PIN_WRITE,TCK); // clk #endif for(i=0;i<64;i++) answer[i]=buf[i]; CommandAnswer(64); break; case INIT_JTAG: set_direction(0xf4); break; case TAP_RESET: break; case TAP_SHIFT: tap_shift(buf,(uint8_t)buf[1]); for(i=0;i<64;i++) answer[i]=buf[i]; CommandAnswer(64); break; case TAP_SHIFT_FINAL: tap_shift_final(buf,(uint8_t)buf[1]); for(i=0;i<64;i++) answer[i]=buf[i]; CommandAnswer(64); break; case TAP_CAPTURE_DR: break; case TAP_CAPTURE_IR: break; default: // unkown command answer[0] = UNKOWN_COMMAND; answer[1] = 0x00; CommandAnswer(2); } }
void ADCDisableInterrupt(void) { CLEARPIN(ADCSRA, ADIE); }
void ADCDisable(void) { CLEARPIN(ADCSRA, ADEN); }