MCPcopy Create free account
hub / github.com/SmingHub/Sming / init

Function init

samples/Basic_Storage/app/application.cpp:65–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63} // namespace
64
65void init()
66{
67 Serial.begin(SERIAL_BAUD_RATE);
68 Serial.systemDebugOutput(true);
69
70 Storage::Debug::listDevices(Serial);
71
72 listSpiffsPartitions();
73
74 printPart(F("user0"));
75
76 auto part = Storage::findPartition(F("user1"));
77 printPart(part);
78 Serial.println(_F("Writing some stuff to partition..."));
79 String s = F("Some test stuff to write...");
80 part.write(32, s.c_str(), s.length() + 1);
81 uint8_t buf[32];
82 os_get_random(buf, sizeof buf);
83 part.write(64, buf, sizeof buf);
84 printPart(part);
85
86 Serial.println(_F("** Reading tests, repeat 3 times to show effect of caching (if any)"));
87
88 Serial.println(_F("** Reading SysMem device (flash)"));
89 part = Storage::sysMem.editablePartitions().add(F("fs_app FLASH"), FS_app, {Storage::Partition::Type::data, 100});
90 printPart(part);
91 printPart(part);
92 printPart(part);
93
94 Serial.println(_F("** Reading SysMem device (RAM)"));
95 const size_t bufferSize{4096};
96 auto buffer = std::make_unique<char[]>(bufferSize);
97 FS_app.readFlash(0, buffer.get(), bufferSize);
98 part = Storage::sysMem.editablePartitions().add(F("fs_app RAM"), {Storage::Partition::Type::data, 100},
99 storage_size_t(buffer.get()), bufferSize);
100 printPart(part);
101 printPart(part);
102 printPart(part);
103
104 Serial.println(_F("** Reading ProgMem device"));
105 part =
106 Storage::progMem.editablePartitions().add(F("fs_app PROGMEM"), FS_app, {Storage::Partition::Type::data, 100});
107 printPart(part);
108 printPart(part);
109 printPart(part);
110}

Callers

nothing calls this directly

Calls 14

listDevicesFunction · 0.85
listSpiffsPartitionsFunction · 0.85
printPartFunction · 0.85
systemDebugOutputMethod · 0.80
printlnMethod · 0.80
FFunction · 0.50
findPartitionFunction · 0.50
os_get_randomFunction · 0.50
beginMethod · 0.45
writeMethod · 0.45
c_strMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected