parent
e2a790b759
commit
22bf774d61
|
@ -1,10 +1,9 @@
|
||||||
/**
|
/**
|
||||||
* Marlin 3D Printer Firmware
|
* Marlin 3D Printer Firmware
|
||||||
*
|
|
||||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
|
*
|
||||||
* Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
|
* Based on Sprinter and grbl.
|
||||||
* Copyright (c) 2016 Victor Perez victor_pv@hotmail.com
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -20,12 +19,19 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of EEPROM settings in SD Card
|
||||||
|
*/
|
||||||
|
|
||||||
#ifdef TARGET_LPC1768
|
#ifdef TARGET_LPC1768
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
#include "../../inc/MarlinConfig.h"
|
||||||
|
|
||||||
#if ENABLED(SDCARD_EEPROM_EMULATION)
|
#if ENABLED(SDCARD_EEPROM_EMULATION)
|
||||||
|
|
||||||
|
//#define DEBUG_SD_EEPROM_EMULATION
|
||||||
|
|
||||||
#include "../shared/eeprom_api.h"
|
#include "../shared/eeprom_api.h"
|
||||||
|
|
||||||
#include <chanfs/diskio.h>
|
#include <chanfs/diskio.h>
|
||||||
|
@ -38,9 +44,11 @@ FATFS fat_fs;
|
||||||
FIL eeprom_file;
|
FIL eeprom_file;
|
||||||
bool eeprom_file_open = false;
|
bool eeprom_file_open = false;
|
||||||
|
|
||||||
|
#define EEPROM_FILENAME "eeprom.dat"
|
||||||
#ifndef MARLIN_EEPROM_SIZE
|
#ifndef MARLIN_EEPROM_SIZE
|
||||||
#define MARLIN_EEPROM_SIZE size_t(0x1000) // 4KiB of Emulated EEPROM
|
#define MARLIN_EEPROM_SIZE size_t(0x1000) // 4KiB of Emulated EEPROM
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }
|
size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }
|
||||||
|
|
||||||
bool PersistentStore::access_start() {
|
bool PersistentStore::access_start() {
|
||||||
|
@ -50,7 +58,7 @@ bool PersistentStore::access_start() {
|
||||||
MSC_Release_Lock();
|
MSC_Release_Lock();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
FRESULT res = f_open(&eeprom_file, "eeprom.dat", FA_OPEN_ALWAYS | FA_WRITE | FA_READ);
|
FRESULT res = f_open(&eeprom_file, EEPROM_FILENAME, FA_OPEN_ALWAYS | FA_WRITE | FA_READ);
|
||||||
if (res) MSC_Release_Lock();
|
if (res) MSC_Release_Lock();
|
||||||
|
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
|
@ -81,18 +89,20 @@ bool PersistentStore::access_finish() {
|
||||||
// This extra chit-chat goes away soon, but is helpful for now
|
// This extra chit-chat goes away soon, but is helpful for now
|
||||||
// to see errors that are happening in read_data / write_data
|
// to see errors that are happening in read_data / write_data
|
||||||
static void debug_rw(const bool write, int &pos, const uint8_t *value, const size_t size, const FRESULT s, const size_t total=0) {
|
static void debug_rw(const bool write, int &pos, const uint8_t *value, const size_t size, const FRESULT s, const size_t total=0) {
|
||||||
PGM_P const rw_str = write ? PSTR("write") : PSTR("read");
|
#if ENABLED(DEBUG_SD_EEPROM_EMULATION)
|
||||||
SERIAL_CHAR(' ');
|
PGM_P const rw_str = write ? PSTR("write") : PSTR("read");
|
||||||
SERIAL_ECHOPGM_P(rw_str);
|
SERIAL_CHAR(' ');
|
||||||
SERIAL_ECHOLNPGM("_data(", pos, ",", value, ",", size, ", ...)");
|
|
||||||
if (total) {
|
|
||||||
SERIAL_ECHOPGM(" f_");
|
|
||||||
SERIAL_ECHOPGM_P(rw_str);
|
SERIAL_ECHOPGM_P(rw_str);
|
||||||
SERIAL_ECHOPGM("()=", s, "\n size=", size, "\n bytes_");
|
SERIAL_ECHOLNPGM("_data(", pos, ",", *value, ",", size, ", ...)");
|
||||||
SERIAL_ECHOLNPGM_P(write ? PSTR("written=") : PSTR("read="), total);
|
if (total) {
|
||||||
}
|
SERIAL_ECHOPGM(" f_");
|
||||||
else
|
SERIAL_ECHOPGM_P(rw_str);
|
||||||
SERIAL_ECHOLNPGM(" f_lseek()=", s);
|
SERIAL_ECHOPGM("()=", s, "\n size=", size, "\n bytes_");
|
||||||
|
SERIAL_ECHOLNPGM_P(write ? PSTR("written=") : PSTR("read="), total);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SERIAL_ECHOLNPGM(" f_lseek()=", s);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// File function return codes for type FRESULT. This goes away soon, but
|
// File function return codes for type FRESULT. This goes away soon, but
|
||||||
|
|
|
@ -38,8 +38,10 @@
|
||||||
#define BOARD_INFO_NAME "Arm'ed"
|
#define BOARD_INFO_NAME "Arm'ed"
|
||||||
#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME
|
#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME
|
||||||
|
|
||||||
#define I2C_EEPROM
|
#if NO_EEPROM_SELECTED
|
||||||
#define MARLIN_EEPROM_SIZE 0x1000 // 4KB
|
#define I2C_EEPROM
|
||||||
|
#define MARLIN_EEPROM_SIZE 0x1000 // 4KB
|
||||||
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// Limit Switches
|
// Limit Switches
|
||||||
|
|
Loading…
Reference in a new issue