Beispiel #1
0
/* Main program : Initialize the system and start the first task */
int main (void)
{	
	Initialize_Button(USER);
	Initialize_Button(TAMPER);

	Initialize_Led(LED1);
	Initialize_Led(LED2);
	Initialize_Led(LED3);
	Initialize_Led(LED4);
	Initialize_Led(LED5);
	Initialize_Led(LED6);
	Initialize_Led(LED7);
	Initialize_Led(LED8);
	
	Turn_Led(LED1,ON);
	GPU_Init();
	JOY_Init();	
	initSD(&fs32);
	
	wait(1000000);

	while(1)
	{
		// Start the task menu allow to choose the program
		// - GIF unicorn
		// - Street of rage
		// - Zelda		
		os_sys_init (taskMenu);
	}	
} //Fin main
/**
 * Arduino's setup function, called once at startup, after init
 */
void
setup()
{
  initLeds();
  initDebugSerial();
  initUserSwitch();
  marioThemePlayer.playMarioTheme();
  initSD();
  initGpsSerial();
}
Beispiel #3
0
DSTATUS disk_initialize (void)
{
	DSTATUS stat;

    if(initSD(&SD_PORT, SD_CS) == 0){
        // Failed:
        stat = RES_ERROR;
    } else {
        // Worked:
        stat = RES_OK;
    }

	return stat;
}
Beispiel #4
0
//Displayed when the game is over
void GameOverScreen() {
	clearScreen();
	updateScreen();
	clearCharBuffer();

	initSD();
	int i;
	for (i = 0; i < numPlayers; ++i) {
		if (p[i].name != NULL && p[i].type == HUMAN) {
			char name[10];
			strcpy(name, p[i].name);
			writeSD(name, p[i].points);
			printf("write:%i score: %i\n", i,p[i].points);
		}
	}

	for (i = 0; i < numPlayers; ++i) {
		printf("%s", p[i].name);
	}

	printString("GAME OVER!", 30, 25);
	usleep(1000000);

	clearScreen();
	updateScreen();
	clearCharBuffer();
	//displayHighScore("abc","a","b","c");
	if (numPlayers == 2) {
		displayHighScore(p[pOne].name, p[pTwo].name, NULL, NULL);
		printf("TWO");
	} else if (numPlayers == 3) {
		displayHighScore(p[pOne].name, p[pTwo].name, p[pThree].name, NULL);
		printf("THREE");
	} else {
		displayHighScore(p[pOne].name, p[pTwo].name, p[pThree].name,
				p[pFour].name);
		printf("ALL");
	}
	updateScreen();
	usleep(10000000);
	state = 0;
}
int main(void)
{

//  u16 len = 0;			    
//  len = menuDisplay(bufExtBin);
//  if (len)
//	signUSBMass = 0;

  signUSBMass = 0;
//***********************************DEBUG********************************************/

      
//***********************************END OF DEBUG********************************************/

    /* Configure IO connected to USB PWR DET *********************/	
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE );
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
  	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  	GPIO_Init(GPIOD, &GPIO_InitStructure);

    if((GPIO_ReadInputData(GPIOD) & 0x08))   // USB is present after switch - work MASS Storage
      {
	     signUSBMass = 1;
      }

	signUSBMass = 0;   //debugga

#if 1  	  //that's for temporary off USB - for debugging
  
  NVIC_Configuration();
  Set_System();
  Set_USBClock();
  USB_Interrupts_Config();
  USB_Init();
  if(signUSBMass)
     while (bDeviceState != CONFIGURED);

#endif 
//
#if 1
  if(!signUSBMass)
   {
    if (SysTick_Config(SystemCoreClock / 1000))  //1ms
     { 
       /* Capture error */ 
       while (1);
     }

  	 /* Flash unlock */
     FLASH_Unlock();
     /* Clear All pending flags */
     FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);	

