当前位置: 首页>>代码示例>>C++>>正文


C++ SdVolume::init方法代码示例

本文整理汇总了C++中SdVolume::init方法的典型用法代码示例。如果您正苦于以下问题:C++ SdVolume::init方法的具体用法?C++ SdVolume::init怎么用?C++ SdVolume::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SdVolume的用法示例。


在下文中一共展示了SdVolume::init方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: initSDCard

int initSDCard(void){
    
  if (!card.init(SPI_HALF_SPEED, SS_CS_Pin))  //Set SCK rate to F_CPU/4 (mode 1)
  {
  	Serial.println("Error Init SD-Card");
  	return SDCARD_ERROR;
  }
  else
  {	 
  	// initialize a FAT volume
  	if (!volume.init(&card))
  	{
  	  	Serial.println("Error Init Volume in SD-Card");
  	  	return SDCARD_ERROR;
	}  	  	
  	else
  	{ 
  		// Open volume
  		if (!root.openRoot(&volume))
  		{
  			Serial.println("Error Open Volume in SD-Card");
  			return SDCARD_ERROR;
		}  	  	
  		else
  		{   
  			return SUCCESS;    			
        } 
    }
  }            			
}    			
开发者ID:,项目名称:,代码行数:30,代码来源:

示例2: setup

void setup() {
  Serial.begin(BPS_115200);
  PgmPrintln("Type any character to start");
  while (!Serial.available());
  
  // initialize the SD card at SPI_FULL_SPEED for best performance.
  // try SPI_HALF_SPEED if bus errors occur.
  if (!card.init(SPI_FULL_SPEED)) error("card.init failed");
  
  // initialize a FAT volume
  if (!volume.init(&card)) error("volume.init failed");

  // open the root directory
  if (!root.openRoot(&volume)) error("openRoot failed");
  
  // write files to root if FAT32
  if (volume.fatType() == 32) {
    PgmPrintln("Writing files to root");
    dirAllocTest(root);
  }
  
  // create sub1 and write files
  SdFile sub1;
  if (!sub1.makeDir(&root, "SUB1")) error("makdeDir SUB1 failed");
  PgmPrintln("Writing files to SUB1");
  dirAllocTest(sub1);

  // create sub2 and write files
  SdFile sub2;
  if (!sub2.makeDir(&sub1, "SUB2")) error("makeDir SUB2 failed");
  PgmPrintln("Writing files to SUB2"); 
  dirAllocTest(sub2);
  
  PgmPrintln("Done");
}
开发者ID:cohabo,项目名称:my_src,代码行数:35,代码来源:main.cpp

示例3: run

int App::run()
{
    if (!card.init(SPI_HALF_SPEED, 4))
    {
        Serial.puts("initialization failed. Things to check:\r\n");
        Serial.puts("* is a card is inserted?\r\n");
        Serial.puts("* Is your wiring correct?\r\n");
        Serial.puts("* did you change the chipSelect pin to match your shield or module?\r\n");
        return 0;
    }
    else
    {
        Serial.puts("Wiring is correct and a card is present.\r\n");
    }

    Serial.puts("\r\nCard type: ");
    switch(card.type())
    {
    case SD_CARD_TYPE_SD1:
        Serial.puts("SD1\r\n");
        break;
    case SD_CARD_TYPE_SD2:
        Serial.puts("SD2\r\n");
        break;
    case SD_CARD_TYPE_SDHC:
        Serial.puts("SDHC\r\n");
        break;
    default:
        Serial.puts("Unknown\r\n");
    }

    if (!volume.init(card))
    {
        Serial.puts("Could not find FAT16/FAT32 partition.\r\n");
        Serial.puts("Make sure you've formatted the card\r\n");
        return 0;
    }

    uint32_t volumesize;
    Serial.printf("\r\nVolume type is FAT%u\r\n", volume.fatType());
    volumesize = volume.blocksPerCluster();
    volumesize *= volume.clusterCount();
    volumesize *= 512;
    Serial.printf("Volume size (bytes): %u\r\n", volumesize);
    volumesize /= 1024;
    Serial.printf("Volume size (Kbytes): %u\r\n");
    volumesize /= 1024;
    Serial.printf("Volume size (Mbytes): %u\r\n");
    Serial.puts("\r\nFiles found on the card (name, date and size in bytes): \r\n");
    root.openRoot(volume);
    root.ls(LS_R | LS_DATE | LS_SIZE, 0, Serial);
    while (true) { }
    return 0;
}
开发者ID:jterweeme,项目名称:helios,代码行数:54,代码来源:app_sd3.cpp

