-
Notifications
You must be signed in to change notification settings - Fork 8
/
cardManagement.h
57 lines (44 loc) · 1.14 KB
/
cardManagement.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* Flybrix Flight Controller -- Copyright 2018 Flying Selfie Inc. d/b/a Flybrix
*
* http://www.flybrix.com
*/
#ifndef CARD_MANAGEMENT_H
#define CARD_MANAGEMENT_H
#include <Arduino.h>
namespace sdcard {
enum class State {
Closed,
WriteStates,
WriteCommands,
ReadCommands,
};
// Card startup takes a long time to perform
//
// Any SD card operation requires establishing a connection to it.
// Establishing that connection causes lag.
// Run this at boot to prevent lag later on.
void startup();
State getState();
namespace writing {
// Opening and clearing the file takes a long time to perform
void open();
// File closing (saving and truncating the file) takes a long time to perform
void close();
void write(const uint8_t* data, size_t length);
void send();
uint32_t bytesWritten();
void printReport();
// We can set a lock to SD opening/closing controls, which can only be overriden with serial commands
void setLock(bool enable);
bool isLocked();
bool fileIsFull();
} // namespace writing
namespace reading {
void open();
void close();
bool hasMore();
char read();
} // namespace reading
} // namespace sdcard
#endif