//***********************************DEBUG********************************************/

     
//***********************************END OF DEBUG********************************************/

  /* Enable CRC clock */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE);
    
  ledDioGPIOInit();
  //LED_MIDDLE = 1;
  //GPIO_ResetBits(LED_MID_PORT, LED_MID_PORT_PIN);
  BKPInit();
  //debugga

  /*
  u32 mileage = 0;
  mileage         = BKPReadReg(BKP_DR_MSG_NUMBER1)  | ( (u32)(BKPReadReg(BKP_DR_MSG_NUMBER2) << 16)  );
  mileage++;
  BKPWriteReg(BKP_DR_MSG_NUMBER1,mileage);BKPWriteReg(BKP_DR_MSG_NUMBER2,mileage >> 16);
  mileage         = BKPReadReg(BKP_DR_MSG_NUMBER1)  | ( (u32)(BKPReadReg(BKP_DR_MSG_NUMBER2) << 16)  );
  mileage = 0;
  BKPWriteReg(BKP_DR_MSG_NUMBER1,mileage);BKPWriteReg(BKP_DR_MSG_NUMBER2,mileage >> 16);
  mileage         = BKPReadReg(BKP_DR_MSG_NUMBER1)  | ( (u32)(BKPReadReg(BKP_DR_MSG_NUMBER2) << 16)  );
  if(mileage)
	signUSBMass = 0;   //debugga
  */

  Delay(1000);

  //rs485Init();

  //Delay(1000);

  ais326dq_init();
  ais326dq_data(&ais326dq_out);

  adcInit();

  gpsInit();

  gprsModemInit();
  
  gprsModemOn();
#ifndef BRIDGE_USB_GSM
  setupGSM();
  ftpGSMPrepare();
  packetsIni();
#endif
  rtc_init();
  rtc_gettime(&rtc);
  initSD();

  /* reading settings */
  readConfig();
  /* Log  */
  saveSDInfo((u8 *)"TURN ON BLOCK ",strlen((u8 *)"TURN ON BLOCK "), SD_SENDED, SD_TYPE_MSG_LOG );
  saveSDInfo((u8 *)readRTCTime(&rtc),strlen((const char *)readRTCTime(&rtc)), SD_SENDED, SD_TYPE_MSG_LOG );

  }	 //if(!signUSBMass)
#endif

  //u8 tempCnt;
  while (1)
  {
    if(!signUSBMass)
	 {
	     gpsHandling();
		 #ifndef BRIDGE_USB_GSM
		    loopGSM();
			loopFTP();
            UpdatingFlash();
			naviPacketHandle();
			rcvPacketHandle();
            rcvPacketHandleUSB();
		 #endif 
		 buttonScan();
		 accelScan();
		 
//		 if(getButtonUserPressed())
//		  {
//		    led_mid(BOARD_LED_XOR);
//		    ais326dq_data(&ais326dq_out);
//		  }

		 //rs485Analyse();
		 handleFOS();
         adcScan();

  	 }  /* if(!signUSBMass)  */
  }
}
int main(void)
{
  UINT n = 0;
  GPIO_InitTypeDef  GPIO_InitStructure;

/* FF用のPB14の設定 */
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
/* RWD用のPB13の設定 */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
/* HOLD用のPB12の設定 */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
/* FN1242 DAC コントロール用のPC4-6の設定 */
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 |GPIO_Pin_5 |GPIO_Pin_6;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOC, &GPIO_InitStructure);
  GPIO_ResetBits(GPIOC,GPIO_Pin_4 | GPIO_Pin_5); // MC <= 0 MD <= 0
  GPIO_SetBits(GPIOC,GPIO_Pin_6);   // ML <= 1

#ifdef USE_USART
  conio_init(UART_DEFAULT_NUM,UART_BAUDLATE);
#ifdef USE_PRINTF
  printf("\n");
  printf("Welcome to %s test program !!\n",MPU_SUBMODEL);
  printf("Version %s!!\n",APP_VERSION);
  printf("Build Date : %s\n",__DATE__);
#else
  cputs("\r\n");
  cputs("Welcome to");
  cputs(MPU_SUBMODEL);
  cputs("test program !!\r\n");
  cputs("Version");
  cputs(APP_VERSION);
  cputs("!!\r\n");
  cputs("Build Date : ");
  cputs(__DATE__);
  cputs("\r\n");
#endif
#endif

/* ADCの初期化 */
  initADC();
