int regmatch(regex_t *regex, char *call, char *pattern, char *buf, size_t buflen) { int ret = reginit(regex, pattern, buf, buflen); if (ret) { out_error("GCC plugin: failed to compile regexp: %s", buf); return ret; } return regexec(regex, call, 0, NULL, 0); }
/* start(): * Called at the end of reset.s as the first C function after processor * bootup. It is passed a state that is used to determine whether or not * the CPU is restarting as a result of a warmstart or a coldstart. If * the restart is a coldstart, then state will be INITIALIZE. if the * restart is a warmstart, then there are a few typical values of state, * the most common of which are APP_EXIT and EXCEPTION. * * The bss_start and bss_end variables are usually defined in the * target-specific linker memory-map definition file. They symbolically * identify the beginning and end of the .bss section. Many compilers * support intrinsic tags for this; however, since it is apparently not * consistent from one toolset to the next; I chose to make up my own * tags so that this file never changes from one toolset to the next. * * The FORCE_BSS_INIT definition can be established in the target-specific * config.h file to force .bss space initialization regardless of warm/cold * start. */ void start(int state) { char buf[48]; #ifdef FORCE_BSS_INIT state = INITIALIZE; #endif /* Based on the incoming value of 'state' we may or may not initialize * monitor-owned ram. Ideally, we only want to initialize * monitor-owned ram when 'state' is INITIALIZE (power-up or reset); * however, to support the case where the incoming state variable may * be corrupted, we also initialize monitor-owned ram when 'state' * is anything unexpected... */ switch(state) { case EXCEPTION: case APP_EXIT: break; case INITIALIZE: default: umonBssInit(); break; } /* Now that the BSS clear loop has been done, we can copy the * value of state (either a register or on stack) to the global * variable (in BSS) StateOfMonitor... */ StateOfMonitor = state; /* Step through different phases of startup... */ init0(); init1(); init2(); /* Depending on the type of startup, alert the console and do * further initialization as needed... */ switch(StateOfMonitor) { case INITIALIZE: reginit(); init3(); break; case APP_EXIT: EthernetStartup(0,0); if(!MFLAGS_NOEXITSTATUS()) { printf("\nApplication Exit Status: %d (0x%x)\n", AppExitStatus,AppExitStatus); } break; case EXCEPTION: EthernetStartup(0,0); printf("\n%s: '%s'\n",EXCEPTION_HEADING, ExceptionType2String(ExceptionType)); printf(" Occurred near 0x%lx",ExceptionAddr); if(AddrToSym(-1,ExceptionAddr,buf,0)) { printf(" (within %s)",buf); } printf("\n\n"); exceptionAutoRestart(INITIALIZE); break; default: printf("Unexpected monitor state: 0x%x (sp @ 0x%x)\n", StateOfMonitor, buf); /* To attempt to recover from the bad state, just do * what INITIALIZE would do... */ reginit(); init3(); break; } #ifdef LOCK_FLASH_PROTECT_RANGE /* Issue the command that will cause the range of sectors * designated by FLASH_PROTECT_RANGE to be locked. This only * works if the flash device is capable of being locked. */ sprintf(buf,"flash lock %s",FLASH_PROTECT_RANGE); docommand(buf,0); #endif #ifdef PRE_COMMANDLOOP_HOOK PRE_COMMANDLOOP_HOOK(); #endif /* Enter the endless loop of command processing: */ CommandLoop(); printf("ERROR: CommandLoop() returned\n"); monrestart(INITIALIZE); }
void main(void) { unsigned char n; #pragma optsize- #asm("cli") n=(PMIC.CTRL & (~(PMIC_RREN_bm | PMIC_IVSEL_bm | PMIC_HILVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_LOLVLEN_bm))) | PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm; CCP=CCP_IOREG_gc; PMIC.CTRL=n; PMIC.INTPRI=0x00; #pragma optsize_default system_clocks_init(); ports_init(); usartc0_init(); usartd1_init(); rtc32_init_my(); delay_ms(50); tcd0_init(); twie_init(); sprintf(info,"start i2c"); monitor(); delay_ms(50); #asm("sei") delay_ms(1); PORTE.OUT=PORTE.OUT|0b00010000; init_buferU1(); delay_ms(50); PORTE.OUT=PORTE.OUT&0b11101111; delay_ms(50); PORTE.OUT=PORTE.OUT|0b00010000; init_buferU2(); delay_ms(50); PORTE.OUT=PORTE.OUT&0b11101111; delay_ms(50); PORTE.OUT=PORTE.OUT|0b00010000; init_buferU3(); delay_ms(50); PORTE.OUT=PORTE.OUT&0b11101111; delay_ms(50); sprintf(info,"buf i2c start ok"); monitor(); delay_ms(50); PORTE.OUT=PORTE.OUT|0b00010000; bmp_reg_init(); delay_ms(50); sprintf(info,"bmp i2c start ok"); PORTE.OUT=PORTE.OUT&0b11101111; delay_ms(50); monitor(); delay_ms(100); spic_init(); sprintf(info,"SPI START"); monitor(); #asm("sei") delay_ms(200); check_sd_card(); spic_init(); PORTA.DIRSET=0b00000001; PORTA.OUTSET = 0b00000001; delay_ms(10); PORTA.OUTCLR = 0b00000001; delay_ms(100); PORTA.OUTSET = 0b00000001; delay_ms(10); ad7705_init(can1cl,mclk4,can1set,set1); delay_ms(10); PORTE.OUT=PORTE.OUT&0b11101111; delay_ms(10); PORTE.OUT=PORTE.OUT|0b00010000; sprintf(info,"ad7705 start ok"); monitor(); RESULT=ad7705(1); S0[7]=RESULT;// Сигнал усилителя младший S0[8]=(RESULT>>8); //Сигнал усилителя старший // ADCA initialization adca_init(); // ADCB initialization adcb_init(); // Timer/Counter tcc0_init(); tcc1_init(); tcf0_init(); delay_ms(10); sprintf(info,"start device"); monitor(); delay_ms(50); if(Xsave==0xFFFFFFFF)Xsave=0; sprintf(info,"START WHILE"); monitor(); delay_ms(50); if(RTC32.CNT<1454622753) RTC32.CNT=1454622753; PORTE.OUT=PORTE.OUT&0b11101111; //прописываем заводской ответ //!!!! важно смертельно initzavod(); reginit(); while (1) { PORTR.OUTTGL=0b00000010; //////////////////////////////////////************************************* //поиск ошибки буфера //buferU1_error(); //включаю подсветку //if(error_buf!=0) PORTE.OUT=PORTE.OUT|0b00010000; init_buferU1(); ///////////////////////////////////////////////////////////////////////////// read_bmp(); /////////////////////////////////////////////////////////////// if((0.0<Tempf&&Tempf<60.0)&&(300.0<p1&&p1<825.0)) { Tempf_K=Tempf*10.0+2730.0; S0[11]=Tempf_K;// температура бмп младший S0[12]=(Tempf_K>>8); //температура бмп старший /////////////////////////////////////////////////////////////// S0[15]=p/10;//ДАВЛЕНИЕ бмп младший S0[16]=(p/10>>8);//ДАВЛЕНИЕ бмп старший } init_buferU2(); if(SD_IN) { get_CNTRTC(&X); calcDateTime(X, 0, &date1,&time1); bufform(); GETFILNAME(); } init_buferU3(); buferU1_opros(); buferU2_opros(); buferU3_opros(); //обработочка //21.1 b2 io7 + if((U2in.input&0b10000000)==0b10000000) S0[21]=S0[21]|0b00000010; else if((U2in.input&0b10000000)==0b00000000) S0[21]=S0[21]&0b11111101; //21.2 b1 io4 + if((U1in.input&0b00010000)==0b00010000) S0[21]=S0[21]|0b00000100; else if((U1in.input&0b00010000)==0b00000000) S0[21]=S0[21]&0b11111011; //21.3 b1 io5 + if((U1in.input&0b00100000)==0b00100000) S0[21]=S0[21]|0b00001000; else if((U1in.input&0b00100000)==0b00000000) S0[21]=S0[21]&0b11110111; //21.4 b1 io1 ---- if((U1in.input&0b00000010)==0b00000010) S0[21]=S0[21]|0b00010000; else if((U1in.input&0b00000010)==0b00000000) S0[21]=S0[21]&0b11101111; //21.5 b2 io3 if((U2in.input&0b00001000)==0b00001000) S0[21]=S0[21]|0b00100000; else if((U2in.input&0b00001000)==0b00000000) S0[21]=S0[21]&0b11011111; //21.6 b2 io4 if((U2in.input&0b00010000)==0b00010000) S0[21]=S0[21]|0b01000000; else if((U2in.input&0b00010000)==0b00000000) S0[21]=S0[21]&0b10111111; //21.6 b3 io6 if((U3in.input&0b01000000)==0b01000000) S0[21]=S0[21]|0b10000000; else if((U3in.input&0b01000000)==0b00000000) S0[21]=S0[21]&0b01111111; //пождиг if( (B5upr&0b00000010)==0b00000010 ) { U3out.output=U3out.output|0b00000010; } else if( (B5upr&0b00000010)==0b00000000 ) {U3out.output=U3out.output&0b11111101;} //клапан1 if( (B5upr&0b00000100)==0b00000100 ) {U3out.output=U3out.output|0b00000100;} else if( (B5upr&0b00000100)==0b00000000 ) {U3out.output=U3out.output&0b11111011;} //контрольная кювета if( (B5upr&0b00001000)==0b00001000) {U1out.output=U1out.output&0b00111111; U1out.output=U1out.output|0b01000000;} else if((B5upr&0b00001000)==0b00000000) {U1out.output=U1out.output&0b00111111; U1out.output=U1out.output|0b10000000;} //клапан 2 if( (B5upr&0b00010000)==0b00010000 ) {U3out.output=U3out.output|0b00001000;} else if( (B5upr&0b00010000)==0b00000000 ) {U3out.output=U3out.output&0b11110111;} //клапан 3 if( (B5upr&0b00100000)==0b00100000 ) {U3out.output=U3out.output|0b00010000;} else if( (B5upr&0b00100000)==0b00000000 ) {U3out.output=U3out.output&0b11101111;} //реле 1 инверсно if( (B5upr&0b01000000)==0b01000000 ) {U1out.output=U1out.output&0b11111110;} else if( (B5upr&0b01000000)==0b00000000 ) {U1out.output=U1out.output|0b00000001;} //реле 2 инверсно if( (B5upr&0b10000000)==0b10000000 ) {U2out.output=U2out.output&0b11111110;} else if( (B5upr&0b10000000)==0b00000000 ) {U2out.output=U2out.output|0b00000001;} buferU1_set(); buferU2_set(); buferU3_set(); //////////////////////////////////////************************************* //установка даты времени if ((newtime==1)||(newdate==1)) { calcSeconds(date1,time1,0,&X); Xsave=X;//последняя установка set_CNTRTC(); newdate=0; newtime=0; } }