標題: STM32+ADNS3080光流傳感器測距 源程序 [打印本頁]

作者: butterzx    時間: 2020-4-15 17:52
標題: STM32+ADNS3080光流傳感器測距 源程序
這是目前正在做的用ADNS3080光流傳感器做距離定位的工程,主要用來采集平面移動時,坐標系X,Y的值。

單片機源程序如下:
  1. /* Includes ------------------------------------------------------------------*/
  2. #include "stm32f10x.h"
  3. #include "usart.h"
  4. #include "delay.h"
  5. #include "spi.h"
  6. #include"ADNS3080.h"
  7. void RCC_Configuration(void);
  8. void GPIO_Configuration(void);
  9. int main(void)
  10. {
  11.   RCC_Configuration();
  12.   GPIO_Configuration();
  13.   //GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable,ENABLE);        //使能JATG //PB口         
  14.   USART_Configuration(115200);
  15.   delay_init(72); //        精確延時初始化
  16.   delay_ms(10);
  17.   ADNS3080_Init();
  18.   delay_ms(10);
  19. //  printf("%d\n",read_zhenlv());//(3000幀/秒)24000000/3000幀每秒=8000 4800則5000幀
  20. //  delay_ms(10);
  21. //  printf("%d\n",read_register(Motion)&0x01);//等于1則為1600分辨率  
  22. //  delay_ms(10);
  23. //  printf("%f\n",read_average_pixel()); //平均像素
  24. //read_pixel();         //圖像顯示        鏡頭焦距為8毫米時離鏡座3毫米時最清
  25. // read_pixel_burst();  //爆發(fā)方式顯示圖像  
  26.   while (1)
  27.   {          
  28.   Read_Data_burst(); //用爆發(fā)讀
  29.                   delay_ms(10);          
  30.   }       
  31. }
  32. void RCC_Configuration(void)
  33. {  
  34.   SystemInit();// 啟動時鐘 PLL and Flash   
  35.   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOD|RCC_APB2Periph_AFIO,ENABLE);//        時鐘全打開了          
  36. }
  37. void GPIO_Configuration(void)
  38.   {
  39.     GPIO_InitTypeDef GPIO_InitStructure;              //定義一個結構體
  40.         GPIO_InitStructure.GPIO_Pin        = GPIO_Pin_2;//選擇LED管腳
  41.           GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;        //管腳頻率為50MHZ
  42.           GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;        //模式為推挽輸出
  43.           GPIO_Init(GPIOD, &GPIO_InitStructure);   //初始化GPIOB寄存器
  44.     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4|GPIO_Pin_8;
  45.     GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  46.     GPIO_InitStructure.GPIO_Mode =GPIO_Mode_Out_PP; //推挽輸出
  47.     GPIO_Init(GPIOA, &GPIO_InitStructure);
  48.   }
復制代碼

所有資料51hei提供下載:
ADNS3080測距離.7z (1.03 MB, 下載次數(shù): 108)



作者: FEIJI1998    時間: 2021-11-8 11:24
您好,這個項目的使用效果是怎樣的,數(shù)據怎么跟別的系統(tǒng)對接
作者: 32_51_w    時間: 2024-9-20 15:20
您好 我想問一下那個SROM是干什么用的




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1