update code base to Marlin 2.0.9.2
This commit is contained in:
69
Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp
Executable file → Normal file
69
Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp
Executable file → Normal file
@@ -16,7 +16,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -32,53 +32,44 @@
|
||||
#if ENABLED(SDCARD_EEPROM_EMULATION)
|
||||
|
||||
#include "../shared/eeprom_api.h"
|
||||
#include "../../sd/cardreader.h"
|
||||
|
||||
#ifndef E2END
|
||||
#define E2END 0xFFF // 4KB
|
||||
#define EEPROM_FILENAME "eeprom.dat"
|
||||
|
||||
#ifndef MARLIN_EEPROM_SIZE
|
||||
#define MARLIN_EEPROM_SIZE 0x1000 // 4KB
|
||||
#endif
|
||||
#define HAL_EEPROM_SIZE (E2END + 1)
|
||||
size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }
|
||||
|
||||
#define _ALIGN(x) __attribute__ ((aligned(x))) // SDIO uint32_t* compat.
|
||||
static char _ALIGN(4) HAL_eeprom_data[HAL_EEPROM_SIZE];
|
||||
static char _ALIGN(4) HAL_eeprom_data[MARLIN_EEPROM_SIZE];
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
bool PersistentStore::access_start() {
|
||||
if (!card.isMounted()) return false;
|
||||
|
||||
#include "../../sd/cardreader.h"
|
||||
SdFile file, root = card.getroot();
|
||||
if (!file.open(&root, EEPROM_FILENAME, O_RDONLY))
|
||||
return true; // false aborts the save
|
||||
|
||||
#define EEPROM_FILENAME "eeprom.dat"
|
||||
int bytes_read = file.read(HAL_eeprom_data, MARLIN_EEPROM_SIZE);
|
||||
if (bytes_read < 0) return false;
|
||||
for (; bytes_read < MARLIN_EEPROM_SIZE; bytes_read++)
|
||||
HAL_eeprom_data[bytes_read] = 0xFF;
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PersistentStore::access_start() {
|
||||
if (!card.isMounted()) return false;
|
||||
bool PersistentStore::access_finish() {
|
||||
if (!card.isMounted()) return false;
|
||||
|
||||
SdFile file, root = card.getroot();
|
||||
if (!file.open(&root, EEPROM_FILENAME, O_RDONLY))
|
||||
return true; // false aborts the save
|
||||
|
||||
int bytes_read = file.read(HAL_eeprom_data, HAL_EEPROM_SIZE);
|
||||
if (bytes_read < 0) return false;
|
||||
for (; bytes_read < HAL_EEPROM_SIZE; bytes_read++)
|
||||
HAL_eeprom_data[bytes_read] = 0xFF;
|
||||
SdFile file, root = card.getroot();
|
||||
int bytes_written = 0;
|
||||
if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC)) {
|
||||
bytes_written = file.write(HAL_eeprom_data, MARLIN_EEPROM_SIZE);
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PersistentStore::access_finish() {
|
||||
if (!card.isMounted()) return false;
|
||||
|
||||
SdFile file, root = card.getroot();
|
||||
int bytes_written = 0;
|
||||
if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC)) {
|
||||
bytes_written = file.write(HAL_eeprom_data, HAL_EEPROM_SIZE);
|
||||
file.close();
|
||||
}
|
||||
return (bytes_written == HAL_EEPROM_SIZE);
|
||||
}
|
||||
|
||||
#else // !SDSUPPORT
|
||||
|
||||
#error "Please define SPI_EEPROM (in Configuration.h) or disable EEPROM_SETTINGS."
|
||||
|
||||
#endif // !SDSUPPORT
|
||||
return (bytes_written == MARLIN_EEPROM_SIZE);
|
||||
}
|
||||
|
||||
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
|
||||
for (size_t i = 0; i < size; i++)
|
||||
@@ -88,7 +79,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uint16_t *crc, const bool writing/*=true*/) {
|
||||
bool PersistentStore::read_data(int &pos, uint8_t *value, const size_t size, uint16_t *crc, const bool writing/*=true*/) {
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
uint8_t c = HAL_eeprom_data[pos + i];
|
||||
if (writing) value[i] = c;
|
||||
@@ -98,7 +89,5 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uin
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t PersistentStore::capacity() { return HAL_EEPROM_SIZE; }
|
||||
|
||||
#endif // SDCARD_EEPROM_EMULATION
|
||||
#endif // __STM32F1__
|
||||
|
Reference in New Issue
Block a user