99#include " Arduino.h"
1010
1111int gg_DI_count; // 割込み禁止ネスト数(0=割込み許可中)
12- int gg_tp1_no = -1 ; // TP1出力ピン番号(-1=なし)
13- int gg_tp2_no = -1 ; // TP2出力ピン番号(-1=なし)
1412long gg_con_baud = 115200 ; // コンソール用シリアル(Serial)のボーレート(-1=gg_start()で初期化しない)
1513
1614static int std_putc_sub (int c)
@@ -30,9 +28,6 @@ static int std_getc()
3028
3129int gg_start (const char *title) // Arduino用GGの処理開始
3230{
33- // TP出力の初期化(セットされてれば出力に初期化)
34- if (gg_tp1_no>=0 ) pinMode (gg_tp1_no, OUTPUT);
35- if (gg_tp2_no>=0 ) pinMode (gg_tp2_no, OUTPUT);
3631
3732 // コンソール用シリアルのボーレート設定(負数であればセットしない)
3833 if (gg_con_baud>0 ) {
@@ -42,9 +37,13 @@ int gg_start(const char *title) // Arduino用GGの処理開始
4237 }
4338
4439 // GGツールベース初期化
45- ggbase_init (); // GGツール初期化
46- gg_con_MonInit (); // GGモニタ初期化
47- gg_con_RegistCMD (); // 標準コマンド登録
40+ gg_con_MonInit (); // GGモニタ初期化
41+ gg_con_RegistHelpCMD (); // helpコマンド登録(最初はこれだけ)
42+
43+ // tp1/tp2番号指定あればTP機能スタート(旧v1.0.x対応) 2022.06.05 M.Kogan
44+ if ((gg_tp1_no>=0 )||(gg_tp2_no>=0 )) {
45+ gg_tp_start (gg_tp1_no, gg_tp2_no); // TP機能スタート(出力ピン初期化とコマンド登録)
46+ }
4847
4948 // デバッグモニタ開始(タイトル表示) 旧:gg_con_MonStart()
5049 if (title) gg_PutS (title);
@@ -55,6 +54,12 @@ int gg_start(const char *title) // Arduino用GGの処理開始
5554//
5655// テストポイント(TP機能)
5756//
57+ int gg_tp1_sel = -1 ; // TP1(出力ピン1)状態番号変数
58+ int gg_tp2_sel = -1 ; // TP2(出力ピン2)状態番号変数
59+
60+ int gg_tp1_no = -1 ; // TP1出力ピン番号(-1=なし) Arduinoピン番号
61+ int gg_tp2_no = -1 ; // TP2出力ピン番号(-1=なし) Arduinoピン番号
62+
5863void gg_tp1_set (int flag) // TP1(出力ピン1)出力(GG_for_Arduino.cpp)
5964{
6065 if (gg_tp1_no>=0 ) {
@@ -67,3 +72,31 @@ void gg_tp2_set(int flag) // TP2(出力ピン2)出力(GG_for_Arduino.cpp)
6772 digitalWrite (gg_tp2_no, flag);
6873 }
6974}
75+
76+ static int C_tp (int argc, char **argv) // TP設定
77+ {
78+ if (argc<=4 ) {
79+ if (argc>1 ) GG_TP1 = gg_asc2int (argv[1 ]);
80+ if (argc>2 ) GG_TP2 = gg_asc2int (argv[2 ]);
81+ gg_printf (" <TP status number(The specified status number appears in TP)>\n " );
82+ gg_printf (" TP1 = %3d (-1=do nothing)\n " , GG_TP1);
83+ gg_printf (" TP2 = %3d (-1=do nothing)\n " , GG_TP2);
84+ } else {
85+ gg_con_CmdHelp (argv[0 ]);
86+ }
87+ return 0 ;
88+ }
89+
90+ int gg_tp_start (int tp1_no, int tp2_no) // TP機能スタート(出力ピン初期化とコマンド登録)
91+ {
92+ // TP出力の初期化(セットされてれば出力に初期化)
93+ gg_tp1_no = tp1_no;
94+ gg_tp2_no = tp2_no;
95+ if (gg_tp1_no>=0 ) pinMode (gg_tp1_no, OUTPUT);
96+ if (gg_tp2_no>=0 ) pinMode (gg_tp2_no, OUTPUT);
97+
98+ // コマンド登録
99+ GG_CON_CMDMRK (" -- TP command --" ); // 区切り行(helpでコマンド一覧のときに表示)
100+ GG_CON_CMDADD (C_tp, " tp" , " [#1 [#2]]" , " TP(test point) select" ); //
101+ return 0 ;
102+ }
0 commit comments