Atmel software framework API
Set port_pin_dir to PORT_PIN_DIR_OUTPUT_WTH_READBACK

ASF: SAM D20/D21/R21 Port Driver (PORT)


  PORT_PIN_DIR_OUTPUT_WTH_READBACK  
  
  The pin's output and input buffers should be enabled, so that the pin
  state can be set and read back.