static void timer_b_interrupt(void) { //char tmp[128]; time_count++; if(debug_timer == 1 && time_count % 10 == 0) { if(debug_timer_pwm == 0) { debug_timer_pwm = 1; open_pwm(irreceiver_data->pwm_no);;//on } else { debug_timer_pwm = 0; close_pwm(irreceiver_data->pwm_no);//off } } if(shot_time !=0 && (time_count*10) >= shot_time) { //sprintf(tmp, "[%lu][%lu]", shot_time, time_count*10); //strcat(logbuf, tmp); oneshot_event(); } }
static void oneshot_event(void) { shot_time = 0; if(pwmSwitch == 0) { pwmSwitch = 1; open_pwm(irreceiver_data->pwm_no);//on } else { pwmSwitch = 0; close_pwm(irreceiver_data->pwm_no);//off } //set next window timer send_idx++; if(send_idx < send_win.winNum) { set_timer_b_event(send_win.winArray[send_idx]); } else //pwm should be off { close_pwm(irreceiver_data->pwm_no);; pwmSwitch = 0; send_flag = 0; } }
void system_init() { open_pwm(); openINIO(); openOUTIO(); forward(); stop(); }
static int aml_ir_receiver_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long args) { int i; s32 r = 0; unsigned long flags; void __user *argp = (void __user *)args; dbg("aml_ir_receiver_ioctl()\n"); switch(cmd) { case IRRECEIVER_IOC_SEND: if (copy_from_user(&send_win, argp, sizeof(struct ir_window))) return -EFAULT; #ifdef DEBUG for(i=0; i<send_win.winNum; i++) dbg("idx[%d]:[%d]\n", i, send_win.winArray[i]); #endif logbuf[0] = 0; send_idx = 0; pwmSwitch = 1; send_flag = 1; open_pwm(irreceiver_data->pwm_no);; if(send_idx < send_win.winNum) { local_irq_save(flags); set_timer_b_event(send_win.winArray[send_idx]); local_irq_restore(flags); } break; case IRRECEIVER_IOC_RECV: dbg("recv win [%d]\n", reced_win.winNum); if(copy_to_user(argp, &reced_win, sizeof(struct ir_window))) return -EFAULT; break; case IRRECEIVER_IOC_STUDY_S: dbg("IRRECEIVER_IOC_STUDY_S\n"); rec_win.winNum = 0; reced_win.winNum = 0; invalid_win = 0; end_key = false; break; case IRRECEIVER_IOC_STUDY_E: dbg("IRRECEIVER_IOC_STUDY_E\n"); break; default: r = -ENOIOCTLCMD; break; } return r; }
/*---------------------------------------------------------------------------------------------------------*/ int main (void) { unsigned int i=0; SYS_Init(); P20=0;P21=0; _GPIO_SET_PIN_MODE(P3,6,GPIO_PMD_OUTPUT); open_capture(); //open capture funcation open_pwm3(); while(1) { if(LIGHT_RESISTANCES) //day { if(light_flag!=DAY) //night turn to day need close LED { light_flag=DAY; close_pwm(0); close_pwm(1); clean_capture_flag(); //day close capture } } else //night { if(light_flag!=NIGHT) //day turn to night { light_flag=NIGHT; open_pwm(0); //open led0 //open_pwm(1); if(!capture_start_enable) open_capture_flag(); } else { if(capture_wave_count>=CAPTURE_ALL_TIME) //capture compelet once time { if(calculate_capture_frequency()==0) //have someone pass by, led1 light { open_pwm(1); open_timer0(); open_capture_flag(); while(timer0_100ms_count<50) // 3s { if(capture_wave_count>=CAPTURE_ALL_TIME) { if(calculate_capture_frequency()==0) //have peope { timer0_100ms_count=0; } open_capture_flag(); } if(LIGHT_RESISTANCES) //day { open_capture_flag(); break; } } close_timer0(); close_pwm(1); } else open_capture_flag(); } } } //delay some time for check light resistance for(i=0;i<1000;i++); } //return 0; }