aboutsummaryrefslogtreecommitdiff
path: root/src/jtag/drivers/libjaylink/libjaylink/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/jtag/drivers/libjaylink/libjaylink/util.c')
m---------src/jtag/drivers/libjaylink0
-rw-r--r--src/jtag/drivers/libjaylink/libjaylink/util.c56
2 files changed, 56 insertions, 0 deletions
diff --git a/src/jtag/drivers/libjaylink b/src/jtag/drivers/libjaylink
deleted file mode 160000
-Subproject 8645845c1abebd004e991ba9a7f808f4fd0c608
diff --git a/src/jtag/drivers/libjaylink/libjaylink/util.c b/src/jtag/drivers/libjaylink/libjaylink/util.c
new file mode 100644
index 0000000..4862d4e
--- /dev/null
+++ b/src/jtag/drivers/libjaylink/libjaylink/util.c
@@ -0,0 +1,56 @@
+/*
+ * This file is part of the libjaylink project.
+ *
+ * Copyright (C) 2014-2015 Marc Schink <jaylink-dev@marcschink.de>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdbool.h>
+
+#include "libjaylink.h"
+
+/**
+ * @file
+ *
+ * Utility functions.
+ */
+
+/**
+ * Check for a capability.
+ *
+ * The capabilities are expected to be stored in a bit array consisting of one
+ * or more bytes where each individual bit represents a capability. The first
+ * bit of this array is the least significant bit of the first byte and the
+ * following bits are sequentially numbered in order of increasing bit
+ * significance and byte index. A set bit indicates a supported capability.
+ *
+ * @param[in] caps Buffer with capabilities.
+ * @param[in] cap Bit position of the capability to check for.
+ *
+ * @retval true Capability is supported.
+ * @retval false Capability is not supported or invalid argument.
+ *
+ * @since 0.1.0
+ */
+JAYLINK_API bool jaylink_has_cap(const uint8_t *caps, uint32_t cap)
+{
+ if (!caps)
+ return false;
+
+ if (caps[cap / 8] & (1 << (cap % 8)))
+ return true;
+
+ return false;
+}