33.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 an I/O line is 0, the I/O line is set in General Purpose mode and can be configured to be driven by the PIO Controller (software) instead of the peripheral.

If the (S_)PIO_CFGRx.DIR bit is configured in Output mode and (S_)PIO_CFGRx.FUNC=0, 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 Set Output Data register (PIO_SODRx)/Secure Set Output Data register (S_PIO_SODRx) and the Clear Output Data register (PIO_CODRx)/Secure Clear Output Data register (S_PIO_CODRx). These write operations set and clear, respectively, the Output Data Status register (PIO_ODSRx)/Secure Output Data Status register (S_PIO_ODSRx), which represent the data driven on the I/O lines. Writing (S_)PIO_ODSRx directly is possible and only affects the I/O line set to 1 in (S_)PIO_MSKRx. See Synchronous Data Output.

When the DIR bit for the I/O line configuration is at zero, the I/O line is used as an input only.

DIR has no effect if the 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 (S_)PIO_SODRx and (S_)PIO_CODRx affects (S_)PIO_ODSRx. This is important, since it defines the first level driven on the I/O line.