Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop ab1cfd442 -> 4045e9612


Move endiannes related API from ble.h to endian.h

It makes more sense to have this API available for all components.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/4045e961
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/4045e961
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/4045e961

Branch: refs/heads/develop
Commit: 4045e96124f2f1bea3fea4b6a68a590e0aa294ed
Parents: c78ed8a
Author: Szymon Janc <[email protected]>
Authored: Mon Jan 23 17:14:33 2017 +0100
Committer: Christopher Collins <[email protected]>
Committed: Tue Jan 24 16:03:30 2017 -0800

----------------------------------------------------------------------
 kernel/os/include/os/endian.h   |  16 +++
 kernel/os/src/endian.c          | 218 ++++++++++++++++++++++++++++++++++
 net/nimble/include/nimble/ble.h |  16 ---
 net/nimble/src/util.c           | 219 -----------------------------------
 4 files changed, 234 insertions(+), 235 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4045e961/kernel/os/include/os/endian.h
----------------------------------------------------------------------
diff --git a/kernel/os/include/os/endian.h b/kernel/os/include/os/endian.h
index 8786f40..b8b39b5 100644
--- a/kernel/os/include/os/endian.h
+++ b/kernel/os/include/os/endian.h
@@ -202,6 +202,22 @@ extern "C" {
 #endif
 
 #endif
+
+void put_le16(void *buf, uint16_t x);
+void put_le32(void *buf, uint32_t x);
+void put_le64(void *buf, uint64_t x);
+uint16_t get_le16(const void *buf);
+uint32_t get_le32(const void *buf);
+uint64_t get_le64(const void *buf);
+void put_be16(void *buf, uint16_t x);
+void put_be32(void *buf, uint32_t x);
+void put_be64(void *buf, uint64_t x);
+uint16_t get_be16(const void *buf);
+uint32_t get_be32(const void *buf);
+uint64_t get_be64(const void *buf);
+void swap_in_place(void *buf, int len);
+void swap_buf(uint8_t *dst, const uint8_t *src, int len);
+
 #ifdef __cplusplus
 }
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4045e961/kernel/os/src/endian.c
----------------------------------------------------------------------
diff --git a/kernel/os/src/endian.c b/kernel/os/src/endian.c
new file mode 100644
index 0000000..1311f43
--- /dev/null
+++ b/kernel/os/src/endian.c
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "os/endian.h"
+
+void
+put_le16(void *buf, uint16_t x)
+{
+    uint8_t *u8ptr;
+
+    u8ptr = buf;
+    u8ptr[0] = (uint8_t)x;
+    u8ptr[1] = (uint8_t)(x >> 8);
+}
+
+void
+put_le32(void *buf, uint32_t x)
+{
+    uint8_t *u8ptr;
+
+    u8ptr = buf;
+    u8ptr[0] = (uint8_t)x;
+    u8ptr[1] = (uint8_t)(x >> 8);
+    u8ptr[2] = (uint8_t)(x >> 16);
+    u8ptr[3] = (uint8_t)(x >> 24);
+}
+
+void
+put_le64(void *buf, uint64_t x)
+{
+    uint8_t *u8ptr;
+
+    u8ptr = buf;
+    u8ptr[0] = (uint8_t)x;
+    u8ptr[1] = (uint8_t)(x >> 8);
+    u8ptr[2] = (uint8_t)(x >> 16);
+    u8ptr[3] = (uint8_t)(x >> 24);
+    u8ptr[4] = (uint8_t)(x >> 32);
+    u8ptr[5] = (uint8_t)(x >> 40);
+    u8ptr[6] = (uint8_t)(x >> 48);
+    u8ptr[7] = (uint8_t)(x >> 56);
+}
+
+uint16_t
+get_le16(const void *buf)
+{
+    const uint8_t *u8ptr;
+    uint16_t x;
+
+    u8ptr = buf;
+    x = u8ptr[0];
+    x |= (uint16_t)u8ptr[1] << 8;
+
+    return x;
+}
+
+uint32_t
+get_le32(const void *buf)
+{
+    const uint8_t *u8ptr;
+    uint32_t x;
+
+    u8ptr = buf;
+    x = u8ptr[0];
+    x |= (uint32_t)u8ptr[1] << 8;
+    x |= (uint32_t)u8ptr[2] << 16;
+    x |= (uint32_t)u8ptr[3] << 24;
+
+    return x;
+}
+
+uint64_t
+get_le64(const void *buf)
+{
+    const uint8_t *u8ptr;
+    uint64_t x;
+
+    u8ptr = buf;
+    x = u8ptr[0];
+    x |= (uint64_t)u8ptr[1] << 8;
+    x |= (uint64_t)u8ptr[2] << 16;
+    x |= (uint64_t)u8ptr[3] << 24;
+    x |= (uint64_t)u8ptr[4] << 32;
+    x |= (uint64_t)u8ptr[5] << 40;
+    x |= (uint64_t)u8ptr[6] << 48;
+    x |= (uint64_t)u8ptr[7] << 56;
+
+    return x;
+}
+
+void
+put_be16(void *buf, uint16_t x)
+{
+    uint8_t *u8ptr;
+
+    u8ptr = buf;
+    u8ptr[0] = (uint8_t)(x >> 8);
+    u8ptr[1] = (uint8_t)x;
+}
+
+void
+put_be32(void *buf, uint32_t x)
+{
+    uint8_t *u8ptr;
+
+    u8ptr = buf;
+    u8ptr[0] = (uint8_t)(x >> 24);
+    u8ptr[1] = (uint8_t)(x >> 16);
+    u8ptr[2] = (uint8_t)(x >> 8);
+    u8ptr[3] = (uint8_t)x;
+}
+
+void
+put_be64(void *buf, uint64_t x)
+{
+    uint8_t *u8ptr;
+
+    u8ptr = buf;
+    u8ptr[0] = (uint8_t)(x >> 56);
+    u8ptr[1] = (uint8_t)(x >> 48);
+    u8ptr[2] = (uint8_t)(x >> 40);
+    u8ptr[3] = (uint8_t)(x >> 32);
+    u8ptr[4] = (uint8_t)(x >> 24);
+    u8ptr[5] = (uint8_t)(x >> 16);
+    u8ptr[6] = (uint8_t)(x >> 8);
+    u8ptr[7] = (uint8_t)x;
+}
+
+uint16_t
+get_be16(const void *buf)
+{
+    const uint8_t *u8ptr;
+    uint16_t x;
+
+    u8ptr = buf;
+    x = (uint16_t)u8ptr[0] << 8;
+    x |= u8ptr[1];
+
+    return x;
+}
+
+uint32_t
+get_be32(const void *buf)
+{
+    const uint8_t *u8ptr;
+    uint32_t x;
+
+    u8ptr = buf;
+    x = (uint32_t)u8ptr[0] << 24;
+    x |= (uint32_t)u8ptr[1] << 16;
+    x |= (uint32_t)u8ptr[2] << 8;
+    x |= u8ptr[3];
+
+    return x;
+}
+
+uint64_t
+get_be64(const void *buf)
+{
+    const uint8_t *u8ptr;
+    uint64_t x;
+
+    u8ptr = buf;
+    x = (uint64_t)u8ptr[0] << 56;
+    x |= (uint64_t)u8ptr[1] << 48;
+    x |= (uint64_t)u8ptr[2] << 40;
+    x |= (uint64_t)u8ptr[3] << 32;
+    x |= (uint64_t)u8ptr[4] << 24;
+    x |= (uint64_t)u8ptr[5] << 16;
+    x |= (uint64_t)u8ptr[6] << 8;
+    x |= u8ptr[7];
+
+    return x;
+}
+void
+swap_in_place(void *buf, int len)
+{
+    uint8_t *u8ptr;
+    uint8_t tmp;
+    int i;
+    int j;
+
+    u8ptr = buf;
+
+    for (i = 0, j = len - 1; i < j; i++, j--) {
+        tmp = u8ptr[i];
+
+        u8ptr[i] = u8ptr[j];
+        u8ptr[j] = tmp;
+    }
+}
+
+/* swap octets */
+void
+swap_buf(uint8_t *dst, const uint8_t *src, int len)
+{
+    int i;
+
+    for (i = 0; i < len; i++) {
+        dst[len - 1 - i] = src[i];
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4045e961/net/nimble/include/nimble/ble.h
----------------------------------------------------------------------
diff --git a/net/nimble/include/nimble/ble.h b/net/nimble/include/nimble/ble.h
index 4dfa336..c6c38ca 100644
--- a/net/nimble/include/nimble/ble.h
+++ b/net/nimble/include/nimble/ble.h
@@ -123,22 +123,6 @@ struct ble_mbuf_hdr
 extern uint8_t g_dev_addr[BLE_DEV_ADDR_LEN];
 extern uint8_t g_random_addr[BLE_DEV_ADDR_LEN];
 
-void put_le16(void *buf, uint16_t x);
-void put_le32(void *buf, uint32_t x);
-void put_le64(void *buf, uint64_t x);
-uint16_t get_le16(const void *buf);
-uint32_t get_le32(const void *buf);
-uint64_t get_le64(const void *buf);
-void put_be16(void *buf, uint16_t x);
-void put_be32(void *buf, uint32_t x);
-void put_be64(void *buf, uint64_t x);
-uint16_t get_be16(const void *buf);
-uint32_t get_be32(const void *buf);
-uint64_t get_be64(const void *buf);
-void swap_in_place(void *buf, int len);
-void swap_buf(uint8_t *dst, const uint8_t *src, int len);
-/* XXX */
-
 /* BLE Error Codes (Core v4.2 Vol 2 part D) */
 enum ble_error_codes
 {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4045e961/net/nimble/src/util.c
----------------------------------------------------------------------
diff --git a/net/nimble/src/util.c b/net/nimble/src/util.c
deleted file mode 100644
index 726a2a5..0000000
--- a/net/nimble/src/util.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-#include <stdint.h>
-#include "nimble/ble.h"
-
-void
-put_le16(void *buf, uint16_t x)
-{
-    uint8_t *u8ptr;
-
-    u8ptr = buf;
-    u8ptr[0] = (uint8_t)x;
-    u8ptr[1] = (uint8_t)(x >> 8);
-}
-
-void
-put_le32(void *buf, uint32_t x)
-{
-    uint8_t *u8ptr;
-
-    u8ptr = buf;
-    u8ptr[0] = (uint8_t)x;
-    u8ptr[1] = (uint8_t)(x >> 8);
-    u8ptr[2] = (uint8_t)(x >> 16);
-    u8ptr[3] = (uint8_t)(x >> 24);
-}
-
-void
-put_le64(void *buf, uint64_t x)
-{
-    uint8_t *u8ptr;
-
-    u8ptr = buf;
-    u8ptr[0] = (uint8_t)x;
-    u8ptr[1] = (uint8_t)(x >> 8);
-    u8ptr[2] = (uint8_t)(x >> 16);
-    u8ptr[3] = (uint8_t)(x >> 24);
-    u8ptr[4] = (uint8_t)(x >> 32);
-    u8ptr[5] = (uint8_t)(x >> 40);
-    u8ptr[6] = (uint8_t)(x >> 48);
-    u8ptr[7] = (uint8_t)(x >> 56);
-}
-
-uint16_t
-get_le16(const void *buf)
-{
-    const uint8_t *u8ptr;
-    uint16_t x;
-
-    u8ptr = buf;
-    x = u8ptr[0];
-    x |= (uint16_t)u8ptr[1] << 8;
-
-    return x;
-}
-
-uint32_t
-get_le32(const void *buf)
-{
-    const uint8_t *u8ptr;
-    uint32_t x;
-
-    u8ptr = buf;
-    x = u8ptr[0];
-    x |= (uint32_t)u8ptr[1] << 8;
-    x |= (uint32_t)u8ptr[2] << 16;
-    x |= (uint32_t)u8ptr[3] << 24;
-
-    return x;
-}
-
-uint64_t
-get_le64(const void *buf)
-{
-    const uint8_t *u8ptr;
-    uint64_t x;
-
-    u8ptr = buf;
-    x = u8ptr[0];
-    x |= (uint64_t)u8ptr[1] << 8;
-    x |= (uint64_t)u8ptr[2] << 16;
-    x |= (uint64_t)u8ptr[3] << 24;
-    x |= (uint64_t)u8ptr[4] << 32;
-    x |= (uint64_t)u8ptr[5] << 40;
-    x |= (uint64_t)u8ptr[6] << 48;
-    x |= (uint64_t)u8ptr[7] << 56;
-
-    return x;
-}
-
-void
-put_be16(void *buf, uint16_t x)
-{
-    uint8_t *u8ptr;
-
-    u8ptr = buf;
-    u8ptr[0] = (uint8_t)(x >> 8);
-    u8ptr[1] = (uint8_t)x;
-}
-
-void
-put_be32(void *buf, uint32_t x)
-{
-    uint8_t *u8ptr;
-
-    u8ptr = buf;
-    u8ptr[0] = (uint8_t)(x >> 24);
-    u8ptr[1] = (uint8_t)(x >> 16);
-    u8ptr[2] = (uint8_t)(x >> 8);
-    u8ptr[3] = (uint8_t)x;
-}
-
-void
-put_be64(void *buf, uint64_t x)
-{
-    uint8_t *u8ptr;
-
-    u8ptr = buf;
-    u8ptr[0] = (uint8_t)(x >> 56);
-    u8ptr[1] = (uint8_t)(x >> 48);
-    u8ptr[2] = (uint8_t)(x >> 40);
-    u8ptr[3] = (uint8_t)(x >> 32);
-    u8ptr[4] = (uint8_t)(x >> 24);
-    u8ptr[5] = (uint8_t)(x >> 16);
-    u8ptr[6] = (uint8_t)(x >> 8);
-    u8ptr[7] = (uint8_t)x;
-}
-
-uint16_t
-get_be16(const void *buf)
-{
-    const uint8_t *u8ptr;
-    uint16_t x;
-
-    u8ptr = buf;
-    x = (uint16_t)u8ptr[0] << 8;
-    x |= u8ptr[1];
-
-    return x;
-}
-
-uint32_t
-get_be32(const void *buf)
-{
-    const uint8_t *u8ptr;
-    uint32_t x;
-
-    u8ptr = buf;
-    x = (uint32_t)u8ptr[0] << 24;
-    x |= (uint32_t)u8ptr[1] << 16;
-    x |= (uint32_t)u8ptr[2] << 8;
-    x |= u8ptr[3];
-
-    return x;
-}
-
-uint64_t
-get_be64(const void *buf)
-{
-    const uint8_t *u8ptr;
-    uint64_t x;
-
-    u8ptr = buf;
-    x = (uint64_t)u8ptr[0] << 56;
-    x |= (uint64_t)u8ptr[1] << 48;
-    x |= (uint64_t)u8ptr[2] << 40;
-    x |= (uint64_t)u8ptr[3] << 32;
-    x |= (uint64_t)u8ptr[4] << 24;
-    x |= (uint64_t)u8ptr[5] << 16;
-    x |= (uint64_t)u8ptr[6] << 8;
-    x |= u8ptr[7];
-
-    return x;
-}
-void
-swap_in_place(void *buf, int len)
-{
-    uint8_t *u8ptr;
-    uint8_t tmp;
-    int i;
-    int j;
-
-    u8ptr = buf;
-
-    for (i = 0, j = len - 1; i < j; i++, j--) {
-        tmp = u8ptr[i];
-
-        u8ptr[i] = u8ptr[j];
-        u8ptr[j] = tmp;
-    }
-}
-
-/* swap octets */
-void
-swap_buf(uint8_t *dst, const uint8_t *src, int len)
-{
-    int i;
-
-    for (i = 0; i < len; i++) {
-        dst[len - 1 - i] = src[i];
-    }
-}
-

Reply via email to