⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main_bac.c.bak

📁 bu1566dsp芯片用来处理ov7660或其他30万摄像模组的图像预览.图像拍照(jpeg压缩)
💻 BAK
字号:
/****************************************Copyright (c)**************************************************
**--------------File Info-------------------------------------------------------------------------------
** File name:			main.c
** Last modified Date:  2004-09-16
** Last Version:		1.0
** Descriptions:		The main() function example template

********************************************************************************************************/
#include "config.h"
#include "stdlib.h"
#include "BUxx_Sample.h"
#include "BUxx_aDSC.h"
#include "BUxx_Main.h"
#include "I2C.h"
#include "zlg7290.h"

#define	  KEY1	(1 << 20)           /* P0.20为KEY1 */
#define	  BEEP	(1 << 7)            /* P0.07为蜂鸣器 */
//#define   HcRECT   (1<<10)          /* reset pin  */
#define   HcRECT   0x00000400          /* reset pin  */

// LED控制宏函数定义。LED1--LED4的控制I/O为P2.28--P2.31
#define   LED_ADJ	        28
#define   LED_IOCON	        (0xFF<<LED_ADJ)
#define   LED_OFF() 	    IO2SET=LED_IOCON
#define   LED_DISP(dat) 	LED_OFF(); IO2CLR=((dat)<<LED_ADJ)

#define	TaskStkLengh	64			//Define the Task0 stack length 定义用户任务0的堆栈长度 
#define TASK_STK_SIZE  128

OS_STK  TaskStartStk[TASK_STK_SIZE]; 
OS_STK	TaskStk0[TaskStkLengh];		//Define the Task0 stack 定义用户任务0的堆栈
OS_STK	TaskStk1[TaskStkLengh];		//Define the Task1 stack 定义用户任务1的堆栈
OS_STK	TaskStk2[TaskStkLengh];		//Define the Task2 stack 定

void 	Task0(void *pdata);			//Task0 任务0
void 	Task1(void *pdata);			//Task0 任务1
void 	Task2(void *pdata);			//Task0 任务2
void    TaskStart(void *data);

void  TaskStart(void *data);

/****************************************************************************
* 名    称:DelayNS()
* 功    能:长软件延时。
* 入口参数:dly		延时参数,值越大,延时越久
* 出口参数:无
****************************************************************************/
void  DelayNS(uint32  dly)
{  
    uint32  i;
    for(; dly>0; dly--) 
    {
        for(i=0; i<5000; i++);
    }
}
/****************************************************************************
* 名    称:IRQ_DSP()  配置DSP中断
****************************************************************************/
void IRQ_DSP(void)
{
   //p0.16 INT pin
    PINSEL1 |= 0x00000001;   // 设置管脚连接,P0.16设置为EINT0
    
    EXTMODE = 0x0f;		// 设置EINT0中断为边沿触发模式 
    EXTPOLAR = 0x00;        //下降沿有或低电平
    
    VICVectCntl1 = (0x20|0x0E);   // 设置EINT0分配到IRQslot1
    VICVectAddr1 = (int) aDSC_int_disp;		// 设置中断服务程序地?
     EXTINT = 0x01;  //清除EINT0 中断标志
    
    VICIntEnable = 1<<14;		    	// 使能EINT0中断,EINT0在Bit10上   
}

/****************************************************************************
* 名    称:DSP Reseet()  配置Reset DSP
****************************************************************************/
void Reset_DSP(void)
{
  
   PINSEL0|= 0x00000000;            // 设置管脚连接GPIO   
   //PINSEL0 &=~(0x3<<20);         // 设置管脚po.10为连接GPIO输出		    
     IO0DIR = HcRECT;				   // 设置po.10 I/O为输出
 
   IO0SET|= HcRECT;				  // BEEPCON = 1
     DelayNS(100);
   IO0CLR |= HcRECT;				 // BEEPCON = 0
	DelayNS(100);	
   IO0SET |= HcRECT;		
	DelayNS(100);            // BEEPCON = 1
}

