这是目前正在做的用ADNS3080光流传感器做距离定位的工程,主要用来采集平面移动时,坐标系X,Y的值。
单片机源程序如下:
- /* 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(); //爆发方式显示图像
- while (1)
- {
- Read_Data_burst(); //用爆发读
- 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; //定义一个结构体
- 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);
- }
复制代码
所有资料51hei提供下载:
ADNS3080测距离.7z
(1.03 MB, 下载次数: 108)
|