Пример #1
0
int main(){

#ifndef TESTING

#include "uart.h"
#include "mmc.h"

	// Initializam modulele hardware

	uart_init();
	SPI_init();
	MMC_init();
	BTN_init();
	LCD_init();
#endif
	/* Gaseste prima partitie FAT32 de pe card*/
	init_partition(buffer);

	/**
	  * Gaseste datele despre sistemul de fisiere :
	  * nr de tabele FAT, cluster-ul directorului Root, etc.
	  */
	initFAT32(buffer);
	print_volid(buffer);

	LCD_str( "  ", 0);
	LCD_str( "  ", 0);
	LCD_str( "  Welcome to", 0);
	LCD_str( " MMC Explorer", 0);
	_delay_ms(2500);
	LCD_clear();
	printdirs(openroot());
	return EXIT_SUCCESS;
}
Пример #2
0
int main (void)
{
	boot_up();						//Initialize USB port pins and set up the UART
	rprintf("Boot up complete\n");	

	if(IOPIN0 & (1<<23))			//Check to see if the USB cable is plugged in
	{
		main_msc();					//If so, run the USB device driver.
	}
	else{
		rprintf("No USB Detected\n");
	}
	
	//Init SD
	if(sd_raw_init())				//Initialize the SD card
	{
		openroot();					//Open the root directory on the SD card
		rprintf("Root open\n");
		if(root_file_exists(FW_FILE))	//Check to see if the firmware file is residing in the root directory
		{
			rprintf("New firmware found\n");
			load_fw(FW_FILE);			//If we found the firmware file, then program it's contents into memory.
			rprintf("New firmware loaded\n");
		}
	}
	else{
		//Didn't find a card to initialize
		rprintf("No SD Card Detected\n");
		delay_ms(250);
	}
	rprintf("Boot Done. Calling firmware...\n");
	call_firmware();					//Run the new code!

	while(1);
}
Пример #3
0
// intialization functions
void bootARM(void) {
    // had to steal some code from the original SparkFun code because I don't
    // understand it yet.
    rprintf_devopen(putc_serial0);  // Init rprintf
    delay_ms(30);                   // wait for power to stabilize
    
    // bring up SD / FAT *
    if (! (sd_raw_init()) ) { rprintf("SD init error!\n"); }
    if ( openroot() ) { rprintf("openroot error!\n"); }
    
    // set up I/O pins *
    
	//Setup the MP3 I/O Lines
	IODIR0 |= MP3_XCS;
	IODIR0 &= ~MP3_DREQ;
	PINSEL1 |= 0x00000C00;	        // Set the MP3_DREQ Pin to be a capture pin
	IODIR1 |= MP3_XDCS | MP3_GPIO0 | MP3_XRES;	
	
	//Setupt the FM Trans. Lines
	IODIR1 |= FM_LA; 				// FM trans outputs (Leave SPI pins 
	IODIR1 |= FM_CS;                //    unconfigured for now)
	
	//Setup the SD Card I/O Lines
	IODIR0 |= SD_CS;				// SD card outputs
	
	//Setup the Accelerometer I/O Lines
	IODIR0 |= (GS1 | GS2);			// accelerometer outputs
	
	// ensure ADC pins have ADC Functions selected
	PINSEL0 |= (MMA_X_PINSEL | MMA_Y_PINSEL | MMA_Z_PINSEL);		
	IOCLR0 = (GS1 | GS2);		    // initialize acceleration to 1.5 G mode
	
	//Setup the LCD I/O Lines
	IODIR0 |= (LCD_RES | LCD_CS);   // LCD Outputs
	
	//Setup the LED Lines										
	IODIR0 |= (LED_BLU | LED_RED | LED_GRN);
	ledBlueOff();
	ledRedOff();
	ledGrnOff();
	
	//Setup the Buttons
	IODIR1 &= (~SW_UP & ~SW_DWN & ~SW_MID);		//Button Inputs

	IODIR0 &= ~(1<<23);							//Set the Vbus line as an input

    //Setupt the Interrupts
	VPBDIV = 1;									// Set PCLK equal to the system clock	
	VICIntSelect = ~0x30; 						// Timer 0 AND TIMER 1 interrupt is an IRQ interrupt
    VICIntEnable = 0x10; 						// Enable Timer 0 interrupts 
                                                // (don't start sending song data with Timer 1)
    VICVectCntl0= 0x25; 						// Use slot 0 for timer 1 interrupt
    VICVectAddr0 = (unsigned int)timer1ISR; 	// Set the address of ISR for slot 1		
    VICVectCntl1 = 0x24; 						// Use slot 1 for timer 0 interrupt
    VICVectAddr1 = (unsigned int)timer0ISR; 	// Set the address of ISR for slot 1
	
	//Configure Timer0
	T0PR = 1500;								// divide clock(60MHz) by 1500 for 40kHz PS
	T0TCR |=0X01;							    // enable the clock
	T0CTCR=0;									// timer node
	T0MCR=0x0003;								// interrupt and reset timer on match
	T0MR0=1000;									// interrupt on 40Hz
	
	//Configure Timer1
	T1PR = 200;									// divide clock by 300 for 40kHz PS
	T1TCR |=0X01;								// enable the clock
	T1CTCR=0;									// timer mode
	T1CCR=0x0A00;								// capture and interrupt on the 
	                                            //    rising edge of DREQ
	
	//Setup the SPI Port
    S0SPCCR = 64;              					// SCK = 1 MHz, counter > 8 and even
    S0SPCR  = 0x20;                				// Master, no interrupt enable, 8 bits	
    
    
    
    // set up MP3 decoder
    vs1002Config();	// set up ARM <-> VS1002 communication
    vs1002Reset();	// hardware reset
    vs1002Init();	// initialization
    
    return;
    
}
Пример #4
0
/*---------------------------------------------------------------------------
 * T_DIR_INFO *osd_opendir( const char *filename )
 *---------------------------------------------------------------------------*/
