Fixed a bug with how many bytes I was allowing to be written. It mostly works but it writes the chips in reverse...oops

This commit is contained in:
Doug Brown 2011-12-17 10:32:40 -08:00
parent ca84a1d562
commit b052bb62f8

View File

@ -52,7 +52,7 @@ typedef enum ProgrammerCommandState
ReadingByteWaitingForAddress, ReadingByteWaitingForAddress,
ReadingChips, ReadingChips,
ReadingChipsUnableSendError, ReadingChipsUnableSendError,
WritingChips, WritingChips
} ProgrammerCommandState; } ProgrammerCommandState;
typedef enum ProgrammerCommand typedef enum ProgrammerCommand
@ -63,20 +63,20 @@ typedef enum ProgrammerCommand
ReadByte, ReadByte,
ReadChips, ReadChips,
EraseChips, EraseChips,
WriteChips, WriteChips
} ProgrammerCommand; } ProgrammerCommand;
typedef enum ProgrammerReply typedef enum ProgrammerReply
{ {
CommandReplyOK, CommandReplyOK,
CommandReplyError, CommandReplyError,
CommandReplyInvalid, CommandReplyInvalid
} ProgrammerReply; } ProgrammerReply;
typedef enum ComputerReadReply typedef enum ComputerReadReply
{ {
ComputerReadOK, ComputerReadOK,
ComputerReadCancel, ComputerReadCancel
} ComputerReadReply; } ComputerReadReply;
typedef enum ProgrammerReadReply typedef enum ProgrammerReadReply
@ -85,22 +85,22 @@ typedef enum ProgrammerReadReply
ProgrammerReadError, ProgrammerReadError,
ProgrammerReadMoreData, ProgrammerReadMoreData,
ProgrammerReadFinished, ProgrammerReadFinished,
ProgrammerReadConfirmCancel, ProgrammerReadConfirmCancel
} ProgrammerReadReply; } ProgrammerReadReply;
typedef enum ComputerWriteReply typedef enum ComputerWriteReply
{ {
ComputerWriteMore, ComputerWriteMore,
ComputerWriteFinish, ComputerWriteFinish,
ComputerWriteCancel, ComputerWriteCancel
} ComputerWriteReply; } ComputerWriteReply;
typedef enum ProgrammerWriteReply typedef enum ProgrammerWriteReply
{ {
ProgrammerWriteOK, ProgrammerWriteOK,
ProgrammerWriteError, ProgrammerWriteError,
ProgrammerWriteConfirmCancel, ProgrammerWriteConfirmCancel
}; } ProgrammerWriteReply;
static ProgrammerCommandState curCommandState = WaitingForCommand; static ProgrammerCommandState curCommandState = WaitingForCommand;
static uint8_t byteAddressReceiveCount = 0; static uint8_t byteAddressReceiveCount = 0;
@ -274,7 +274,7 @@ void USBSerial_HandleReadingChipsByte(uint8_t byte)
switch (byte) switch (byte)
{ {
case ComputerReadOK: case ComputerReadOK:
if (curReadIndex >= (CHIP_SIZE / READ_CHUNK_SIZE_BYTES)) if (curReadIndex >= (CHIP_SIZE / (READ_CHUNK_SIZE_BYTES/4)))
{ {
SendByte(ProgrammerReadFinished); SendByte(ProgrammerReadFinished);
curCommandState = WaitingForCommand; curCommandState = WaitingForCommand;
@ -330,7 +330,7 @@ void USBSerial_HandleWritingChipsByte(uint8_t byte)
{ {
case ComputerWriteMore: case ComputerWriteMore:
writePosInChunk = 0; writePosInChunk = 0;
if (curWriteIndex < CHIP_SIZE / WRITE_CHUNK_SIZE_BYTES) if (curWriteIndex < CHIP_SIZE / (WRITE_CHUNK_SIZE_BYTES/4))
{ {
SendByte(ProgrammerWriteOK); SendByte(ProgrammerWriteOK);
} }