提交裸机版工程
This commit is contained in:
parent
0e839fdba3
commit
b0e72aa6df
1099 changed files with 607159 additions and 0 deletions
86
软件/mouse_paw3395/MyCode/Delay.c
Normal file
86
软件/mouse_paw3395/MyCode/Delay.c
Normal file
|
@ -0,0 +1,86 @@
|
|||
#include "delay.h"
|
||||
#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */
|
||||
#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */
|
||||
|
||||
/* following defines should be used for structure members */
|
||||
#define __IM volatile const /*! Defines 'read only' structure member permissions */
|
||||
#define __OM volatile /*! Defines 'write only' structure member permissions */
|
||||
#define __IOM volatile /*! Defines 'read / write' structure member permissions */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
__IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */
|
||||
__IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */
|
||||
__IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */
|
||||
__IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */
|
||||
} SysTick_Type;
|
||||
|
||||
#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */
|
||||
|
||||
//void delay_ms(unsigned int t)
|
||||
//{
|
||||
// int i;
|
||||
// for( i=0;i<t;i++)
|
||||
// {
|
||||
// int a=10300;//10300
|
||||
// while(a--);
|
||||
// }
|
||||
//}
|
||||
|
||||
//void delay_us(unsigned int t)
|
||||
//{
|
||||
// int i;
|
||||
// for( i=0;i<t;i++)
|
||||
// {
|
||||
// int a=9;//9
|
||||
// while(a--);
|
||||
// }
|
||||
//}
|
||||
|
||||
/******************************************************************************/
|
||||
//用于3.0或者以上库
|
||||
/******************************************************************************/
|
||||
|
||||
uint8_t fac_us; //延时基数(延时一微秒所要设置的时间)
|
||||
uint16_t fac_ms;
|
||||
void delay_init(uint8_t SYSCLK)
|
||||
{
|
||||
SysTick->CTRL &= 0xfffffffb;// HCLK/8 bit2 = CLKSOURCE 选择外部时钟 0=外部时钟源 1=内核时钟源
|
||||
fac_us=SYSCLK/8;
|
||||
fac_ms=(uint16_t)fac_us*1000;
|
||||
}
|
||||
void delay_us(uint32_t nus)
|
||||
{
|
||||
uint32_t temp;
|
||||
SysTick->LOAD = nus*fac_us;//加载的时间
|
||||
SysTick->VAL = 0x00; //清空计数器
|
||||
SysTick->CTRL = 0x01; //开始倒数
|
||||
temp = SysTick->CTRL;
|
||||
while((temp&0x01)&&(!(temp&(1<<16))))temp = SysTick->CTRL;
|
||||
SysTick->CTRL=0x00; //关闭计数器
|
||||
SysTick->VAL =0X00; //清空计数器
|
||||
|
||||
}
|
||||
void delay_ms(uint16_t nms)
|
||||
{
|
||||
uint32_t temp;
|
||||
SysTick->LOAD = (uint32_t)nms*fac_ms;//加载的时间
|
||||
SysTick->VAL = 0x00; //清空计数器
|
||||
SysTick->CTRL = 0x01; //开始倒数
|
||||
temp = SysTick->CTRL;
|
||||
while((temp&0x01)&&(!(temp&(1<<16)))) temp = SysTick->CTRL;
|
||||
SysTick->CTRL=0x00; //关闭计数器
|
||||
SysTick->VAL =0X00; //清空计数器
|
||||
}
|
||||
|
||||
void delay_125_ns(uint8_t nns)
|
||||
{
|
||||
uint32_t temp;
|
||||
SysTick->LOAD = (uint32_t)nns;//加载的时间
|
||||
SysTick->VAL = 0x00; //清空计数器
|
||||
SysTick->CTRL = 0x01; //开始倒数
|
||||
temp = SysTick->CTRL;
|
||||
while((temp&0x01)&&(!(temp&(1<<16)))) temp = SysTick->CTRL;
|
||||
SysTick->CTRL=0x00; //关闭计数器
|
||||
SysTick->VAL =0X00; //清空计数器
|
||||
}
|
8
软件/mouse_paw3395/MyCode/Delay.h
Normal file
8
软件/mouse_paw3395/MyCode/Delay.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef __DELAY_H__
|
||||
#define __DELAY_H__
|
||||
#include "stdint.h"
|
||||
void delay_init(uint8_t SYSCLK);
|
||||
void delay_ms(uint16_t nms);
|
||||
void delay_us(uint32_t nus);
|
||||
void delay_125_ns(uint8_t nns);
|
||||
#endif
|
1422
软件/mouse_paw3395/MyCode/OLED.c
Normal file
1422
软件/mouse_paw3395/MyCode/OLED.c
Normal file
File diff suppressed because it is too large
Load diff
67
软件/mouse_paw3395/MyCode/OLED.h
Normal file
67
软件/mouse_paw3395/MyCode/OLED.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
#ifndef __OLED_H
|
||||
#define __OLED_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "OLED_Data.h"
|
||||
|
||||
/*参数宏定义*********************/
|
||||
|
||||
/*OLED地址*/
|
||||
#define OLED_ADDRESS 0x78
|
||||
|
||||
/*FontSize参数取值*/
|
||||
/*此参数值不仅用于判断,而且用于计算横向字符偏移,默认值为字体像素宽度*/
|
||||
#define OLED_8X16 8
|
||||
#define OLED_6X8 6
|
||||
|
||||
/*IsFilled参数数值*/
|
||||
#define OLED_UNFILLED 0
|
||||
#define OLED_FILLED 1
|
||||
|
||||
/*********************参数宏定义*/
|
||||
|
||||
|
||||
/*函数声明*********************/
|
||||
|
||||
/*初始化函数*/
|
||||
void OLED_Init(void);
|
||||
|
||||
/*更新函数*/
|
||||
void OLED_Update(void);
|
||||
void OLED_UpdateArea(int16_t X, int16_t Y, uint8_t Width, uint8_t Height);
|
||||
|
||||
/*显存控制函数*/
|
||||
void OLED_Clear(void);
|
||||
void OLED_ClearArea(int16_t X, int16_t Y, uint8_t Width, uint8_t Height);
|
||||
void OLED_Reverse(void);
|
||||
void OLED_ReverseArea(int16_t X, int16_t Y, uint8_t Width, uint8_t Height);
|
||||
|
||||
/*显示函数*/
|
||||
void OLED_ShowChar(int16_t X, int16_t Y, char Char, uint8_t FontSize);
|
||||
void OLED_ShowString(int16_t X, int16_t Y, char *String, uint8_t FontSize);
|
||||
void OLED_ShowNum(int16_t X, int16_t Y, uint32_t Number, uint8_t Length, uint8_t FontSize);
|
||||
void OLED_ShowSignedNum(int16_t X, int16_t Y, int32_t Number, uint8_t Length, uint8_t FontSize);
|
||||
void OLED_ShowHexNum(int16_t X, int16_t Y, uint32_t Number, uint8_t Length, uint8_t FontSize);
|
||||
void OLED_ShowBinNum(int16_t X, int16_t Y, uint32_t Number, uint8_t Length, uint8_t FontSize);
|
||||
void OLED_ShowFloatNum(int16_t X, int16_t Y, double Number, uint8_t IntLength, uint8_t FraLength, uint8_t FontSize);
|
||||
void OLED_ShowChinese(int16_t X, int16_t Y, char *Chinese);
|
||||
void OLED_ShowImage(int16_t X, int16_t Y, uint8_t Width, uint8_t Height, const uint8_t *Image);
|
||||
void OLED_Printf(int16_t X, int16_t Y, uint8_t FontSize, char *format, ...);
|
||||
|
||||
/*绘图函数*/
|
||||
void OLED_DrawPoint(int16_t X, int16_t Y);
|
||||
uint8_t OLED_GetPoint(int16_t X, int16_t Y);
|
||||
void OLED_DrawLine(int16_t X0, int16_t Y0, int16_t X1, int16_t Y1);
|
||||
void OLED_DrawRectangle(int16_t X, int16_t Y, uint8_t Width, uint8_t Height, uint8_t IsFilled);
|
||||
void OLED_DrawTriangle(int16_t X0, int16_t Y0, int16_t X1, int16_t Y1, int16_t X2, int16_t Y2, uint8_t IsFilled);
|
||||
void OLED_DrawCircle(int16_t X, int16_t Y, uint8_t Radius, uint8_t IsFilled);
|
||||
void OLED_DrawEllipse(int16_t X, int16_t Y, uint8_t A, uint8_t B, uint8_t IsFilled);
|
||||
void OLED_DrawArc(int16_t X, int16_t Y, uint8_t Radius, int16_t StartAngle, int16_t EndAngle, uint8_t IsFilled);
|
||||
|
||||
/*********************函数声明*/
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*****************江协科技|版权所有****************/
|
||||
/*****************jiangxiekeji.com*****************/
|
390
软件/mouse_paw3395/MyCode/OLED_Data.c
Normal file
390
软件/mouse_paw3395/MyCode/OLED_Data.c
Normal file
|
@ -0,0 +1,390 @@
|
|||
#include "OLED_Data.h"
|
||||
|
||||
/**
|
||||
* 数据存储格式:
|
||||
* 纵向8点,高位在下,先从左到右,再从上到下
|
||||
* 每一个Bit对应一个像素点
|
||||
*
|
||||
* B0 B0 B0 B0
|
||||
* B1 B1 B1 B1
|
||||
* B2 B2 B2 B2
|
||||
* B3 B3 -------------> B3 B3 --
|
||||
* B4 B4 B4 B4 |
|
||||
* B5 B5 B5 B5 |
|
||||
* B6 B6 B6 B6 |
|
||||
* B7 B7 B7 B7 |
|
||||
* |
|
||||
* -----------------------------------
|
||||
* |
|
||||
* | B0 B0 B0 B0
|
||||
* | B1 B1 B1 B1
|
||||
* | B2 B2 B2 B2
|
||||
* --> B3 B3 -------------> B3 B3
|
||||
* B4 B4 B4 B4
|
||||
* B5 B5 B5 B5
|
||||
* B6 B6 B6 B6
|
||||
* B7 B7 B7 B7
|
||||
*
|
||||
*/
|
||||
|
||||
/*ASCII字模数据*********************/
|
||||
|
||||
/*宽8像素,高16像素*/
|
||||
const uint8_t OLED_F8x16[][16] =
|
||||
{
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0
|
||||
0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,// ! 1
|
||||
0x00,0x16,0x0E,0x00,0x16,0x0E,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// " 2
|
||||
0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,
|
||||
0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,// # 3
|
||||
0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,
|
||||
0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,// $ 4
|
||||
0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,
|
||||
0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,// % 5
|
||||
0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,
|
||||
0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,// & 6
|
||||
0x00,0x00,0x00,0x16,0x0E,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// ' 7
|
||||
0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,
|
||||
0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,// ( 8
|
||||
0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,
|
||||
0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,// ) 9
|
||||
0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,
|
||||
0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,// * 10
|
||||
0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,
|
||||
0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,// + 11
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,// , 12
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,// - 13
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,// . 14
|
||||
0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,
|
||||
0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,// / 15
|
||||
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
|
||||
0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,// 0 16
|
||||
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,
|
||||
0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,// 1 17
|
||||
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,
|
||||
0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,// 2 18
|
||||
0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,
|
||||
0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,// 3 19
|
||||
0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,
|
||||
0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,// 4 20
|
||||
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,
|
||||
0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,// 5 21
|
||||
0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,
|
||||
0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,// 6 22
|
||||
0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,
|
||||
0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,// 7 23
|
||||
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,
|
||||
0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,// 8 24
|
||||
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
|
||||
0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,// 9 25
|
||||
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,// : 26
|
||||
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,
|
||||
0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,// ; 27
|
||||
0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,
|
||||
0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,// < 28
|
||||
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,
|
||||
0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,// = 29
|
||||
0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,
|
||||
0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,// > 30
|
||||
0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,
|
||||
0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,// ? 31
|
||||
0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,
|
||||
0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,// @ 32
|
||||
0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,
|
||||
0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,// A 33
|
||||
0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,
|
||||
0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,// B 34
|
||||
0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,
|
||||
0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,// C 35
|
||||
0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,
|
||||
0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,// D 36
|
||||
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,
|
||||
0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,// E 37
|
||||
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,
|
||||
0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,// F 38
|
||||
0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,
|
||||
0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,// G 39
|
||||
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,
|
||||
0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,// H 40
|
||||
0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,
|
||||
0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,// I 41
|
||||
0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,
|
||||
0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,// J 42
|
||||
0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,
|
||||
0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,// K 43
|
||||
0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,
|
||||
0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,// L 44
|
||||
0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,
|
||||
0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,// M 45
|
||||
0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,
|
||||
0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,// N 46
|
||||
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,
|
||||
0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,// O 47
|
||||
0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,
|
||||
0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,// P 48
|
||||
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,
|
||||
0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,// Q 49
|
||||
0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,
|
||||
0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,// R 50
|
||||
0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,
|
||||
0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,// S 51
|
||||
0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,
|
||||
0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,// T 52
|
||||
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,
|
||||
0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,// U 53
|
||||
0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,
|
||||
0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,// V 54
|
||||
0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,
|
||||
0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,// W 55
|
||||
0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,
|
||||
0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,// X 56
|
||||
0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,
|
||||
0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,// Y 57
|
||||
0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,
|
||||
0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,// Z 58
|
||||
0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,
|
||||
0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,// [ 59
|
||||
0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,// \ 60
|
||||
0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,
|
||||
0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,// ] 61
|
||||
0x00,0x20,0x10,0x08,0x04,0x08,0x10,0x20,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// ^ 62
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,// _ 63
|
||||
0x00,0x02,0x04,0x08,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// ` 64
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,
|
||||
0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,// a 65
|
||||
0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,
|
||||
0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,// b 66
|
||||
0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,
|
||||
0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,// c 67
|
||||
0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,
|
||||
0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,// d 68
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,
|
||||
0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,// e 69
|
||||
0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,
|
||||
0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,// f 70
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,
|
||||
0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,// g 71
|
||||
0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,
|
||||
0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,// h 72
|
||||
0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,
|
||||
0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,// i 73
|
||||
0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,
|
||||
0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,// j 74
|
||||
0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,
|
||||
0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,// k 75
|
||||
0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,
|
||||
0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,// l 76
|
||||
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
|
||||
0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,// m 77
|
||||
0x00,0x80,0x80,0x00,0x80,0x80,0x00,0x00,
|
||||
0x00,0x20,0x3F,0x21,0x00,0x20,0x3F,0x20,// n 78
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,
|
||||
0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,// o 79
|
||||
0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,
|
||||
0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,// p 80
|
||||
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,
|
||||
0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,// q 81
|
||||
0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,
|
||||
0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,// r 82
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,
|
||||
0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,// s 83
|
||||
0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,
|
||||
0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,// t 84
|
||||
0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,
|
||||
0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,// u 85
|
||||
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,
|
||||
0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,// v 86
|
||||
0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,
|
||||
0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,// w 87
|
||||
0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,
|
||||
0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,// x 88
|
||||
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,
|
||||
0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,// y 89
|
||||
0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
|
||||
0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,// z 90
|
||||
0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,
|
||||
0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,// { 91
|
||||
0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,// | 92
|
||||
0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,
|
||||
0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,// } 93
|
||||
0x00,0x80,0x40,0x40,0x80,0x00,0x00,0x80,
|
||||
0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,// ~ 94
|
||||
};
|
||||
|
||||
/*宽6像素,高8像素*/
|
||||
const uint8_t OLED_F6x8[][6] =
|
||||
{
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,// 0
|
||||
0x00,0x00,0x00,0x2F,0x00,0x00,// ! 1
|
||||
0x00,0x00,0x07,0x00,0x07,0x00,// " 2
|
||||
0x00,0x14,0x7F,0x14,0x7F,0x14,// # 3
|
||||
0x00,0x24,0x2A,0x7F,0x2A,0x12,// $ 4
|
||||
0x00,0x23,0x13,0x08,0x64,0x62,// % 5
|
||||
0x00,0x36,0x49,0x55,0x22,0x50,// & 6
|
||||
0x00,0x00,0x00,0x07,0x00,0x00,// ' 7
|
||||
0x00,0x00,0x1C,0x22,0x41,0x00,// ( 8
|
||||
0x00,0x00,0x41,0x22,0x1C,0x00,// ) 9
|
||||
0x00,0x14,0x08,0x3E,0x08,0x14,// * 10
|
||||
0x00,0x08,0x08,0x3E,0x08,0x08,// + 11
|
||||
0x00,0x00,0x00,0xA0,0x60,0x00,// , 12
|
||||
0x00,0x08,0x08,0x08,0x08,0x08,// - 13
|
||||
0x00,0x00,0x60,0x60,0x00,0x00,// . 14
|
||||
0x00,0x20,0x10,0x08,0x04,0x02,// / 15
|
||||
0x00,0x3E,0x51,0x49,0x45,0x3E,// 0 16
|
||||
0x00,0x00,0x42,0x7F,0x40,0x00,// 1 17
|
||||
0x00,0x42,0x61,0x51,0x49,0x46,// 2 18
|
||||
0x00,0x21,0x41,0x45,0x4B,0x31,// 3 19
|
||||
0x00,0x18,0x14,0x12,0x7F,0x10,// 4 20
|
||||
0x00,0x27,0x45,0x45,0x45,0x39,// 5 21
|
||||
0x00,0x3C,0x4A,0x49,0x49,0x30,// 6 22
|
||||
0x00,0x01,0x71,0x09,0x05,0x03,// 7 23
|
||||
0x00,0x36,0x49,0x49,0x49,0x36,// 8 24
|
||||
0x00,0x06,0x49,0x49,0x29,0x1E,// 9 25
|
||||
0x00,0x00,0x36,0x36,0x00,0x00,// : 26
|
||||
0x00,0x00,0x56,0x36,0x00,0x00,// ; 27
|
||||
0x00,0x08,0x14,0x22,0x41,0x00,// < 28
|
||||
0x00,0x14,0x14,0x14,0x14,0x14,// = 29
|
||||
0x00,0x00,0x41,0x22,0x14,0x08,// > 30
|
||||
0x00,0x02,0x01,0x51,0x09,0x06,// ? 31
|
||||
0x00,0x3E,0x49,0x55,0x59,0x2E,// @ 32
|
||||
0x00,0x7C,0x12,0x11,0x12,0x7C,// A 33
|
||||
0x00,0x7F,0x49,0x49,0x49,0x36,// B 34
|
||||
0x00,0x3E,0x41,0x41,0x41,0x22,// C 35
|
||||
0x00,0x7F,0x41,0x41,0x22,0x1C,// D 36
|
||||
0x00,0x7F,0x49,0x49,0x49,0x41,// E 37
|
||||
0x00,0x7F,0x09,0x09,0x09,0x01,// F 38
|
||||
0x00,0x3E,0x41,0x49,0x49,0x7A,// G 39
|
||||
0x00,0x7F,0x08,0x08,0x08,0x7F,// H 40
|
||||
0x00,0x00,0x41,0x7F,0x41,0x00,// I 41
|
||||
0x00,0x20,0x40,0x41,0x3F,0x01,// J 42
|
||||
0x00,0x7F,0x08,0x14,0x22,0x41,// K 43
|
||||
0x00,0x7F,0x40,0x40,0x40,0x40,// L 44
|
||||
0x00,0x7F,0x02,0x0C,0x02,0x7F,// M 45
|
||||
0x00,0x7F,0x04,0x08,0x10,0x7F,// N 46
|
||||
0x00,0x3E,0x41,0x41,0x41,0x3E,// O 47
|
||||
0x00,0x7F,0x09,0x09,0x09,0x06,// P 48
|
||||
0x00,0x3E,0x41,0x51,0x21,0x5E,// Q 49
|
||||
0x00,0x7F,0x09,0x19,0x29,0x46,// R 50
|
||||
0x00,0x46,0x49,0x49,0x49,0x31,// S 51
|
||||
0x00,0x01,0x01,0x7F,0x01,0x01,// T 52
|
||||
0x00,0x3F,0x40,0x40,0x40,0x3F,// U 53
|
||||
0x00,0x1F,0x20,0x40,0x20,0x1F,// V 54
|
||||
0x00,0x3F,0x40,0x38,0x40,0x3F,// W 55
|
||||
0x00,0x63,0x14,0x08,0x14,0x63,// X 56
|
||||
0x00,0x07,0x08,0x70,0x08,0x07,// Y 57
|
||||
0x00,0x61,0x51,0x49,0x45,0x43,// Z 58
|
||||
0x00,0x00,0x7F,0x41,0x41,0x00,// [ 59
|
||||
0x00,0x02,0x04,0x08,0x10,0x20,// \ 60
|
||||
0x00,0x00,0x41,0x41,0x7F,0x00,// ] 61
|
||||
0x00,0x04,0x02,0x01,0x02,0x04,// ^ 62
|
||||
0x00,0x40,0x40,0x40,0x40,0x40,// _ 63
|
||||
0x00,0x00,0x01,0x02,0x04,0x00,// ` 64
|
||||
0x00,0x20,0x54,0x54,0x54,0x78,// a 65
|
||||
0x00,0x7F,0x48,0x44,0x44,0x38,// b 66
|
||||
0x00,0x38,0x44,0x44,0x44,0x20,// c 67
|
||||
0x00,0x38,0x44,0x44,0x48,0x7F,// d 68
|
||||
0x00,0x38,0x54,0x54,0x54,0x18,// e 69
|
||||
0x00,0x08,0x7E,0x09,0x01,0x02,// f 70
|
||||
0x00,0x18,0xA4,0xA4,0xA4,0x7C,// g 71
|
||||
0x00,0x7F,0x08,0x04,0x04,0x78,// h 72
|
||||
0x00,0x00,0x44,0x7D,0x40,0x00,// i 73
|
||||
0x00,0x40,0x80,0x84,0x7D,0x00,// j 74
|
||||
0x00,0x7F,0x10,0x28,0x44,0x00,// k 75
|
||||
0x00,0x00,0x41,0x7F,0x40,0x00,// l 76
|
||||
0x00,0x7C,0x04,0x18,0x04,0x78,// m 77
|
||||
0x00,0x7C,0x08,0x04,0x04,0x78,// n 78
|
||||
0x00,0x38,0x44,0x44,0x44,0x38,// o 79
|
||||
0x00,0xFC,0x24,0x24,0x24,0x18,// p 80
|
||||
0x00,0x18,0x24,0x24,0x18,0xFC,// q 81
|
||||
0x00,0x7C,0x08,0x04,0x04,0x08,// r 82
|
||||
0x00,0x48,0x54,0x54,0x54,0x20,// s 83
|
||||
0x00,0x04,0x3F,0x44,0x40,0x20,// t 84
|
||||
0x00,0x3C,0x40,0x40,0x20,0x7C,// u 85
|
||||
0x00,0x1C,0x20,0x40,0x20,0x1C,// v 86
|
||||
0x00,0x3C,0x40,0x30,0x40,0x3C,// w 87
|
||||
0x00,0x44,0x28,0x10,0x28,0x44,// x 88
|
||||
0x00,0x1C,0xA0,0xA0,0xA0,0x7C,// y 89
|
||||
0x00,0x44,0x64,0x54,0x4C,0x44,// z 90
|
||||
0x00,0x00,0x08,0x7F,0x41,0x00,// { 91
|
||||
0x00,0x00,0x00,0x7F,0x00,0x00,// | 92
|
||||
0x00,0x00,0x41,0x7F,0x08,0x00,// } 93
|
||||
0x00,0x08,0x04,0x08,0x10,0x08,// ~ 94
|
||||
};
|
||||
/*********************ASCII字模数据*/
|
||||
|
||||
|
||||
/*汉字字模数据*********************/
|
||||
|
||||
/*相同的汉字只需要定义一次,汉字不分先后顺序*/
|
||||
/*必须全部为汉字或者全角字符,不要加入任何半角字符*/
|
||||
|
||||
/*宽16像素,高16像素*/
|
||||
const ChineseCell_t OLED_CF16x16[] = {
|
||||
|
||||
",",
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x58,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
|
||||
"。",
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x18,0x24,0x24,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
|
||||
"你",
|
||||
0x00,0x80,0x60,0xF8,0x07,0x40,0x20,0x18,0x0F,0x08,0xC8,0x08,0x08,0x28,0x18,0x00,
|
||||
0x01,0x00,0x00,0xFF,0x00,0x10,0x0C,0x03,0x40,0x80,0x7F,0x00,0x01,0x06,0x18,0x00,
|
||||
|
||||
"好",
|
||||
0x10,0x10,0xF0,0x1F,0x10,0xF0,0x00,0x80,0x82,0x82,0xE2,0x92,0x8A,0x86,0x80,0x00,
|
||||
0x40,0x22,0x15,0x08,0x16,0x61,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,
|
||||
|
||||
"世",
|
||||
0x20,0x20,0x20,0xFE,0x20,0x20,0xFF,0x20,0x20,0x20,0xFF,0x20,0x20,0x20,0x20,0x00,
|
||||
0x00,0x00,0x00,0x7F,0x40,0x40,0x47,0x44,0x44,0x44,0x47,0x40,0x40,0x40,0x00,0x00,
|
||||
|
||||
"界",
|
||||
0x00,0x00,0x00,0xFE,0x92,0x92,0x92,0xFE,0x92,0x92,0x92,0xFE,0x00,0x00,0x00,0x00,
|
||||
0x08,0x08,0x04,0x84,0x62,0x1E,0x01,0x00,0x01,0xFE,0x02,0x04,0x04,0x08,0x08,0x00,
|
||||
|
||||
/*按照上面的格式,在这个位置加入新的汉字数据*/
|
||||
//...
|
||||
|
||||
|
||||
/*未找到指定汉字时显示的默认图形(一个方框,内部一个问号),请确保其位于数组最末尾*/
|
||||
"",
|
||||
0xFF,0x01,0x01,0x01,0x31,0x09,0x09,0x09,0x09,0x89,0x71,0x01,0x01,0x01,0x01,0xFF,
|
||||
0xFF,0x80,0x80,0x80,0x80,0x80,0x80,0x96,0x81,0x80,0x80,0x80,0x80,0x80,0x80,0xFF,
|
||||
|
||||
};
|
||||
|
||||
/*********************汉字字模数据*/
|
||||
|
||||
|
||||
/*图像数据*********************/
|
||||
|
||||
/*测试图像(一个方框,内部一个二极管符号),宽16像素,高16像素*/
|
||||
const uint8_t Diode[] = {
|
||||
0xFF,0x01,0x81,0x81,0x81,0xFD,0x89,0x91,0xA1,0xC1,0xFD,0x81,0x81,0x81,0x01,0xFF,
|
||||
0xFF,0x80,0x80,0x80,0x80,0x9F,0x88,0x84,0x82,0x81,0x9F,0x80,0x80,0x80,0x80,0xFF,
|
||||
};
|
||||
|
||||
/*按照上面的格式,在这个位置加入新的图像数据*/
|
||||
//...
|
||||
|
||||
/*********************图像数据*/
|
||||
|
||||
|
||||
/*****************江协科技|版权所有****************/
|
||||
/*****************jiangxiekeji.com*****************/
|
32
软件/mouse_paw3395/MyCode/OLED_Data.h
Normal file
32
软件/mouse_paw3395/MyCode/OLED_Data.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
#ifndef __OLED_DATA_H
|
||||
#define __OLED_DATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*中文字符字节宽度*/
|
||||
#define OLED_CHN_CHAR_WIDTH 2 //UTF-8编码格式给3,GB2312编码格式给2
|
||||
|
||||
/*字模基本单元*/
|
||||
typedef struct
|
||||
{
|
||||
char Index[OLED_CHN_CHAR_WIDTH + 1]; //汉字索引
|
||||
uint8_t Data[32]; //字模数据
|
||||
} ChineseCell_t;
|
||||
|
||||
/*ASCII字模数据声明*/
|
||||
extern const uint8_t OLED_F8x16[][16];
|
||||
extern const uint8_t OLED_F6x8[][6];
|
||||
|
||||
/*汉字字模数据声明*/
|
||||
extern const ChineseCell_t OLED_CF16x16[];
|
||||
|
||||
/*图像数据声明*/
|
||||
extern const uint8_t Diode[];
|
||||
/*按照上面的格式,在这个位置加入新的图像数据声明*/
|
||||
//...
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*****************江协科技|版权所有****************/
|
||||
/*****************jiangxiekeji.com*****************/
|
356
软件/mouse_paw3395/MyCode/PAW3395.c
Normal file
356
软件/mouse_paw3395/MyCode/PAW3395.c
Normal file
|
@ -0,0 +1,356 @@
|
|||
#include "PAW3395.h"
|
||||
#include "Delay.h"
|
||||
#include "usr_spi.h"
|
||||
static void Power_Up_Initializaton_Register_Setting(void);
|
||||
|
||||
|
||||
/*
|
||||
*严格按照开机顺序执行:
|
||||
* 虽然芯片执行内部上电自复位,但仍建议将Power_Up_Reset
|
||||
* 每次上电时都会写入寄存器。推荐的芯片上电顺序如下:
|
||||
* 1. 以任何顺序为VDD和VDDIO供电,每次供电之间的延迟不超过100ms。确保所有供应稳定。
|
||||
* 2. 等待至少50毫秒。
|
||||
* 3. 将NCS拉高,然后拉低以重置SPI端口。
|
||||
* 4. 将0x5A写入Power_Up_Reset寄存器(或者切换NRESET引脚)。
|
||||
* 5. 等待至少5ms。
|
||||
* 6. 加载上电初始化寄存器设置。
|
||||
* 7. 无论运动位状态如何,都读取寄存器0x02、0x03、0x04、0x05和0x06一次。
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
void Power_up_sequence(void)
|
||||
{
|
||||
uint8_t reg_it;
|
||||
//Wait for at least 50ms(2.等待至少50毫秒。)
|
||||
delay_ms(50);
|
||||
// drive NCS high, then low to reset the SPI port(3.重置SPI端口)
|
||||
CS_Low;
|
||||
delay_125_ns(PAW3395_TIMINGS_NCS_SCLK);
|
||||
CS_High;
|
||||
delay_125_ns(PAW3395_TIMINGS_NCS_SCLK);
|
||||
CS_Low;
|
||||
delay_125_ns(PAW3395_TIMINGS_NCS_SCLK);
|
||||
|
||||
// Write 0x5A to POWER_UP_Reset register(4.将0x5A写入Power_Up_Reset寄存器)
|
||||
writr_register(PAW3395_SPIREGISTER_POWERUPRESET
|
||||
,PAW3395_POWERUPRESET_POWERON);
|
||||
//Wait for at least 5ms(5.等待至少5ms)
|
||||
delay_ms(5);
|
||||
//Load Power-up initialization register setting(6.加载上电初始化寄存器设置)
|
||||
Power_Up_Initializaton_Register_Setting();
|
||||
CS_High;
|
||||
delay_125_ns(PAW3395_TIMINGS_NCS_SCLK);
|
||||
// read register from 0x02 to 0x06(7.无论运动位状态如何,都读取寄存器0x02、0x03、0x04、0x05和0x06一次)
|
||||
for(reg_it=0x02; reg_it<=0x06; reg_it++)
|
||||
{
|
||||
read_register(reg_it);
|
||||
delay_us(PAW3395_TIMINGS_SRWSRR);
|
||||
}
|
||||
//片选拉高,本次SPI通讯结束
|
||||
CS_High;
|
||||
delay_125_ns(PAW3395_TIMINGS_BEXIT);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*严格执行启动Motion Burst的程序:
|
||||
* 1. 降低NCS。
|
||||
* 2. 等待tNCS-SCLK
|
||||
* 3. 发送Motion_Burst地址(0x16)。发送此地址后,MOSI应保持静态(高电平或低电平),直到突发传输完成。
|
||||
* 4. 等待tSRAD
|
||||
* 5. 开始连续读取最多12个字节的SPI数据。可以通过将NCS拉高持续at来终止运动突发至少tBEXIT。
|
||||
* 6. 要读取新的运动突发数据,请从步骤1开始重复。
|
||||
*
|
||||
*注意:
|
||||
* 即使在运行或静止模式下,也可以从Burst_Motion_Read寄存器读取运动突发数据。
|
||||
*
|
||||
*/
|
||||
void Motion_Burst(uint8_t *buffer)
|
||||
{
|
||||
//Lower NCS
|
||||
CS_Low;
|
||||
//Wait for t(NCS-SCLK)
|
||||
delay_125_ns(PAW3395_TIMINGS_NCS_SCLK);
|
||||
//Send Motion_Brust address(0x16)
|
||||
SPI_SendReceive(PAW3395_SPIREGISTER_MotionBurst); //读
|
||||
//Wait for tSRAD
|
||||
delay_us(PAW3395_TIMINGS_SRAD);
|
||||
//Start reading SPI data continuously up to 12 bytes.
|
||||
for(uint8_t i = 0;i < 12;i++)
|
||||
{
|
||||
buffer[i] = SPI_SendReceive(0x00);
|
||||
}
|
||||
CS_High;
|
||||
delay_125_ns(PAW3395_TIMINGS_BEXIT);
|
||||
}
|
||||
|
||||
/*
|
||||
*上电初始化寄存器设置
|
||||
*
|
||||
*/
|
||||
static void Power_Up_Initializaton_Register_Setting(void)
|
||||
{
|
||||
uint8_t read_tmp;
|
||||
uint8_t i ;
|
||||
writr_register(0x7F ,0x07);
|
||||
writr_register(0x40 ,0x41);
|
||||
writr_register(0x7F ,0x00);
|
||||
writr_register(0x40 ,0x80);
|
||||
writr_register(0x7F ,0x0E);
|
||||
writr_register(0x55 ,0x0D);
|
||||
writr_register(0x56 ,0x1B);
|
||||
writr_register(0x57 ,0xE8);
|
||||
writr_register(0x58 ,0xD5);
|
||||
writr_register(0x7F ,0x14);
|
||||
writr_register(0x42 ,0xBC);
|
||||
writr_register(0x43 ,0x74);
|
||||
writr_register(0x4B ,0x20);
|
||||
writr_register(0x4D ,0x00);
|
||||
writr_register(0x53 ,0x0E);
|
||||
writr_register(0x7F ,0x05);
|
||||
writr_register(0x44 ,0x04);
|
||||
writr_register(0x4D ,0x06);
|
||||
writr_register(0x51 ,0x40);
|
||||
writr_register(0x53 ,0x40);
|
||||
writr_register(0x55 ,0xCA);
|
||||
writr_register(0x5A ,0xE8);
|
||||
writr_register(0x5B ,0xEA);
|
||||
writr_register(0x61 ,0x31);
|
||||
writr_register(0x62 ,0x64);
|
||||
writr_register(0x6D ,0xB8);
|
||||
writr_register(0x6E ,0x0F);
|
||||
|
||||
writr_register(0x70 ,0x02);
|
||||
writr_register(0x4A ,0x2A);
|
||||
writr_register(0x60 ,0x26);
|
||||
writr_register(0x7F ,0x06);
|
||||
writr_register(0x6D ,0x70);
|
||||
writr_register(0x6E ,0x60);
|
||||
writr_register(0x6F ,0x04);
|
||||
writr_register(0x53 ,0x02);
|
||||
writr_register(0x55 ,0x11);
|
||||
writr_register(0x7A ,0x01);
|
||||
writr_register(0x7D ,0x51);
|
||||
writr_register(0x7F ,0x07);
|
||||
writr_register(0x41 ,0x10);
|
||||
writr_register(0x42 ,0x32);
|
||||
writr_register(0x43 ,0x00);
|
||||
writr_register(0x7F ,0x08);
|
||||
writr_register(0x71 ,0x4F);
|
||||
writr_register(0x7F ,0x09);
|
||||
writr_register(0x62 ,0x1F);
|
||||
writr_register(0x63 ,0x1F);
|
||||
writr_register(0x65 ,0x03);
|
||||
writr_register(0x66 ,0x03);
|
||||
writr_register(0x67 ,0x1F);
|
||||
writr_register(0x68 ,0x1F);
|
||||
writr_register(0x69 ,0x03);
|
||||
writr_register(0x6A ,0x03);
|
||||
writr_register(0x6C ,0x1F);
|
||||
|
||||
writr_register(0x6D ,0x1F);
|
||||
writr_register(0x51 ,0x04);
|
||||
writr_register(0x53 ,0x20);
|
||||
writr_register(0x54 ,0x20);
|
||||
writr_register(0x71 ,0x0C);
|
||||
writr_register(0x72 ,0x07);
|
||||
writr_register(0x73 ,0x07);
|
||||
writr_register(0x7F ,0x0A);
|
||||
writr_register(0x4A ,0x14);
|
||||
writr_register(0x4C ,0x14);
|
||||
writr_register(0x55 ,0x19);
|
||||
writr_register(0x7F ,0x14);
|
||||
writr_register(0x4B ,0x30);
|
||||
writr_register(0x4C ,0x03);
|
||||
writr_register(0x61 ,0x0B);
|
||||
writr_register(0x62 ,0x0A);
|
||||
writr_register(0x63 ,0x02);
|
||||
writr_register(0x7F ,0x15);
|
||||
writr_register(0x4C ,0x02);
|
||||
writr_register(0x56 ,0x02);
|
||||
writr_register(0x41 ,0x91);
|
||||
writr_register(0x4D ,0x0A);
|
||||
writr_register(0x7F ,0x0C);
|
||||
writr_register(0x4A ,0x10);
|
||||
writr_register(0x4B ,0x0C);
|
||||
writr_register(0x4C ,0x40);
|
||||
writr_register(0x41 ,0x25);
|
||||
writr_register(0x55 ,0x18);
|
||||
writr_register(0x56 ,0x14);
|
||||
writr_register(0x49 ,0x0A);
|
||||
writr_register(0x42 ,0x00);
|
||||
writr_register(0x43 ,0x2D);
|
||||
writr_register(0x44 ,0x0C);
|
||||
writr_register(0x54 ,0x1A);
|
||||
writr_register(0x5A ,0x0D);
|
||||
writr_register(0x5F ,0x1E);
|
||||
writr_register(0x5B ,0x05);
|
||||
writr_register(0x5E ,0x0F);
|
||||
writr_register(0x7F ,0x0D);
|
||||
writr_register(0x48 ,0xDD);
|
||||
writr_register(0x4F ,0x03);
|
||||
writr_register(0x52 ,0x49);
|
||||
|
||||
writr_register(0x51 ,0x00);
|
||||
writr_register(0x54 ,0x5B);
|
||||
writr_register(0x53 ,0x00);
|
||||
|
||||
writr_register(0x56 ,0x64);
|
||||
writr_register(0x55 ,0x00);
|
||||
writr_register(0x58 ,0xA5);
|
||||
writr_register(0x57 ,0x02);
|
||||
writr_register(0x5A ,0x29);
|
||||
writr_register(0x5B ,0x47);
|
||||
writr_register(0x5C ,0x81);
|
||||
writr_register(0x5D ,0x40);
|
||||
writr_register(0x71 ,0xDC);
|
||||
writr_register(0x70 ,0x07);
|
||||
writr_register(0x73 ,0x00);
|
||||
writr_register(0x72 ,0x08);
|
||||
writr_register(0x75 ,0xDC);
|
||||
writr_register(0x74 ,0x07);
|
||||
writr_register(0x77 ,0x00);
|
||||
writr_register(0x76 ,0x08);
|
||||
writr_register(0x7F ,0x10);
|
||||
writr_register(0x4C ,0xD0);
|
||||
writr_register(0x7F ,0x00);
|
||||
writr_register(0x4F ,0x63);
|
||||
writr_register(0x4E ,0x00);
|
||||
writr_register(0x52 ,0x63);
|
||||
writr_register(0x51 ,0x00);
|
||||
writr_register(0x54 ,0x54);
|
||||
writr_register(0x5A ,0x10);
|
||||
writr_register(0x77 ,0x4F);
|
||||
writr_register(0x47 ,0x01);
|
||||
writr_register(0x5B ,0x40);
|
||||
writr_register(0x64 ,0x60);
|
||||
writr_register(0x65 ,0x06);
|
||||
writr_register(0x66 ,0x13);
|
||||
writr_register(0x67 ,0x0F);
|
||||
writr_register(0x78 ,0x01);
|
||||
writr_register(0x79 ,0x9C);
|
||||
writr_register(0x40 ,0x00);
|
||||
writr_register(0x55 ,0x02);
|
||||
writr_register(0x23 ,0x70);
|
||||
writr_register(0x22 ,0x01);
|
||||
|
||||
//Wait for 1ms
|
||||
delay_ms(1);
|
||||
|
||||
for( i = 0 ;i < 60 ;i++)
|
||||
{
|
||||
read_tmp = read_register(0x6C);
|
||||
if(read_tmp == 0x80 )
|
||||
break;
|
||||
delay_ms(1);
|
||||
}
|
||||
if(i == 60)
|
||||
{
|
||||
writr_register(0x7F ,0x14);
|
||||
writr_register(0x6C ,0x00);
|
||||
writr_register(0x7F ,0x00);
|
||||
}
|
||||
writr_register(0x22 ,0x00);
|
||||
writr_register(0x55 ,0x00);
|
||||
writr_register(0x7F ,0x07);
|
||||
writr_register(0x40 ,0x40);
|
||||
writr_register(0x7F ,0x00);
|
||||
}
|
||||
|
||||
/*
|
||||
*RawData输出程序
|
||||
* 读取当前鼠标摄像头拍摄到的接触面的像素阵列信息
|
||||
* 像素信息存入数组pFrame中
|
||||
*
|
||||
*注意:
|
||||
* 在RawData输出过程中,必须将鼠标置于静止位置
|
||||
*
|
||||
*/
|
||||
void Pixel_Burst_Read(uint8_t* pFrame)
|
||||
{
|
||||
uint8_t reg_tmp;
|
||||
//Lower NCS
|
||||
CS_Low;
|
||||
//Wait for t(NCS-SCLK)
|
||||
delay_125_ns(PAW3395_TIMINGS_NCS_SCLK);
|
||||
writr_register(0x7F ,0x00);
|
||||
writr_register(0x40 ,0x80);
|
||||
|
||||
do
|
||||
{
|
||||
reg_tmp = read_register(PAW3395_SPIREGISTER_MOTION);
|
||||
delay_us(PAW3395_TIMINGS_SRWSRR);
|
||||
}
|
||||
while((reg_tmp & ((1 << PAW3395_OP_MODE0) | (1 << PAW3395_OP_MODE1))) != 0);
|
||||
|
||||
writr_register(0x50 ,0x01);
|
||||
writr_register(0x55 ,0x04);
|
||||
writr_register(0x58 ,0xFF);
|
||||
|
||||
do
|
||||
{
|
||||
reg_tmp = read_register(0x59);
|
||||
delay_us(PAW3395_TIMINGS_SRWSRR);
|
||||
}
|
||||
while((reg_tmp & ((1 << PAW3395_PG_FIRST) | (1 << PAW3395_PG_VALID)))
|
||||
!= ((1 << PAW3395_PG_FIRST) | (1 << PAW3395_PG_VALID)));
|
||||
|
||||
pFrame[35*2]=read_register(0x58);//Read the first rawdata from register 0x58
|
||||
delay_us(PAW3395_TIMINGS_SRWSRR);
|
||||
for(uint8_t width = 0;width < 36;width++)
|
||||
{
|
||||
for(uint8_t height = 0;height < 36;height++)
|
||||
{
|
||||
if((width == 0)&&(height == 0))
|
||||
continue;
|
||||
do
|
||||
{
|
||||
reg_tmp = read_register(0x59);
|
||||
delay_us(PAW3395_TIMINGS_SRWSRR);
|
||||
}
|
||||
while(!((reg_tmp >> PAW3395_PG_VALID) & 0x01));
|
||||
pFrame[(height * 36 + (35-width)) * 2] = read_register(0x58);
|
||||
delay_us(PAW3395_TIMINGS_SRWSRR);
|
||||
}
|
||||
}
|
||||
|
||||
writr_register(0x40 ,0x00);
|
||||
writr_register(0x50 ,0x00);
|
||||
writr_register(0x55 ,0x00);
|
||||
CS_High;
|
||||
delay_125_ns(PAW3395_TIMINGS_BEXIT);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*更改DPI
|
||||
*
|
||||
*/
|
||||
void DPI_Config(uint16_t CPI_Num)
|
||||
{
|
||||
uint8_t temp;
|
||||
|
||||
//Lower NCS
|
||||
CS_Low;
|
||||
//Wait for t(NCS-SCLK)
|
||||
delay_125_ns(PAW3395_TIMINGS_NCS_SCLK);
|
||||
|
||||
//设置分辨率模式:X轴和Y轴分辨率均由RESOLUTION_X_LOW和RESOLUTION_X_HIGH定义
|
||||
writr_register(MOTION_CTRL, 0x00);
|
||||
|
||||
//两个8位寄存器设置X轴分辨率
|
||||
temp = (uint8_t)(((CPI_Num/50) << 8) >> 8);
|
||||
writr_register(RESOLUTION_X_LOW, temp);
|
||||
temp = (uint8_t)((CPI_Num/50) >> 8);
|
||||
writr_register(RESOLUTION_X_HIGH, temp);
|
||||
|
||||
//更新分辨率
|
||||
writr_register(SET_RESOLUTION, 0x01);
|
||||
|
||||
CS_High;
|
||||
delay_125_ns(PAW3395_TIMINGS_BEXIT);
|
||||
}
|
60
软件/mouse_paw3395/MyCode/PAW3395.h
Normal file
60
软件/mouse_paw3395/MyCode/PAW3395.h
Normal file
|
@ -0,0 +1,60 @@
|
|||
#ifndef PAW3395_H_
|
||||
#define PAW3395_H_
|
||||
#include "stdint.h"
|
||||
//Register Address
|
||||
#define PAW3395_SPIREGISTER_MOTION 0x02
|
||||
|
||||
#define PAW3395_SPIREGISTER_MotionBurst 0x16
|
||||
|
||||
#define PAW3395_SPIREGISTER_POWERUPRESET 0x3A
|
||||
|
||||
/*******************CPIÅäÖüĴæÆ÷********************/
|
||||
#define SET_RESOLUTION 0x47
|
||||
|
||||
#define RESOLUTION_X_LOW 0x48
|
||||
#define RESOLUTION_X_HIGH 0x49
|
||||
|
||||
#define RESOLUTION_Y_LOW 0x4A
|
||||
#define RESOLUTION_Y_HIGH 0x4B
|
||||
|
||||
#define RIPPLE_CONTROL 0x5A
|
||||
|
||||
#define MOTION_CTRL 0x5C
|
||||
|
||||
//Register Value
|
||||
#define PAW3395_POWERUPRESET_POWERON 0x5A
|
||||
|
||||
// Registers bits
|
||||
#define PAW3395_OP_MODE0 0
|
||||
#define PAW3395_OP_MODE1 1
|
||||
|
||||
#define PAW3395_PG_FIRST 6
|
||||
#define PAW3395_PG_VALID 7
|
||||
|
||||
//Operation time
|
||||
|
||||
/// SPI read - address delay
|
||||
#define PAW3395_TIMINGS_SRAD 2 //2¦Ìs
|
||||
|
||||
/// SPI time between read and subsequent commands
|
||||
#define PAW3395_TIMINGS_SRWSRR 2//2¦Ìs
|
||||
|
||||
/// SPI time between write commands
|
||||
#define PAW3395_TIMINGS_SWW 5//5¦Ìs
|
||||
|
||||
/// SPI time between write and read commands
|
||||
#define PAW3395_TIMINGS_SWR 5//5¦Ìs
|
||||
|
||||
/// SPI, NCS to SCLK active/inactive
|
||||
#define PAW3395_TIMINGS_NCS_SCLK 1//120ns
|
||||
|
||||
/// Time to drive NCS high in order to exit burst mode
|
||||
#define PAW3395_TIMINGS_BEXIT 4//500ns
|
||||
|
||||
#define PAW3395_SPI_WRITE 0x80
|
||||
|
||||
void Power_up_sequence(void);
|
||||
void Motion_Burst(uint8_t *buffer);
|
||||
void Pixel_Burst_Read(uint8_t* pFrame);
|
||||
void DPI_Config(uint16_t CPI_Num);
|
||||
#endif
|
58
软件/mouse_paw3395/MyCode/myMouse.c
Normal file
58
软件/mouse_paw3395/MyCode/myMouse.c
Normal file
|
@ -0,0 +1,58 @@
|
|||
#include "myMouse.h"
|
||||
#include "usbd_hid.h"
|
||||
|
||||
extern USBD_HandleTypeDef hUsbDeviceFS;
|
||||
|
||||
extern int16_t X_Speed,Y_Speed;
|
||||
|
||||
extern uint8_t Left_Key_Value;
|
||||
extern uint8_t Right_Key_Value;
|
||||
extern uint8_t Middel_Key_Value;
|
||||
|
||||
extern int8_t wheel_num;
|
||||
|
||||
//给鼠标报文赋初值
|
||||
void myMouse_init(struct mouseHID_t* mouseHID)
|
||||
{
|
||||
// mouseHID->button_left = 0;
|
||||
// mouseHID->button_middel = 0;
|
||||
// mouseHID->button_right = 0;
|
||||
//
|
||||
// mouseHID->u_x_move.x_move = 0;
|
||||
// mouseHID->u_y_move.y_move = 0;
|
||||
//
|
||||
// mouseHID->wheel = 0;
|
||||
|
||||
mouseHID->button_left = 0;
|
||||
mouseHID->button_right = 0;
|
||||
mouseHID->button_middel = 0;
|
||||
|
||||
mouseHID->x = 0;
|
||||
mouseHID->y = 0;
|
||||
mouseHID->wheel = 0;
|
||||
}
|
||||
|
||||
//更新鼠标报文
|
||||
void myMouse_update(struct mouseHID_t* mouseHID)
|
||||
{
|
||||
// mouseHID->u_x_move.t_x_move.x_move_l = motion_burst_data[2];
|
||||
// mouseHID->u_x_move.t_x_move.x_move_h = motion_burst_data[3];
|
||||
// mouseHID->u_y_move.t_y_move.y_move_l = motion_burst_data[4];
|
||||
// mouseHID->u_y_move.t_y_move.y_move_h = motion_burst_data[5];
|
||||
//
|
||||
// mouseHID->u_x_move.x_move = mouseHID->u_x_move.t_x_move.x_move_l + (mouseHID->u_x_move.t_x_move.x_move_h << 8);
|
||||
// mouseHID->u_y_move.y_move = mouseHID->u_y_move.t_y_move.y_move_l + (mouseHID->u_y_move.t_y_move.y_move_h << 8);
|
||||
|
||||
mouseHID->button_left = Left_Key_Value;
|
||||
mouseHID->button_right = Right_Key_Value;
|
||||
mouseHID->button_middel = Middel_Key_Value;
|
||||
|
||||
mouseHID->x = X_Speed;
|
||||
mouseHID->y = Y_Speed;
|
||||
|
||||
mouseHID->wheel = wheel_num;
|
||||
|
||||
USBD_HID_SendReport(&hUsbDeviceFS,(uint8_t*)mouseHID,sizeof(struct mouseHID_t));
|
||||
|
||||
wheel_num = 0x80;
|
||||
}
|
52
软件/mouse_paw3395/MyCode/myMouse.h
Normal file
52
软件/mouse_paw3395/MyCode/myMouse.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
#ifndef _MYMOUSE_H_
|
||||
#define _MYMOUSE_H_
|
||||
|
||||
#include "main.h"
|
||||
|
||||
//鼠标信息结构体
|
||||
__packed struct mouseHID_t
|
||||
{
|
||||
/*鼠标按键:
|
||||
* bit0: 左键
|
||||
* bit1: 右键
|
||||
* bit2: 中键
|
||||
* bit3: 自定义
|
||||
* ...
|
||||
* bit7: 自定义
|
||||
*/
|
||||
// uint8_t button_left:1;
|
||||
// uint8_t button_right:1;
|
||||
// uint8_t button_middel:1;
|
||||
|
||||
// //x轴移动值
|
||||
// union{
|
||||
// struct{
|
||||
// uint8_t x_move_l;
|
||||
// uint8_t x_move_h;
|
||||
// }t_x_move;
|
||||
// uint16_t x_move;
|
||||
// }u_x_move;
|
||||
//
|
||||
// //y轴移动值
|
||||
// union{
|
||||
// struct{
|
||||
// uint8_t y_move_l;
|
||||
// uint8_t y_move_h;
|
||||
// }t_y_move;
|
||||
// uint16_t y_move;
|
||||
// }u_y_move;
|
||||
|
||||
uint8_t button_left:1; //左键
|
||||
uint8_t button_right:1; //右键
|
||||
uint8_t button_middel:1; //中建
|
||||
|
||||
int16_t x; //x轴相对位移
|
||||
int16_t y; //y轴相对位移
|
||||
|
||||
int8_t wheel; //滚轮位移大小
|
||||
};
|
||||
|
||||
void myMouse_init(struct mouseHID_t* mouseHID);
|
||||
void myMouse_update(struct mouseHID_t* mouseHID);
|
||||
|
||||
#endif
|
75
软件/mouse_paw3395/MyCode/usr_spi.c
Normal file
75
软件/mouse_paw3395/MyCode/usr_spi.c
Normal file
|
@ -0,0 +1,75 @@
|
|||
#include "stm32f1xx_hal.h"
|
||||
#include "Delay.h"
|
||||
#include "usr_spi.h"
|
||||
FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG);
|
||||
static void SPI_I2S_SendData(SPI_TypeDef* SPIx, uint16_t Data);
|
||||
static uint16_t SPI_I2S_ReceiveData(SPI_TypeDef* SPIx);
|
||||
extern SPI_HandleTypeDef hspi1;
|
||||
uint8_t SPI_SendReceive(uint8_t data)
|
||||
{
|
||||
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET){;}
|
||||
SPI_I2S_SendData(SPI1, data);
|
||||
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET){;}
|
||||
return SPI_I2S_ReceiveData(SPI1);
|
||||
|
||||
}
|
||||
|
||||
uint8_t read_register(uint8_t adress)
|
||||
{
|
||||
unsigned char temp;
|
||||
CS_Low;
|
||||
delay_125_ns(1);
|
||||
temp=SPI_SendReceive(adress+0x00); //¶Á
|
||||
delay_us(5);
|
||||
temp=SPI_SendReceive(0xff); //ÌṩʱÖÓÐźÅ_¶Á
|
||||
// CS_High;
|
||||
return temp;
|
||||
}
|
||||
|
||||
void writr_register(uint8_t adress,uint8_t vlue)
|
||||
{
|
||||
CS_Low;
|
||||
delay_125_ns(1);
|
||||
SPI_SendReceive(adress+0x80);
|
||||
SPI_SendReceive(vlue);
|
||||
CS_High;
|
||||
delay_us(5);
|
||||
}
|
||||
|
||||
FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG)
|
||||
{
|
||||
FlagStatus bitstatus = RESET;
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SPI_ALL_PERIPH(SPIx));
|
||||
assert_param(IS_SPI_I2S_GET_FLAG(SPI_I2S_FLAG));
|
||||
/* Check the status of the specified SPI/I2S flag */
|
||||
if ((SPIx->SR & SPI_I2S_FLAG) != (uint16_t)RESET)
|
||||
{
|
||||
/* SPI_I2S_FLAG is set */
|
||||
bitstatus = SET;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* SPI_I2S_FLAG is reset */
|
||||
bitstatus = RESET;
|
||||
}
|
||||
/* Return the SPI_I2S_FLAG status */
|
||||
return bitstatus;
|
||||
}
|
||||
|
||||
static void SPI_I2S_SendData(SPI_TypeDef* SPIx, uint16_t Data)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SPI_ALL_PERIPH(SPIx));
|
||||
|
||||
/* Write in the DR register the data to be sent */
|
||||
SPIx->DR = Data;
|
||||
}
|
||||
static uint16_t SPI_I2S_ReceiveData(SPI_TypeDef* SPIx)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SPI_ALL_PERIPH(SPIx));
|
||||
|
||||
/* Return the data in the DR register */
|
||||
return SPIx->DR;
|
||||
}
|
18
软件/mouse_paw3395/MyCode/usr_spi.h
Normal file
18
软件/mouse_paw3395/MyCode/usr_spi.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef _SPI_H_
|
||||
#define _SPI_H_
|
||||
#include "stdint.h"
|
||||
#include "gpio.h"
|
||||
|
||||
#define CS_High HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_SET)
|
||||
#define CS_Low HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_RESET)
|
||||
|
||||
#define SPI_I2S_FLAG_RXNE ((uint16_t)0x0001)
|
||||
#define SPI_I2S_FLAG_TXE ((uint16_t)0x0002)
|
||||
/**********************************************************************************************************/
|
||||
void SPI1_Init(void);
|
||||
uint8_t SPI_SendReceive(uint8_t data);
|
||||
uint8_t read_register(uint8_t adress);
|
||||
void writr_register(uint8_t adress,uint8_t vlue);
|
||||
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue