x mbed2リビジョン144
x リビジョンの変更がわかる人むけ
目的
GPIOのテスト
// gpio_7seg_3min_812_1
#include "mbed.h"
//******* ****** ***** *****
// * * * *
// * * ***** * ***
// * **** * * *
// * * * * *
// * ***** ***** *****
int kk;
#define oun_min() for(kk=0;kk<60;kk++){wait_ms(1000);}
#define swclk1 P0_16 //B 9
#define swdio1 P0_17 //G 8
#define en1 P0_7 //R 7
//GPIOの初期化
DigitalOut swdclk(swclk1);
DigitalOut swdio(swdio1);
DigitalOut en(en1);
char seg[32] = {
0x00, //0 @ -> ' '
0x77, //1 A o
0x7c, //2 B combined use "6"
0x39, //3 C
0x5e, //4 D
0x79, //5 E o
0x71, //6 F
0x3d, //7 G
0x76, //8 H o
0x06, //9 I combined use "1"
0x1e, //10 J
0x75, //11 K
0x38, //12 L o
0x15, //13 M
0x37, //14 N o
0x3f, //15 O o combined use "0"
0x73, //16 P
0x67, //17 Q combined use "9"
0x50, //18 R
0x6d, //19 S combined use "5"
0x78, //20 T
0x3e, //21 U
0x1c, //22 V
0x2a, //23 W o
0x64, //24 X
0x6e, //25 Y
0x5b, //26 Z combined use "2"
0x4f, //27 [ --> "3"
0x66, //28 \ --> "4"
0x27, //29 ] --> "7"
0x7f, //26 ^ --> "8"
0x08 //31 _
};
void seg1(char v)
{
for(int jj=0; jj<8; jj++) {
if( (v<<jj) & 0x80 ) {
swdio=1; //ビットが1
} else {
swdio=0; //ビットが0
}//endif
swdclk=1;
swdclk=0; //clk
}//for
en=1;
en=0;
}//seg1
char nn[]= {'O','I','Z','[','\\','S','B', ']','^','Q'};
int comma1=0; // コンマ(小数点)の有効フラグ 1で有効 0無効
//7segの一文字出力 nana_seg
int ns_putc(char ch)
{
if(ch == ' ') {
ch = '@';
} else if(ch == '.') {
return(0);
} else if (ch >= '0' && ch <= '9' ) {
ch = nn[ch-'0'];
}
if( comma1 != 0 ) {
comma1 = (0x80);
}
seg1(seg[ch-64] | comma1 );
comma1 = 0;
//戻り値
return(0);
}//ns_putc
//文字列の表示 nana_seg
int ns_printf(char *str1)
{
//文字の中身がゼロか
while(*str1) {
//コンマの処理
comma1=0;
if( (*(str1+1) ) == '.' ) {
comma1=1;
}
//一文字出力
ns_putc(*str1 ++);
} //while
//戻り値
return(0);
}//ns_printf
//メイン関数
int main()
{
//7セグの初期化
en=0;
swdclk=0;
swdio=0;
wait_ms(200); //debug
ns_printf( (char *)"STAR");
wait_ms(700); //debug
//3分をカウント
ns_printf( (char *)" 0." );
oun_min()
ns_printf( (char *)" 1." );
oun_min()
ns_printf( (char *)" 2." );
oun_min()
ns_printf( (char *)" 3." );
while(1) {} //無限ループ
}//main
-4-