Example #1
0
uint8_t usart_sendmotor(void){
	usart_sendbyte(motor1_state);
	_delay_ms(1);
	usart_sendbyte(motor2_state);
	_delay_ms(1);
	return(1);
}
Example #2
0
void print(char *str)
{
	char c;
	while ((c=*(str++))!=0) { // C drunken kung-fu
		usart_sendbyte(c);
	}
}
Example #3
0
void  console_putc(char ch)
{
	if(console_dev){
		usart_sendbyte(console_dev,ch);
	}else{
		if(console_fifo==NULL)
			console_alloc_kfifo();
		if(console_fifo){
			kfifo_putc(console_fifo,ch);
		}
	}
}
Example #4
0
int main(void){
	ddr_setup();		//set up pins
	usart_setup(BAUD);	//set up USART with defined Baudrate

	uint8_t adc_data_xaxis = 0;	//hold x tilt data
	uint8_t adc_data_yaxis = 0;	//hold y tilt data

	uint8_t motor1_prev = 0;	//hold previous m1 state
	uint8_t motor2_prev = 0;	//hold previous m2 state
	uint8_t mtr_prev = 0;


	while(1){
		_delay_ms(1);				//just wait
		adc_data_xaxis = adc_read(X_AXIS);	//read x tilt
		adc_data_yaxis = adc_read(Y_AXIS);	//read y tilt


		set_mtr_state(adc_data_xaxis, adc_data_yaxis);
		//if ( mtr_state != mtr_prev){
		usart_sendbyte(mtr_state);
		//}
		mtr_prev = mtr_state;
		if (PINA & (1<<0)){
			usart_sendbyte(FORWARD);
		}
		else if (PINA & (1<<1)){
			usart_sendbyte(BACKWARD);
		}
		else if (PINA & (1<<2)){
			usart_sendbyte(RIGHT);
		}
		else if (PINA & (1<<3)){
			usart_sendbyte(LEFT);
		}
	}


}