Fix word-based addressing for writing EEPROM
This commit is contained in:
parent
2d8882b886
commit
95e99f2ef6
1 changed files with 6 additions and 3 deletions
|
|
@ -488,8 +488,10 @@ byte write_eeprom(int length) {
|
|||
// here is a word address, so we use here*2
|
||||
// this writes byte-by-byte,
|
||||
// page writing may be faster (4 bytes at a time)
|
||||
int start = _addr*2;
|
||||
for (int x = 0; x < length; x++) {
|
||||
spi_transaction(0xC0, 0x00, _addr*2+x, buff[x]);
|
||||
int addr = start + x;
|
||||
spi_transaction(0xC0, (addr >> 8) & 0xFF, addr & 0xFF, buff[x]);
|
||||
delay(45);
|
||||
}
|
||||
return STK_OK;
|
||||
|
|
@ -497,8 +499,9 @@ byte write_eeprom(int length) {
|
|||
|
||||
void program_page() {
|
||||
byte result = STK_FAILED;
|
||||
int length = 256 * getch() + getch();
|
||||
if (length > 256) {
|
||||
unsigned int length = 256 * getch();
|
||||
length += getch();
|
||||
if (length > param.eepromsize) {
|
||||
Serial.write(STK_FAILED);
|
||||
error++;
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue