36.5.4 Output Control
When the I/O line is assigned to a peripheral function, i.e., the corresponding FUNC field of the line configuration is 1, the drive of the I/O line (direction, output value) is controlled by the peripheral.
When the FUNC field of a I/O line is 0, then the I/O line is set in General Purpose mode and the I/O line can be configured to be driven by the PIO Controller (software) instead of the peripheral.
If PIO_CFGRx/S_PIO_CFGRx/.DIR is configured in Output mode and PIO_CFGRx/S_PIO_CFGRx/.FUNC=0, then the I/O line can be driven by the PIO Controller. The level driven on an I/O line can be determined by writing in the PIO Set Output Data Register (PIO_SODRx)/Secure PIO Set Output Data Register (S_PIO_SODRx)/ and the PIO Clear Output Data Register (PIO_CODRx)Secure PIO Clear Output Data Register (S_PIO_CODRx)/. These write operations, respectively, set and clear the PIO Output Data Status Register (PIO_ODSRx)/Secure PIO Output Data Status Register (S_PIO_ODSRx)/, which represents the data driven on the I/O lines. Writing PIO_ODSRx/S_PIO_ODSRx directly is possible and only affects the I/O line set to 1 in PIO_MSKRx/S_PIO_MSKRx (see Synchronous Data Output).
When DIR of the I/O line configuration is at zero, the corresponding I/O line is used as an input only.
DIR has no effect if the corresponding line is assigned to a peripheral function, but writing DIR is managed whether the pin is configured to be controlled by the PIO Controller or assigned to a peripheral function. This enables configuration of the I/O line prior to setting it to be managed by the PIO Controller.
Similarly, writing in PIO_SODRx/S_PIO_SODRx and PIO_CODRx/S_PIO_CODRx affects PIO_ODSRx/S_PIO_ODSRx. This is important as it defines the first level driven on the I/O line.