for DISCO-F769NI based on BD_SD_DISCO_F746NG library by Roy Krikke
Dependents: DISCO-F769NI_several_example DISCO-F769NI_BD_SD_Card_Control
Revision 1:0d436ebd49be, committed 2019-07-25
- Comitter:
- kenjiArai
- Date:
- Thu Jul 25 19:39:05 2019 +0000
- Parent:
- 0:c0eba637f7c7
- Commit message:
- modified is_valid_read(), is_valid_program(), is_valid_erase and get_type() functions
Changed in this revision
SDBlockDeviceDISCOF769NI.cpp | Show annotated file Show diff for this revision Revisions of this file |
SDBlockDeviceDISCOF769NI.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r c0eba637f7c7 -r 0d436ebd49be SDBlockDeviceDISCOF769NI.cpp --- a/SDBlockDeviceDISCOF769NI.cpp Sat Apr 07 02:06:27 2018 +0000 +++ b/SDBlockDeviceDISCOF769NI.cpp Thu Jul 25 19:39:05 2019 +0000 @@ -19,8 +19,8 @@ https://os.mbed.com/users/roykrikke/code/BD_SD_DISCO_F746NG/ https://os.mbed.com/users/roykrikke/ - Modified by K.Arai / JH1PJL April 5th, 2018 - + Modified by K.Arai / JH1PJL July 22nd, 2019 + All of following keywords are changed F746NG -> F769NI 32746g -> 32f769i @@ -29,18 +29,6 @@ #include "SDBlockDeviceDISCOF769NI.h" #include "mbed_debug.h" -/* Required version: 5.5.0 and above */ -#if defined(MBED_MAJOR_VERSION) && MBED_MAJOR_VERSION >= 5 -#if (MBED_VERSION < MBED_ENCODE_VERSION(5,5,0)) -#error "Incompatible mbed-os version detected! Required 5.5.0 and above" -#endif -#else -#warning "mbed-os version 5.5.0 or above required" -#endif - -/* Required version: 5.5.0 and above */ -#warning "Block device class BD_SD_DISCO_F769NI is depending on BSP_DISCO_F769NI libary (Revision 3:145e71 with date 06 Jul 2017)" - #define SD_DBG 0 /*!< 1 - Enable debugging */ /** Enum of standard error codes
diff -r c0eba637f7c7 -r 0d436ebd49be SDBlockDeviceDISCOF769NI.h --- a/SDBlockDeviceDISCOF769NI.h Sat Apr 07 02:06:27 2018 +0000 +++ b/SDBlockDeviceDISCOF769NI.h Thu Jul 25 19:39:05 2019 +0000 @@ -19,8 +19,8 @@ https://os.mbed.com/users/roykrikke/code/BD_SD_DISCO_F746NG/ https://os.mbed.com/users/roykrikke/ - Modified by K.Arai / JH1PJL April 5th, 2018 - + Modified by K.Arai / JH1PJL July 22nd, 2019 + All of following keywords are changed F746NG -> F769NI 32746g -> 32f769i @@ -181,6 +181,56 @@ */ virtual bd_size_t size() const; +//--------- July 23rd, 2019 + + /** Convenience function for checking block read validity + * + * @param addr Address of block to begin reading from + * @param size Size to read in bytes + * @return True if read is valid for underlying block device + */ + virtual bool is_valid_read(bd_addr_t addr, bd_size_t size) const + { + return (addr % get_read_size() == 0 && + size % get_read_size() == 0 && + addr + size <= this->size()); + } + + /** Convenience function for checking block program validity + * + * @param addr Address of block to begin writing to + * @param size Size to write in bytes + * @return True if program is valid for underlying block device + */ + virtual bool is_valid_program(bd_addr_t addr, bd_size_t size) const + { + return (addr % get_program_size() == 0 && + size % get_program_size() == 0 && + addr + size <= this->size()); + } + + /** Convenience function for checking block erase validity + * + * @param addr Address of block to begin erasing + * @param size Size to erase in bytes + * @return True if erase is valid for underlying block device + */ + virtual bool is_valid_erase(bd_addr_t addr, bd_size_t size) const + { + return 1;// Dummy implementation -> Please modify yourself in the future + } + + /** Get the BlockDevice class type. + * + * @return A string represent the BlockDevice class type. + */ + virtual const char *get_type() const + { + return "microSD"; + } + +//---------- + private: uint8_t _card_type; bd_size_t _read_size; @@ -195,12 +245,14 @@ bool _is_initialized; virtual void - lock () { + lock () + { _mutex.lock(); } virtual void - unlock() { + unlock() + { _mutex.unlock (); }