/****************************************************************************
* 名    称:main()
****************************************************************************/

int main(void)
{	
	OSInit ();
       DelayNS(10);	
       IRQ_DSP();
       Reset_DSP();
      C_Entry();	//Int LCD Sensor
	DelayNS(50);	
      OSTaskCreate (Task0,(void *)0, &TaskStk0[TaskStkLengh - 1], 2);	
	//OSTaskCreate(TaskStart, (void *)0, &TaskStartStk[TASK_STK_SIZE - 1], 0);  //key function	
	OSStart ();
	return 0;															
}


/*********************************************************************************************************
** 函数名称: TaskStart
** 功能描述: μCOS-II的第一个任务,通常由它初始化目标板和建立其它任务
** 输 入: 无
** 输 出: 无
** 全局变量: 无
** 调用模块: 
**
** 作 者: 陈明计
** 日 期: 2003年7月7日
**-------------------------------------------------------------------------------------------------------
** 修改人: 
** 日 期: 
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/

        void  TaskStart(void *pdata)
{
    uint16 Key;

    pdata = pdata;                                                  /* 避免编译警告 */

    TargetInit();                                                   /* 目标板初始化 */

    ZLG7290ShowChar(7, 0x1f);
    OSTimeDly(OS_TICKS_PER_SEC / 100);
    ZLG7290ShowChar(6, 0x1f);
    OSTimeDly(OS_TICKS_PER_SEC / 100);
    ZLG7290ShowChar(5, 0x1f);
    OSTimeDly(OS_TICKS_PER_SEC / 100);
    ZLG7290ShowChar(4, 0x1f);
    OSTimeDly(OS_TICKS_PER_SEC / 100);
    ZLG7290ShowChar(3, 0x1f);
    OSTimeDly(OS_TICKS_PER_SEC / 100);
    ZLG7290ShowChar(2, 0x1f);
    OSTimeDly(OS_TICKS_PER_SEC / 100);
    ZLG7290ShowChar(1, 0x1f);
    OSTimeDly(OS_TICKS_PER_SEC / 100);
    ZLG7290ShowChar(0, 0x1f);
    OSTimeDly(OS_TICKS_PER_SEC);


    ZLG7290ShowChar(7, 0x14);
    OSTimeDly(OS_TICKS_PER_SEC / 100);
    ZLG7290ShowChar(6, 0x16);
    OSTimeDly(OS_TICKS_PER_SEC / 100);
    ZLG7290ShowChar(5, 0x0c);
    OSTimeDly(OS_TICKS_PER_SEC / 100);
    ZLG7290ShowChar(4, 0x02);
    OSTimeDly(OS_TICKS_PER_SEC / 100);
    ZLG7290ShowChar(3, 0x02);
    OSTimeDly(OS_TICKS_PER_SEC / 100);
    ZLG7290ShowChar(2, 0x00);
    OSTimeDly(OS_TICKS_PER_SEC / 100);
    ZLG7290ShowChar(1, 0x00);
    OSTimeDly(OS_TICKS_PER_SEC / 100);
    ZLG7290ShowChar(0, 0x0f);
    OSTimeDly(OS_TICKS_PER_SEC / 100);
    
    while (1)
    {
        Key = ZLG7290GetKey();
        {
            if (Key == 0 || Key >= 0x100)
            {

                OSTimeDly(OS_TICKS_PER_SEC / 50);
                continue;
            }
        }
        Key--;
        if (Key < 8)
        {
           
            ZLG7290Wink(1 << Key);
        }
    }
}

/*********************************************************************************************************
**                            End Of File
********************************************************************************************************/

