All pastes #109544 Raw Edit

Stuff

public text v1 · immutable
·published 2006-08-01 04:33 UTC
rendered paste body
void Send_RC_Packet(void)

{
	uint8_t left_encoder_high;
	uint8_t left_encoder_low;
	uint8_t right_encoder_high;
	uint8_t right_encoder_low;
	uint8_t heading_high;
	uint8_t heading_low;
	
	USART_Transmit(0x00);
	// Initialize packet
	packet[0]	=	"\0";
	

	// Get the current number of left encoder

	// clicks

	left_encoder_clicks	=	Left_Encoder_Count();

	
	// Split it into a high and low byte
	left_encoder_high	=	left_encoder_clicks >> 8;
	left_encoder_low	=	left_encoder_clicks << 8;
	
	USART_Transmit(0x01);
	

	// Get the current number of right encoder

	// clicks

	right_encoder_clicks =	Right_Encoder_Count();

	
	// Split into high and low byte
	right_encoder_high	=	right_encoder_clicks >> 8;
	right_encoder_low	=	right_encoder_clicks << 8;
	
	
	// Split heading into high and low
	heading_high	=	current_heading >> 8;
	heading_low	=	current_heading << 8;
	
	USART_Transmit(0x02);
	

	// Send two starting bits, to tell the receiving uC

	// that a data packet is coming.

	strcat(packet, 0x00);
	strcat(packet, 0x00);

	

	// Left encoder value

	strcat(packet, left_encoder_high);

	strcat(packet, left_encoder_low);
	

	// Right encoder value

	strcat(packet, right_encoder_high);
	strcat(packet, right_encoder_low);
	
	// Heading
	strcat(packet, heading_high);
	strcat(packet, heading_low);
	

	// Ending bit, to tell the receiving uC that data

	// transmission is over.

	strcat(packet, 0xFF);
	
	USART_Transmit(0x03);
	
	// Send packet
	USART_Transmit(packet);

}