main() { int cnt[4]={0},buf[4]={0}; int i,sw; initSCI1(); /*SCI-ch1の初期化*/ initPushSW(); /*押しボタンスイッチの初期化*/ SCI1_printf("Hello. How are you?\n"); while (1) { sw = getPushSW(); for(i=3;i>=0;i--){ if( (sw&(1<<i)) == (1<<i) ){ if(buf[i]==0){ cnt[i]++; buf[i]=1; } }else if(buf[i]!=0){ buf[i]=0; } SCI1_printf("SW%d:%2d回 ",i,cnt[i]); } SCI1_printf("\n"); } }
void func3(void) { short int x; long int y; x=SCI1_getInt("Key in a decimal number >>>"); SCI1_printf("The number you keyed in is %d %x\n",x,x); x=SCI1_getInt("Key in a hexdecimal number (ex. 0x23ff) >>>"); SCI1_printf("The number you keyed in is %d %x\n",x,x); y=SCI1_getInt4("Key in a decimal big number (ex. 12345678)>>>"); SCI1_printf("The number you keyed in is %ld %lx\n",y,y); y=SCI1_getInt4("Key in a hexdecimal big number (ex. 0x23ff0000) >>>"); SCI1_printf("The number you keyed in is %ld %lx\n",y,y); }
void func1(void) { unsigned char sw,previous; SCI1_printf("Printing 8-bitSW status...\n"); SCI1_printf("Change 8-bitSW and new status will appear.\n"); SCI1_printf("If any key on the keyboard, this test will quit.\n"); previous=sw=get8BitSW(); SCI1_printf("8-bitSW status= %2x[%08b]\n",sw,sw); do { sw=get8BitSW(); if (sw!=previous) { SCI1_printf("8-bitSW status= %2x[%08b]\n",sw,sw); previous=sw; } } while (SCI1_chkgetChar()<0); }
void main(void) { PushSW_Init(); /* 初期化 */ #if defined(MODE_SCI0) SCI0_Init(BT_BAUDRATE, -1); #elif defined(MODE_SCI1) SCI1_Init(PC_BAUDRATE, -1); #elif defined(MODE_SCI3) SCI3_Init(BT_BAUDRATE, -1); #endif while(1) { while(PushSW_CheckBit(0)); /* 通常のprintfと用法は同じ */ #if defined(MODE_SCI0) SCI0_printf("[S:%s][C:%c][D:%d][B:%b][O:%o][X:%x]\n", "HELLO", 46, 46, 46, 46, 46); #elif defined(MODE_SCI1) SCI1_printf("[S:%s][C:%c][D:%d][B:%b][O:%o][X:%x]\n", "HELLO", 46, 46, 46, 46, 46); #elif defined(MODE_SCI3) SCI3_printf("[S:%s][C:%c][D:%d][B:%b][O:%o][X:%x]\n", "HELLO", 46, 46, 46, 46, 46); #endif } }
void main(void) { DIO_Init(0xFF, DIO_DIR_IN); SCI1_Init(PC_BAUDRATE, -1); while(1) { SCI1_printf("%x\n", DIO_CheckByte()); } }
main() { int menu; initSCI1(); /*SCI-ch1の初期化*/ initPushSW(); /*押しボタンスイッチの初期化*/ init8BitSW(); /*8ビットスイッチの初期化*/ SCI1_printf("Hello. How are you?\n"); while (1) { SCI1_printf("***************menu**********\n"); SCI1_printf("1: get 8-bit SW and print \n"); SCI1_printf("2: get Push SW and print \n"); SCI1_printf("3: get integer from SCI1 and print \n"); do { menu=SCI1_getChar(); /*menuには'1','2','3'が入るはず*/ } while (menu<'1'||'3'<menu); SCI1_printf("\n"); switch (menu) { case '1': func1(); break; case '2': func2(); break; case '3': func3(); break; default: break; } } }