Example #1
0
void COM1_restart()
{
	UINT8 i;
#if (defined __18F8722_H) ||(defined __18F46K22_H)
	UART1_init(UART1_BAUD);
#ifdef UART2_ACTIVE
	UART2_init(UART2_BAUD);
#endif
#else
	UART_init();	//initialize uart
#endif

	for( i = 0 ; i < ACTIVE_USARTS ; i++)
	{
		communication[i].rxPacketIndex = 0;
		communication[i].txPacketLength = 0;
		communication[i].state = COM_START;
		communication[i].txCode = IGNORE;
		communication[i].timeout = TIMEOUT;
		communication[i].prevAppTime = communication[i].curAppTime;
		communication[i].prevState = communication[i].state;
	}

}
Example #2
0
int main(void)
{	
	clock_time_t * myClock=(clock_time_t *) &time_val;
	encoder_init();
	UART2_init(9600);
	clock_init();
	lcd_init();
	serial_printf(UART2_serial,"\nSystem ready\n");
	serial_printf(LCD_serial,"\fPOS %d",encoder_getPosition());
	
	while(1){
		if(encoder_hasChanged()){
			lcd_goto(4,0);
			serial_printf(LCD_serial,"%d  ",encoder_getPosition());
		}
		timer_count=clock_getSeconds();
		if(last_timer_count!=timer_count){
			time_val=clock_getTime();
			lcd_goto(0,1);
			serial_printf(LCD_serial,"%7s:%2d:%2d:%2d",dias[myClock->days],myClock->hours,myClock->minutes,myClock->seconds);
			last_timer_count=timer_count;
		}
	}
}