金牌会员
 
- 积分
- 1714
- 威望
- 876
- 贡献
- 516
- 兑换币
- 549
- 注册时间
- 2014-11-14
- 在线时间
- 161 小时
|
2#

楼主 |
发表于 2015-4-28 23:23:58
|
只看该作者
mian函数如下
#include "common.h"
#include "include.h"
#include "MK60_port.h"
#include "MK60_it.h"
extern uint8 imgbuff[CAMERA_H][CAMERA_W]; //定义存储接收图像的数组
extern uint8 Is_SendPhoto; //图像发送标志
//uint8 nrf_rx_buff[CAMERA_SIZE + 2*COM_LEN + DATA_PACKET]; //预多
//uint8 nrf_tx_buff[CAMERA_SIZE + 2*COM_LEN + DATA_PACKET]; //预多
////uint8 *imgbuff = (uint8 *)(((uint8 *)&nrf_tx_buff) + COM_LEN); //图像地址
uint16 i,j;
uint16 H = CAMERA_H; //发送图像高度
uint16 W = CAMERA_W; //发送图像宽度
/*!
* @brief main函数
* @since v5.0
* @note 测试 LED 功能是否正常
看到的效果是LED0和LED1同时亮灭闪烁
*/
void main()
{
// com_e com;
// nrf_result_e nrf_result;
DisableInterrupts;//关闭全局中断,似乎不需要?
gpio_init(PTA15,GPO,0);//指示灯初始化,用于显示程序执行情况
uart_init(UART5, 115200);//串口初始化,TXD TB8 RXD:PTB9
OV7620_Init();//OV7620摄像头初始化
// while(!nrf_init());//无线模块初始化
//
// nrf_msg_init();//无线模块消息初始化
DELAY_MS(1000);//延时1秒钟
EnableInterrupts;//开启全局中断,似乎不需要?
for(;;)
{
GPIO_TURN(PTA15);
if(1 == Is_SendPhoto)
{
//直接发送灰度数据,上位机软件会把图像信息显示出来
disable_irq(PORTA_IRQn); //关闭PORTA中断,即关闭场中断,防止串口发送图像数据进程被打乱
disable_irq(PORTB_IRQn); //关闭PORTB中断,即关闭行中断,防止串口发送图像数据进程被打乱
//以下2句话是固定格式,是串口和上位机软件之间的协议
uart_putchar(UART5,0x01);
uart_putchar(UART5,0xfe);//与上位机的协议
for(i=0;i<H;i++)
{
for(j=0;j<W;j++)
{
uart_putchar(UART5,imgbuff[i][j]);
}
}
uart_putchar(UART5,0xfe);
uart_putchar(UART5,0x01);//与上位机的协议
PORTA_ISFR = ~0; //写1清中断标志位(必须的,不然回导致一开中断就马上触发中断)
enable_irq(PORTA_IRQn); //先只打开PORTA场中断
Is_SendPhoto=0; //发送标志清零
}
}
}
|
|