Replace cast-as-char* byte access of multibyte variables with proper shifts and masks to preserve endianness across different architectures.
This commit is contained in:
		
							parent
							
								
									4b1f6cac75
								
							
						
					
					
						commit
						e0852408de
					
				
					 4 changed files with 9 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -43,9 +43,9 @@ static void TINYNVM_SendPointerAddress(const uint16_t AbsoluteAddress)
 | 
			
		|||
{
 | 
			
		||||
	/* Send the given 16-bit address to the target, LSB first */
 | 
			
		||||
	XPROGTarget_SendByte(TPI_CMD_SSTPR | 0);
 | 
			
		||||
	XPROGTarget_SendByte(((uint8_t*)&AbsoluteAddress)[0]);
 | 
			
		||||
	XPROGTarget_SendByte(AbsoluteAddress & 0xFF);
 | 
			
		||||
	XPROGTarget_SendByte(TPI_CMD_SSTPR | 1);
 | 
			
		||||
	XPROGTarget_SendByte(((uint8_t*)&AbsoluteAddress)[1]);
 | 
			
		||||
	XPROGTarget_SendByte(AbsoluteAddress >> 8);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Sends a SIN command to the target with the specified I/O address, ready for the data byte to be written.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -45,10 +45,10 @@
 | 
			
		|||
static void XMEGANVM_SendAddress(const uint32_t AbsoluteAddress)
 | 
			
		||||
{
 | 
			
		||||
	/* Send the given 32-bit address to the target, LSB first */
 | 
			
		||||
	XPROGTarget_SendByte(((uint8_t*)&AbsoluteAddress)[0]);
 | 
			
		||||
	XPROGTarget_SendByte(((uint8_t*)&AbsoluteAddress)[1]);
 | 
			
		||||
	XPROGTarget_SendByte(((uint8_t*)&AbsoluteAddress)[2]);
 | 
			
		||||
	XPROGTarget_SendByte(((uint8_t*)&AbsoluteAddress)[3]);
 | 
			
		||||
	XPROGTarget_SendByte(AbsoluteAddress &  0xFF);
 | 
			
		||||
	XPROGTarget_SendByte(AbsoluteAddress >> 8);
 | 
			
		||||
	XPROGTarget_SendByte(AbsoluteAddress >> 16);
 | 
			
		||||
	XPROGTarget_SendByte(AbsoluteAddress >> 24);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Sends the given NVM register address to the target.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue