static void kb_irq(void) { char buf[2]={0}; char numbuf[6];/*five digit will be enough for a int*/ int i; byte scancode=inportb(0x60); //really ineffective for(i=0;i<sizeof(Scan_Tab);i++) { if(scancode==Scan_Tab[i]) break; } if(i<sizeof(Scan_Tab) ) { kprintf("%c", Disp_Tab[i]); switch (Disp_Tab[i]) { case 'X': enable_timer(); break; case 'R': disable_timer(); break; case 'S': reset_sys(); } } outportb(0x20,0x20); }
void *infrad_ctrl(void *ptr) { int ret; int fd_infrad = -1; int fd_adc = -1; int adc_value = -1; fd_infrad = open(INFRAD_DEV_NAME, O_RDWR); if(fd_infrad<0){ printf("infrad_ctrl: open device %s failed.\n", INFRAD_DEV_NAME); goto exit_infrad_ctrl; } fd_adc = open(KEY_DEV_NAME, O_RDONLY|O_NONBLOCK); if(fd_adc<0){ printf("infrad_ctrl: open device %s failed.\n", KEY_DEV_NAME); goto exit_infrad_ctrl; } printf("infrad_ctrl control start....\n"); set_to_Color(fd_infrad);//开始强制关闭 while(1){ switch(getInfradStatue()){ case 1://强制开 set_to_Color(fd_infrad); break; case 2://强制关 set_to_White(fd_infrad); break; case 0://自动 default: adc_value = get_adc_value(fd_adc); if(adc_value<0){ break; } if(adc_value>getImgWtoC()){ set_to_Color(fd_infrad); }else if(adc_value<getImgCtoW()){ set_to_White(fd_infrad); } break; } if(0==get_reset_value(fd_infrad)){ reset_stat++; }else{ reset_stat = 0; } if(reset_stat>2){ reset_sys(); reset_stat = 0; } sleep(2); } exit_infrad_ctrl: if(fd_infrad>0){ close(fd_infrad); fd_infrad = -1; } if(fd_adc>0){ close(fd_adc); fd_adc = -1; } return; }