いろいろなテクニック.Nucleo と DISCO-F746 用.

Dependencies:   Array_Matrix mbed

Revision:
0:bb939e0bc6e2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UnionExample.hpp	Sun Oct 15 11:41:48 2017 +0000
@@ -0,0 +1,25 @@
+//--------------------------------------------------------------
+//  "union" のテスト
+//--------------------------------------------------------------
+
+#include "mbed.h"
+
+void UnionExample()
+{
+    union Int16U8
+    {
+        int16_t v16;
+        uint8_t uv8[2];
+    };
+    Int16U8 x1, x2;
+
+    x1.uv8[0] = 1;      // 下位バイト
+    x1.uv8[1] = 2;      // 上位バイト
+    
+    printf("\r\nx1.v16 = 0x%04X", x1.v16);
+    printf("\r\nx1.uv8[0] = 0x%02X, x1.uv8[1] = 0x%02X\r\n", x1.uv8[0], x1.uv8[1]);
+    
+    x2.uv8[0] = 255;
+    x2.uv8[1] = 255;   
+    printf("\r\nx2.v16 = %d\r\n", x2.v16);
+}
\ No newline at end of file