SDCard version
Fork of gr-peach-opencv-project-sd-card by
SDBlockDevice_GR_PEACH/SDBlockDevice_GR_PEACH.h@167:2ee3e82cb6f5, 2017-07-21 (annotated)
- Committer:
- thedo
- Date:
- Fri Jul 21 01:26:54 2017 +0000
- Revision:
- 167:2ee3e82cb6f5
- Parent:
- 166:240bc5a0f42a
gr-peach-opencv-project-sd-card
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thedo | 166:240bc5a0f42a | 1 | #ifndef MBED_SDFILESYSTEM_GR_PEACH_H |
thedo | 166:240bc5a0f42a | 2 | #define MBED_SDFILESYSTEM_GR_PEACH_H |
thedo | 166:240bc5a0f42a | 3 | |
thedo | 166:240bc5a0f42a | 4 | #include "SDBlockDevice.h" |
thedo | 166:240bc5a0f42a | 5 | |
thedo | 166:240bc5a0f42a | 6 | /** |
thedo | 166:240bc5a0f42a | 7 | * A class to communicate a SD |
thedo | 166:240bc5a0f42a | 8 | */ |
thedo | 166:240bc5a0f42a | 9 | class SDBlockDevice_GR_PEACH : public SDBlockDevice { |
thedo | 166:240bc5a0f42a | 10 | public: |
thedo | 166:240bc5a0f42a | 11 | |
thedo | 166:240bc5a0f42a | 12 | /** |
thedo | 166:240bc5a0f42a | 13 | * Constructor |
thedo | 166:240bc5a0f42a | 14 | * |
thedo | 166:240bc5a0f42a | 15 | * @param rootdir mount name |
thedo | 166:240bc5a0f42a | 16 | */ |
thedo | 166:240bc5a0f42a | 17 | SDBlockDevice_GR_PEACH() : SDBlockDevice(P8_5, P8_6, P8_3, P8_4), _sd_cd(P7_8), _connect(false) { |
thedo | 166:240bc5a0f42a | 18 | // Set SPI clock rate to 20MHz for data transfer |
thedo | 166:240bc5a0f42a | 19 | _transfer_sck = 20000000; |
thedo | 166:240bc5a0f42a | 20 | } |
thedo | 166:240bc5a0f42a | 21 | |
thedo | 166:240bc5a0f42a | 22 | /** |
thedo | 166:240bc5a0f42a | 23 | * Check if a SD is connected |
thedo | 166:240bc5a0f42a | 24 | * |
thedo | 166:240bc5a0f42a | 25 | * @return true if a SD is connected |
thedo | 166:240bc5a0f42a | 26 | */ |
thedo | 166:240bc5a0f42a | 27 | bool connected() { |
thedo | 166:240bc5a0f42a | 28 | if (_sd_cd.read() != 0) { |
thedo | 166:240bc5a0f42a | 29 | _connect = false; |
thedo | 166:240bc5a0f42a | 30 | } |
thedo | 166:240bc5a0f42a | 31 | return _connect; |
thedo | 166:240bc5a0f42a | 32 | } |
thedo | 166:240bc5a0f42a | 33 | |
thedo | 166:240bc5a0f42a | 34 | /** |
thedo | 166:240bc5a0f42a | 35 | * Try to connect to a SD |
thedo | 166:240bc5a0f42a | 36 | * |
thedo | 166:240bc5a0f42a | 37 | * @return true if connection was successful |
thedo | 166:240bc5a0f42a | 38 | */ |
thedo | 166:240bc5a0f42a | 39 | bool connect() { |
thedo | 166:240bc5a0f42a | 40 | if (_sd_cd.read() == 0) { |
thedo | 166:240bc5a0f42a | 41 | _connect = true; |
thedo | 166:240bc5a0f42a | 42 | } else { |
thedo | 166:240bc5a0f42a | 43 | _connect = false; |
thedo | 166:240bc5a0f42a | 44 | } |
thedo | 166:240bc5a0f42a | 45 | return _connect; |
thedo | 166:240bc5a0f42a | 46 | } |
thedo | 166:240bc5a0f42a | 47 | |
thedo | 166:240bc5a0f42a | 48 | |
thedo | 166:240bc5a0f42a | 49 | private: |
thedo | 166:240bc5a0f42a | 50 | DigitalIn _sd_cd; |
thedo | 166:240bc5a0f42a | 51 | bool _connect; |
thedo | 166:240bc5a0f42a | 52 | }; |
thedo | 166:240bc5a0f42a | 53 | |
thedo | 166:240bc5a0f42a | 54 | #endif |