/* I2Sポートの初期化*/
  initI2S();
/* I2Sポートをスタート */
  startI2S(44100,16);
/* IRQの設定とDMAのイネーブル */
  setIRQandDMA();
  if ((!initSD()) && (lsSD() == FR_OK)) {
    while (Command_index != 3) {
      sdio_playNO(n);
      if ((Command_index == 0) || (Command_index == 1)) {
        n++;
        if (n >= sMUSIC) {
          n = 0;
        }
      } else if (Command_index == 2){
        if (n == 0) {
          if (sMUSIC > 0) {
            n = sMUSIC - 1;
          } else {
            n = 0;
          }
        } else {
          n--;
        }
      }
    }
  }
  while(1) {
  }

#ifndef NO_ADC
#ifdef USE_PRINTF
  printf("Low Voltage Stop\n");
#endif
  PWR_EnterSTANDBYMode();
#endif

  while(1) {
  }
}
Beispiel #7
0
int main()
{
    typedef boost::shared_ptr<boost::thread> ThreadPtr;
    SharedData sd;

    
    initSD(sd);
    ThreadPtr thP(new boost::thread(worker, &sd));

    ::sleep(1);
    {
        Lock lk(*sd.mutexP);
        sd.isWorkerAllowed = false;
        sd.condP->notify_one();
    }
    
    {
        Lock lk(*sd.mutexP);
        sd.isWorkerAllowed = true;
        ::printf("master: %d\n", sd.id);
        sd.condP->notify_one();
    }
    ::sleep(1);

    {
        Lock lk(*sd.mutexP);
        sd.isWorkerAllowed = false;
        sd.condP->notify_one();
    }

    thP->interrupt();
    thP->join();
    thP = ThreadPtr();
    //finalizeSD(sd);
    
    int pid;
    ::sigignore(SIGCHLD);
    if ((pid = ::fork()) == 0) {
        /* child */
        //thP->interrupt();
        //thP->join();
        ::printf("child: %d\n", sd.id);
        ::sleep(5);
        ::printf("child end\n");
        ::exit(0);
    } else {
        /* parent */
    }
    ::printf("parent: %d\n", sd.id);

    initSD(sd);
    thP = ThreadPtr(new boost::thread(worker, &sd));
    {
        Lock lk(*sd.mutexP);
        sd.isWorkerAllowed = true;
        sd.condP->notify_one();
    }
    ::sleep(1);
    {
        Lock lk(*sd.mutexP);
        ::printf("master: %d\n", sd.id);
        sd.isWorkerAllowed = false;
        sd.condP->notify_one();
    }
    thP->interrupt();
    thP->join();
    thP = ThreadPtr();
    //finalizeSD(sd);
    ::printf("parent: %d\n", sd.id);

    int status;
    ::wait(&status);
    
    return 0;
}
Beispiel #8
0
void RETROCADE::setupMegaWing()
{
  activeChannel = 0;
  activeInstrument = 0;
  smallfsActiveTrack = 0;
  timeout = TIMEOUTMAX;
  smallFs = false;
  sdFs = false;
  invadersCurLoc = 0;
  invadersCurSeg = 1;
  invadersTimer = INVADERSTIMERMAX;
  lcdMode = MENU_WELCOME;
  buttonPressed = None;
  

  SIGMADELTACTL=0x3;
  //Move the audio output to the appropriate pins on the Papilio Hardware
  pinMode(AUDIO_J1_L,OUTPUT);
  digitalWrite(AUDIO_J1_L,HIGH);
  //outputPinForFunction(AUDIO_J1_L, IOPIN_SIGMADELTA0);
  outputPinForFunction(AUDIO_J1_L, 8);
  pinModePPS(AUDIO_J1_L, HIGH);

  pinMode(AUDIO_J1_R,OUTPUT);
  digitalWrite(AUDIO_J1_R,HIGH);
  outputPinForFunction(AUDIO_J1_R, 8);
  //outputPinForFunction(AUDIO_J1_R, IOPIN_SIGMADELTA1);
  pinModePPS(AUDIO_J1_R, HIGH);
  
  pinMode(AUDIO_J2_L,OUTPUT);
  digitalWrite(AUDIO_J2_L,HIGH);
  outputPinForFunction(AUDIO_J2_L, 8);
  pinModePPS(AUDIO_J2_L, HIGH);

  pinMode(AUDIO_J2_R,OUTPUT);
  digitalWrite(AUDIO_J2_R,HIGH);
  outputPinForFunction(AUDIO_J2_R, 8);
  pinModePPS(AUDIO_J2_R, HIGH);
  
  //Move the second serial port pin to where we need it, this is for MIDI input.
  pinMode(SERIAL1RXPIN,INPUT);
  inputPinForFunction(SERIAL1RXPIN, 1);
  pinMode(SERIAL1TXPIN,OUTPUT);
  //digitalWrite(SERIAL1TXPIN,HIGH);
  outputPinForFunction(SERIAL1TXPIN, 6);
  pinModePPS(SERIAL1TXPIN, HIGH);
 
   //Start SmallFS
  if (SmallFS.begin()<0) {
	Serial.println("No SmalLFS found.");
  }
  else{
     Serial.println("SmallFS Started.");
     smallFs = true; 
  }
 
  //Setup SD Card
  initSD();
  
  //Setup Joystick
  pinMode(JSELECT, INPUT); 
  pinMode(JUP, INPUT); 
  pinMode(JDOWN, INPUT); 
  pinMode(JLEFT, INPUT); 
  pinMode(JRIGHT, INPUT);  
 
  //Setup LCD
  pinMode(WING_C_14, OUTPUT);     //Set contrast to GND
  digitalWrite(WING_C_14, LOW);   //Set contrast to GND    
 // set up the LCD's number of columns and rows:
 lcd.begin(16,2);
 // clear the LCD screen:
 lcd.clear();
 lcd.setCursor(0,1);
 lcd.print("RetroCade Synth");

 //Setup timer for YM and mod players
  TMR0CTL = 0;
  TMR0CNT = 0;
  TMR0CMP = ((CLK_FREQ/2) / FREQ )- 1;
  TMR0CTL = _BV(TCTLENA)|_BV(TCTLCCM)|_BV(TCTLDIR)|
  	_BV(TCTLCP0) | _BV(TCTLIEN);
  INTRMASK = BIT(INTRLINE_TIMER0); // Enable Timer0 interrupt
  INTRCTL=1;    

}
int main(void)
{
//***********************************DEBUG********************************************/
#if 0

nmeaPOS p1,p2;
nmeaINFO info;
info.lat = 5547.1206;
info.lon = 4906.2111;
nmea_info2pos(&info, &p1);
info.lat = 5547.1221;
info.lon = 4906.208;
nmea_info2pos(&info, &p2);

m += 23;

u32 t    = nmea_distance(&p1, &p2);
if(m)
#endif
//***********************************END OF DEBUG********************************************/
  NVIC_Configuration();	//for  all peripheria
  if (SysTick_Config(SystemCoreClock / 1000))  //1ms
     { 
       /* Capture error */ 
       while (1);
     }
  Delay(500);


  USBIniPin();
  	  
  signUSBMass = USBDetectPin();
  signUSBMass = 0;  //deb
  #if not defined (VER_3)
    USBCommonIni(); 
  #endif
  if(signUSBMass)
    {
	 #if defined (VER_3)
	 USBCommonIni();
	 #endif
     while (bDeviceState != CONFIGURED);
	}
  else //if(!signUSBMass)
   {

  	 /* Flash unlock */
     FLASH_Unlock();
     /* Clear All pending flags */
     FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);	

//***********************************DEBUG********************************************/

     
//***********************************END OF DEBUG********************************************/
  /* Enable CRC clock */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE);
    
  ledDioGPIOInit();
  led_dn(BOARD_LED_ON);
  led_mid(BOARD_LED_ON);