/********************************************************************************
**                            Task0 任务0
*********************************************************************************/
void Task0(void *pdata)
{  

   UINT32 jpeg_size = JPEG_BUFFER;  //定义最大JPEG尺寸
   UINT16 * start_add = (UINT16 *) 0x80400000;
   char *Decode = "DECODE";         //write Frame jpeg
   char *View = "VIEW";         //write Frame jpeg
	 pdata = pdata;

	TargetInit ();
      PINSEL0 = PINSEL0 & 0xffff3fff;                                 // 管教选择模块初始化
      PINSEL1 = PINSEL1 & 0xfffffcff;
      IO0DIR &= ~KEY1;			                                    // 设置KEY1的控制I/O为输入
      IO0DIR |= BEEP;			                                        // 设置蜂鸣器为输出
      IO0SET |= BEEP;    
	
	OSTaskCreate (Task1,(void *)0, &TaskStk1[TaskStkLengh - 1], 5);
	
	for (;;)
    {   OSTaskSuspend(OS_PRIO_SELF);
        IO0CLR |= BEEP;
        OSTimeDly(OS_TICKS_PER_SEC / 8);
        IO0SET |= BEEP;
        OSTimeDly(OS_TICKS_PER_SEC / 4);

        IO0CLR |= BEEP;
        OSTimeDly(OS_TICKS_PER_SEC / 8);
        IO0SET |= BEEP;
        OSTimeDly(OS_TICKS_PER_SEC / 4);

	sJPEGFEncode((UINT16 *)start_add, &jpeg_size); 
	    DelayNS(200);
	aDRT_write_string(Decode,10, 20, 80);
	   DelayNS(200);
       sJPEGDecode((UINT16 *)start_add,  &jpeg_size);	
	    DelayNS(200);
      aDSC_fmemory_clear(0, 0, M_LCD_WSIZE, M_LCD_HSIZE,0xf800);
       aDSC_data_trans_st(0, 0, M_LCD_WSIZE, M_LCD_HSIZE);    
      aDRT_write_string(View,10, 20, 80);
	    DelayNS(200);

      // 建立任务2(用于LED点亮)
       OSTaskCreate (Task2,(void *)0, &TaskStk2[TaskStkLengh - 1], 6);	
			
           DelayNS(200);
      sStartPreview();
  
    }
}

/********************************************************************************
**                            Task1 任务1
********************************************************************************/
void  Task1(void *pdata)
{   pdata = pdata;                                      /* 避免编译警告 */
    
    for (;;)
    {  
	OSTimeDly(OS_TICKS_PER_SEC / 50);               /* 延时20毫秒 */
        if ((IO0PIN & KEY1) != 0)
        {   continue;
        }
        OSTimeDly(OS_TICKS_PER_SEC / 50);               /* 延时20毫秒 */
        if ((IO0PIN & KEY1) != 0)
        {   continue;
        }
        OSTaskResume(2);
	
        while ((IO0PIN & KEY1) == 0)
        {   OSTimeDly(OS_TICKS_PER_SEC / 50);           /* 延时20毫秒 */
        }
    }
}

/*********************************************************************************************************
**                            Task2 任务2
********************************************************************************************************/
void Task2(void *pdata)
{   const uint8  DISP_TAB[24] = { 0x0F,0x00,0x0F,0x00,0x0F,0x00,0x0F,0x00,
                                 0x01,0x02,0x04,0x08,0x04,0x02,0x01,0x00, 
                                 0x05,0x0A,0x05,0x0A,0x05,0x0A,0x05,0x00 }; 
       uint8  i; 
   
	pdata = pdata;
	TargetInit ();	
	PINSEL0 |= 0x00000000;		// 设置P0口管脚连接GPIO  
	IO0DIR |= BEEP;	            // 设置蜂鸣器控制口为输出
       IO0SET |= BEEP;
	IO2DIR |= LED_IOCON;         // 设置LED1--LED4的控制口为输出

	LED_OFF();
   	
	while (1)
	{   for(i=0; i<24; i++)
        {   LED_DISP(DISP_TAB[i]);          // 输出LED显示数据
            OSTimeDly(OS_TICKS_PER_SEC/2);	// 延时0.5S
        } 		
	}
}
 

/*********************************************************************************
**                            End Of File
*********************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -