Przeglądaj źródła

add define stm32id

balbekova 7 lat temu
rodzic
commit
1f31519785

+ 23 - 0
peripheral_modules/inc/stm32_uid.h

@@ -0,0 +1,23 @@
+/*
+ * stm32_uid.h
+ *
+ *  Created on: 25.07.2016
+ *      Author: balbekova
+ */
+
+#ifndef STM32_UID_H_
+#define STM32_UID_H_
+
+#include <stdint.h>
+
+/**
+ * The STM32 factory-programmed UUID memory.
+ * Three values of 32 bits each starting at this address
+ * Use like this: STM32_UUID[0], STM32_UUID[1], STM32_UUID[2]
+ */
+#define STM32_UUID ((uint8_t *)0x1FFF7A10)
+
+void GetSTM32IDStr(char* str, uint8_t* len);
+
+
+#endif /* STM32_UID_H_ */

+ 35 - 0
peripheral_modules/src/stm32_uid.c

@@ -0,0 +1,35 @@
+/*
+ * stm32_uid.c
+ *
+ *  Created on: 25.07.2016
+ *      Author: balbekova
+ */
+
+#include "stm32_uid.h"
+
+#ifdef PRINTF_STDLIB
+#include <stdio.h>
+#endif
+#ifdef PRINTF_CUSTOM
+#include "tinystdio.h"
+#endif
+
+#include <string.h>
+
+
+void GetSTM32IDStr(char* str, uint8_t* len)
+{
+	uint8_t i;
+	char TempStr[33];
+
+	memset(TempStr, 0, 33);
+	for(i = 0; i < 12; i++)
+	{
+		sprintf(TempStr, "%02X", STM32_UUID[i]);
+		*len = strlen(TempStr);
+		strncat(str, TempStr, *len);
+	}
+	*len = strlen(str);
+}
+
+