Reads an Ap/DP register on a CoreSight DAP.

        Wait responses and special handling are both handled by this method.

        Note:
          ``coresight_configure()`` must be called prior to calling this method.

        Args:
          self (JLink): the ``JLink`` instance
          reg (int): index of DP/AP register to read
          ap (bool): ``True`` if reading from an Access Port register,
            otherwise ``False`` for Debug Port

        Returns:
          Data read from register.

        Raises:
          JLinkException: on hardware error

def coresight_read(self, reg, ap=True):
        """Reads an Ap/DP register on a CoreSight DAP.

        Wait responses and special handling are both handled by this method.

        Note:
          ``coresight_configure()`` must be called prior to calling this method.

        Args:
          self (JLink): the ``JLink`` instance
          reg (int): index of DP/AP register to read
          ap (bool): ``True`` if reading from an Access Port register,
            otherwise ``False`` for Debug Port

        Returns:
          Data read from register.

        Raises:
          JLinkException: on hardware error
        """
        data = ctypes.c_uint32()
        ap = 1 if ap else 0
        res = self._dll.JLINKARM_CORESIGHT_ReadAPDPReg(reg, ap, ctypes.byref(data))
        if res < 0:
            raise errors.JLinkException(res)

        return data.value