コード例 #1
0
ファイル: Application.c プロジェクト: BettyET/K64FAccel
void APP_Run(void){
	/* SD card detection: PTE6 with pull-down! */
	  PORT_PDD_SetPinPullSelect(PORTE_BASE_PTR, 6, PORT_PDD_PULL_DOWN);
	  PORT_PDD_SetPinPullEnable(PORTE_BASE_PTR, 6, PORT_PDD_PULL_ENABLE);

	  if (FAT1_Init()!=ERR_OK) { 								/* initialize FAT driver */
	      Err();
	   }
	  if (FAT1_mount(&fileSystemObject, (const TCHAR*)"0", 1) != FR_OK) { /* mount file system */
	      Err();
	  }
	  initH3LI(); 												/* init accelerometer */
	  startLog();												/* start the logger */
	  while(counter<((MEASDUR/TICK_MS)-1)){
		  isNewDataAvailable(Z_AXIS_DA, &newDataAvailableFlag); /* check if new data available */
		  if(newDataAvailableFlag == TRUE){
			  logAccData();										/* read sensor and save on SD card */
		  }
		  dataOverrun(Z_AXIS_OR, &dataOverrunFlag);				/* data overrun? */
		  if(dataOverrunFlag == TRUE){
			  count_or++;										/* count overruns */
		  }

	  }
	  stopLog();												/* stop the logger */
	  TI2_Disable();											/* disable the counter */
	  LED_G_Off();
}
コード例 #2
0
ファイル: ProcessorExpert.c プロジェクト: cothoe/mcuoneclipse
static void Test(void) {
  UINT bw; /* number of bytes written */

  if (FAT1_isDiskPresent()) { /* if no hardware CardDetect pin is assigned, it will always return TRUE */
    LEDR_On(); /* turn red RGB LED on */
    FAT1_mount(0, &fs); /* mount file system */
    if (!FAT1_isWriteProtected()) { /* if no hardware WritePtotect pin is assigned, it will always return FALSE */
      LEDG_On(); /* turn green RGB LED on */
      if (FAT1_open(&fp, "./test.txt", FA_CREATE_ALWAYS|FA_WRITE)!=FR_OK) { /* open file, will always create it if not already on disk */
        for(;;){} /* error! */
      }
      if (FAT1_write(&fp, "Hello World!", sizeof("Hello World!")-1, &bw)!=FR_OK) { /* write string to file */
        for(;;){} /* error! */
      }
    }
    (void)FAT1_close(&fp); /* close file */
    FAT1_mount(0, NULL); /* unmount file system */
  }
}
コード例 #3
0
ファイル: Application.c プロジェクト: CesarCalva/mcuoneclipse
static void DiskTest(void) {
  CLS1_ConstStdIOTypePtr io;

  io = CLS1_GetStdio();
  FAT1_Init();
  CLS1_SendStr((unsigned char*)"Waiting for disk to be inserted...\r\n", io->stdOut);
  while(!FAT1_isDiskPresent()) {
    /* wait until card is present */
  }
  CLS1_SendStr((unsigned char*)"Mounting File system...\r\n", io->stdOut);
  FAT1_mount(0, &fileSystemObject); /* mount file system */
  (void)Test(io);
  CLS1_SendStr((unsigned char*)"Finished test...\r\n", io->stdOut);
  for(;;) {
    LED2_Neg();
    WAIT1_Waitms(100);
  }
}
コード例 #4
0
ファイル: Application.c プロジェクト: sonlazio/mcuoneclipse
static void DiskTest(void) {
  CLS1_ConstStdIOTypePtr io;

  io = CLS1_GetStdio();
  if (FAT1_Init()!=ERR_OK) {
    CLS1_SendStr((unsigned char*)"Failed FatFS initialization!\r\n", io->stdErr);
    return;
  }
  CLS1_SendStr((unsigned char*)"Waiting for disk to be inserted...\r\n", io->stdOut);
  while(!FAT1_isDiskPresent((uint8_t*)"0")) {
    /* wait until card is present */
  }
  CLS1_SendStr((unsigned char*)"Mounting File system...\r\n", io->stdOut);
  if (FAT1_mount(&fileSystemObject, (const TCHAR*)"0", 1) != FR_OK) { /* mount file system */
    CLS1_SendStr((unsigned char*)"Failed FatFS initialization!\r\n", io->stdErr);
    return;
  }
  (void)Test(io);
  CLS1_SendStr((unsigned char*)"Finished test...\r\n", io->stdOut);
}
コード例 #5
0
ファイル: Application.c プロジェクト: dansog56/mcuoneclipse
void APP_Run(void) {
  int16_t x,y,z;
  uint8_t res;
  #define ACCEL_VAL  2000

  res = FX1_Enable(); /* enable accelerometer (just in case) */
  if (res!=ERR_OK) {
    Err();
  }
  if (FAT1_Init()!=ERR_OK) {
    Err();
  }
  if (FAT1_mount(0, &fileSystemObject) != FR_OK) { /* mount file system */
    Err();
  }
  for(;;) {
    //LED1_Neg();
    x = FX1_GetX();
    y = FX1_GetY();
    z = FX1_GetZ();
    if (x>ACCEL_VAL || x<-ACCEL_VAL) {
      LED1_On();
      LED2_Off();
      LED3_Off();
    } else if (y>ACCEL_VAL || y<-ACCEL_VAL) {
      LED1_Off();
      LED2_On();
      LED3_Off();
    } else if (z>ACCEL_VAL || z<-ACCEL_VAL) {
      LED1_Off();
      LED2_Off();
      LED3_On();
    }
    LogToFile(x, y, z);
    WAIT1_Waitms(1000);
  }
}