SDCard is a library to access SDCard files mounted as FAT filesystem

Dependents:   PrV_SDCard

Committer:
villemejane
Date:
Tue Mar 10 14:22:02 2020 +0000
Revision:
0:1477b4630c35
SDCard is a library to access SDCard files mounted as FAT filesystem

Who changed what in which revision?

UserRevisionLine numberNew contents of line
villemejane 0:1477b4630c35 1 /****************************************************************************/
villemejane 0:1477b4630c35 2 /* SDCard - Library for Nucleo */
villemejane 0:1477b4630c35 3 /****************************************************************************/
villemejane 0:1477b4630c35 4 /* LEnsE / Julien VILLEMEJANE / Institut d'Optique Graduate School */
villemejane 0:1477b4630c35 5 /****************************************************************************/
villemejane 0:1477b4630c35 6 /* Pins */
villemejane 0:1477b4630c35 7 /* USBTX, USBRX RS232 communication with computer */
villemejane 0:1477b4630c35 8 /* D11, D12, D13 SPI communication with SD Card */
villemejane 0:1477b4630c35 9 /* D4 CS of SD Card */
villemejane 0:1477b4630c35 10 /****************************************************************************/
villemejane 0:1477b4630c35 11 /* Tested on L476RG */
villemejane 0:1477b4630c35 12 /****************************************************************************/
villemejane 0:1477b4630c35 13 #ifndef RPLIDAR_H
villemejane 0:1477b4630c35 14 #define RPLIDAR_H
villemejane 0:1477b4630c35 15
villemejane 0:1477b4630c35 16 #include "mbed.h"
villemejane 0:1477b4630c35 17 // Block devices
villemejane 0:1477b4630c35 18 #include "SDBlockDevice.h"
villemejane 0:1477b4630c35 19 // File systems
villemejane 0:1477b4630c35 20 #include "FATFileSystem.h"
villemejane 0:1477b4630c35 21
villemejane 0:1477b4630c35 22 class SDCard
villemejane 0:1477b4630c35 23 {
villemejane 0:1477b4630c35 24 public:
villemejane 0:1477b4630c35 25 /**
villemejane 0:1477b4630c35 26 * Constructor
villemejane 0:1477b4630c35 27 *
villemejane 0:1477b4630c35 28 * @param miso SPI communication for SD Card / MISO pin
villemejane 0:1477b4630c35 29 * @param mosi SPI communication for SD Card / MOSI pin
villemejane 0:1477b4630c35 30 * @param sck SPI communication for SD Card / SCK pin
villemejane 0:1477b4630c35 31 * @param cs SPI communication for SD Card / CS pin
villemejane 0:1477b4630c35 32 */
villemejane 0:1477b4630c35 33 SDCard(PinName miso, PinName mosi, PinName sck, PinName cs);
villemejane 0:1477b4630c35 34
villemejane 0:1477b4630c35 35 /**
villemejane 0:1477b4630c35 36 * Mounting SD Card and FileSystem
villemejane 0:1477b4630c35 37 *
villemejane 0:1477b4630c35 38 * @return error 1 if OK, -1 if not OK
villemejane 0:1477b4630c35 39 */
villemejane 0:1477b4630c35 40 int mounting(void);
villemejane 0:1477b4630c35 41 /**
villemejane 0:1477b4630c35 42 * Opening file on SD Card
villemejane 0:1477b4630c35 43 *
villemejane 0:1477b4630c35 44 * @param path directory of the file
villemejane 0:1477b4630c35 45 * @param file name of the file with extension
villemejane 0:1477b4630c35 46 * @return error 1 if OK, -1 if not OK
villemejane 0:1477b4630c35 47 */
villemejane 0:1477b4630c35 48 int opening_file(char *path, char* filename);
villemejane 0:1477b4630c35 49 /**
villemejane 0:1477b4630c35 50 * Closing file on SD Card
villemejane 0:1477b4630c35 51 *
villemejane 0:1477b4630c35 52 * @return error 1 if OK, -1 if not OK
villemejane 0:1477b4630c35 53 */
villemejane 0:1477b4630c35 54 int closing_file(void);
villemejane 0:1477b4630c35 55 /**
villemejane 0:1477b4630c35 56 * Unmounting SD Card and FileSystem
villemejane 0:1477b4630c35 57 *
villemejane 0:1477b4630c35 58 * @return error 1 if OK, -1 if not OK
villemejane 0:1477b4630c35 59 */
villemejane 0:1477b4630c35 60 int unmounting(void);
villemejane 0:1477b4630c35 61
villemejane 0:1477b4630c35 62 FILE *getFile(void);
villemejane 0:1477b4630c35 63
villemejane 0:1477b4630c35 64 private:
villemejane 0:1477b4630c35 65 /* CS Pin of SD Card */
villemejane 0:1477b4630c35 66 PinName __cs;
villemejane 0:1477b4630c35 67 /* Block device of SD Card */
villemejane 0:1477b4630c35 68 SDBlockDevice __blockDevice;
villemejane 0:1477b4630c35 69 /* File system of the SD Card */
villemejane 0:1477b4630c35 70 FATFileSystem __fileSystem;
villemejane 0:1477b4630c35 71 /* File to process */
villemejane 0:1477b4630c35 72 FILE *__f;
villemejane 0:1477b4630c35 73 /* Error during process */
villemejane 0:1477b4630c35 74 int __err;
villemejane 0:1477b4630c35 75 };
villemejane 0:1477b4630c35 76 #endif