示例#1
0
// Fetch and return the next char from input stream.
void fetchc(void) {
	// terrible horrible eeprom addressing kludge
	if (isram(fetchptr)) {
		if (*fetchptr) fetchptr++;
		inchar = *fetchptr;
	} 
	else {	// fetch char from eeprom
		int addr = dekludge(fetchptr);
		inchar = eeread(addr);
		if ((inchar != 0) && (inchar != 255)) {
			inchar = eeread(++addr);
			fetchptr = kludge(addr);		// save incremented pointer
			if (inchar == 255) inchar = 0;
		}
	}

#ifdef PARSER_TRACE
	// char trace
	if (trace) {
		//spb('['); printInteger(inchar);spb(':'); if (inchar) spb(inchar); spb(']');
		spb('[');
		if (inchar >= 0x20) spb(inchar);
		else { spb('\\'); printInteger(inchar); }
		spb(']');
	}
#endif

	//return inchar;
}
示例#2
0
void
read_config(void)
{
	byte i;
	for (i = 0; i < PH_NUM; i++) {
		sinus[i] = eeread(i);
	}
	ampl = eeread(AMPL_START);
	period = FREQ_MAX/eeread(FREQ_START);
	delay_step = eeread(DS_START);
	delay_num = eeread(DN_START);
}
示例#3
0
// return the address of the first unused space at or after addr
int findunoccupied(int addr) {
	while (addr < ENDDB) {
		if (eeread(addr) == EMPTY) return addr;
		addr++;
	}
	return FAIL;
}
示例#4
0
void cmd_peep(void) {
int i=0;

#ifdef AVROPENDOUS_BUILD
	usbMouseOff();
#endif

	while (i <= ENDEEPROM) {
		if (i%64 == 0) {speol(); printHex(i+0xe000); spb(':'); }
		if (i%8 == 0) spb(' ');
		if (i%4 == 0) spb(' ');		
		byte c = eeread(i) & 0xff;

		if (c == 0) spb('\\');
		else if ((c == 255) || (c < 0)) spb('.');
		else if (c < ' ') spb('^');
		else spb(c);
		i++;
	}
	speol();

#ifdef AVROPENDOUS_BUILD
	usbMouseOn();
#endif

}
示例#5
0
// Fetch a string from EEPROM at addr into buffer at str
void getString(int addr, char *str, int buflen) {
	while (--buflen) {
		byte c = eeread(addr++);
		if ((c == 0) || (c == 255)) break;
		*str++ = c;
	}
	*str = 0;
}
示例#6
0
void nukeeeprom(void) {
	initTaskList();		// stop any currently running background tasks
	int addr = STARTDB;
	while (addr <= ENDDB) {
		if (eeread(addr) != EMPTY) eewrite(addr, EMPTY);
		addr++;
	}
}
示例#7
0
// find the end of this occupied string slot.  returns location or ENDDB.
int findend(int addr) {
	while (++addr < ENDDB) {
		byte c = eeread(addr);
		if (c == EMPTY) return addr;	// return pointer to first empty byte
		if (!c) return (++addr);		// or first byte past terminator
	}
	return ENDDB;
}
示例#8
0
// erase string at addy.  return addy of byte past end.
int erasestr(int addr) {
	for (;;) {
		byte c = eeread(addr);
		if (c == EMPTY) return addr;
		eewrite(addr++, EMPTY);
		if (!c) return addr;
	}
}
void nukeeeprom(void) {
	initTaskList();		// stop any currently running background tasks
	int addr;
	
	for (addr = STARTDB; addr < ENDDB; addr++) {
	    if (eeread(addr) != EMPTY) {
	        eewrite(addr, EMPTY);
	    }
	}
}
示例#10
0
void IMU::loadCalib(){
  short magic = 0;
  int addr = ADDR;
  eeread(addr, magic);
  if (magic != MAGIC) {
    Console.println(F("IMU error: no calib data"));
    return;  
  }
  Console.println(F("IMU: found calib data"));
  loadSaveCalib(true);
}
示例#11
0
static int
eeload(Ctlr* ctlr)
{
	ushort sum;
	int data, adr;

	sum = 0;
	for (adr = 0; adr < 0x40; adr++) {
		data = eeread(ctlr, adr);
		ctlr->eeprom[adr] = data;
		sum += data;
	}
	return sum;
}
示例#12
0
// print eeprom string at addr
void eeputs(int addr) {
	for (;;) {
		byte c = eeread(addr++);
		if (!c || (c == EMPTY)) return;
		//else if (c == '"') { spb('\\'); spb('"'); }
		else if (c == '\\') { spb('\\'); spb('\\'); }
		else if (c == '\n') { spb('\\'); spb('n'); }
		else if (c == '\t') { spb('\\'); spb('t'); }
		else if (c == '\r') { spb('\\'); spb('r'); }
		else if ((c >= 0x80) || (c < ' ')) {
			spb('\\'); spb('x'); 
			if (c < 0x10) spb('0'); printHex(c);
		}
		else spb(c);
	}
}
示例#13
0
文件: isp861.c 项目: vasik041/openlab
void rdee()
{
int i;
	printf("\nconnecting...%s", ((i = penable()) == 1)? "Ok" : "Error");
	if(!i) {
		err = 1;
		return;
	}

	printf("\n");
	for(i=0; i < EESIZE; i++) {
		printf("\ree reading... %4x",i);
		buf[i] = eeread(i);
	}
	printf("\ree reading Ok     \n");
	err = 0;
}
示例#14
0
// Re-prime the lookahead character buffer 'inchar'
void primec(void) {
	// terrible horrible eeprom addressing kludge
	if (isram(fetchptr)) inchar = *fetchptr;
	else {
		inchar = eeread(dekludge(fetchptr));
		if (inchar == 255) inchar = 0;
	}

#ifdef PARSER_TRACE
		// char trace
		if (trace) {
			spb('<'); 
			if (inchar >= 0x20) spb(inchar);
			else { spb('\\'); printInteger(inchar); }
			spb('>');
		}
#endif
}
示例#15
0
void cmd_peep(void) {
int i=0;

	while (i <= ENDEEPROM) {
		if (!(i&63)) {speol(); printHex(i+0xe000); spb(':'); }
		if (!(i&7)) spb(' ');
		if (!(i&3)) spb(' ');		
		byte c = eeread(i) & 0xff;

		if (c == 0) spb('\\');
		//else if ((c == 255) || (c < 0)) spb('.');
		else if (c == 255) spb('.');
		else if (c < ' ') spb('^');
		else spb(c);
		i++;
	}
	speol();
}
示例#16
0
unsigned char eeReadByte(unsigned long wAddr)
{
	char RetVal;

	eestart();
	eewrite(BP_EEPROM_ID_W);
	eewrite((wAddr >> 8));		//Sent write Address high bits first
	eewrite(wAddr);				//Send write address low bits section

	eestart();
	eewrite(BP_EEPROM_ID_R);

	RetVal = eeread();			//Write the single bit.
	
	eesendack(1);				//send nak?
	eestop();

	return RetVal;
}
示例#17
0
文件: isp861.c 项目: vasik041/openlab
void wree()
{
int i,e;
	printf("\nconnecting...%s", ((i = penable()) == 1) ? "Ok" : "Error");
	if(!i) {
		err = 1;
		return;
	}
	err = 0;
	printf("\n");
	for(i=0; i < sz; i++) {
		printf("\ree writing ... %4x",i);
		eewrite(i,buf[i]);
		delay(50);
		if((e = eeread(i)) != buf[i]) {
			printf("\nerror at %x ee %x buf %x\n",i,e & 0xff,buf[i] & 0xff);
			err = 1;
		}
		if(err) break;
	}
	if(!err) printf("\ree writing Ok      \n");
}
示例#18
0
/////////
//
//	primec(): 
//		fetch the current character from the input stream
//		set inchar to the character or zero on EOF
//
void primec(void) {
	switch (fetchtype) {
		case SCRIPT_RAM:		inchar = *(char *) fetchptr;		break;
		case SCRIPT_PROGMEM:	inchar = pgm_read_byte(fetchptr); 	break;
		case SCRIPT_EEPROM:		inchar = eeread((int) fetchptr);	break;

#if defined(SDFILE)
		case SCRIPT_FILE:		inchar = scriptread();				break;
#endif

		default:				unexpected(M_oops);
	}

#ifdef PARSER_TRACE
	if (trace) {
		spb('<'); 
		if (inchar >= 0x20) spb(inchar);
		else { spb('\\'); printInteger(inchar); }
		spb('>');
	}
#endif

}
void ReadConfigurations(){
	 eeread(0, Arduino);
}
示例#20
0
// return true if string in EEPROM at addr matches string at str
char eestrmatch(int addr, char *str) {
	while (*str) if (eeread(addr++) != *str++) return 0;
	if (eeread(addr) == 0) return 1;	// ended at the same place?
	return 0;
}
示例#21
0
int main(void)
{
	int cnt;
	setup_ports();
	read_config();
	setup_timer();
	setup_control();
	PORTC = DISABLED;
	setup_uart(9600UL);
	flags = eeread(FLAGS_START);
	ph_u = 0;
	ph_v = 24;
	ph_w = 12;
	pwm_u = 0;
	pwm_v = 0;
	pwm_w = 0;

	sei();
	cnt = 0;
	while (1) {
		register byte i;
		if ((flags & FLAG_POT) && cnt == 0)
			read_speed();
		cnt++;
		cnt &= 0x3F;
		
		if (flags & FLAG_GO) {
			int8_t cnt_u, cnt_v, cnt_w;
			int u_u, u_v, u_w;
			/* Disable all phases */
			PORTC &= ~((1 << EU) | (1 << EV) | (1 << EW));

			/* Wait to turn mosfets off */
			_delay_loop_2(delay_num * delay_step);

			/* Switch all bridges to HIGH */
			PORTC |= ((1<<UU) | (1<<UV) | (1<<UW));

			/* Enable all phases */
			PORTC |= ((1<<EU) | (1<<EV) | (1<<EW));
			//_delay_loop_2(50);

			cnt_u = cnt_v = cnt_w = -1;
			u_u = u_v = u_w = 1;
			for (i = 0; i < MAX_PWM; i++) {
				if (i == pwm_u || (i > pwm_u && u_u)) {
					CLRBIT(PORTC, EU); // DISABLE U
					u_u = 0;
					cnt_u = delay_num;
				}
				if (i == pwm_v || (i > pwm_v && u_v)) {
					CLRBIT(PORTC, EV); // DISABLE V
					u_v = 0;
					cnt_v = delay_num;
				}
				if (i == pwm_w  || (i > pwm_w && u_w)) {
					CLRBIT(PORTC, EW); // DISABLE W
					u_w = 0;
					cnt_w = delay_num;
				}
				_delay_loop_2(delay_step);
				if (cnt_u == 0) {
					CLRBIT(PORTC, UU);  // Set U to LOW
					PORTC |= (1<<EU);
					cnt_u = -1;
				}
				if (cnt_v == 0) {
					CLRBIT(PORTC, UV);  // Set V to LOW
					PORTC |= (1<<EV);
					cnt_v = -1;
				}
				if (cnt_w == 0) {
					CLRBIT(PORTC, UW);  // Set W to LOW
					PORTC |= (1<<EW);
					cnt_w = -1;
				}
				if (cnt_u > 0)
					cnt_u--;
				if (cnt_v > 0)
					cnt_v--;
				if (cnt_w > 0)
					cnt_w--;
			}
		} else {
			PORTC = DISABLED;
			_delay_loop_1(250);
		}
	}
	return 0;
}