Refine EEPROM types / flags (#17772)
This commit is contained in:
30
Marlin/src/HAL/shared/eeprom_if.h
Normal file
30
Marlin/src/HAL/shared/eeprom_if.h
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
//
|
||||
// EEPROM
|
||||
//
|
||||
void eeprom_write_byte(uint8_t *pos, unsigned char value);
|
||||
uint8_t eeprom_read_byte(uint8_t *pos);
|
||||
void eeprom_read_block(void *__dst, const void *__src, size_t __n);
|
||||
void eeprom_update_block(const void *__src, void *__dst, size_t __n);
|
@ -21,20 +21,19 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description: functions for I2C connected external EEPROM.
|
||||
* Not platform dependent.
|
||||
*
|
||||
* TODO: Some platform Arduino libraries define these functions
|
||||
* so Marlin needs to add a glue layer to prevent the conflict.
|
||||
* Platform-independent Arduino functions for I2C EEPROM.
|
||||
* Enable USE_SHARED_EEPROM if not supplied by the framework.
|
||||
*/
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(I2C_EEPROM)
|
||||
#if BOTH(USE_SHARED_EEPROM, I2C_EEPROM)
|
||||
|
||||
#include "../HAL.h"
|
||||
#include <Wire.h>
|
||||
|
||||
#include "eeprom_if.h"
|
||||
|
||||
#ifndef EEPROM_WRITE_DELAY
|
||||
#define EEPROM_WRITE_DELAY 5
|
||||
#endif
|
||||
@ -126,4 +125,4 @@ void eeprom_read_block(void* pos, const void *__dst, size_t n) {
|
||||
if (Wire.available()) *((uint8_t*)pos + c) = Wire.read();
|
||||
}
|
||||
|
||||
#endif // I2C_EEPROM
|
||||
#endif // USE_SHARED_EEPROM && I2C_EEPROM
|
@ -21,15 +21,16 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description: functions for SPI connected external EEPROM.
|
||||
* Not platform dependent.
|
||||
* Platform-independent Arduino functions for SPI EEPROM.
|
||||
* Enable USE_SHARED_EEPROM if not supplied by the framework.
|
||||
*/
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(SPI_EEPROM)
|
||||
#if BOTH(USE_SHARED_EEPROM, SPI_EEPROM)
|
||||
|
||||
#include "../HAL.h"
|
||||
#include "eeprom_if.h"
|
||||
|
||||
#define CMD_WREN 6 // WREN
|
||||
#define CMD_READ 2 // WRITE
|
||||
@ -119,4 +120,4 @@ void eeprom_update_block(const void* src, void* eeprom_address, size_t n) {
|
||||
delay(EEPROM_WRITE_DELAY); // wait for page write to complete
|
||||
}
|
||||
|
||||
#endif // SPI_EEPROM
|
||||
#endif // USE_SHARED_EEPROM && I2C_EEPROM
|
Reference in New Issue
Block a user