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

Dependents:   PrV_SDCard

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SDCard.h Source File

SDCard.h

00001 /****************************************************************************/
00002 /*  SDCard - Library for Nucleo                                             */
00003 /****************************************************************************/
00004 /*  LEnsE / Julien VILLEMEJANE       /   Institut d'Optique Graduate School */
00005 /****************************************************************************/
00006 /*  Pins                                                                    */
00007 /*      USBTX, USBRX    RS232 communication with computer                   */
00008 /*      D11, D12, D13   SPI communication with SD Card                      */
00009 /*      D4              CS of SD Card                                       */
00010 /****************************************************************************/
00011 /*  Tested on L476RG                                                        */
00012 /****************************************************************************/
00013 #ifndef RPLIDAR_H
00014 #define RPLIDAR_H
00015 
00016 #include "mbed.h"
00017 // Block devices
00018 #include "SDBlockDevice.h"
00019 // File systems
00020 #include "FATFileSystem.h"
00021 
00022 class SDCard
00023 {
00024 public:
00025     /**
00026     *   Constructor
00027     *
00028     * @param miso   SPI communication for SD Card / MISO pin
00029     * @param mosi   SPI communication for SD Card / MOSI pin
00030     * @param sck    SPI communication for SD Card / SCK pin
00031     * @param cs     SPI communication for SD Card / CS pin
00032     */
00033     SDCard(PinName miso, PinName mosi, PinName sck, PinName cs);
00034 
00035     /**
00036     *   Mounting SD Card and FileSystem
00037     *
00038     * @return error   1 if OK, -1 if not OK
00039     */
00040     int mounting(void);
00041     /**
00042     *   Opening file on SD Card
00043     *
00044     * @param path   directory of the file
00045     * @param file   name of the file with extension
00046     * @return error 1 if OK, -1 if not OK
00047     */
00048     int opening_file(char *path, char* filename);
00049     /**
00050     *   Closing file on SD Card
00051     *
00052     * @return error   1 if OK, -1 if not OK
00053     */
00054     int closing_file(void);
00055     /**
00056     *   Unmounting SD Card and FileSystem
00057     *
00058     * @return error   1 if OK, -1 if not OK
00059     */
00060     int unmounting(void);
00061     
00062     FILE *getFile(void);
00063 
00064 private:
00065     /* CS Pin of SD Card */
00066     PinName     __cs;
00067     /* Block device of SD Card */
00068     SDBlockDevice   __blockDevice;
00069     /* File system of the SD Card */
00070     FATFileSystem   __fileSystem;
00071     /* File to process */
00072     FILE *__f;
00073     /* Error during process */
00074     int __err;
00075 };
00076 #endif