Send address bytes to the EEPROM in the right order.
This commit is contained in:
@@ -17,6 +17,7 @@ static uint16_t eepromStartAddress;
|
||||
static uint16_t sourceLength;
|
||||
static uint8_t writeLength;
|
||||
static bool isReadSent;
|
||||
static uint8_t addressBuffer[EEPROM_ADDRESS_LENGTH];
|
||||
|
||||
static status_t i2cAsyncWrite(uint8_t *data, size_t dataSize)
|
||||
{
|
||||
@@ -40,8 +41,8 @@ static status_t writePage()
|
||||
{
|
||||
static uint8_t buffer[EEPROM_BUFFER_SIZE];
|
||||
uint16_t targetEepromOffset = sourceOffset + eepromStartAddress;
|
||||
buffer[0] = targetEepromOffset & 0xff;
|
||||
buffer[1] = targetEepromOffset >> 8;
|
||||
buffer[0] = targetEepromOffset >> 8;
|
||||
buffer[1] = targetEepromOffset & 0xff;
|
||||
writeLength = MIN(sourceLength - sourceOffset, EEPROM_PAGE_SIZE);
|
||||
memcpy(buffer+EEPROM_ADDRESS_LENGTH, sourceBuffer+sourceOffset, writeLength);
|
||||
status_t status = i2cAsyncWrite(buffer, writeLength+EEPROM_ADDRESS_LENGTH);
|
||||
@@ -99,12 +100,14 @@ status_t EEPROM_LaunchTransfer(eeprom_transfer_t transferType)
|
||||
bool isHardwareConfig = CurrentEepromTransfer == EepromTransfer_ReadHardwareConfiguration ||
|
||||
CurrentEepromTransfer == EepromTransfer_WriteHardwareConfiguration;
|
||||
eepromStartAddress = isHardwareConfig ? 0 : HARDWARE_CONFIG_SIZE;
|
||||
addressBuffer[0] = eepromStartAddress >> 8;
|
||||
addressBuffer[1] = eepromStartAddress & 0xff;
|
||||
|
||||
switch (transferType) {
|
||||
case EepromTransfer_ReadHardwareConfiguration:
|
||||
case EepromTransfer_ReadUserConfiguration:
|
||||
isReadSent = false;
|
||||
LastEepromTransferStatus = i2cAsyncWrite((uint8_t*)&eepromStartAddress, EEPROM_ADDRESS_LENGTH);
|
||||
LastEepromTransferStatus = i2cAsyncWrite(addressBuffer, EEPROM_ADDRESS_LENGTH);
|
||||
break;
|
||||
case EepromTransfer_WriteHardwareConfiguration:
|
||||
case EepromTransfer_WriteUserConfiguration:
|
||||
|
||||
Reference in New Issue
Block a user