|  |  | @ -222,7 +222,8 @@ ISR(UART_TRANSMIT_COMPLETE_INTERRUPT) | 
			
		
	
		
		
			
				
					
					|  |  |  | 	modbusReset(); |  |  |  | 	modbusReset(); | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | //TODO
 |  |  |  | const uint16_t bsel = 208; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | const int8_t bscale = 0; | 
			
		
	
		
		
			
				
					
					|  |  |  | void modbusInit(void) |  |  |  | void modbusInit(void) | 
			
		
	
		
		
			
				
					
					|  |  |  | { |  |  |  | { | 
			
		
	
		
		
			
				
					
					|  |  |  | #ifndef __AVR_ATxmega32A4__ |  |  |  | #ifndef __AVR_ATxmega32A4__ | 
			
		
	
	
		
		
			
				
					|  |  | @ -240,12 +241,28 @@ void modbusInit(void) | 
			
		
	
		
		
			
				
					
					|  |  |  | 	transceiver_rxen(); |  |  |  | 	transceiver_rxen(); | 
			
		
	
		
		
			
				
					
					|  |  |  | 	#endif |  |  |  | 	#endif | 
			
		
	
		
		
			
				
					
					|  |  |  | 	BusState=(1<<TimerActive); |  |  |  | 	BusState=(1<<TimerActive); | 
			
		
	
		
		
			
				
					
					|  |  |  | #elif |  |  |  | #else | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     //BRR
 |  |  |  |     //8bit
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     //RX, TX enable
 |  |  |  |     USARTD0.CTRLC = USART_CHSIZE0_bm | USART_CHSIZE1_bm; | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //38400
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     USARTD0.BAUDCTRLA = bsel; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     USARTD0.BAUDCTRLB = 0 | (bsel >> 8) | (bscale << USART_BSCALE0_bp); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     USARTD0.CTRLB = USART_TXEN_bm | USART_RXEN_bm; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     //Interrupt enable (levels)
 |  |  |  |     //Interrupt enable (levels)
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     //Physical type
 |  |  |  |     USARTD0.CTRLA |= USART_RXCINTLVL_HI_gc; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     //Busstate
 |  |  |  |     USARTD0.CTRLA |= USART_TXCINTLVL_HI_gc; | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     PORTD_OUTSET = PIN3_bm; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     PORTD_DIRSET = PIN3_bm; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     PORTD_OUTCLR = PIN2_bm; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     PORTD_DIRCLR = PIN2_bm; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //TODO Physical type 485
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     BusState=(1<<TimerActive); | 
			
		
	
		
		
			
				
					
					|  |  |  | #endif |  |  |  | #endif | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -267,6 +284,7 @@ void modbusSendMessage(unsigned char packtop) | 
			
		
	
		
		
			
				
					
					|  |  |  | #ifndef __AVR_ATxmega32A4__ |  |  |  | #ifndef __AVR_ATxmega32A4__ | 
			
		
	
		
		
			
				
					
					|  |  |  |     UART_CONTROL|=(1<<UART_UDRIE); |  |  |  |     UART_CONTROL|=(1<<UART_UDRIE); | 
			
		
	
		
		
			
				
					
					|  |  |  | #else |  |  |  | #else | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //TODO use define for usartd
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     USARTD0_CTRLA |= USART_DREINTLVL_HI_gc; |  |  |  |     USARTD0_CTRLA |= USART_DREINTLVL_HI_gc; | 
			
		
	
		
		
			
				
					
					|  |  |  | #endif |  |  |  | #endif | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |