HAL cleanup, Teensy 3.1 platform

This commit is contained in:
Scott Lahteine
2019-08-02 07:22:07 -05:00
parent 940c59d9da
commit e85eca2630
12 changed files with 146 additions and 78 deletions

View File

@ -31,12 +31,12 @@
#ifdef ARDUINO_ARCH_SAM
#include "../shared/persistent_store_api.h"
#include "../../inc/MarlinConfig.h"
#if ENABLED(EEPROM_SETTINGS) && NONE(I2C_EEPROM, SPI_EEPROM)
#include "../shared/Marduino.h"
#include "../shared/persistent_store_api.h"
#define EEPROMSize 4096
#define PagesPerGroup 128

View File

@ -19,19 +19,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* Description: HAL for Teensy 3.5 and Teensy 3.6
*/
#pragma once
#define CPU_32_BIT
#include "../shared/Marduino.h"
#include "../math_32bit.h"
#include "../HAL_SPI.h"
#include "../shared/math_32bit.h"
#include "../shared/HAL_SPI.h"
#include "fastio_Teensy.h"
#include "watchdog_Teensy.h"

View File

@ -24,13 +24,10 @@
#include "../shared/persistent_store_api.h"
namespace HAL {
namespace PersistentStore {
bool PersistentStore::access_start() { return true; }
bool PersistentStore::access_finish() { return true; }
bool access_start() { return true; }
bool access_finish() { return true; }
bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
bool PersistentStore::write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
while (size--) {
uint8_t * const p = (uint8_t * const)pos;
uint8_t v = *value;
@ -50,7 +47,7 @@ bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
return false;
}
bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const bool writing/*=true*/) {
bool PersistentStore::read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const bool writing/*=true*/) {
do {
uint8_t c = eeprom_read_byte((uint8_t*)pos);
if (writing) *value = c;
@ -61,8 +58,5 @@ bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const boo
return false;
}
} // PersistentStore
} // HAL
#endif // EEPROM_SETTINGS
#endif // __MK20DX256__

View File

@ -1,50 +0,0 @@
#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
#include "../../inc/MarlinConfig.h"
#if ENABLED(EEPROM_SETTINGS)
#include "../shared/persistent_store_api.h"
namespace HAL {
namespace PersistentStore {
bool access_start() { return true; }
bool access_finish() { return true; }
bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
while (size--) {
uint8_t * const p = (uint8_t * const)pos;
uint8_t v = *value;
// EEPROM has only ~100,000 write cycles,
// so only write bytes that have changed!
if (v != eeprom_read_byte(p)) {
eeprom_write_byte(p, v);
if (eeprom_read_byte(p) != v) {
SERIAL_ECHO_MSG(MSG_ERR_EEPROM_WRITE);
return true;
}
}
crc16(crc, &v, 1);
pos++;
value++;
};
return false;
}
bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const bool writing/*=true*/) {
do {
uint8_t c = eeprom_read_byte((uint8_t*)pos);
if (writing) *value = c;
crc16(crc, &c, 1);
pos++;
value++;
} while (--size);
return false;
}
} // PersistentStore
} // HAL
#endif // EEPROM_SETTINGS
#endif // __MK64FX512__ || __MK66FX1M0__

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef HAL_PINSDEBUG_TEENSY_H
#pragma once
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
@ -103,5 +102,3 @@ bool HAL_pwm_status(int8_t pin) {
}
static void HAL_pwm_details(uint8_t pin) { /* TODO */ }
#endif

View File

@ -39,13 +39,13 @@
// #define MCU_STM32F103ZE // not yet required
// Enable EEPROM Emulation for this board, so that we don't overwrite factory data
// #define I2C_EEPROM // AT24C64
// #define E2END 0x7FFF // 64KB
// #define FLASH_EEPROM_EMULATION 1
// #define E2END 0xFFF // 4KB
// #define E2END uint32(EEPROM_START_ADDRESS + (EEPROM_PAGE_SIZE * 2) - 1)
// #define EEPROM_CHITCHAT
// #define DEBUG_EEPROM_READWRITE
//#define I2C_EEPROM // AT24C64
//#define E2END 0x7FFF // 64KB
//#define FLASH_EEPROM_EMULATION
//#define E2END 0xFFF // 4KB
//#define E2END uint32(EEPROM_START_ADDRESS + (EEPROM_PAGE_SIZE * 2) - 1)
//#define EEPROM_CHITCHAT
//#define DEBUG_EEPROM_READWRITE
//
// Limit Switches