Changeset - 61bd3e3de919
[Not reviewed]
default
0 1 0
mkanning@CL-SEC241-10.cedarville.edu - 12 years ago 2012-11-08 15:23:45
mkanning@CL-SEC241-10.cedarville.edu
a few updates for sd card handling
1 file changed with 13 insertions and 18 deletions:
0 comments (0 inline, 0 general)
master/master/lib/logger.c
Show inline comments
 
@@ -19,49 +19,46 @@
 
	//config edits
 
  * By changing the MCU* variables in the Makefile, you can use other Atmel
 
  * microcontrollers or different clock speeds. You might also want to change
 
  * the configuration defines in the files fat_config.h, partition_config.h,
 
  * sd_raw_config.h and sd-reader_config.h. For example, you could disable
 
  * write support completely if you only need read support.
 

	
 
 */
 
 
void logger_setup()
 
{
 
	while(1)
 
	{
 
		//check for sd exist/power/ready
 
		/* setup sd card slot */
 
		if(!sd_raw_init()) //sd_raw.c
 
		//check for SD exist/power/ready BEGIN
 
		/* setup SD card slot */
 
		if(!sd_raw_init()) //sd_raw.c this function may need an overhaul
 
		{
 
				#if DEBUG
 
		uart_puts_p(PSTR("MMC/SD initialization failed\n"));
 
			#endif
 
	#if DEBUG
 
			uart_puts_p(PSTR("MMC/SD initialization failed\n"));
 
	#endif
 
			continue;
 
		}
 
	
 
		//check for SD exist/power/ready END
 
	
 
		//create partition BEGIN
 
		/* open first partition */ 
 
		struct partition_struct* partition = partition_open(sd_raw_read,
 
															sd_raw_read_interval,
 
	#if SD_RAW_WRITE_SUPPORT //probably want this to be true ??
 
	//#if SD_RAW_WRITE_SUPPORT //probably want this to be true ??
 
															sd_raw_write,
 
															sd_raw_write_interval,
 
	#else
 
															0,
 
															0,
 
	#endif
 
	//#endif
 
															0
 
															);
 
		//check that partition was created correctly
 
		if(!partition)
 
		{
 
			/* If the partition did not open, assume the storage device
 
				* is a "superfloppy", i.e. has no MBR.
 
				*/
 
			//what is MBR ??
 
			partition = partition_open(sd_raw_read,
 
										sd_raw_read_interval,
 
	#if SD_RAW_WRITE_SUPPORT //probably want this to be true ??
 
										sd_raw_write,
 
										sd_raw_write_interval,
 
	#else
 
@@ -131,13 +128,14 @@ void logger_setup()
 
				
 
				fat_close_file(fd);
 
				continue;
 
			}
 

	
 
			/* read text from the shell and write it to the file */
 
			uint8_t data_len;
 
			uint8_t data_len = sizeof(buffer);
 
			
 
			while(1)
 
			{
 
				/* write text to file !! */
 
				if(fat_write_file(fd, (uint8_t*) buffer, data_len) != data_len)
 
				{
 
					//uart_puts_p(PSTR("error writing to file\n"));
 
@@ -157,20 +155,19 @@ void logger_setup()
 
		/* close file system */
 
		fat_close(fs); //fat.c
 

	
 
		/* close partition */
 
		partition_close(partition); //partition.c
 
		//prepare for closing SD connection END
 
 
	}
 
}	
 
 
//writes a single line to the SD card
 
uint8_t logger_writeLine(char* dateLine, uint8_t length)
 
{
 
	
 
	return length; //does not actually return length
 
}
 
 
//i think opens a file so it can be read/written
 
struct fat_file_struct* open_file_in_dir(struct fat_fs_struct* fs, struct fat_dir_struct* dd, const char* name)
 
{
 
	struct fat_dir_entry_struct file_entry;
 
@@ -191,8 +188,6 @@ uint8_t find_file_in_dir(struct fat_fs_s
 
			return 1;
 
		}
 
	}
 

	
 
	return 0;
 
}
 

	
 
//i think this initializes the SD for read and write ??
 
\ No newline at end of file
0 comments (0 inline, 0 general)