T_DIR_INFO	*osd_opendir( const char *filename )
{
  char *p;
  short	 i;
  OSErr  err;
  short  vRefNum;
  int    num;
  long   dirID;
  T_DIR_INFO	*dir;
  Str63		temp;
  CInfoPBRec	pbr;

  /* : なら、ルート(トップレベル) とみなす */
  if (strcmp(filename, ":")==0) {
    return openroot();
  }

  /* filenameが無いときも、ルート(トップレベル) とみなす */
  if( filename==NULL || filename[0]=='\0' ) return openroot();


				/* T_DIR_INFO ワークを 1個確保 */
  if( (dir = (T_DIR_INFO *)malloc( sizeof(T_DIR_INFO) ))==NULL ){
    return NULL;
  }

  err = PathToSpec(filename, &vRefNum, &dirID, NULL);
  if (noErr != err) {
    free( dir );
    return NULL;
  }

  /* 項目の数を取得する */
  dir->nr_entry = 2;		/* 最低でも2エントリ (TOPとparent) */
  i = 1;
  pbr.hFileInfo.ioNamePtr = temp;
  pbr.hFileInfo.ioVRefNum = vRefNum;
  do {
    pbr.hFileInfo.ioFDirIndex = i;
    pbr.hFileInfo.ioDirID     = dirID;
    pbr.hFileInfo.ioACUser    = 0;
    err = PBGetCatInfoSync(&pbr);
    if (err == noErr && !(pbr.hFileInfo.ioFlFndrInfo.fdFlags & 0x4000)) {
      dir->nr_entry += 1;
    }
    i++;
  } while (err == noErr);
				/* T_DIR_ENTRY ワークを 項目数分 確保 */
  dir->entry = (T_DIR_ENTRY *)malloc( dir->nr_entry * sizeof(T_DIR_ENTRY) );
  if( dir->entry==NULL ){
    free( dir );
    return NULL;
  }
  for( i=0; i<dir->nr_entry; i++ ) {
    dir->entry[ i ].name = NULL;
  /*dir->entry[ i ].str  = NULL;*/
  }


  dir->cur_entry = 0;

  /* 先頭に <TOP> と <parent> を追加 */

#define	TOP_NAME	":"
#define	TOP_STR		"<< TOP >>"
#define	PAR_NAME	"::"
#define	PAR_STR		"<< parent >>"

  num = 0;
  {
    p = (char *)malloc( sizeof(TOP_NAME) + sizeof(TOP_STR) );
    if( p==NULL ){	/* ↑ファイル名    ↑表示名    */
      dir->nr_entry = num;
      return dir;
    }
    dir->entry[ num ].name = &p[0];
    dir->entry[ num ].str =  &p[sizeof(TOP_NAME)];

    strcpy(dir->entry[ num ].name, TOP_NAME);
    strcpy(dir->entry[ num ].str,  TOP_STR );

    dir->entry[ num ].type = FILE_STAT_DIR;
  }
  num = 1;
  {
    p = (char *)malloc( sizeof(PAR_NAME) + sizeof(PAR_STR) );
    if( p==NULL ){	/* ↑ファイル名    ↑表示名    */
      dir->nr_entry = num;
      return dir;
    }
    dir->entry[ num ].name = &p[0];
    dir->entry[ num ].str =  &p[sizeof(PAR_NAME)];

    strcpy(dir->entry[ num ].name, PAR_NAME );
    strcpy(dir->entry[ num ].str,  PAR_STR  );

    dir->entry[ num ].type = FILE_STAT_DIR;
  }

  /* フォルダ内の項目を追加 */
  i = 1;
  num = 2;
  pbr.hFileInfo.ioNamePtr = temp;
  pbr.hFileInfo.ioVRefNum = vRefNum;
  do {
    pbr.hFileInfo.ioFDirIndex = i;
    pbr.hFileInfo.ioDirID     = dirID;
    pbr.hFileInfo.ioACUser    = 0;
    err = PBGetCatInfo(&pbr, 0);
    if (err == noErr &&		/* ↓ 不可視属性のファイルは除く */
	!(pbr.hFileInfo.ioFlFndrInfo.fdFlags & 0x4000)) {
      temp[temp[0] + 1] = 0;

      p = (char *)malloc( (temp[0] + 1) + (temp[0] + 3) );
      if( p==NULL ){	/* ↑ファイル名    ↑表示名    */
	dir->nr_entry = num;
        break;
      }

      dir->entry[ num ].name = &p[0];
      dir->entry[ num ].str =  &p[(temp[0] + 1)];

      if (pbr.hFileInfo.ioFlAttrib & 16) {
        sprintf(dir->entry[ num ].name, "%s", temp + 1);
        sprintf(dir->entry[ num ].str, "[%s]", temp + 1);
        dir->entry[ num ].type = FILE_STAT_DIR;
      } else {
        sprintf(dir->entry[ num ].name, "%s", temp + 1);
        sprintf(dir->entry[ num ].str,  "%s", temp + 1);
        dir->entry[ num ].type = FILE_STAT_FILE;
      }
      num++;
    }
    i++;
  } while (err == noErr && num < dir->nr_entry);

  dir->nr_entry = num;

  return dir;
}