/** * @brief Example firmware main entry point. * @par Parameters: * None * @retval * None */ void main(void) { // u8 Leds; /* Contains which LEDs to operate */ SysInit_Config(); //系统配置 DelayMs_Soft(100); Si4431TX_Init(); /* Initialize I/O in Input Mode with Interrupt */ // GPIO_Init(BUTTON_PORT, BUTTON_PIN, GPIO_MODE_IN_FL_IT); /* Initialize the Interrupt sensitivity */ // EXTI_SetExtIntSensitivity(EXTI_PORT_GPIOB, EXTI_SENSITIVITY_FALL_ONLY); enableInterrupts(); //开全局中断 //发送完毕回到接收状态 // Si4431TX_ReceiveMod(TRUE , RX_ADDRESS_Si4431); WorkSta1 = STA_NETCONNECT; //上电进入组网状态。 /* Toggles LEDs */ // Uart1_SendString_End(TestStr); // GPIO_WriteHigh(LEDS_PORT, LED0_PIN); while (1) { SysRun(); SPI1Rx_Parse(); CmdSpiExecute(); } }
/* * Main */ int main( int argc, char* *argv ) { // Internal variables int opt; char optformat[128]; char progname[128]; // Parameters char conf_file_name[128]; int ret; struct timeval t0; struct timeval t1; struct timeval dt; // Initialization verbose = 0; sprintf(conf_file_name, DEF_ConfFileName ); sprintf(progname, "%s", basename(argv[0])); /******************************/ /* Check for input parameters */ /******************************/ sprintf( optformat, "c:vh" ); while( ( opt = getopt( argc, argv, optformat ) ) != -1 ) { switch( opt ) { break; case 'c': sprintf( conf_file_name, "%s", optarg ); break; case 'v': verbose++; break; case 'h': default: usage( progname ); return 0; } } if( verbose ) { printf( "conf_file_name = %s\n", conf_file_name ); printf( "verbose = %d\n", verbose ); } /***********************/ /* Set signal hendler */ /***********************/ signal( SIGABRT, sig_hndlr); signal( SIGFPE, sig_hndlr); signal( SIGILL, sig_hndlr); signal( SIGINT, sig_hndlr); signal( SIGSEGV, sig_hndlr); signal( SIGTERM, sig_hndlr); if( verbose ) printf( "%s: signal handler set\n", progname ); // Get start time for performance measurements gettimeofday(&t0,0); /* * Configure system */ if( (ret=SysConfigFromFile( conf_file_name )) != D_RetCode_Sucsess ) { fprintf( stderr, "%s: SysConfigFromFile failed for file %s with %d\n", progname, conf_file_name, ret ); cleanup(ret); } if( verbose ) printf( "%s: SysConfig OK\n", progname ); // Get end time for performance measurements gettimeofday(&t1, 0); timersub(&t1,&t0,&dt); printf("%s: The system has been configured in %d sec and %d usec\n", progname, dt.tv_sec, dt.tv_usec ); /* * The following does not belong to configuration * This is a test of bringing the system in running mode for data taking * This has to be added to the CODA rocPrestart() */ printf("%s: The system should be in Idle state; Press CR to go to Running state <-", progname ); getchar(); // Set system in Running state if( (ret=SysRun()) != D_RetCode_Sucsess ) { fprintf( stderr, "%s: SysRun failed for file %s with %d\n", progname, conf_file_name, ret ); cleanup(ret); } if( verbose ) printf( "%s: SysRun OK\n", progname ); /* * This is a test of enabling trigger processing * This has to be added to the CODA rocGo() */ printf("%s: The system should be in Running state; Press CR to enable trigger processing <-", progname ); getchar(); // Enable trigger processing if( (ret=SysGo()) != D_RetCode_Sucsess ) { fprintf( stderr, "%s: SysGo failed for file %s with %d\n", progname, conf_file_name, ret ); cleanup(ret); } if( verbose ) printf( "%s: SysGo OK\n", progname ); /* * This is a test of diabling trigger processing * This has to be added to the CODA rocEnd() */ printf("%s: The system should be in Running state; Press CR to go to IDLE state <-", progname ); getchar(); // Set system in Idle state if( (ret=SysStop()) != D_RetCode_Sucsess ) { fprintf( stderr, "%s: SysStop failed for file %s with %d\n", progname, conf_file_name, ret ); cleanup(ret); } if( verbose ) printf( "%s: SysStop OK\n", progname ); /********************/ /* Cleanup and stop */ /********************/ cleanup(0); return 0; }