#if defined (VER_3)
  led_up(BOARD_LED_ON);
  ibuttonInit();
  rfmodemInit();
#endif
  Delay(1000);
  alarmInit();
  BKPInit();

  //timer6Init();

  //rs485Init();
#if not defined (VER_3)
  ais326dq_init();
#endif

  //ais326dq_data(&ais326dq_out);
  /*ADC*/
  adcInit();
  /*GPS*/
  gpsInit();

  /* reading settings */
  readConfig();
  /*MODEM*/
  gprsModemInit();
  gprsModemOn(innerState.activeSIMCard);
//***********************************DEBUG********************************************/
  //GSMSpeaker(1);
//***********************************END OF DEBUG********************************************/

#ifndef BRIDGE_USB_GSM
  setupGSM();
  ftpGSMPrepare();
  packetsIni();
#endif

  led_dn(BOARD_LED_OFF);
  led_mid(BOARD_LED_OFF);
#if defined (VER_3)
  led_up(BOARD_LED_OFF);
#endif

  rtc_init();
  rtc_gettime(&rtc);

#if 1			  /* WATCH DOG */
  /* IWDG timeout equal to 3.27 sec (the timeout may varies due to LSI frequency dispersion) */
  /* Enable write access to IWDG_PR and IWDG_RLR registers */
  IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
  /* IWDG counter clock: 40KHz(LSI) / 32 = 1.25 KHz */
  IWDG_SetPrescaler(IWDG_Prescaler_64);	//32
  /* Set counter reload value to 0xFFF */
  IWDG_SetReload(0xFFF);
  /* Reload IWDG counter */
  IWDG_ReloadCounter();
  /* Enable IWDG (the LSI oscillator will be enabled by hardware) */
  IWDG_Enable();
  setTimerIWDG(ONE_SEC);
