forked from mfulz_github/qmk_firmware
		
	Fixed issues with EEPROM and FLASH ISP programming in the AVRISP project.
This commit is contained in:
		
							parent
							
								
									b6a4584a19
								
							
						
					
					
						commit
						5f363996e3
					
				| @ -49,6 +49,7 @@ | |||||||
|   *    ranges are specified (thanks to Thomas Bleeker) |   *    ranges are specified (thanks to Thomas Bleeker) | ||||||
|   *  - Fixed CDC and RNDIS host demos and class drivers - bidirectional endpoints should use two seperate pipes, not one half-duplex pipe |   *  - Fixed CDC and RNDIS host demos and class drivers - bidirectional endpoints should use two seperate pipes, not one half-duplex pipe | ||||||
|   *  - Fixed Pipe_IsEndpointBound() not taking the endpoint's direction into account |   *  - Fixed Pipe_IsEndpointBound() not taking the endpoint's direction into account | ||||||
|  |   *  - Fixed EEPROM and FLASH ISP programming in the AVRISP project | ||||||
|   * |   * | ||||||
|   *  \section Sec_ChangeLog091223 Version 091223 |   *  \section Sec_ChangeLog091223 Version 091223 | ||||||
|   * |   * | ||||||
|  | |||||||
| @ -198,6 +198,7 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command) | |||||||
| 			 | 			 | ||||||
| 			/* AVR FLASH addressing requires us to modify the write command based on if we are writing a high
 | 			/* AVR FLASH addressing requires us to modify the write command based on if we are writing a high
 | ||||||
| 			 * or low byte at the current word address */ | 			 * or low byte at the current word address */ | ||||||
|  | 			if (V2Command == CMD_PROGRAM_FLASH_ISP) | ||||||
| 			  Write_Memory_Params.ProgrammingCommands[0] ^= READ_WRITE_HIGH_BYTE_MASK; | 			  Write_Memory_Params.ProgrammingCommands[0] ^= READ_WRITE_HIGH_BYTE_MASK; | ||||||
| 
 | 
 | ||||||
| 			/* Check to see the write completion method, to see if we have a valid polling address */ | 			/* Check to see the write completion method, to see if we have a valid polling address */ | ||||||
| @ -240,16 +241,16 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command) | |||||||
| 			bool    IsOddByte   = (CurrentByte & 0x01); | 			bool    IsOddByte   = (CurrentByte & 0x01); | ||||||
| 			uint8_t ByteToWrite = *(NextWriteByte++); | 			uint8_t ByteToWrite = *(NextWriteByte++); | ||||||
| 			   | 			   | ||||||
| 			if (IsOddByte && (V2Command == CMD_READ_FLASH_ISP)) |  | ||||||
| 			  Write_Memory_Params.ProgrammingCommands[0] |=  READ_WRITE_HIGH_BYTE_MASK; |  | ||||||
| 			else |  | ||||||
| 			  Write_Memory_Params.ProgrammingCommands[0] &= ~READ_WRITE_HIGH_BYTE_MASK;			 |  | ||||||
| 			   |  | ||||||
| 			SPI_SendByte(Write_Memory_Params.ProgrammingCommands[0]); | 			SPI_SendByte(Write_Memory_Params.ProgrammingCommands[0]); | ||||||
| 			SPI_SendByte(CurrentAddress >> 8); | 			SPI_SendByte(CurrentAddress >> 8); | ||||||
| 			SPI_SendByte(CurrentAddress & 0xFF); | 			SPI_SendByte(CurrentAddress & 0xFF); | ||||||
| 			SPI_SendByte(ByteToWrite); | 			SPI_SendByte(ByteToWrite); | ||||||
| 			 | 			 | ||||||
|  | 			/* AVR FLASH addressing requires us to modify the write command based on if we are writing a high
 | ||||||
|  | 			 * or low byte at the current word address */ | ||||||
|  | 			if (V2Command == CMD_PROGRAM_FLASH_ISP) | ||||||
|  | 			  Write_Memory_Params.ProgrammingCommands[0] ^= READ_WRITE_HIGH_BYTE_MASK; | ||||||
|  | 
 | ||||||
| 			if (ByteToWrite != PollValue) | 			if (ByteToWrite != PollValue) | ||||||
| 			{ | 			{ | ||||||
| 				if (IsOddByte && (V2Command == CMD_PROGRAM_FLASH_ISP)) | 				if (IsOddByte && (V2Command == CMD_PROGRAM_FLASH_ISP)) | ||||||
|  | |||||||
| @ -128,7 +128,7 @@ uint8_t ISPTarget_WaitForProgComplete(const uint8_t ProgrammingMode, const uint1 | |||||||
| 				SPI_SendByte(PollAddress >> 8); | 				SPI_SendByte(PollAddress >> 8); | ||||||
| 				SPI_SendByte(PollAddress & 0xFF); | 				SPI_SendByte(PollAddress & 0xFF); | ||||||
| 			} | 			} | ||||||
| 			while ((SPI_TransferByte(0x00) != PollValue) && TimeoutMSRemaining); | 			while ((SPI_TransferByte(0x00) == PollValue) && TimeoutMSRemaining); | ||||||
| 
 | 
 | ||||||
| 			if (!(TimeoutMSRemaining)) | 			if (!(TimeoutMSRemaining)) | ||||||
| 			 ProgrammingStatus = STATUS_CMD_TOUT; | 			 ProgrammingStatus = STATUS_CMD_TOUT; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Dean Camera
						Dean Camera