예제 #1
0
파일: vp_jpeg.c 프로젝트: LucidOne/Rovio
void vjpegInit(void)
{
#ifndef ECOS
    tt_rmutex_init(&g_vpJPEG.mtLock);
    tt_rmutex_init(&g_vpJPEG.mtLockEncoder);
    tt_rmutex_init(&g_vpJPEG.mtLockDecoder);
    
    tt_sem_init(&g_vpJPEG.semEncoder, 1);
    tt_sem_init(&g_vpJPEG.semDecoder, 1);
	tt_sem_down(&g_vpJPEG.semEncoder);
	tt_sem_down(&g_vpJPEG.semDecoder);
#else
    cyg_mutex_init(&g_vpJPEG.mtLock);
    cyg_mutex_init(&g_vpJPEG.mtLockEncoder);
    cyg_mutex_init(&g_vpJPEG.mtLockDecoder);
    
    cyg_semaphore_init(&g_vpJPEG.semEncoder, 1);
    cyg_semaphore_init(&g_vpJPEG.semDecoder, 1);
	cyg_semaphore_wait(&g_vpJPEG.semEncoder);
	cyg_semaphore_wait(&g_vpJPEG.semDecoder);
#endif
    
    g_vpJPEG.nRefCount = 0;
    g_vpJPEG.nRefCount_Encoder = 0;
    g_vpJPEG.nRefCount_Decoder = 0;
        
    g_vpJPEG.pJPEGEncodeBuffer = NULL;
    
   	listInit (&g_vpJPEG.listEncodedJPEG);
   	
   	g_vpJPEG.nJPEGQua = 2;
   	g_vpJPEG.bOnTheFly = TRUE;
   	g_vpJPEG.nOnTheFlyCount = 0;

#ifndef ECOS
    sysInstallISR(IRQ_LEVEL_1, IRQ_JPEG, (void*)jpegIntHandler);
#else
	cyg_interrupt_disable();
	cyg_interrupt_create(IRQ_JPEG, IRQ_LEVEL_1, NULL, &jpegIntHandler, &jpegIntHandler_DSR,
				&(g_vpJPEG.cygIntrHandle), &(g_vpJPEG.cygIntrBuffer));
	cyg_interrupt_attach(g_vpJPEG.cygIntrHandle);
	cyg_interrupt_unmask(IRQ_JPEG);
	cyg_interrupt_enable();
#endif

    jpegSetIRQHandler(C_JPEG_CALLBACK_ENCODE_COMPLETE_INTERRUPT, vjpegEncoderCom_Callback);
    jpegSetIRQHandler(C_JPEG_CALLBACK_DECODE_COMPLETE_INTERRUPT, vjpegDecoderCom_Callback);
    jpegSetIRQHandler(C_JPEG_CALLBACK_DECODE_ERROR_INTERRUPT, vjpegDecoderErr_Callback);
	if(g_vpJPEG.bOnTheFly == TRUE)
	{
		jpegSetIRQHandler(C_JPEG_CALLBACK_ENCODE_SWONTHEFLY_WAIT_INTERRUPT, vjpegOnTheFlyCom_Callback);
	}
		
    bJPEGInit = TRUE;
}
예제 #2
0
파일: MCU.c 프로젝트: LucidOne/Rovio
/* Initialize MCU parameters. */
void mcuInit()
{
	tt_rmutex_init(&g_rmutex_MCU);
	g_bSendMCU = FALSE;
#if 1	//xhchen - MCU debug
	g_nMCU_Debug_Count = 0;
	g_nMCU_Command_Count = 0;
#endif

	/* Set GPIO for MCU */
	outpw(REG_GPIOB_OE,inpw(REG_GPIOB_OE) & ~MCU_GPIO);		//19 output;
    outpw(REG_GPIOB_DAT,inpw(REG_GPIOB_DAT) | MCU_GPIO);	//19 high	
    
    tt_msleep(100);
}
예제 #3
0
파일: Main.c 프로젝트: bimopraks/tinythread
int main()
{
	int i;

	/* The clock frequency of systick may be changed by user's application.
	   Please change the value of SYSTICK_CLOCK according to real situration */
#define TT_SYSTICK_CLOCK		22118400
	/* Initialize TinyThread */
	tt_init(TT_SYSTICK_CLOCK);
	
	/* Open LED GPIO for testing */
	_GPIO_SET_PIN_MODE(LED0_GPIO_GRP, LED0_GPIO_BIT, GPIO_PMD_OUTPUT);
	_GPIO_SET_PIN_MODE(LED1_GPIO_GRP, LED1_GPIO_BIT, GPIO_PMD_OUTPUT);
	_GPIO_SET_PIN_MODE(LED2_GPIO_GRP, LED2_GPIO_BIT, GPIO_PMD_OUTPUT);
	_GPIO_SET_PIN_MODE(LED3_GPIO_GRP, LED3_GPIO_BIT, GPIO_PMD_OUTPUT);

	/* Test threads lock by value[]
	   the element in value should be the same,
	   if not, there must be an error */
	tt_rmutex_init(&mutex);
	for(i = 0; i < THREAD_NUM; ++i)
		value[i] = 0;

	arg[0].gpio_group = LED0_GPIO_GRP;
	arg[1].gpio_group = LED1_GPIO_GRP;
	arg[2].gpio_group = LED2_GPIO_GRP;
	arg[0].gpio_bit = LED0_GPIO_BIT;
	arg[1].gpio_bit = LED1_GPIO_BIT;
	arg[2].gpio_bit = LED2_GPIO_BIT;

	for(i = THREAD_NUM; i-- != 0; )
	{
		arg[i].value = value;
		arg[i].mutex = &mutex;
		thread[i] = tt_thread_create("th", 
			0,
			stack[i], sizeof(stack[i]),
			thread_entry, (void *)&arg[i]);
	}
	
	tt_sleep(1024);
	
	while(1);
	return 0;
}
예제 #4
0
void ServerStart(void)
{

	int i, j;	

	char *pcDocRoot = "./";
	static int aiPort[] = {80, 0};
#ifndef WLAN
    FMI_CARD_DETECT_T card;
#endif	
	cyg_mutex_init(&g_ptmConfigParam);
	cyg_mutex_init(&g_ptmState);
	cyg_mutex_init(&g_ptmTimeSetting);
	cyg_mutex_init(&g_ptmWebCameraLog);
	tt_rmutex_init(&g_rmutex);
	
	{
		UINT32 uFlashTotal, uFlashFreeBegin, uFlashFreeEnd;
		GetFlashCapability(&uFlashTotal, &uFlashFreeBegin, &uFlashFreeEnd);
		diag_printf("Flash total: %d, free space [%d - %d]\n", uFlashTotal, uFlashFreeBegin, uFlashFreeEnd);
	}
	
#ifndef WLAN
	/*init the sd card*/
    //do {outpw (REG_CLKCON, inpw (REG_CLKCON) | FMICLK_EN); } while (0);
    fmiSetFMIReferenceClock(OPT_UPLL_OUT_CLOCK/3/1000);    
	fsFixDriveNumber('D', 'C', 'Z');    
    fsInitFileSystem();    
   	card.uCard = FMI_SD_CARD;		// card type
	card.uGPIO = 4;				// card detect GPIO pin
	card.uWriteProtect = 16;			// card detect GPIO pin
	card.uInsert = 0;				// 0/1 which one is insert
	card.nPowerPin = 12;				// card power pin, -1 means no power pin
	card.bIsTFlashCard = FALSE;
	fmiSetCardDetection(&card);
	fmiInitSDDevice();
	diag_printf("Init the SD Card ok!\n");
	g_StreamServer_Buf = (char*)(g_StreamServer_Buf1);
#endif
#ifdef FILESYSTEM
	/* Check if disk need to be formatted. */
	ipcCheckDisk( );	
#endif
	
	/*register reset interrupt*/
	InitResetGPIO();
	// Set HIC ready
   	outpw(REG_HICSR, inpw(REG_HICSR) & 0xFFFFFF7F);

	if (0)
	{
		int j = 0;
		for(;j<5;j++)
			init_loopback_interface(0);
	}

	
	/* 初始化camera的参数 */ 
	ResetCameraParam();    
	/* 挂载需要额外处理的URL */
	RegisterUrls();
	//GetDHCPInfo();

	/* 設置进入不同特权领域的提示语 */
	httpSetAuthPrompt(CONFIG_LOGIN_PROMPT_USER, CONFIG_LOGIN_PROMPT_ADMIN, NULL);
	/* 选择从命令行或者配置参数中设定的http端口 */
	for (i = 0; i < sizeof(g_ConfigParam.usHttpPort) / sizeof(unsigned short); i++)
	{
		if (g_ConfigParam.usHttpPort[i] == 0) g_ConfigParam.usHttpPort[i] = aiPort[i];
	}
	for (i = 0, j = 0; i < sizeof(g_ConfigParam.usHttpPort) / sizeof(unsigned short); i++)
	{
		if (g_ConfigParam.usHttpPort[i] != 0)
			aiPort[j++] = g_ConfigParam.usHttpPort[i];
	}
	aiPort[j] = 0;
	diag_printf("Port is %d,%d\n",aiPort[0],aiPort[1]);

	ResetOtherThread();
	
	{
 	   cyg_thread_create(PTD_PRIORITY, &MctestThread, (cyg_addrword_t)aiPort, "ptdMctest", ptdMctest_stack, STACKSIZE2, &ptdMctest_handle, &g_ptdMctest);
		if ( ptdMctest_handle == NULL)
		{
			fprintf(stderr, "Thread for mctest creation failed!\n");
			return;
		}
		cyg_thread_resume(ptdMctest_handle);
	}

	cyg_thread_set_priority(cyg_thread_self(), PTD_PRIORITY);
	// 开始http服务 	
	httpdStartEx(pcDocRoot, aiPort,3600, 30 * 60 * 60 , 20, OnHttpInit, OnRequestBegin);	

}