出力ポートを,オープンドレインまたはプッシュプルに設定するグローバル関数の使用例. Example of global functions for setting the output port bits as open-drain or push-pull.

Dependencies:   UIT_SetOutputPortType mbed

Files at this revision

API Documentation at this revision

Comitter:
MikamiUitOpen
Date:
Fri Oct 21 07:55:02 2016 +0000
Parent:
2:966a8ad956d3
Child:
4:b8b4d42fa9fd
Commit message:
4

Changed in this revision

UIT_SetOutputPortType.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.bld Show annotated file Show diff for this revision Revisions of this file
--- a/UIT_SetOutputPortType.lib	Fri Sep 04 12:02:07 2015 +0000
+++ b/UIT_SetOutputPortType.lib	Fri Oct 21 07:55:02 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/MikamiUitOpen/code/UIT_SetOutputPortType/#670919fefe1c
+https://developer.mbed.org/users/MikamiUitOpen/code/UIT_SetOutputPortType/#faa854cf5f0e
--- a/main.cpp	Fri Sep 04 12:02:07 2015 +0000
+++ b/main.cpp	Fri Oct 21 07:55:02 2016 +0000
@@ -3,33 +3,37 @@
 // (Example of global functions for setting the output port bit
 //  as open-drain or push-pull)
 //
-// 2015/09/04, Copyright (c) 2015 MIKAMI, Naoki
+// 2016/10/21, Copyright (c) 2016 MIKAMI, Naoki
 //---------------------------------------------------------------------------------
 
 #include "SetOutputPortType.hpp"
 using namespace Mikami;
 
-BusOut bus_(D2, D3, D4, D5, D6, D7, D8);
-DigitalIn uButton_(USER_BUTTON);
-
 // ユーザ・ボタン(青のボタン)を押すまで待つ関数 
 void WaitButton(char str[])
 {
+    DigitalIn uButton(USER_BUTTON);
     printf(str);
     printf("\r\nPush blue button");
-    while (uButton_ == 1) {}
+#ifdef STM32F7
+    while (uButton != 1) {}
+#else
+    while (uButton == 1) {}
+#endif
     wait(0.5);
 }
 
 int main()
 {
+    BusOut bus(D2, D3, D4, D5, D6, D7, D8);
+
 // MODER    I/O ポートを,入力/汎用出力/代替え機能/アナログに設定するレジスタ
 // PUPDR    I/O ポートを,プルアップ,プルダウン,プルアップ・プルダウンなしに設定するレジスタ
 // OTYPER   出力のタイプをプッシュプル/オープンドレインに設定するレジスタ
     printf("\r\n\nGPIOB mode Reg.: 0x%08x", GPIOB->MODER);
     printf("\r\nGPIOB pull-up/pull-down Reg.: 0x%08x", GPIOB->PUPDR);
     
-    bus_ = 0x7F;
+    bus = 0x7F;
     SetOpenDrain(D2, D3, D4, D5, D6, D7, D8);
     printf("\r\n\nGPIOB output type Reg.: 0x%04x", GPIOB->OTYPER);
     printf("\r\nGPIOA output type Reg.: 0x%04x", GPIOA->OTYPER);
@@ -50,5 +54,20 @@
     printf("\r\nGPIOA output type Reg.: 0x%04x", GPIOA->OTYPER);
     printf("\r\nD2 - D4: open drain\r\n");
     
+#ifdef STM32F7
+    DigitalOut pg(PG_0, 0);
+    WaitButton("\r\nPG_0: push-pull, Output: 0\r\n");
+    
+    pg = 1;
+    WaitButton("\r\nPG_0: push-pull, Output: 1\r\n");
+    SetOpenDrain(PG_0);
+    
+    WaitButton("\r\nPG_0: Open RDain\r\n");
+    SetPushPull(PG_0);
+    WaitButton("\r\nPG_0: push-pull\r\n");
+#endif
+    
+    printf("\r\nEnd of Test\r\n");
+
     while (true);
 }
--- a/mbed.bld	Fri Sep 04 12:02:07 2015 +0000
+++ b/mbed.bld	Fri Oct 21 07:55:02 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/ba1f97679dad
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/25aea2a3f4e3
\ No newline at end of file