Example #1
0
File: rc5.c Project: zbanks/oggvosh
void main(void) {
#if 0 /*Perform some extra inits because we are started from SPI boot. */
    InitAudio(); /* goto 3.0x..4.0x */
    PERIP(INT_ENABLEL) = INTF_RX | INTF_TIM0;
    PERIP(INT_ENABLEH) = INTF_DAC;
    //ph = FsPhNandCreate(0); /*We do not use FLASH, so no init for it. */
#endif

    /* Set the leds after nand-boot! */
    PERIP(GPIO1_ODATA) |=  LED1|LED2;      /* POWER led on */
    PERIP(GPIO1_DDR)   |=  LED1|LED2; /* SI and SO to outputs */
    PERIP(GPIO1_MODE)  &= ~(LED1|LED2); /* SI and SO to GPIO */

    /* Initialize RC5 reception */
    Rc5Init(INTV_GPIO0);
    PERIP(GPIO0_INT_FALL) |= (1<<14); /*DISPLAY_XCS*/
    PERIP(GPIO0_INT_RISE) |= (1<<14);
    PERIP(INT_ENABLEL) |= INTF_GPIO0;

    SetHookFunction((u_int16)IdleHook, MyUserInterfaceIdleHook);
    SetHookFunction((u_int16)USBSuspend, MyUSBSuspend);
#if 0
    while (1) {
	register u_int16 t = Rc5GetFIFO();
	if (t) {
	    puthex(t);
	    puts("=got");
	}
    }
#endif
#if 0
    while (1) {
	s_int16 tmp[32];
	memset(tmp, 0, sizeof(tmp));
	AudioOutputSamples(tmp, 16);
    }
#endif
}
Example #2
0
void main(void) {
    FILE *fp;
    long size;

    SetHookFunction((u_int16)IdleHook, UserInterfaceIdleHook);

    applAddr = NULL;
    currentKeyMap = sixKeyMap;
    ph = &fsNandPhys;
    //fsNandPhys.nandType = 0; /* 16MB small-page */
    fsNandPhys.waitns = 100;

    USEX(SCI_STATUS) |= SCISTF_ANADRV_PDOWN; /* quiet it.. */

    ph->Read(ph, 0, 1, mallocAreaX, NULL); /* read first sector */

    PERIP(INT_ENABLEL) &= ~INTF_RX; /* prevent jump to monitor when IO done!!*/
    if (fp = fopen("boot.img", "rb")) {
	int len;
	if (mallocAreaX[0] == (('V'<<8)|'L') &&
	    mallocAreaX[1] == (('S'<<8)|'I')) {
	    /* NAND info not needed, discard it */
	    puts("info ok");
	    fseek(fp, 10, SEEK_SET); /* 10 bytes = 5 words */
	} else {
	    puts("info from file");
	    /* NAND info not present, read it */
	    fread(mallocAreaX, 5, 1, fp);
	}
	memset(mallocAreaX+5, 0xffff, 0x1000-5);

	fsNandPhys.nandType = mallocAreaX[2];
	puthex(fsNandPhys.nandType);
	puts("=type");
	puthex(mallocAreaX[0]);
	puthex(mallocAreaX[1]);
	puthex(mallocAreaX[2]);
	puthex(mallocAreaX[3]);
	puthex(mallocAreaX[4]);

	size = fread(mallocAreaX+5, 1, 0x1000-5, fp) + 6;
	puthex(size);
	puts("=size");

	puts("Erasing");
	ph->Erase(ph, 0); /* erase first XX sectors */

	puthex(mallocAreaX[5]);
	puts("=blocks");
	puthex((size+255)/256);
	puts("=Writing");
	puthex(ph->Write(ph, 0, (size+255)/256, mallocAreaX, NULL));
	puts("fclose()");
	fclose(fp);
    } else {
	puts("boot.img not found!");
    }
    puts("restart");
    fflush(stdout);
 PERIP(INT_ENABLEL) |= INTF_RX; 
}
Example #3
0
//--------------------------------------------------------------------------
void main(void){
 //-------------------------------------------------------------------------
 if(USBIsAttached()){
   return; //Quit to ROM code to handle USB traffic
 }
 //-------------------------------------------------------------------------
 ph = &fsNandPhys.p; //physical disk is nand flash ROM handler
 map = FsMapTnCreate(ph,0); //logical disk mapper is ROM tiny mapper (read only)
 currentKeyMap = ZeroKeyMap;
 PERIP(GPIO1_MODE) = 0x30; //-\seting
 PERIP(GPIO1_DDR)  = 0x0F; //-/port GPIO1
 //-------------------------------------------------------------------------
 if(InitFileSystem()){
  while(1); // NO File System
 }
  else{ //FAT IS INIT
   minifatInfo.supportedSuffixes = supportedFiles; //play '.ogg' files
   player.totalFiles = OpenFile(0xffffU);
   SetVOL(0x10);
   player.currentFile = 0;
   player.nextStep = 1;
   player.offDelay = 0;
   player.randomOn = 0; /// Off random
   PERIP(GPIO1_ODATA) |= 0x01;
   SetHookFunction((u_int16)PowerOff, MyPowerOff);
   if(OpenFile(player.currentFile) < 0){
    OpenFile(player.currentFile);
    PlayCurrentFile();
   }
   player.currentFile++;
   currentKeyMap = MyKeyMap;
   while (1) {//player loop
    // "Previous" file selected at the first file
    if (player.currentFile < 1) {
     player.currentFile = (player.totalFiles-1);
    }
    // "Next" file selected at or after the last file
    if (player.currentFile >= player.totalFiles){
     player.currentFile = 1;
    }
    if(OpenFile(player.currentFile) < 0){ 
     OpenFile(player.currentFile);
     player.nextStep = 1;
     {
      u_int16 result = PlayCurrentFile();
      if (result == ceFormatNotFound){
       player.currentFile++; //Skip erroneous file
      }
      if(result == ceFormatNotSupported){
       player.currentFile++; //Skip erroneous file
      }
      if(result == ceOtherError){
       player.currentFile++; //Skip erroneous file
      }
     }
     player.currentFile += player.nextStep;
    }
     else{ // Could not OpenFile.
      player.currentFile++; // Revert to playing the first file
     }
   } //end of player loop
  } //end FAT
} //end main