示例4: initSDCard

bool FileSystem::initSDCard() {
    boolean status;

    if (root.isOpen())
        root.close();      // allows repeated calls

    // First, detect the card
    status = card.init(pinCS); // Audio shield has SD card SD on pin 10
    if (status) {
        Serial.println("SD card is connected :-)");
    } else {
        Serial.println("SD card is not connected or unusable :-(");
        sdCardInitialized = false;
        return sdCardInitialized;
    }

    // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
    if (!volume.init(card)) {
        Serial.println(
                "Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
        sdCardInitialized = false;
        return sdCardInitialized;
    }

    root.openRoot(volume);

    // print the type and size of the first FAT-type volume
    Serial.print("\nVolume type is FAT");
    Serial.println(volume.fatType(), DEC);
    Serial.println();

    float size = volume.blocksPerCluster() * volume.clusterCount();
    size = size * (512.0 / 1e6); // convert blocks to millions of bytes
    Serial.print("File system space is ");
    Serial.print(size);
    Serial.println(" Mbytes.");

    status = SD.begin(pinCS); // Audio shield has SD card CS on pin 10
    if (status) {
        Serial.println("SD library is able to access the filesystem");
    } else {
        Serial.println("SD library can not access the filesystem!");
        Serial.println(
                "Please report this problem, with the make & model of your SD card.");
        Serial.println(
                "  http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports");
    }
    sdCardInitialized = true;
    return sdCardInitialized;
}
开发者ID:kigster,项目名称:flix-capacitor,代码行数:50,代码来源:FileSystem.cpp

示例5: setup

void setup() {
  //Serial.begin(9600);

  PgmPrint("Free RAM: ");
  //Serial.println(FreeRam());  

  // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
  // breadboards.  use SPI_FULL_SPEED for better performance.
  pinMode(10, OUTPUT);                       // set the SS pin as an output (necessary!)
  digitalWrite(10, HIGH);                    // but turn off the W5100 chip!

  if (!card.init(SPI_HALF_SPEED, 4)) error("card.init failed!");

  // initialize a FAT volume
  if (!volume.init(&card)) error("vol.init failed!");

  PgmPrint("Volume is FAT");
  //Serial.println(volume.fatType(),DEC);
  //Serial.println();

  if (!root.openRoot(&volume)) error("openRoot failed");

  // list file in root with date and size
  PgmPrintln("Files found in root:");
  root.ls(LS_DATE | LS_SIZE);
  //Serial.println();

  // Recursive list of all directories
  PgmPrintln("Files found in all dirs:");
  root.ls(LS_R);

  //Serial.println();
  PgmPrintln("Done");

  // Debugging complete, we start the server!
  Ethernet.begin(mac, ip);
  server.begin();
  
  // Start up the temperature library
  sensorsa.begin();
  sensorsb.begin();
  sensorsc.begin();
  sensorsd.begin();
  
  setTime(0); // start the clock
  time33mins = time60mins = now();

}
开发者ID:edboel,项目名称:projects,代码行数:48,代码来源:logtemps.c

示例6: initialize

/**
* initialize
* Initialize Writter and SD Card behavior
* @return {void}
*/
bool SDWriter::initialize()
{
	Sd2Card card;
	card.init(SPI_HALF_SPEED, pin);

	SdVolume volume;
  	volume.init(card);
  
  	volumesize = volume.blocksPerCluster() * volume.clusterCount() * 512;

	if (!SD.begin(pin))
		state = false;
	else
		state = true;

	return state;
}
开发者ID:LaZyFiZz,项目名称:HermesProject,代码行数:22,代码来源:SDWriter.cpp

示例7: scanSD

// ----------------------------------------------------------------------------
//	Scan the SD card and open the volume
//	Set reg[STATUS] to FDC_ST_NOTREADY if no card present
// ----------------------------------------------------------------------------
void scanSD()
{
	if (!card.init(SPI_FULL_SPEED, SD_CHIP_SELECT_PIN))
	{
		Serial.print("Init failed, error:");
		Serial.println(card.errorCode());
		mb8877.reg[STATUS] = FDC_ST_NOTREADY;
		return;
	}

#ifdef SD_DEBUG
	Serial.print("\nCard type: ");
	switch(card.type()) {
		case SD_CARD_TYPE_SD1: Serial.println("SD1"); break;
		case SD_CARD_TYPE_SD2: Serial.println("SD2"); break;
		case SD_CARD_TYPE_SDHC: Serial.println("SDHC"); break;
		default: Serial.println("Unknown");
	}
#endif

	if (!volume.init(card)) {
#ifdef SD_DEBUG
		Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
#endif
		mb8877.reg[STATUS] = FDC_ST_NOTREADY;
		return;
	}

#ifdef SD_DEBUG
	// ----- Print the type and size of the first FAT-type volume
	Serial.print("\nVolume type is FAT");
	Serial.println(volume.fatType(), DEC);
	Serial.println();

	long volumesize;
	volumesize = volume.blocksPerCluster();    // clusters are collections of blocks
	volumesize *= volume.clusterCount();       // we'll have a lot of clusters
	volumesize *= 512;                            // SD card blocks are always 512 bytes
	Serial.print("Volume size (bytes): ");
	Serial.println(volumesize);
#endif
	root.openRoot(volume);
	mb8877.reg[STATUS]=0x00;
}
开发者ID:victorlomax,项目名称:qx1,代码行数:48,代码来源:mb8877.cpp

示例8: setup

void setup(void) {
    Serial.begin(9600);
    Serial.println();
    Serial.println("type any character to start");
    while (!Serial.available());
    Serial.println();

    // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
    // breadboards.  use SPI_FULL_SPEED for better performance.
    if (!card.init(SPI_HALF_SPEED)) error("card.init failed");

    // initialize a FAT volume
    if (!volume.init(&card)) error("volume.init failed");

    // open the root directory
    if (!root.openRoot(&volume)) error("openRoot failed");

    // open a file
    if (file.open(&root, "PRINT00.TXT", O_READ)) {
        Serial.println("Opened PRINT00.TXT");
    }
    else if (file.open(&root, "WRITE00.TXT", O_READ)) {
        Serial.println("Opened WRITE00.TXT");
    }
    else {
        error("file.open failed");
    }
    Serial.println();

    // copy file to serial port
    int16_t n;
    uint8_t buf[7];// nothing special about 7, just a lucky number.
    while ((n = file.read(buf, sizeof(buf))) > 0) {
        for (uint8_t i = 0; i < n; i++) Serial.print(buf[i]);
    }
    /* easier way
    int16_t c;
    while ((c = file.read()) > 0) Serial.print((char)c);
    */
    Serial.println("\nDone");
}
开发者ID:aerospace6666,项目名称:AeroQuad,代码行数:41,代码来源:SdFatRead.c

示例9: setup

void setup() {
  Serial.begin(115200);
  while (!Serial.available()) SPARK_WLAN_Loop();
  while (Serial.available()) Serial.read();

  // initialize the SD card at SPI_FULL_SPEED for best performance.
  // try SPI_HALF_SPEED if bus errors occur.
  // Initialize HARDWARE SPI with user defined chipSelect
  if (!card.init(SPI_FULL_SPEED, chipSelect)) error("card.init failed");
  
  // Initialize SOFTWARE SPI
  //if (!card.init(mosiPin, misoPin, clockPin, chipSelect)) error("card.init failed");

  // initialize a FAT volume
  if (!volume.init(&card)) error("volume.init failed!");

  Serial.print("Type is FAT");
  Serial.println(volume.fatType(), DEC);

  if (!root.openRoot(&volume)) error("openRoot failed");
}
开发者ID:TomEngr44,项目名称:SparkCore-SD,代码行数:21,代码来源:Spark-SpeedTest.cpp

示例10: setup

void setup() {


  Serial.begin(9600);

  pinMode(greenLEDandBEEP, OUTPUT);
  pinMode(redLEDpin, OUTPUT);

  PgmPrint("Free RAM: ");
  Serial.println(FreeRam());  

  pinMode(10, OUTPUT);              
  digitalWrite(10, HIGH);              

  if (!card.init(SPI_HALF_SPEED, 4)) error("card.init failed!");

  if (!volume.init(&card)) error("vol.init failed!");

  PgmPrint("Volume is FAT");
  Serial.println(volume.fatType(),DEC);
  Serial.println();

  if (!root.openRoot(&volume)) error("openRoot failed");

  PgmPrintln("Files found in root:");
  root.ls(LS_DATE | LS_SIZE);
  Serial.println();

  PgmPrintln("Files found in all dirs:");
  root.ls(LS_R);

  Serial.println();
  PgmPrintln("Done");

  Ethernet.begin(mac, ip);
  server.begin();
}
开发者ID:Akrobate,项目名称:sketchbook,代码行数:37,代码来源:untitled.c

示例11: setupLog

void setupLog() {
    if (!card.init(SPI_HALF_SPEED, SD_CS)) {
        Serial.println(F("No SD card inserted, disabling data logger."));
        disableLogging = true;
    }

    if (!disableLogging && !volume.init(card)) {
        Serial.println(F("Unable to initialize SD volume"));
        disableLogging = true;
    }

    if (!disableLogging && !root.openRoot(volume)) {
        Serial.println(F("Unable to open volume root"));
        disableLogging = true;
    }

#ifdef DEBUG
    printCardInfo();
#endif

    if (!disableLogging) {
        openLog();
    }
}
开发者ID:veonik,项目名称:transpond,代码行数:24,代码来源:handset.cpp

示例12: setup

void setup()
{
  Serial.begin(115200);
  while (!Serial.available());

  Serial.print("\nInitializing SD card...");
  
  // we'll use the initialization code from the utility libraries
  // since we're just testing if the card is working!
  // Initialize HARDWARE SPI with user defined chipSelect
  if (!card.init(SPI_HALF_SPEED, chipSelect)) {

  // Initialize SOFTWARE SPI (uncomment and comment out above line to use)
//  if (!card.init(mosiPin, misoPin, clockPin, chipSelect)) {
    Serial.println("initialization failed. Things to check:");
    Serial.println("* is a card is inserted?");
    Serial.println("* Is your wiring correct?");
    Serial.println("* did you change the chipSelect pin to match your shield or module?");
    return;
  } else {
   Serial.println("Wiring is correct and a card is present."); 
  }

  // print the type of card
  Serial.print("\nCard type: ");
  switch(card.type()) {
    case SD_CARD_TYPE_SD1:
      Serial.println("SD1");
      break;
    case SD_CARD_TYPE_SD2:
      Serial.println("SD2");
      break;
    case SD_CARD_TYPE_SDHC:
      Serial.println("SDHC");
      break;
    default:
      Serial.println("Unknown");
  }

  // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
  if (!volume.init(card)) {
    Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
    return;
  }

  // print the type and size of the first FAT-type volume
  uint32_t volumesize;
  Serial.print("\nVolume type is FAT");
  Serial.println(volume.fatType(), DEC);
  Serial.println();
  
  volumesize = volume.blocksPerCluster();    // clusters are collections of blocks
  volumesize *= volume.clusterCount();       // we'll have a lot of clusters
  volumesize *= 512;                         // SD card blocks are always 512 bytes
  Serial.print("Volume size (bytes): ");
  Serial.println(volumesize);
  Serial.print("Volume size (Kbytes): ");
  volumesize /= 1024;
  Serial.println(volumesize);
  Serial.print("Volume size (Mbytes): ");
  volumesize /= 1024;
  Serial.println(volumesize);

  Serial.println("\nFiles found on the card (name, date and size in bytes): ");
  root.openRoot(volume);
  
  // list all files in the card with date and size
  root.ls(LS_R | LS_DATE | LS_SIZE);
}
开发者ID:TomEngr44,项目名称:SparkCore-SD,代码行数:69,代码来源:Spark-CardInfo.cpp

示例13: setup

void setup()
{
  Serial.begin(BPS_115200);
  PgmPrintln("Type any character to start");
  while (!Serial.available());

  Serial.print("\nInitializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin 
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output 
  // or the SD library functions will not work. 
  //pinMode(10, OUTPUT);     // change this to 53 on a mega


  // we'll use the initialization code from the utility libraries
  // since we're just testing if the card is working!
  if (!card.init(SPI_HALF_SPEED, chipSelect)) {
    Serial.println("initialization failed. Things to check:");
    Serial.println("* is a card is inserted?");
    Serial.println("* Is your wiring correct?");
    Serial.println("* did you change the chipSelect pin to match your shield or module?");
    return;
  } else {
   Serial.println("Wiring is correct and a card is present."); 
  }

  // print the type of card
  Serial.print("\nCard type: ");
  switch(card.type()) {
    case SD_CARD_TYPE_SD1:
      Serial.println("SD1");
      break;
    case SD_CARD_TYPE_SD2:
      Serial.println("SD2");
      break;
    case SD_CARD_TYPE_SDHC:
      Serial.println("SDHC");
      break;
    default:
      Serial.println("Unknown");
  }

  // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
  if (!volume.init(card)) {
    Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
    return;
  }


  // print the type and size of the first FAT-type volume
  uint32_t volumesize;
  Serial.print("\nVolume type is FAT");
  Serial.println(volume.fatType(), DEC);
  Serial.println();
  
  volumesize = volume.blocksPerCluster();    // clusters are collections of blocks
  volumesize *= volume.clusterCount();       // we'll have a lot of clusters
  volumesize *= 512;                            // SD card blocks are always 512 bytes
  Serial.print("Volume size (bytes): ");
  Serial.println(volumesize);
  Serial.print("Volume size (Kbytes): ");
  volumesize /= 1024;
  Serial.println(volumesize);
  Serial.print("Volume size (Mbytes): ");
  volumesize /= 1024;
  Serial.println(volumesize);

  
  Serial.println("\nFiles found on the card (name, date and size in bytes): ");
  root.openRoot(volume);
  
  // list all files in the card with date and size
  root.ls(LS_R | LS_DATE | LS_SIZE);
}
开发者ID:cohabo,项目名称:my_src,代码行数:74,代码来源:main.cpp

示例14: setup

void setup() {

    int logNo;
	char configLineBuffer[LINE_BUFFER_MAX];
    spi.begin(SPI_281_250KHZ, MSBFIRST, 0);
	
	pinMode(GRN_LED,OUTPUT);
	pinMode(ORN_LED,OUTPUT);
	pinMode(RED_LED,OUTPUT);
	digitalWrite(GRN_LED,HIGH);
	digitalWrite(ORN_LED,LOW);
	digitalWrite(RED_LED,LOW);

    iwdg_init(IWDG_PRE_256, WATCHDOG_TIMEOUT);
    Watchdog_Reset();

	
    if (!card.init(&spi)) { 
    //if (!card.init()) { 
        console.printf("FTL: card.init failed");
    }
    delay(100);
    
    // initialize a FAT volume
    if (!volume.init(&card)) {
        console.printf("FTL: volume.init failed");
    }
    
    // open the root directory
    if (!root.openRoot(&volume)) 
        ;//SerialUSB.println("FTL: openRoot failed");
    
    for (logNo=0; (!logOpened) && logNo<512; logNo++) {
        Watchdog_Reset();
       //int snprintf(char *str, size_t size, const char *format, ...);
        snprintf(logFileName,15,"LOG%03d.TXT",logNo);
        if (file.open(&root, logFileName, O_READ)) {
            //SerialUSB.print("DBG: Exists  :"); SerialUSB.println(logFileName);
            file.close();
        } else if (file.open(&root, logFileName, O_CREAT|O_READ|O_WRITE)) {
            //SerialUSB.print("DBG: New File:"); SerialUSB.println(logFileName); 
            logOpened=true;
            file.sync();
            file.close();
            file.open(&root,logFileName,O_WRITE|O_READ);
			while (file.read(configLineBuffer,LINE_BUFFER_MAX)) {
				
			}
            file.sync();
        }    
    }
    //if (!logOpened) SerialUSB.println("FTL: openRoot failed");

	digitalWrite(GRN_LED,LOW);
	digitalWrite(RED_LED,HIGH);
    readSettings();
	console.printf("LSV:" BOM_VERSION "\r\n");
    console.printf("NST: %s\r\n",networkStatus()?"CONNECTED":"NOT CONNECTED");
	digitalWrite(ORN_LED,HIGH);
	digitalWrite(RED_LED,networkStatus()?HIGH:LOW);
	
}
开发者ID:suspect-devices,项目名称:cache-and-carry,代码行数:62,代码来源:main.cpp


注:本文中的SdVolume::init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。