#endif

  initSD();
#if defined (VER_3)
  //DACInit();
#endif

  /* Log  */
  saveSDInfo((u8 *)"TURN ON BLOCK ",strlen((u8 *)"TURN ON BLOCK "), SD_SENDED, SD_TYPE_MSG_LOG );
  //saveSDInfo((u8 *)readRTCTime(&rtc),strlen((const char *)readRTCTime(&rtc)), SD_SENDED, SD_TYPE_MSG_LOG );
#if defined (VER_3)  
  //DACSpeaker(1);
  //wp_play("0:/sound.wav");
  //DACSpeaker(0);
#endif 

  }	 //if(!signUSBMass)

  while (1)
  {
    if(!signUSBMass)
	  {
		 monitorWatchDog();

		 #ifndef BRIDGE_USB_GPS
	     if(!innerState.bootFTPStarted)
	         gpsHandling();
		 #endif

		 #ifndef BRIDGE_USB_GSM
		 if(!innerState.flagTmpDebug)
		    loopGSM();
			loopFTP();
            UpdatingFlash();
			if(!innerState.bootFTPStarted)
			   naviPacketHandle();
			rcvPacketHandle();
            rcvPacketHandleUSB();
		 #endif 

		 #if !defined (VER_3)
			 buttonScan();
		     accelScan();
		 #endif
		 
		 //rs485Analyse();
		 handleFOS();
		 executeDelayedCmd();
#if defined (VER_3)
		 #if 0 
		 if(innerState.flagDebug)
		 {
  			DACSpeaker(1);
	        /* Start DAC Channel1 conversion by software */
		    //a += 300;
    		//DAC_SetChannel1Data(DAC_Align_12b_R, 4000);
    		//DAC_SetChannel1Data(DAC_Align_12b_L, a);  //for saw
    		//DAC_SetChannel1Data(DAC_Align_8b_R, a);
			
			//DAC_SetChannel1Data(DAC_Align_12b_R, 4095);
			//DAC_SetChannel1Data(DAC_Align_12b_R, 0);
			//for (a = 0; a<4095; ++a)
			//for(;;)
			//  DAC_SetChannel1Data(DAC_Align_12b_R, 0);

			//DAC_SetChannel1Data(DAC_Align_12b_R, 0);
			//for ( ; ; )
			//{
			//   DAC_SoftwareTriggerCmd(DAC_Channel_1, ENABLE);
			//}
 

	        DAC_SoftwareTriggerCmd(DAC_Channel_1, ENABLE);  //debugga
		 }
		 else
		 {
		     DACSpeaker(0);
		 }
	  #endif
#endif
	 }
	else
	  handleUSBPresent();
  }	   //while(1)
}