diff libutil/bitfunc.c @ 194:05d01e810217

libutil: add TFO message gen function based on Osmocom crc8gen
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 17 Mar 2023 16:52:21 -0800
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libutil/bitfunc.c	Fri Mar 17 16:52:21 2023 -0800
@@ -0,0 +1,14 @@
+/*
+ * Some bit manipulation functions.
+ */
+
+#include <stdint.h>
+#include "osmo_bits.h"
+
+void uint16_to_bits(uint16_t word, ubit_t *out, unsigned nbits)
+{
+	unsigned n;
+
+	for (n = 0; n < nbits; n++)
+		out[n] = (word >> (nbits-n-1)) & 1;
+}