基于K60單片機的攝像頭歷程,0.96OLED時實屏幕顯示圖片。
單片機源程序如下:
- /*!
- * @file main.c
- * @brief 山外K60 平臺主程序
- * @author 山外科技
- * @version v5.0
- * @date 2013-08-28
- */
- #include "common.h"
- #include "include.h"
- uint8 imgbuff[CAMERA_SIZE]; //定義存儲接收圖像的數組
- uint8 img[CAMERA_H][CAMERA_W];
- //函數聲明
- void PORTA_IRQHandler();
- void DMA0_IRQHandler();
- /*!
- * @brief main函數
- * @since v5.0
- * @note 山外攝像頭 LCD 測試實驗
- */
- void main(void)
- {
- Site_t site = {0, 0}; //顯示圖像左上角位置
- Size_t imgsize = {CAMERA_W, CAMERA_H}; //圖像大小
- Size_t size; //顯示區域圖像大小
- LCD_init();
- LCD_str (site,"Cam init ing",FCOLOUR,BCOLOUR);
- size.H = LCD_H;
- size.W = LCD_W;
- camera_init(imgbuff);
- LCD_str (site,"Cam init OK!",FCOLOUR,BCOLOUR);
- site.y = 110;
- LCD_FSTR_CH(site,vcan_str,FCOLOUR,BCOLOUR);
- //配置中斷服務函數
- set_vector_handler(PORTA_VECTORn , PORTA_IRQHandler); //設置 PORTA 的中斷服務函數為 PORTA_IRQHandler
- set_vector_handler(DMA0_VECTORn , DMA0_IRQHandler); //設置 DMA0 的中斷服務函數為 PORTA_IRQHandler
- site.y = 0;
- while(1)
- {
- camera_get_img(); //攝像頭獲取圖像
- //黑白攝像頭
- LCD_Img_Binary_Z(site, size, imgbuff, imgsize);
- /******************** 山外多功能調試助手 【黑白模式】 發送圖像到上位機 ***********************/
- vcan_sendimg(imgbuff, sizeof(imgbuff));
- /******************** 山外多功能調試助手 【灰度模式】 發送圖像到上位機 ***********************/
- //img_extract(img, imgbuff, CAMERA_SIZE); //解壓為灰度圖像,方便發送到上位機顯
- //vcan_sendimg(img, sizeof(img));
- /******************** 發送圖像到上位機 ***********************/
- //img_extract(img, imgbuff, CAMERA_SIZE); //解壓為灰度圖像,方便發送到上位機顯
- //sendimg(img, CAMERA_W * CAMERA_H); //發送到上位機
- }
- }
- /*!
- * @brief PORTA中斷服務函數
- * @since v5.0
- */
- void PORTA_IRQHandler()
- {
- uint8 n; //引腳號
- uint32 flag;
- while(!PORTA_ISFR);
- flag = PORTA_ISFR;
- PORTA_ISFR = ~0; //清中斷標志位
- n = 29; //場中斷
- if(flag & (1 << n)) //PTA29觸發中斷
- {
- camera_vsync();
- }
- #if ( CAMERA_USE_HREF == 1 ) //使用行中斷
- n = 28;
- if(flag & (1 << n)) //PTA28觸發中斷
- {
- camera_href();
- }
- #endif
- }
- /*!
- * @brief DMA0中斷服務函數
- * @since v5.0
- */
- void DMA0_IRQHandler()
- {
- camera_dma();
- }
復制代碼
所有資料51hei提供下載:
K60鷹眼攝像頭例程.rar
(2.53 MB, 下載次數: 32)
2018-11-16 14:57 上傳
點擊文件名下載附件
K60攝像頭
|