Generic SPI as EEPROM changes.
This commit is contained in:
parent
3a73508cc3
commit
106b75509d
|
@ -20,14 +20,14 @@ lib_deps = EEPROM
|
|||
platform=teensy
|
||||
board=teensy35
|
||||
framework=arduino
|
||||
lib_deps = EEPROM, FlexCAN
|
||||
lib_deps = EEPROM, FlexCAN, SD
|
||||
|
||||
[env:DropBearT]
|
||||
platform=teensy
|
||||
board=teensy35
|
||||
framework=arduino
|
||||
lib_deps = EEPROM, FlexCAN
|
||||
build_flags = -DUSE_MC33810
|
||||
lib_deps = EEPROM, FlexCAN, SD
|
||||
build_flags = -DUSE_MC33810 -DUSE_SPI_EEPROM
|
||||
|
||||
[env:teensy40]
|
||||
platform=teensy
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#define micros_safe() micros() //timer5 method is not used on anything but AVR, the micros_safe() macro is simply an alias for the normal micros()
|
||||
#if defined(SRAM_AS_EEPROM)
|
||||
#define EEPROM_LIB_H "src/BackupSram/BackupSramAsEEPROM.h"
|
||||
#elif defined(SPIFLASH_AS_EEPROM)
|
||||
#elif defined(USE_SPI_FLASH)
|
||||
#define EEPROM_LIB_H "src/SPIAsEEPROM/SPIAsEEPROM.h"
|
||||
#else
|
||||
#define EEPROM_LIB_H <EEPROM.h>
|
||||
|
|
|
@ -15,7 +15,11 @@
|
|||
#define BOARD_DIGITAL_GPIO_PINS 34
|
||||
#define BOARD_NR_GPIO_PINS 34
|
||||
#define USE_SERIAL3
|
||||
#ifdef USE_SPI_EEPROM
|
||||
#define EEPROM_LIB_H "src/SPIAsEEPROM/SPIAsEEPROM.h"
|
||||
#else
|
||||
#define EEPROM_LIB_H <EEPROM.h>
|
||||
#endif
|
||||
|
||||
#define micros_safe() micros() //timer5 method is not used on anything but AVR, the micros_safe() macro is simply an alias for the normal micros()
|
||||
|
||||
|
|
|
@ -1066,9 +1066,12 @@ byte pinFlex; //Pin with the flex sensor attached
|
|||
byte pinBaro; //Pin that an external barometric pressure sensor is attached to (If used)
|
||||
byte pinResetControl; // Output pin used control resetting the Arduino
|
||||
#ifdef USE_MC33810
|
||||
//If the MC33810 IC\s are in use, these are the chip select pins
|
||||
byte pinMC33810_1_CS;
|
||||
byte pinMC33810_2_CS;
|
||||
//If the MC33810 IC\s are in use, these are the chip select pins
|
||||
byte pinMC33810_1_CS;
|
||||
byte pinMC33810_2_CS;
|
||||
#endif
|
||||
#ifdef USE_SPI_EEPROM
|
||||
byte pinSPIFlash_CS;
|
||||
#endif
|
||||
|
||||
/* global variables */ // from speeduino.ino
|
||||
|
|
|
@ -1695,7 +1695,30 @@ void setPinMapping(byte boardID)
|
|||
#ifdef USE_MC33810
|
||||
pinMC33810_1_CS = 10;
|
||||
pinMC33810_2_CS = 9;
|
||||
|
||||
//Pin alignment to the MC33810 outputs
|
||||
MC33810_BIT_INJ1 = 3;
|
||||
MC33810_BIT_INJ2 = 1;
|
||||
MC33810_BIT_INJ3 = 0;
|
||||
MC33810_BIT_INJ4 = 2;
|
||||
MC33810_BIT_IGN1 = 5;
|
||||
MC33810_BIT_IGN2 = 6;
|
||||
MC33810_BIT_IGN3 = 7;
|
||||
MC33810_BIT_IGN4 = 8;
|
||||
MC33810_BIT_INJ5 = 3;
|
||||
MC33810_BIT_INJ6 = 1;
|
||||
MC33810_BIT_INJ7 = 0;
|
||||
MC33810_BIT_INJ8 = 2;
|
||||
MC33810_BIT_IGN5 = 5;
|
||||
MC33810_BIT_IGN6 = 6;
|
||||
MC33810_BIT_IGN7 = 7;
|
||||
MC33810_BIT_IGN8 = 8;
|
||||
#endif
|
||||
|
||||
#ifdef USE_SPI_EEPROM
|
||||
pinSPIFlash_CS = 6;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
break;
|
||||
|
||||
|
@ -2094,6 +2117,11 @@ void setPinMapping(byte boardID)
|
|||
initMC33810();
|
||||
#endif
|
||||
|
||||
#ifdef USE_SPI_EEPROM
|
||||
//We need to send the flash CS (SS) pin if we're using SPI flash. It cannot read from globals.h
|
||||
EEPROM.begin(pinSPIFlash_CS);
|
||||
#endif
|
||||
|
||||
tach_pin_port = portOutputRegister(digitalPinToPort(pinTachOut));
|
||||
tach_pin_mask = digitalPinToBitMask(pinTachOut);
|
||||
pump_pin_port = portOutputRegister(digitalPinToPort(pinFuelPump));
|
||||
|
|
|
@ -26,23 +26,26 @@
|
|||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if defined(CORE_STM32_OFFICIAL) && defined(SPIFLASH_AS_EEPROM)
|
||||
//#if defined(CORE_STM32_OFFICIAL) && defined(SPIFLASH_AS_EEPROM)
|
||||
#if defined(USE_SPI_EEPROM)
|
||||
|
||||
#include "SPIAsEEPROM.h"
|
||||
#include "SPI.h"
|
||||
//#include "globals.h"
|
||||
|
||||
SPIAsEEPROM::SPIAsEEPROM()
|
||||
{
|
||||
pinMode(PB0, OUTPUT);
|
||||
//pinMode(PB0, OUTPUT);
|
||||
magicbuf[0] = MAGICNUMBER1;
|
||||
magicbuf[1] = MAGICNUMBER2;
|
||||
magicbuf[2] = MAGICNUMBER3;
|
||||
magicbuf[3] = 0x00;
|
||||
|
||||
}
|
||||
uint8_t SPIAsEEPROM::begin() {
|
||||
|
||||
SpiFlashAvialable = winbondSPIFlash.begin(_W25Q16,SPI,PB0);
|
||||
uint8_t SPIAsEEPROM::begin(uint8_t pinSPIFlash_CS=6)
|
||||
{
|
||||
pinMode(pinSPIFlash_CS, OUTPUT);
|
||||
SpiFlashAvialable = winbondSPIFlash.begin(_W25Q16,SPI, pinSPIFlash_CS);
|
||||
uint8_t formatted = 0;
|
||||
if(SpiFlashAvialable){
|
||||
//check for magic numbers
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
#ifndef SPI_AS_EEPROM_H
|
||||
#define SPI_AS_EEPROM_H
|
||||
|
||||
#if defined(CORE_STM32_OFFICIAL) && defined(SPIFLASH_AS_EEPROM)
|
||||
//#if defined(CORE_STM32_OFFICIAL) && defined(SPIFLASH_AS_EEPROM)
|
||||
#if defined(USE_SPI_EEPROM)
|
||||
|
||||
#define FLASHSIZEUSED 1757184 //must be a multiple of sectorsize //1757184 = 6006 bytes of EEPROM
|
||||
#define BYTESPERSECTOR 14
|
||||
|
@ -63,11 +64,12 @@ class SPIAsEEPROM {
|
|||
uint32_t infoFlashAddress;
|
||||
uint8_t writeMagicNumber(uint16_t sectorNumber);
|
||||
uint16_t count(uint8_t buf[FLASH_PAGESIZE/BITS_PER_BYTE]);
|
||||
uint8_t pinSPIFlash_CS;
|
||||
|
||||
public:
|
||||
|
||||
SPIAsEEPROM();
|
||||
uint8_t begin();
|
||||
uint8_t begin(uint8_t pinSPIFlash_CS);
|
||||
uint8_t formatFlashForUse();
|
||||
uint8_t read(uint16_t addressEEPROM);
|
||||
int8_t write(uint16_t addressEEPROM, uint8_t val);
|
||||
|
|
Loading…
Reference in New Issue