stm32f103c8 s5851 r1

Dependencies:   mbed mbed-STM32F103C8T6 USBDevice_STM32F103

Files at this revision

API Documentation at this revision

Comitter:
caa45040
Date:
Thu Jun 17 12:06:42 2021 +0000
Commit message:
stm32f103c8 s5851 1

Changed in this revision

USBDevice_STM32F103.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-STM32F103C8T6.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r c6bef2125fe4 USBDevice_STM32F103.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice_STM32F103.lib	Thu Jun 17 12:06:42 2021 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/hudakz/code/USBDevice_STM32F103/#faedf6c65e43
diff -r 000000000000 -r c6bef2125fe4 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jun 17 12:06:42 2021 +0000
@@ -0,0 +1,65 @@
+#include "stm32f103c8t6.h"
+#include "mbed.h"
+#include "USBSerial.h"
+
+USBSerial usbSerial(0x1f00, 0x2012, 0x0001,  false);    // connection is not blocked when USB is not plugged in
+//Serial    pc(PA_2, PA_3);
+
+
+//#define S5851A 0x48
+#define ADDR        ((0x48)<<1)   //  address
+
+//I2C i2c(I2C_SDA, I2C_SCL);
+I2C i2c(PB_7, PB_6); //103
+
+
+int     tempval;        //温度
+char    data_read[6];   //i2cバッファー
+int     n10;            //10の桁
+
+int main() {
+    confSysClock();     //Configure system clock (72MHz HSE clock, 48MHz USB clock)
+
+    //usbSerial.printf("\r\n103\r\n");
+
+    while(1) {
+
+        //初期化
+        //set address 0
+        i2c.write(ADDR, "\000", 1); //addres 0
+
+        //温度の読み込み
+        // Read temperature register
+        i2c.read(ADDR, data_read,1,false);
+
+        //温度の保存
+        // Calculate temperature value in Celcius
+        tempval =  data_read[0];
+
+        //tempval = 12; //debug
+
+        //計算
+        // Calculation temp
+        n10 = tempval/10;                 //10の桁
+        tempval = tempval - ( n10 * 10 ); //1の桁
+
+        //液晶に出力
+        // Display result
+        data_read[0] = '0' + n10;
+        data_read[1] = '0' + tempval;
+        data_read[2] = '\r';
+        data_read[3] = '\n';
+        data_read[4] = 0;
+
+        //温度の出力
+        //puts(data_read); //010
+        //pc.printf(data_read); //767
+        usbSerial.printf(data_read); //103
+
+        //1秒待つ
+        wait_ms(1000);
+        
+    }//while
+    
+}//main
+
diff -r 000000000000 -r c6bef2125fe4 mbed-STM32F103C8T6.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-STM32F103C8T6.lib	Thu Jun 17 12:06:42 2021 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/hudakz/code/mbed-STM32F103C8T6/#727468adfd1d
diff -r 000000000000 -r c6bef2125fe4 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jun 17 12:06:42 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file
diff -r 000000000000 -r c6bef2125fe4 mbed_app.json
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json	Thu Jun 17 12:06:42 2021 +0000
@@ -0,0 +1,9 @@
+{
+    "target_overrides": {
+        "NUCLEO_F103RB": {
+            "target.clock_source": "USE_PLL_HSE_XTAL",
+            "target.clock_source_usb": "1",
+            "target.default_lib": "small"
+        }
+    }
+}