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