예제 #1
0
int initialSDCard()
{
  //SPI speed: 0 - F_CPU/2, 1 - F_CPU/4
  if (!card.init(0,SD_CS_PIN))
  {
    error("card.init failed");
    return 0;
  }
  // initialize a FAT16 volume
  if (!Fat16::init(&card))
  {
    error("Fat16::init");
    return 0;
  }
  return 1;
}
예제 #2
0
unsigned char newSD::init()
{
  //SPI speed: 0 - F_CPU/2, 1 - F_CPU/4
  if (!card.init(1,SD_CS_PIN))
  {
    error("card.init failed");
    return 0;
  }
  // initialize a FAT16 volume
  if (!Fat16::init(&card))
  {
    error("Fat16::init");
    return 0;
  }
  return 1;
}
예제 #3
0
파일: main.cpp 프로젝트: rschuck/K64f
int main (void)
{
   OSA_Init();

   /* Initialize clocks, debug console interface and configure required pins */
   hardware_init();

   /* Disable Memory Protection Unit */
   MPU_HAL_Disable(MPU);

	testPin.pinName = test_pin_name;
	testPin.config.outputLogic = 0;
	testPin.config.slewRate = kPortFastSlewRate;
	testPin.config.driveStrength = kPortHighDriveStrength;
	testPin.config.isOpenDrainEnabled = false;
	GPIO_DRV_OutputPinInit(&testPin);

	// Structure of initialize PIT channel No.0
   pit_user_config_t chn0Confg;
   chn0Confg.isInterruptEnabled = true;
   chn0Confg.periodUs = 1000000u;

   // Init pit module and enable run in debug
   PIT_DRV_Init(BOARD_PIT_INSTANCE, false);

   // Initialize PIT timer instance for channel 0 and 1
   PIT_DRV_InitChannel(BOARD_PIT_INSTANCE, 0, &chn0Confg);

   // Start channel 0
   PRINTF("\n\rStarting channel No.0 ...");
   PIT_DRV_StartTimer(BOARD_PIT_INSTANCE, 0);

//	drv_Mpu9250.Init();
	sdCard.Init(1);

   OSA_TaskCreate((task_t)MainTask,   (uint8_t*)"Main Task",    4096, NULL, 2, NULL, true, NULL);
   //OSA_TaskCreate((task_t)FnetTask,   (uint8_t*)"FNET Task",    2048, NULL, 3, NULL, true, NULL);

   OSA_Start(); // This function will not return

   while(1);

   return(0);
}
예제 #4
0
void logInit() {
    // initialize the SD card
    if (!card.init()) { 
        Serial.print("Error initializing card - ");
        Serial.println(card.errorCode, HEX);
        return;
    }
    
    // initialize a FAT16 volume
    if (!Fat16::init(&card)) {
        Serial.println("Can't initialize volume.");
        return;
    }
    
    // create a new file
    char name[] = "LOGGER00.TXT";
    for (uint8_t i = 0; i < 100; i++) {
        name[6] = i/10 + '0';
        name[7] = i%10 + '0';
        // O_CREAT - create the file if it does not exist
        // O_EXCL - fail if the file exists
        // O_WRITE - open for write only
        if (file.open(name, O_CREAT | O_EXCL | O_WRITE)) break;
    }

    if (!file.isOpen()) {
        Serial.println("Error creating log file.");
        return;
    }
    
    Serial.print("Logging to: ");
    Serial.println(name);

    // write data header
    
    // clear write error
    file.writeError = false;
    file.println("Started log.");
    file.sync();
    
    fileReady = 1;
}