Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed SerialTxRxIntr F446_AD_DA_Multirate
Diff: main.cpp
- Revision:
- 13:bcaee883b812
- Parent:
- 10:54bbf5ced7fb
- Child:
- 14:2f1af14e6c0d
--- a/main.cpp Mon Jan 27 07:44:05 2020 +0000
+++ b/main.cpp Wed Feb 05 08:45:41 2020 +0000
@@ -16,9 +16,8 @@
//
// PC 側のプログラム
// F446_AD_DA_Ctrl
-// 端末エミュレータでも使用可能(ボーレート:9,600 baud)
//
-// 2019/11/23, Copyright (c) 2019 MIKAMI, Naoki
+// 2020/02/05, Copyright (c) 2020 MIKAMI, Naoki
//----------------------------------------------------------------------
#include "F446_Multirate.hpp"
@@ -27,26 +26,21 @@
#pragma diag_suppress 870 // マルチバイト文字使用の警告抑制のため
using namespace Mikami;
-
-const int FS_ = 10000; // 入力の標本化周波数: 10 kHz
-F446_Multirate myAdDa_; // 出力標本化周波数を4倍にするオブジェクト
-SerialRxTxIntr rxTx_(32, 9600); // Serial クラスの受送信割込み用オブジェクト
- // ボーレート:9,600 baud
+
+const int FS_ = 10000; // 入力の標本化周波数: 10 kHz
+F446_Multirate myAdDa_; // 出力標本化周波数を4倍にするオブジェクト
+SerialRxTxIntr rxTx_(32, 115200); // Serial クラスの受送信割込み用オブジェクト
+ // ボーレート:115,200 baud
void SendParm(float param); // パラメータの値を送信
void Respond(bool &sw, float ¶m); // 受信バッファのデータが有効になった場合の処理
int main()
{
- printf("\r\n端末エミュレータでも使用可能\r\n");
- printf("端末エミュレータから数値を入力する場合は 0 ~ 5000 の\r\n");
- printf("範囲の数値を入力してください\r\n");
- rxTx_.EchobackEnable(); // エコーバックを有効にする
-
// 以下の割り込み優先順位の設定を忘れないこと
NVIC_SetPriority(ADC_IRQn, 0); // ADC 終了割り込み:最優先
NVIC_SetPriority(USART2_IRQn, 1); // USART2 割り込み:次に優先
-
+
float volume = 0.4f; // 音量を決める変数(初期値)
bool sw = true;
@@ -73,14 +67,14 @@
string str = rxTx_.GetBuffer();
if (str == "ENQ")
{
- rxTx_.Tx("ACK\n"); // PC からの "ENQ" に対して "ACK" を送信する
- SendParm(param); // 最初に Label に表示する文字列を送信
+ rxTx_.TxString("ACK\n"); // PC からの "ENQ" に対して "ACK" を送信する
+ SendParm(param); // 最初に Label に表示する文字列を送信
char buf[16];
sprintf(buf, "S%5d\n", (uint32_t)(5000*param));
- rxTx_.Tx(buf); // 起動時のスライダ(TrackBar)の位置を送信
+ rxTx_.TxString(buf); // 起動時のスライダ(TrackBar)の位置を送信
- rxTx_.Tx("M入力信号をそのまま出力\n");
+ rxTx_.TxString("M入力信号をそのまま出力します.\n");
}
else // "ENQ" 以外の処理
{
@@ -107,5 +101,5 @@
char buf[32];
// Tera Term を使わない場合は,"\r" は無くても構わない
sprintf(buf, "L音量: %3d %%\r\n", (int)(param*100));
- rxTx_.Tx(buf); // label1 に表示する文字列を送信
-}
+ rxTx_.TxString(buf); // label1 に表示する文字列を送信
+}
\ No newline at end of file