void ov7725_eagle_vsync(void) { //uart_putchar (UART0, 0); //场中断需要判断是场结束还是场开始 if(ov7725_eagle_img_flag == IMG_START) //需要开始采集图像 { if(PORTD_ISFR & 0x2000) //PTD13触发中断,采集的行中断 { PORTD_ISFR |= 0x2000; //写1清中断标志位 if(Sample_Flag==0) { return; } if((LinCout%(480/DATALINE)==0)&&(LinADCout<DATALINE)) { //uart_putchar (UART0, 1); systick_delay_us(8); DMA_DADDR(DMA_CH4) = (uint32_t)ov7725_eagle_img_buff[LinADCout] ; //数据存储地址变化 DMA_EN(DMA_CH4); //使能通道CHn 硬件请求 (这样才能继续触发DMA传输) DMA_IRQ_EN(DMA_CH4) ; //允许DMA通道传输 LinADCout ++ ; } LinCout++; if(LinADCout==DATALINE) { LinADCout=0; ov7725_eagle_img_flag = IMG_FINISH; Sample_Flag=0; disable_irq(PORTD_IRQn); //关闭PTd的中断 } } if(PORTD_ISFR & 0x4000) //PTD14触发中断,采集的场中断。 { PORTD_ISFR |= 0x4000; //写1清中断标志 //uart_putchar (UART0, 2); LinCout = 0 ; LinADCout=0; Sample_Flag=1; port_init(PTD13, ALT1 | IRQ_FALLING | PULLUP ); //初始化 PTD7 管脚,复用功能为GPIO ,下降沿触发中断,上拉电阻 PORTD_ISFR |= 0x2000; //写1清中断标志位 } } }
/*! * @brief 鹰眼ov7725场中断服务函数 * @since v5.0 */ void ov7725_eagle_vsync(void) { //场中断需要判断是场结束还是场开始 if(ov7725_eagle_img_flag == IMG_START) //需要开始采集图像 { ov7725_eagle_img_flag = IMG_GATHER; //标记图像采集中 disable_irq(PORTC_IRQn); DMA_EN(CAMERA_DMA_CH); //使能通道CHn 硬件请求 DMA_DADDR(CAMERA_DMA_CH) = (uint32)ov7725_eagle_img_buff; //恢复地址 } else //图像采集错误 { disable_irq(PORTC_IRQn); //关闭PTA的中断 ov7725_eagle_img_flag = IMG_FAIL; //标记图像采集失败 } }
void DmaChannelInit(int channel, void *source_ptr, void *dest_ptr, int size, int source, int source_inc, int dest_inc) { // Configure mux. // Disable channel and clear everything. DMAMUX_CHCFG(channel) = 0x00; // Select source. DMAMUX_CHCFG(channel) |= DMAMUX_CHCFG_SOURCE(source); // Configure channel. // Set up source and dest addresses. DMA_SADDR(channel) = (int)source_ptr; DMA_DADDR(channel) = (int)dest_ptr; // Set soruce and dest address increment. DMA_SOFF(channel) = source_inc; DMA_DOFF(channel) = dest_inc; // Set size of transfer 0x00 = 1 byte. DMA_ATTR(channel) = DMA_ATTR_SSIZE(0) | DMA_ATTR_DSIZE(0); // Set bytes per minor loop. DMA_NBYTES_MLNO(channel) = 0x01; // Set number of minor loops. DMA_CITER_ELINKNO(channel) = DMA_CITER_ELINKNO_CITER(size); DMA_BITER_ELINKNO(channel) = DMA_BITER_ELINKNO_BITER(size); // Adjustment applied after major loop finishes DMA_SLAST(channel) = -(size * source_inc); // Source address adjustment. DMA_DLAST_SGA(channel) = -(size * dest_inc); // Destination address adjustment. // Set to disable on completion. DMA_CSR(0) |= DMA_CSR_DREQ_MASK; // Enable DMA request for channel. DMA_ERQ |= (1 << channel); // Enable mux. DMAMUX_CHCFG(channel) |= DMAMUX_CHCFG_ENBL_MASK; }
void PORTA_ISR(void) //场中断处理函数 { if(PORTA_ISFR & (1 << 29)) //PTA29触发中断 { switch(img_flag) { case IMG_START: img_flag = IMG_GATHER; //标记图像采集中 DMA_EN(CAMERA_DMA_CH); //使能通道CHn 硬件请求 DMA_DADDR(CAMERA_DMA_CH) = (uint32)IMG_BUFF; //恢复地址 break; default : break; } } if (PORTA_ISFR & (1 << 10)) // TAGS: 编码器引脚PTA10中断 { encoder_cnt ++; } PORTA_ISFR = ~0; //场中断里,全部都要清中断标志位 }