|
這是目前正在做的用ADNS3080光流傳感器做距離定位的工程,主要用來采集平面移動時,坐標(biāo)系X,Y的值。
單片機(jī)源程序如下:
- /* Includes ------------------------------------------------------------------*/
- #include "stm32f10x.h"
- #include "usart.h"
- #include "delay.h"
- #include "spi.h"
- #include"ADNS3080.h"
- void RCC_Configuration(void);
- void GPIO_Configuration(void);
- int main(void)
- {
- RCC_Configuration();
- GPIO_Configuration();
- //GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable,ENABLE); //使能JATG //PB口
- USART_Configuration(115200);
- delay_init(72); // 精確延時初始化
- delay_ms(10);
- ADNS3080_Init();
- delay_ms(10);
- // printf("%d\n",read_zhenlv());//(3000幀/秒)24000000/3000幀每秒=8000 4800則5000幀
- // delay_ms(10);
- // printf("%d\n",read_register(Motion)&0x01);//等于1則為1600分辨率
- // delay_ms(10);
- // printf("%f\n",read_average_pixel()); //平均像素
- //read_pixel(); //圖像顯示 鏡頭焦距為8毫米時離鏡座3毫米時最清
- // read_pixel_burst(); //爆發(fā)方式顯示圖像
- while (1)
- {
- Read_Data_burst(); //用爆發(fā)讀
- delay_ms(10);
- }
- }
- void RCC_Configuration(void)
- {
- SystemInit();// 啟動時鐘 PLL and Flash
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOD|RCC_APB2Periph_AFIO,ENABLE);// 時鐘全打開了
- }
- void GPIO_Configuration(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure; //定義一個結(jié)構(gòu)體
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;//選擇LED管腳
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //管腳頻率為50MHZ
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //模式為推挽輸出
- GPIO_Init(GPIOD, &GPIO_InitStructure); //初始化GPIOB寄存器
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4|GPIO_Pin_8;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_Mode =GPIO_Mode_Out_PP; //推挽輸出
- GPIO_Init(GPIOA, &GPIO_InitStructure);
- }
復(fù)制代碼
所有資料51hei提供下載:
ADNS3080測距離.7z
(1.03 MB, 下載次數(shù): 108)
2020-4-15 18:46 上傳
點(diǎn)擊文件名下載附件
基于STM32F103ZE的光流傳感器傳平面移動距離采集 下載積分: 黑幣 -5
|
評分
-
查看全部評分
|