\section{Digital Output}

The digital output unit provides a write access to one or more pins of a \gls{GPIO} port. This unit additionally supports pulse generation on any of its pins; this is implemented in software, with timing derived from the system timebase, in order to support pulses on all pins regardless of hardware \gls{PWM} support. Pins in commands are expressed in the packed format (\cref{sec:packedpins}).

\subsection{Digital Output Configuration}

\begin{inicode}
[DO:out@1]
# Port name
port=A
# Pins (comma separated, supports ranges)
pins=0
# Initially high pins
initial=
# Open-drain pins
open-drain=
\end{inicode}

\subsection{Digital Output Commands}

\begin{cmdlist}

	0 & \cname{WRITE} Write to all pins
	& \begin{cmdreq}
		\cfield{u16} new value
	\end{cmdreq} \\

	1 & \cname{SET} Set selected pins to 1
	& \begin{cmdreq}
		\cfield{u16} pins to set
	\end{cmdreq} \\

	2 & \cname{CLEAR} Set selected pins to 0
	& \begin{cmdreq}
		\cfield{u16} pins to clear
	\end{cmdreq} \\

	3 & \cname{TOGGLE} Toggle selected pins
	& \begin{cmdreq}
		\cfield{u16} pins to toggle
	\end{cmdreq} \\

	4 & \cname{PULSE}
	Generate a pulse on the selected pins. The microsecond scale may be used only for 0--999\,$\mu$s.
	& \begin{cmdreq}
		\cfield{u16} pins to pulse
		\cfield{u8} active level (0, 1)
		\cfield{u8} scale: 0-ms, 1-$\mu$s
		\cfield{u16} duration
	\end{cmdreq}

\end{cmdlist}
