+/**
+ * Polls an ARM7/9 target for its current status. If DBGACK is set, the target
+ * is manipulated to the right halted state based on its current state. This is
+ * what happens:
+ *
+ * <table>
+ * <tr><th>State</th><th>Action</th></tr>
+ * <tr><td>TARGET_RUNNING | TARGET_RESET</td><td>Enters debug mode. If TARGET_RESET, pc may be checked</td></tr>
+ * <tr><td>TARGET_UNKNOWN</td><td>Warning is logged</td></tr>
+ * <tr><td>TARGET_DEBUG_RUNNING</td><td>Enters debug mode</td></tr>
+ * <tr><td>TARGET_HALTED</td><td>Nothing</td></tr>
+ * </table>
+ *
+ * If the target does not end up in the halted state, a warning is produced. If
+ * DBGACK is cleared, then the target is expected to either be running or
+ * running in debug.
+ *
+ * @param target Pointer to the ARM7/9 target to poll
+ * @return ERROR_OK or an error status if a command fails
+ */