void LXSAMD21DMX::startOutput ( void ) {
	if ( _direction_pin != DIRECTION_PIN_NOT_USED ) {
		digitalWrite(_direction_pin, HIGH);
	}

	if ( _interrupt_status == ISR_INPUT_ENABLED ) {
		stop();
	}
	
	if ( _interrupt_status == ISR_DISABLED ) {	//prevent messing up sequence if already started...
	  SerialDMX.begin(DMX_BREAK_BAUD, (uint8_t)SERIAL_8N2);
  
	  // Assign pin mux to SERCOM functionality (must come after SerialDMX.begin)
	  pinPeripheral(PIN_DMX_RX, PIO_SERCOM_ALT);
	  pinPeripheral(PIN_DMX_TX, PIO_SERCOM_ALT);
	  
	  _interrupt_status = ISR_OUTPUT_ENABLED;
	  _shared_dmx_data = dmxData();
	  _shared_dmx_slot = 0;              
	  _shared_dmx_state = DMX_STATE_START;

	  SERCOM4->USART.INTENSET.reg =  SERCOM_USART_INTENSET_TXC | SERCOM_USART_INTENSET_ERROR;
	  SERCOM4->USART.DATA.reg = 0;  

	}
}
void LXSAMD21DMX::startInput ( void ) {
	if ( _direction_pin != DIRECTION_PIN_NOT_USED ) {
		digitalWrite(_direction_pin, LOW);
	}
	if ( _interrupt_status == ISR_OUTPUT_ENABLED ) {
		stop();
	}
	if ( _interrupt_status == ISR_DISABLED ) {	//prevent messing up sequence if already started...
		SerialDMX.begin(DMX_DATA_BAUD, (uint8_t)SERIAL_8N2);
  
	   // Assign pin mux to SERCOM functionality (must come after SerialDMX.begin)
	   pinPeripheral(PIN_DMX_RX, PIO_SERCOM_ALT);
	   pinPeripheral(PIN_DMX_TX, PIO_SERCOM_ALT);
	   
		_shared_dmx_data = dmxData();
		_shared_dmx_slot = 0;              
		_shared_dmx_state = DMX_STATE_IDLE;

		_interrupt_status = ISR_INPUT_ENABLED;
	}
}