You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/07/08 21:20:02 UTC

[15/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-273; implement bsp_hw_id() for nordic and STM32F4.

MYNEWT-273; implement bsp_hw_id() for nordic and STM32F4.


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/7bd50b3b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/7bd50b3b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/7bd50b3b

Branch: refs/heads/master
Commit: 7bd50b3b24d09f3c8e0052d38a440a5013a67450
Parents: b633dfb
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Jun 23 16:36:24 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Jun 23 16:37:53 2016 -0700

----------------------------------------------------------------------
 hw/mcu/nordic/nrf51xxx/src/nrf51_hw_id.c   | 48 +++++++++++++++++++++++++
 hw/mcu/nordic/nrf52xxx/src/nrf52_hw_id.c   | 48 +++++++++++++++++++++++++
 hw/mcu/stm/stm32f4xx/src/stm32f4xx_hw_id.c | 42 ++++++++++++++++++++++
 3 files changed, 138 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7bd50b3b/hw/mcu/nordic/nrf51xxx/src/nrf51_hw_id.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf51xxx/src/nrf51_hw_id.c b/hw/mcu/nordic/nrf51xxx/src/nrf51_hw_id.c
new file mode 100644
index 0000000..81279ac
--- /dev/null
+++ b/hw/mcu/nordic/nrf51xxx/src/nrf51_hw_id.c
@@ -0,0 +1,48 @@
+/**
+ * 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 <inttypes.h>
+#include <string.h>
+
+#include <hal/hal_bsp.h>
+
+#include "mcu/nrf51.h"
+
+#ifndef min
+#define min(a, b) ((a)<(b)?(a):(b))
+#endif
+
+/*
+ * These values are generated at random.
+ * DEVICEID[0-1] and DEVICEADDR[0-1].
+ */
+int
+bsp_hw_id(uint8_t *id, int max_len)
+{
+    int len, cnt;
+
+    cnt = min(sizeof(NRF_FICR->DEVICEID), max_len);
+    memcpy(id, (void *)NRF_FICR->DEVICEID, cnt);
+    len = cnt;
+
+    cnt = min(sizeof(NRF_FICR->DEVICEADDR), max_len - len);
+    memcpy(id + len, (void *)NRF_FICR->DEVICEID, cnt);
+
+    return len + cnt;
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7bd50b3b/hw/mcu/nordic/nrf52xxx/src/nrf52_hw_id.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf52xxx/src/nrf52_hw_id.c b/hw/mcu/nordic/nrf52xxx/src/nrf52_hw_id.c
new file mode 100644
index 0000000..9042153
--- /dev/null
+++ b/hw/mcu/nordic/nrf52xxx/src/nrf52_hw_id.c
@@ -0,0 +1,48 @@
+/**
+ * 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 <inttypes.h>
+#include <string.h>
+
+#include <hal/hal_bsp.h>
+
+#include "mcu/nrf52.h"
+
+#ifndef min
+#define min(a, b) ((a)<(b)?(a):(b))
+#endif
+
+/*
+ * These values are generated at random.
+ * DEVICEID[0-1] and DEVICEADDR[0-1].
+ */
+int
+bsp_hw_id(uint8_t *id, int max_len)
+{
+    int len, cnt;
+
+    cnt = min(sizeof(NRF_FICR->DEVICEID), max_len);
+    memcpy(id, (void *)NRF_FICR->DEVICEID, cnt);
+    len = cnt;
+
+    cnt = min(sizeof(NRF_FICR->DEVICEADDR), max_len - len);
+    memcpy(id + len, (void *)NRF_FICR->DEVICEID, cnt);
+
+    return len + cnt;
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7bd50b3b/hw/mcu/stm/stm32f4xx/src/stm32f4xx_hw_id.c
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/src/stm32f4xx_hw_id.c b/hw/mcu/stm/stm32f4xx/src/stm32f4xx_hw_id.c
new file mode 100644
index 0000000..c08e8fe
--- /dev/null
+++ b/hw/mcu/stm/stm32f4xx/src/stm32f4xx_hw_id.c
@@ -0,0 +1,42 @@
+/**
+ * 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 <inttypes.h>
+#include <string.h>
+
+#include <hal/hal_bsp.h>
+
+#ifndef min
+#define min(a, b) ((a)<(b)?(a):(b))
+#endif
+
+/*
+ * STM32F4 has a unique 96-bit id at address 0x1FFF7A10.
+ * See ref manual chapter 39.1.
+ */
+int
+bsp_hw_id(uint8_t *id, int max_len)
+{
+    int cnt;
+
+    cnt = min(12, max_len);
+    memcpy(id, (void *)0x1FFF7A10, cnt);
+
+    return cnt;
+}