예제 #1
0
void log_init(void) {
	fprintf(stream_wireless,"# initializing logging\r\n");
	lcd_clear();
	printf(lcd_putch,"Resetting Log!");
	delay_ms(1200);
	write_ext_fram(FRAM_ADDR_RECORD_N,0);
	write_ext_fram(FRAM_ADDR_DATAFLASH_PAGE+0,0);
	write_ext_fram(FRAM_ADDR_DATAFLASH_PAGE+1,0);

	/* erase the first block of the data flash */
	dataflash_select();
	spi_write2(0x50);
	spi_write2(0x00);
	spi_write2(0x00);
	spi_write2(0x00); 
	dataflash_unselect();
	delay_ms(10);
	
	/* wait for page to finish erasing and writing */
	while ( ! bit_test(dataflash_read_status(),7) ) {
		restart_wdt();
		//fputc('x',modem);
	}

	lcd_goto(LCD_LINE_TWO);
	printf(lcd_putch,"Done");
	fprintf(stream_wireless,"> done\r\n");
	delay_ms(1200);
}
예제 #2
0
static int pfsdf_read(polyfs_fs_t *fs, void *ptr,
	uint32_t offset, uint32_t bytes)
{
	struct pfsdf_info *iptr = fs->userptr;
	int err;
	uint8_t sreg;

	// Check the inputs are in range
	if (offset >= iptr->bytes) {
		return -1;
	}
	else if (bytes == 0) {
		return 0;
	}
	else if (offset + bytes >= iptr->bytes) {
		bytes = iptr->bytes - offset;
	}

	// Make sure the flash is ready
	err = dataflash_read_status(&sreg);
	if ((err) || (sreg & DATAFLASH_SREG_BUSY)) {
		return -1;
	}

	// Read the dataflash
	return dataflash_read_data(ptr, iptr->offset + offset, bytes);
}