예제 #1
0
signed char FAT_get_BS_data(void)
{
  signed char resp;
  struct MBR_struct *mbr;
  uint32_t firstSec=0,uliTemp;
  char buf[16];

  resp=sd_readSector(0,SD_SECSIZE); 
  if(resp==-1)
    return resp;
  
  if(sd_buf[0]!=0xE9 && sd_buf[0]!=0xEB)
  {
    if(sd_buf[510]==0x55 && sd_buf[511]==0xAA)
    {
      mbr=(struct MBR_struct *)sd_buf;   
      firstSec=(mbr->partitionData[11]<<24)|(mbr->partitionData[10]<<16)|(mbr->partitionData[9]<<8)|(mbr->partitionData[8]);
      resp=sd_readSector(firstSec,SD_SECSIZE);
    }
    else
      return -1;				//NOT BS nor MBR
  }

  if(sd_buf[0x52+3]=='3')
  {
    FATType=FAT32;
    usart1_puts("\n\rVOLUME Label: ");
    for(resp=0;resp<11;resp++)
      usart1_putch(sd_buf[0x47+resp]);

    usart1_puts("\n\rFAT Type:");
    for(resp=0;resp<8;resp++)
      usart1_putch(sd_buf[0x52+resp]);

    F32_getParameters(sd_buf,firstSec);
  }
  else
  {
    FATType=FAT16;    
    usart1_puts("\n\rVOLUME Label: ");
    for(resp=0;resp<11;resp++)
      usart1_putch(sd_buf[0x2b+resp]);

    usart1_puts("\n\rFAT Type:");
    for(resp=0;resp<8;resp++)
      usart1_putch(sd_buf[0x36+resp]);
    //F16_getParameters(sd_buf);
  }

  return 0;
}
예제 #2
0
void writeTest()
{
  unsigned long int secNum;

  secNum=F32_getFirstSector(8);
  sd_writeSector(secNum,sd_buf);
  //uart0_dump(sd_buf,512,32);
  usart1_puts("\n\r");
  sd_readSector(secNum,512);
  //uart0_dump(sd_buf,512,32);
}
예제 #3
0
	/**
	 * Writes a formatted c string.
	 * Works like printf is expected to work
	 * except it uses a static buffer of size
	 * UART[n]_PRNT_BUFF_SIZE to store the intermediate
	 * string in.
	 */
	int usart1_printf(const char *str, ...){
		if(str == NULL) return -1;

		char buffer[UART1_PRNT_BUFF_SIZE] = {'\0'}; // Warning this might overflow on long str
		va_list args;
		int rc_vsprintf;
		int rc_tx;

		va_start(args, str);
		if((rc_vsprintf = vsnprintf(buffer, UART1_PRNT_BUFF_SIZE, str, args)) < 0){
			return rc_vsprintf; // vsprintf return a negative value on err
		}
		va_end(args);

		if((rc_tx = usart1_puts(buffer)) != rc_vsprintf){
			return -1; // We haven't send the same amount as sprintf wrote the the buffer
		}

		if(rc_tx > UART1_PRNT_BUFF_SIZE) return -UART1_PRNT_BUFF_SIZE; // if buffer overflow

		return rc_tx;
	}
예제 #4
0
파일: syscalls.c 프로젝트: LGTMCU/blixten
int _write (int fd, const void *buf, size_t count)
{
	return usart1_puts((char *) buf, count);
}