110 lines
4.5 KiB
C
Raw Normal View History

2022-01-18 00:58:54 +08:00
/*********************************************************************************************************************
* COPYRIGHT NOTICE
* Copyright (c) 2020,<EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD>
* All rights reserved.
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>QQȺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱥ<EFBFBD><EFBFBD>824575535
*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD>;<EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD>ӭ<EFBFBD><EFBFBD>λʹ<EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD><EFBFBD>İ<EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* @file 7725_UART
* @company <EFBFBD>ɶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>޹<EFBFBD>˾
* @author <EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD>(QQ3184284598)
* @version <EFBFBD>doc<EFBFBD><EFBFBD>version<EFBFBD>ļ<EFBFBD> <EFBFBD>˵<EFBFBD><EFBFBD>
* @Software ADS v1.2.2
* @Target core TC264D
* @Taobao https://seekfree.taobao.com/
* @date 2020-3-23
* @note
OV7725<EFBFBD><EFBFBD><EFBFBD>߶<EFBFBD><EFBFBD>
------------------------------------
ģ<EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD> <EFBFBD><EFBFBD>Ƭ<EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD>
SDA(51<EFBFBD><EFBFBD>RX) <EFBFBD>SEEKFREE_7725_UART.h<EFBFBD>ļ<EFBFBD><EFBFBD>ڵ<EFBFBD>OV7725_COF_UART_TX <EFBFBD><EFBFBD><EFBFBD>
SCL(51<EFBFBD><EFBFBD>TX) <EFBFBD>SEEKFREE_7725_UART.h<EFBFBD>ļ<EFBFBD><EFBFBD>ڵ<EFBFBD>OV7725_COF_UART_RX <EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>(VSY) <EFBFBD>SEEKFREE_7725_UART.h<EFBFBD>ļ<EFBFBD><EFBFBD>ڵ<EFBFBD>OV7725_UART_VSYNC_PIN <EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>(HREF) δʹ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>(PCLK) <EFBFBD>SEEKFREE_7725_UART.h<EFBFBD>ļ<EFBFBD><EFBFBD>ڵ<EFBFBD>OV7725_UART_PCLK_PIN <EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>(D0-D7) <EFBFBD>SEEKFREE_7725_UART.h<EFBFBD>ļ<EFBFBD><EFBFBD>ڵ<EFBFBD>OV7725_UART_DATA_PIN <EFBFBD><EFBFBD><EFBFBD>
Ĭ<EFBFBD>Ϸֱ<EFBFBD><EFBFBD><EFBFBD> 160*120
Ĭ<EFBFBD><EFBFBD>FPS 50֡
------------------------------------
********************************************************************************************************************/
#ifndef _SEEKFREE_7725_UART_h
#define _SEEKFREE_7725_UART_h
#include "common.h"
#include "IfxDma_cfg.h"
#include "zf_uart.h"
#define OV7725_UART_W 160 //ֻ<><D6BB><EFBFBD><EFBFBD>80 160 240 320 <20><><EFBFBD>Ⱥ͸߶<CDB8><DFB6><EFBFBD><EFBFBD><EFBFBD>һһ<D2BB><D2BB>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ80<38><30><EFBFBD>߶<EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ60<36><30>
#define OV7725_UART_H 120 //ֻ<><D6BB><EFBFBD><EFBFBD>60 120 180 240
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>
#define OV7725_UART_SIZE (OV7725_UART_W * OV7725_UART_H/8 ) //ͼ<><CDBC>ռ<EFBFBD>ÿռ<C3BF><D5BC><EFBFBD>С
#define OV7725_UART_DMA_NUM (OV7725_UART_SIZE ) //DMA<4D>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
//--------------------------------------------------------------------------------------------------
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//--------------------------------------------------------------------------------------------------
#define OV7725_COF_UART UART_1 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ʹ<EFBFBD>õ<EFBFBD><C3B5>Ĵ<EFBFBD><C4B4><EFBFBD>
#define OV7725_COF_UART_TX UART1_TX_P02_2
#define OV7725_COF_UART_RX UART1_RX_P02_3
#define OV7725_UART_VSYNC_PIN ERU_CH3_REQ6_P02_0 //<2F><><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD> <09><>ѡ<EFBFBD><D1A1>Χ<EFBFBD>ο<EFBFBD>ERU_PIN_enumö<6D><C3B6> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>Ϊͬһ<CDAC><D2BB>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD><C7B9><EFBFBD><EFBFBD>жϵ<D0B6>ͨ<EFBFBD><CDA8>
//<2F><><EFBFBD><EFBFBD>ж<EFBFBD>ѡ<EFBFBD><D1A1>ERU_CH3 <20><>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>žͲ<C5BE><CDB2><EFBFBD>ѡ<EFBFBD><D1A1>ERU_CH7<48><37><EFBFBD><EFBFBD>Ϊ3<CEAA><33>7<EFBFBD><37><EFBFBD>ж<EFBFBD><D0B6>ǹ<EFBFBD><C7B9>õġ<C3B5>
#define OV7725_UART_DATA_PIN P00_0 //<2F><><EFBFBD><EFBFBD>D0<44><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>D0<44><30><EFBFBD><EFBFBD>ΪP00_0 <20><>ôD1<44><31>ʹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪP00_1<5F><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>P00_0<5F><30>P02_0<5F><30>P15_0<5F><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define OV7725_UART_PCLK_PIN ERU_CH2_REQ14_P02_1 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ѡ<EFBFBD><D1A1>Χ<EFBFBD>ο<EFBFBD>ERU_PIN_enumö<6D><C3B6> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>Ϊͬһ<CDAC><D2BB>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD><C7B9><EFBFBD><EFBFBD>жϵ<D0B6>ͨ<EFBFBD><CDA8>
//<2F><><EFBFBD><EFBFBD>ж<EFBFBD>ѡ<EFBFBD><D1A1>ERU_CH3 <20><>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>žͲ<C5BE><CDB2><EFBFBD>ѡ<EFBFBD><D1A1>ERU_CH7<48><37><EFBFBD><EFBFBD>Ϊ3<CEAA><33>7<EFBFBD><37><EFBFBD>ж<EFBFBD><D0B6>ǹ<EFBFBD><C7B9>õġ<C3B5>
#define OV7725_UART_DMA_CH IfxDma_ChannelId_5 //<2F><><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD>DMAͨ<41><CDA8> 0-47<34><37>ѡ ͨ<><CDA8><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD>Խ<EFBFBD><D4BD>
//<2F>޸Ĵ˴<C4B4>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸Ķ<DEB8>Ӧ<EFBFBD><D3A6>ERU<52>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˴<EFBFBD><CBB4><EFBFBD><EFBFBD><EFBFBD>ΪIfxDma_ChannelId_5<5F><35><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>ERU<52>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ȼ<EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ5
typedef enum
{
OV7725_INIT = 0x00, //<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
OV7725_RESERVE, //<2F><><EFBFBD><EFBFBD>λ
OV7725_CONTRAST, //<2F>Աȶȵ<C8B6><C8B5><EFBFBD> ʵ<><CAB5><EFBFBD><EFBFBD>ֵ<EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD>
OV7725_FPS, //֡<><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֻ֧<D6BB><D6A7>50 75 100 112 150
OV7725_COL, //<2F>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֻ<><D6BB><EFBFBD><EFBFBD>80 160 240 320
OV7725_ROW, //<2F>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֻ<><D6BB><EFBFBD><EFBFBD>60 120 180 240
OV7725_CONFIG_FINISH, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ռλ<D5BC><CEBB><EFBFBD><EFBFBD>
OV7725_GET_WHO_AM_I= 0xEF,
OV7725_GET_STATUS = 0xF1,
OV7725_GET_VERSION = 0xF2,
OV7725_SET_ADDR = 0xFE,
OV7725_SET_DATA = 0xFF,
}OV7725_CMD;
extern uint8 ov7725_uart_image_bin[OV7725_UART_H][OV7725_UART_W/8]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6B4A2><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
extern uint8 ov7725_uart_image_dec[OV7725_UART_H][OV7725_UART_W]; //ͼ<><CDBC><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
extern uint8 ov7725_uart_finish_flag; //ͼ<><CDBC><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ɱ<EFBFBD>־λ
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void ov7725_uart_callback(void);
void ov7725_uart_init(void);
void ov7725_uart_vsync(void);
void ov7725_uart_dma(void);
void image_decompression(uint8 *data1,uint8 *data2);
void seekfree_sendimg_7725(UARTN_enum uartn, uint8 *image, uint16 width, uint16 height);
#endif