spiInterface: add read method
This commit is contained in:
parent
a5489e62f8
commit
3babd5d07d
|
|
@ -140,6 +140,25 @@ bool SPIInterface::write(uint32_t offset, uint8_t *data, uint32_t len,
|
||||||
return ret && ret2;
|
return ret && ret2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SPIInterface::read(uint8_t *data, uint32_t base_addr, uint32_t len)
|
||||||
|
{
|
||||||
|
bool ret = true;
|
||||||
|
/* enable SPI flash access */
|
||||||
|
if (!prepare_flash_access())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
SPIFlash flash(this, false, _spif_verbose);
|
||||||
|
ret = flash.read(base_addr, data, len);
|
||||||
|
} catch (std::exception &e) {
|
||||||
|
printError(e.what());
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* reload bitstream */
|
||||||
|
return post_flash_access() && ret == 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool SPIInterface::dump(uint32_t base_addr, uint32_t len)
|
bool SPIInterface::dump(uint32_t base_addr, uint32_t len)
|
||||||
{
|
{
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#define SRC_SPIINTERFACE_HPP_
|
#define SRC_SPIINTERFACE_HPP_
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -44,6 +45,17 @@ class SPIInterface {
|
||||||
*/
|
*/
|
||||||
bool write(uint32_t offset, uint8_t *data, uint32_t len,
|
bool write(uint32_t offset, uint8_t *data, uint32_t len,
|
||||||
bool unprotect_flash);
|
bool unprotect_flash);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief read flash offset byte starting at base_addr and
|
||||||
|
* store into data buffer
|
||||||
|
* \param[in] data: buffer where to store
|
||||||
|
* \param[in] base_addr: offset into flash
|
||||||
|
* \param[in] len: byte len to read
|
||||||
|
* \return false when something fails
|
||||||
|
*/
|
||||||
|
bool read(uint8_t *data, uint32_t base_addr, uint32_t len);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief read flash offset byte starting at base_addr and
|
* \brief read flash offset byte starting at base_addr and
|
||||||
* store into filename
|
* store into filename
|
||||||
|
|
@ -103,8 +115,8 @@ class SPIInterface {
|
||||||
bool _spif_verify;
|
bool _spif_verify;
|
||||||
bool _skip_load_bridge;
|
bool _skip_load_bridge;
|
||||||
bool _skip_reset; /*!< don't reset the device after write */
|
bool _skip_reset; /*!< don't reset the device after write */
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _spif_filename;
|
std::string _spif_filename;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif // SRC_SPIINTERFACE_HPP_
|
#endif // SRC_SPIINTERFACE_HPP_
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue