예제 #1
0
int main(int argc, char** argv)
{
    char p[512];
    char *server_mem;
    char *client_mem;
    int client_size;
    int server_size;
    force_net_dev_linked();
    cyg_do_net_init();
    SetWlanESSID("zhuna");
#ifdef MP4
    sprintf(p, g_RtspServer_conf, "IMAADPCM", "Mpeg4", "Mpeg4", "IMAADPCM");
#else
    sprintf(p, g_RtspServer_conf, "AMR", "H263", "H263", "AMR");
#endif
    set_config(p);
    cyg_semaphore_init(&video_sem0, 0);
    cyg_semaphore_init(&video_sem1, 0);
    cyg_semaphore_init(&audio_sem0, 0);
    cyg_semaphore_init(&audio_sem1, 0);

    cyg_interrupt_disable();
    cyg_interrupt_disable();
    cyg_interrupt_disable();

    cyg_interrupt_enable();

    set_auth_id("jfyan","jfyanpass");
    set_auth_id("jfyan1","jfyan1");
    set_auth_id("jfyan2","jfyan2");
    del_auth_id("jfyan1","jfyan1");
    //set_auth_disable();
    VideoPhoneInit();
    fmiSetFMIReferenceClock(112000);
    fmiSetSDOutputClockbykHz(18000);
    //FTH_Init();
    init_wbdevice(initlcm);
    set_encoderenable(set_encoderenableFunc);
    set_encoderdisable(set_encoderdisableFunc);
    init_get_video(get_back_video);
    init_get_audio(get_back_audio);
    server_size = get_server_size();
    server_mem = (char*)malloc(server_size);
    if(server_mem == NULL)
        printf("memory out\n");
    rtsp_server_init(server_mem, server_size);
    client_size = get_rtspmem_size(3);
    client_mem = (char*)malloc(client_size);
    if(client_mem == NULL)
        printf("memory out\n");
    rtsp_mem_init(client_mem, client_size);
    RtspServerStart(2);
}
예제 #2
0
void dbg_line_save(int line)
{
	cyg_interrupt_disable();
	dbg_line[dbg_line_pos++] = (unsigned short)line;
	if (dbg_line_pos >= sizeof(dbg_line) / sizeof(dbg_line[0]))
		dbg_line_pos = 0;
	cyg_interrupt_enable();
}
예제 #3
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;
}
예제 #4
0
파일: os_ecos.c 프로젝트: LucidOne/Rovio
void *os_malloc(size_t size)
{
	void *ret = malloc(size);
	if (ret == NULL)
	{
		diag_printf("malloc failed\n");
		cyg_interrupt_disable();
		while(1);
	}
	return ret;
}
예제 #5
0
파일: cap.c 프로젝트: LucidOne/Rovio
void capInit(BOOL bCapEngEnable, BOOL bCapIntEnable)
#endif
{
	int j;
	int i=sizeof(VCEInit)/sizeof(T_REG_INFO);	
	for (j=0; j<i ;j++)
		outpw((CAP_BA+VCEInit[j].uAddr),VCEInit[j].uValue);	
	if(bCapEngEnable==TRUE)
	{
		outpw(REG_CAPEngine,inpw(REG_CAPEngine)|0x01);
	}
	else
	{
		outpw(REG_CAPEngine,inpw(REG_CAPEngine)&0xfffffffe);
	}
	if(bCapIntEnable==TRUE)
	{	
#ifdef ECOS	
		cyg_interrupt_disable();
		cyg_interrupt_create(IRQ_VCE, 1, 0, capIntHandler, capIntHandlerDSR, 
					&(t_eCos->cap_int_handle), &(t_eCos->cap_int));
		cyg_interrupt_attach(t_eCos->cap_int_handle);
		cyg_interrupt_unmask(IRQ_VCE);
		cyg_interrupt_enable();		
#else
		sysInstallISR(IRQ_LEVEL_1, IRQ_VCE, (PVOID)capIntHandler);	//
		sysEnableInterrupt(IRQ_VCE);
#endif		
		outpw(REG_CAPFuncEnable,inpw(REG_CAPFuncEnable)|0x2);
	}
	else
	{
#ifdef ECOS
		cyg_interrupt_mask(IRQ_VCE);
		cyg_interrupt_detach(t_eCos->cap_int_handle);
		cyg_interrupt_delete(t_eCos->cap_int_handle);
#else	
		sysDisableInterrupt(IRQ_VCE);
#endif		
		outpw(REG_CAPFuncEnable,inpw(REG_CAPFuncEnable)&0xfffffffd);
	}		
}	
예제 #6
0
파일: kintr0.c 프로젝트: Undrizzle/yolanda
void kintr0_main( void )
{
    cyg_vector_t v = (CYGNUM_HAL_VSR_MIN + 11) % CYGNUM_HAL_VSR_COUNT;
    cyg_vector_t v1;
    cyg_vector_t lvl1 = CYGNUM_HAL_ISR_MIN + (1 % CYGNUM_HAL_ISR_COUNT);
    cyg_vector_t lvl2 = CYGNUM_HAL_ISR_MIN + (15 % CYGNUM_HAL_ISR_COUNT);
    int in_use;

    cyg_VSR_t *old_vsr, *new_vsr;

    CYG_TEST_INIT();
 
#ifdef CYGPKG_HAL_MIPS_TX39    
    // This can be removed when PR 17831 is fixed
    if ( cyg_test_is_simulator )
        v1 = 12 % CYGNUM_HAL_ISR_COUNT;
    else /* NOTE TRAILING ELSE... */
#endif
    v1 = CYGNUM_HAL_ISR_MIN + ( 6 % CYGNUM_HAL_ISR_COUNT);

    CHECK(flash());
    CHECK(flash());

    // Make sure the chosen levels are not already in use.
    HAL_INTERRUPT_IN_USE( lvl1, in_use );
    intr0 = 0;
    if (!in_use)
        cyg_interrupt_create(lvl1, PRIO_B, (cyg_addrword_t)777,
                             isr0, dsr0, &intr0, &intr_obj[0]);
    
    HAL_INTERRUPT_IN_USE( lvl2, in_use );
    intr1 = 0;
    if (!in_use && lvl1 != lvl2)
        cyg_interrupt_create(lvl2, PRIO_C, 888,
                             isr1, dsr1, &intr1, &intr_obj[1]);

    // Check these functions at least exist

    cyg_interrupt_disable();
    cyg_interrupt_enable();

    if (intr0)
        cyg_interrupt_attach(intr0);
    if (intr1)
        cyg_interrupt_attach(intr1);
    if (intr0)
        cyg_interrupt_detach(intr0);
    if (intr1)
        cyg_interrupt_detach(intr1);

    // If this attaching interrupt replaces the previous interrupt
    // instead of adding to it we could be in a big mess if the
    // vector is being used by something important.
        
    cyg_interrupt_get_vsr( v, &old_vsr );
    cyg_interrupt_set_vsr( v, vsr0 );
    cyg_interrupt_get_vsr( v, &new_vsr );
    CHECK( vsr0 == new_vsr );

    new_vsr = NULL;
    cyg_interrupt_get_vsr( v, &new_vsr );
    cyg_interrupt_set_vsr( v, old_vsr );
    CHECK( new_vsr == vsr0 );

    cyg_interrupt_set_vsr( v, new_vsr );
    new_vsr = NULL;
    cyg_interrupt_get_vsr( v, &new_vsr );       
    CHECK( vsr0 == new_vsr );

    cyg_interrupt_set_vsr( v, old_vsr );
    CHECK( vsr0 == new_vsr );
    new_vsr = NULL;
    cyg_interrupt_get_vsr( v, &new_vsr );
    CHECK( old_vsr == new_vsr );
        
    CHECK( NULL != vsr0 );

    cyg_interrupt_mask(v1);
    cyg_interrupt_unmask(v1);
        
    cyg_interrupt_configure(v1, true, true);

    CYG_TEST_PASS_FINISH("Kernel C API Intr 0 OK");
}
예제 #7
0
int Config_MemDebug(HTTPCONNECTION hConnection, LIST *pParamList, int iAction, XML *pReturnXML)
{
	switch (iAction)
	{
	case CA_AUTH:
		return AUTH_ADMIN;
	case CA_CONFIG:
		{
			UINT32 i;
			char acBuf[128];
			UINT32 nLen = 0;
			static cyg_ppp_handle_t ppp_handle;
			const char *pcAction = httpGetString(pParamList, "action");
			
			if(strcmp(pcAction, "net") == 0)
			{
				if(g_ptdNetDebug_stack == NULL)
				{
					g_ptdNetDebug_stack = (unsigned char *)malloc(STACKSIZE);
					if (g_ptdNetDebug_stack != NULL)
					{
						cyg_thread_create(PTD_PRIORITY, &NetTestThread, NULL, "ptdNetTest",
							g_ptdNetDebug_stack, STACKSIZE, &g_ptdNetDebug_handle, &g_ptdNetDebug);
						if (g_ptdNetDebug_handle == NULL)
							fprintf(stderr, "Thread for \"NetTest\" creation failed!\n");
						else
							cyg_thread_resume(g_ptdNetDebug_handle);
					}
				}
			}
			else if (strcmp(pcAction, "print") == 0)
			{
				while(1)
				{
					diag_printf("random%d", rand());
					if(rand()%12==0)
						diag_printf("\n");
				}
			}
			else if (strcmp(pcAction, "pppip") == 0)
			{
				int fd;
				struct ifreq ifr;
				UINT32 ulIP = 0;
				UINT32 ulNetmask = 0;
				char acIP[16];
				char acNetmask[16];
				
				fd = socket(AF_INET, SOCK_DGRAM, 0);
				strcpy(ifr.ifr_name, "ppp0");
				
				if (fd >= 0) 
				{
					if (ioctl(fd, SIOCGIFADDR, &ifr) >= 0)
						ulIP = (unsigned int)(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr);
						
					if (ioctl(fd, SIOCGIFNETMASK, &ifr) == 0)
						ulNetmask = (unsigned int)(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr);
					
					close(fd);
				}
				
				httpIP2String(ulIP, acIP);
				httpIP2String(ulNetmask, acNetmask);
				AddHttpValue(pReturnXML, "IP", acIP);
				AddHttpValue(pReturnXML, "Netmask", acNetmask);
			}
			else if (strcmp(pcAction, "dppp") == 0)
			{
				ppot_disconnect();
			}
			else if (strcmp(pcAction, "ppp") == 0)
			{
				bool ret;
				const char *pcUsername;
				const char *pcPassword;
				const char *pcServer;
				int iPort;
				
				pcUsername = httpGetString(pParamList, "User");
				pcPassword = httpGetString(pParamList, "Pass");
				pcServer = httpGetString(pParamList, "Server");
				iPort = httpGetLong(pParamList, "Port");

/*				
u: xiaohui      p: 0gogorovio0
u: xiaohui1    p: 1gogorovio1
u: xiaohui2    p: 2gogorovio2
*/

				//ppp user: blah password=blahing
				// ssh port:4239, user: xhchen, pass: aeV2ohTi
				

				// Start up PPP
				//ppot_connect("tools.pimpmyrovio.com", 21201);
				//ppot_connect("116.92.2.11", 21201);
				ret = ppot_connect(&pcServer, &iPort, 1, pcUsername, pcPassword);
				AddHttpValue(pReturnXML, "ppot_connect", (ret ? "true" : "false"));
#if 0		
				ppp_handle = cyg_ppp_up( "/dev/sert0", &options );


				// Wait for it to get running
				if( cyg_ppp_wait_up( ppp_handle ) == 0 )
				{
					// Make use of PPP
					//use_ppp();

					// Bring PPP link down
					//cyg_ppp_down( ppp_handle );

					// Wait for connection to go down.
					//cyg_ppp_wait_down( ppp_handle );
				}
#endif			
				//cyg_thread_delay(5000);
				//ppot_disconnect();
				//diag_printf("Disconnect=====================\n");
				//while(1);
			}
			else if (strcmp(pcAction, "rtsp") == 0)
			{
				g_ntp_add = httpGetLong(pParamList, "ntp");
				g_ts_video = httpGetLong(pParamList, "ts_video");
				g_ts_audio = httpGetLong(pParamList, "ts_audio");
				AddHttpNum(pReturnXML, "ntp", g_ntp_add);
				AddHttpNum(pReturnXML, "ts_video", g_ts_video);
				AddHttpNum(pReturnXML, "ts_audio", g_ts_audio);
				AddHttpNum(pReturnXML, "max_vd_ratio", (int)max_vd_ratio);
				AddHttpNum(pReturnXML, "max_ad_ratio", (int)max_vd_ratio);
			}
			else if (strcmp(pcAction, "dir") == 0)
			{
			}
			else if (strcmp(pcAction, "channel") == 0)
			{
				int ch;
				GetWlanChannel("wlan0", &ch);
				AddHttpNum(pReturnXML, "channel", ch);
			}
			else if (strcmp(pcAction, "upnp") == 0)
			{
				upnp_refresh();
				AddHttpValue(pReturnXML, "UPNP", "refresh");
			}
			else if (strcmp(pcAction, "malloc") == 0)
			{
				static unsigned long ulTotalSize = 0;
				unsigned long ulSize = httpGetLong(pParamList, "size");
				void *pAddr = malloc (ulSize);
				if (pAddr != NULL)
					ulTotalSize += ulSize;
				AddHttpNum(pReturnXML, "addr", (int)pAddr);
				AddHttpNum(pReturnXML, "total_size", ulTotalSize);
			}
			else if (strcmp(pcAction, "checkip") == 0)
			{
				DDNS_CheckIP();
			}
			else if (strcmp(pcAction, "ddns") == 0)
			{
				BOOL bEnable = g_ConfigParam.bEnableDDNS;
				g_ConfigParam.bEnableDDNS = TRUE;
				DDNS_Update();
				g_ConfigParam.bEnableDDNS = bEnable;
			}
			else if (strcmp(pcAction, "line") == 0)
			{
				int i;
				char name[16];
				int size = sizeof(dbg_line_copy) / sizeof(dbg_line_copy[0]);
				cyg_interrupt_disable();
				dbg_line_pos_copy = dbg_line_pos;
				memcpy(dbg_line_copy, dbg_line, sizeof(dbg_line));
				cyg_interrupt_enable();	
				
				for (i = 0; i < size; i += 16)
				{
					int j;
					char str[128];
					int len = 0;
					for (j = 0; j < 16; j++)
					{
						len += sprintf(str + len, "%5d", (int) dbg_line_copy[(i+j+dbg_line_pos)%(size)]);
					}
					sprintf(name, "%5d", i);
					AddHttpValue(pReturnXML, name, str);
				}
			}
#if 1	//xhchen - MCU debug
			else if (strcmp(pcAction, "uart") == 0)
			{
				char log[128];
				char name[16];
				int log_pos;
				int i;
				sysDisableIRQ();
				log_pos = uart_log_pos;
				memcpy(log, uart_log, sizeof(log));
				sysEnableIRQ();
				
				
				for (i = 0; i < sizeof(log); i += 16)
				{
					int j;
					char str[32];
					int len = 0;
					for (j = 0; j < 16; j += 2)
					{
						char ch = log[(log_pos + i + j) % sizeof(log)];
						len += sprintf(str + len, "%c", ( ch != '\0' ? ch : '-') );
						ch = log[(log_pos + i + j + 1) % sizeof(log)];
						len += sprintf(str + len, "%02x", (int)(unsigned char)ch);
					}
					
					sprintf(name, "%08x", i / 2);
					AddHttpValue(pReturnXML, name, str);
				}
			}
			else if (strcmp(pcAction, "mcu") == 0)
			{
				void mcuGetErrorStatus(UINT32 *puCmdNo, UINT32 *puCommandCount, BOOL *pbCrashedLock);
				UINT32 uCmdNo;
				UINT32 uCmdCount;
				BOOL bCrashedLock;
				
				mcuGetErrorStatus(&uCmdNo, &uCmdCount, &bCrashedLock);
				AddHttpNum(pReturnXML, "CmdNo", uCmdNo);			
				AddHttpNum(pReturnXML, "LockCrashed", bCrashedLock);
				AddHttpNum(pReturnXML, "CmdCount", uCmdCount);
			}
			else
#endif
			if (strcmp(pcAction, "break") == 0)
			{
				test_sus();
				AddHttpValue(pReturnXML, "break_after", "3 seconds");
			}
			else if (strcmp(pcAction, "ps") == 0)
			{
				outpw(REG_GPIO_IE, (inpw(REG_GPIO_IE)|0x00000010));
				
				SetWlanPSMode("wlan0", FALSE);
			
				AddHttpValue(pReturnXML, "SetWlanPSMode", "wlan0");
			}
			else if (strcmp(pcAction, "cfg") == 0)
			{
				
				SetWlanHostSleepCfg("wlan0", 5);
				AddHttpValue(pReturnXML, "SetWlanHostSleepCfg", "wlan0 5");
			}
			else if (strcmp(pcAction, "gpiob19") == 0)
			{
				/* Set GPIOB for MCU */
				outpw(REG_GPIOB_OE,inpw(REG_GPIOB_OE)&(~0x00080000));		//19 output;
				outpw(REG_GPIOB_DAT,inpw(REG_GPIOB_DAT)&(~0x00080000));	//19 low
				cyg_thread_delay(8);
				outpw(REG_GPIOB_OE,inpw(REG_GPIOB_OE)&(~0x00080000));		//19 output;
				outpw(REG_GPIOB_DAT,inpw(REG_GPIOB_DAT)|(0x00080000));	//19 high   				
				cyg_thread_delay(8);
				
				sprintf(acBuf, "%08x", inpw(REG_GPIOB_OE));
				AddHttpValue(pReturnXML, "REG_GPIOB_OE", acBuf);
				sprintf(acBuf, "%08x", inpw(REG_GPIOB_DAT));
				AddHttpValue(pReturnXML, "REG_GPIOB_DAT", acBuf);
			}
			else if (strcmp(pcAction, "mall") == 0)
			{
				struct mallinfo info = mallinfo();
				AddHttpNum(pReturnXML, "arena", info.arena);
				AddHttpNum(pReturnXML, "ordblks", info.ordblks);
				AddHttpNum(pReturnXML, "smblks", info.smblks);
				AddHttpNum(pReturnXML, "hblks", info.hblks);
				AddHttpNum(pReturnXML, "hblkhd", info.hblkhd);
				AddHttpNum(pReturnXML, "usmblks", info.usmblks);
				AddHttpNum(pReturnXML, "fsmblks", info.fsmblks);
				AddHttpNum(pReturnXML, "uordblks", info.uordblks);
				AddHttpNum(pReturnXML, "fordblks", info.fordblks);
				AddHttpNum(pReturnXML, "keepcost", info.keepcost);
				AddHttpNum(pReturnXML, "maxfree", info.maxfree);
			}
			else if (strcmp(pcAction, "write_mp4") == 0)
			{
				UINT32 uBitrate = httpGetLong(pParamList, "bitrate");
				wb702SetVideoDynamicBitrate(uBitrate);
				sprintf(acBuf, "%d", uBitrate);
				AddHttpValue(pReturnXML, "bitrate", acBuf);
			}
			else if (strcmp(pcAction, "read_flash") == 0)
			{
				UINT32 uAddr = httpGetLong(pParamList, "address");
				UINT32 uSize = httpGetLong(pParamList, "size");
				if (uSize == 0)
					uSize = 1;
				sprintf(acBuf, "%08x[->%08x]", uAddr, uSize);
				AddHttpValue(pReturnXML, "read_flash", acBuf);
				
				for (i = 0; i < uSize; i += 8)
				{
					int j;
					char acFlash[8];
					UINT32 uThisSize = uSize - i;
					if (uThisSize > sizeof(acFlash))
						uThisSize = sizeof(acFlash);
										
					usiMyRead(uAddr + i, uThisSize, (void *)acFlash);
					
					acBuf[0] = '\0';
					nLen = 0;
					for (j = 0; j < uThisSize; ++j)
						nLen += sprintf(acBuf + nLen, "%02x ", (int)(unsigned char)(acFlash[j]) );
					AddHttpValue(pReturnXML, "read_flash", acBuf);
				}
				return 0;				
			}
			else if (strcmp(pcAction, "read_mem") == 0)
			{
				UINT32 uAddr = httpGetLong(pParamList, "address");
				UINT32 uSize = httpGetLong(pParamList, "size");
				if (uSize == 0)
					uSize = 1;
				sprintf(acBuf, "%08x[->%08x]", uAddr, uSize);
				AddHttpValue(pReturnXML, "read_mem", acBuf);
				acBuf[0] = '\0';
				for (i = 0; i < uSize; ++i)
				{
					nLen += sprintf(acBuf + nLen, "%02x ", (int)*(unsigned char *)(uAddr + i) );
					if (( i + 1 ) % 8 == 0)
					{
						AddHttpValue(pReturnXML, "read_mem", acBuf);
						nLen = 0;
						acBuf[0] = '\0';
					}
				}
				if ( i % 8 != 0)
					AddHttpValue(pReturnXML, "read_mem", acBuf);
				return 0;				
			}
			else if (strcmp(pcAction, "write_mem") == 0)
			{
				UINT32 uAddr = httpGetLong(pParamList, "address");
				UINT32 uValue = httpGetLong(pParamList, "value");
				UINT32 uSize = httpGetLong(pParamList, "size");
				if (uSize == 0)
					uSize = 4;
				memcpy((char *)uAddr, &uValue, uSize);
				sprintf(acBuf, "%08x[->%08x]=%08x", uAddr,uSize,uValue);
				AddHttpValue(pReturnXML, "write_mem", acBuf);
				return 0;
			}
			else if (strcmp(pcAction, "write_register") == 0)
			{
				UINT32 uAddr = httpGetULong(pParamList, "address");
				UINT32 uValue = httpGetULong(pParamList, "value");
				UINT32 uSize = httpGetULong(pParamList, "size");
				if (uSize == 0)
					uSize = 4;
				//outpw(address, value);
				memcpy((char *)uAddr, &uValue, uSize);
				sprintf(acBuf, "%08x[->%08x]=%08x", uAddr,uSize,uValue);
				AddHttpValue(pReturnXML, "write_register", acBuf);
				return 0;
			}
#if 1			
			else if (strcmp(pcAction, "set_oe") == 0)
			{
				UINT32 out = httpGetULong(pParamList, "out");
				UINT32 dir = httpGetULong(pParamList, "dir");
				UINT32 uSize = httpGetULong(pParamList, "size");
				
				UINT32 read_oe=0;
				UINT32 read_dat=0;
				UINT32 read_sts=0;

				if (uSize == 0)
					uSize = 4;
				//outpw(address, value);
				if(out==5 || out==18|| out ==0||out==1 )   // gpio5 is out1, gpio18 is out2
				{
					if(dir==1)
						outpw(REG_GPIO_OE, inpw(REG_GPIO_OE)|(1<<out));
					else
						outpw(REG_GPIO_OE, inpw(REG_GPIO_OE)&~(1<<out));
				}
				
				read_oe = inpw(REG_GPIO_OE);
				read_dat = inpw(REG_GPIO_DAT);
				read_sts = inpw(REG_GPIO_STS);
					
				sprintf(acBuf, "%08xoe[%08xdat]%08xsts", read_oe,read_dat,read_sts);
				AddHttpValue(pReturnXML, "set_oe", acBuf);
				return 0;
			}
			
			else if (strcmp(pcAction, "set_dat") == 0)
			{
				UINT32 out = httpGetULong(pParamList, "out");
				UINT32 dat = httpGetULong(pParamList, "dat");
				UINT32 uSize = httpGetULong(pParamList, "size");
				
				UINT32 read_oe=0;
				UINT32 read_dat=0;
				UINT32 read_sts=0;

				if (uSize == 0)
					uSize = 4;
				//outpw(address, value);
				if(out==5 || out==18)   // gpio5 is out1, gpio18 is out2
				{
					if(dat==1)
						outpw(REG_GPIO_DAT, inpw(REG_GPIO_DAT)|(1<<out));
					else
						outpw(REG_GPIO_DAT, inpw(REG_GPIO_DAT)&~(1<<out));
				}
				
				read_oe = inpw(REG_GPIO_OE);
				read_dat = inpw(REG_GPIO_DAT);
				read_sts = inpw(REG_GPIO_STS);
					
				sprintf(acBuf, "%08xoe[%08xdat]%08xsts", read_oe,read_dat,read_sts);
				AddHttpValue(pReturnXML, "set_dat", acBuf);
				return 0;
			}
			
			else if (strcmp(pcAction, "get_oe") == 0)
			{
				UINT32 uAddr = httpGetULong(pParamList, "address");
				UINT32 uValue = httpGetULong(pParamList, "value");
				UINT32 uSize = httpGetULong(pParamList, "size");
				UINT32 read_oe=0;
				UINT32 read_dat=0;
				UINT32 read_sts=0;
	
				if (uSize == 0)
					uSize = 4;
				read_oe = inpw(REG_GPIO_OE);
				read_dat = inpw(REG_GPIO_DAT);
				read_sts = inpw(REG_GPIO_STS);
				sprintf(acBuf, "%08xoe[%08xdat]%08xsts", read_oe,read_dat,read_sts);
				AddHttpValue(pReturnXML, "get_oe", acBuf);
				return 0;
			}
#endif			
			else if (strcmp(pcAction, "read_i2c") == 0)
			{
				UINT32 uAddr = httpGetLong(pParamList, "address");
				UINT32 uValue = i2cReadI2C(uAddr);
				sprintf(acBuf, "%08x=%08x", uAddr, uValue);
				AddHttpValue(pReturnXML, "read_i2c", acBuf);
				return 0;
			}
			else if (strcmp(pcAction, "write_i2c") == 0)
			{
				UINT32 uAddr = httpGetLong(pParamList, "address");
				UINT32 uValue = httpGetLong(pParamList, "value");
				i2cWriteI2C (uAddr, uValue);
				sprintf(acBuf, "%08x=%08x", uAddr, uValue);
				AddHttpValue(pReturnXML, "write_i2c", acBuf);
				return 0;
			}
			else if (strcmp(pcAction, "debug") == 0)
			{
			}
			else
				AddHttpValue(pReturnXML, "action", "error");
			return 0;
		}		
	}
	return -1;
}
예제 #8
0
파일: System.c 프로젝트: jcrona/rovio-fw
void W99802Reboot(void)
{
#ifndef WLAN
	unsigned int iValue;
	iValue = *((volatile unsigned int *)0x7FF00008);
	iValue |= 1;
	*((volatile unsigned int *)0x7FF00008) = iValue;
#else
	//vp_bitrate_control_uninit();

#if 0	
	DownInterface("wlan0");
	wlan_cleanup_module( );

	/* Reset WiFi card */
	outpw(REG_GPIO_OE, inpw(REG_GPIO_OE) & 0xFFFDFFFF);		/* Set GPIO17 output */
	outpw(REG_GPIO_DAT, inpw(REG_GPIO_DAT) | 0x00020000);	/* Set GPIO17 high */
	tt_msleep(10);
	outpw(REG_GPIO_DAT, inpw(REG_GPIO_DAT) & 0xFFFDFFFF);	/* Set GPIO17 low */
	tt_msleep(10);
	outpw(REG_GPIO_DAT, inpw(REG_GPIO_DAT) | 0x00020000);	/* Set GPIO17 high */
	tt_msleep(10);
#endif	

	//cyg_thread_set_priority(cyg_thread_self(), CYGPKG_NET_FAST_THREAD_PRIORITY - 2);
	
	usiMyLock();
	usiMyFlash();

	cyg_interrupt_disable();
	
//cplu++
	/* Reset WiFi card */
	outpw(REG_GPIO_OE, inpw(REG_GPIO_OE) & 0xFFFDFFFF);		/* Set GPIO17 output */
	outpw(REG_GPIO_DAT, inpw(REG_GPIO_DAT) | 0x00020000);	/* Set GPIO17 high */
	//tt_msleep(10);
	{ int volatile i; for (i = 0; i < 100000; i++); }
	outpw(REG_GPIO_DAT, inpw(REG_GPIO_DAT) & 0xFFFDFFFF);	/* Set GPIO17 low */
	//tt_msleep(10);
	{ int volatile i; for (i = 0; i < 100000; i++); }
	outpw(REG_GPIO_DAT, inpw(REG_GPIO_DAT) | 0x00020000);	/* Set GPIO17 high */
	//tt_msleep(10);
	{ int volatile i; for (i = 0; i < 100000; i++); }
	

	/* Set reboot flag for bootloader */
	diag_printf("Now reboot w99802.......");
#if defined IPCAM_CONFIG_MP4_EVB_VER_0 || defined IPCAM_CONFIG_MP4_EVB_VER_1
	outpw(REG_HICBUF + 0x4, 0x03);	/* HICBUF1 power ready */
#elif defined IPCAM_CONFIG_IP_CAM_VER_0 || defined IPCAM_CONFIG_IP_CAM_VER_1 || defined IPCAM_CONFIG_IP_CAM_VER_2 || defined IPCAM_CONFIG_IP_CAM_VER_3
	outpw(REG_HICBUF + 0x4, 0x02);	/* HICBUF1 power ready */
#else
#	error "No hardware config defined!"
#endif

	/* Disable LED */
	outpw(REG_GPIOB_OE,inpw(REG_GPIOB_OE) & ~(UINT32)(LED_GPIO_RED | LED_GPIO_GREEN)); //set gpiob24 and gpio25 output mode
	outpw(REG_GPIOB_DAT,inpw(REG_GPIOB_DAT) | (UINT32)(LED_GPIO_RED | LED_GPIO_GREEN)); // set gpiob24 and gpio25 high(not light)

	/* Reset W99802 */
	outpw(REG_GPIO_OE, inpw(REG_GPIO_OE) & 0xFFFFFFF7);		/* Set GPIO3 output */
	outpw(REG_GPIO_DAT, inpw(REG_GPIO_DAT) & 0xFFFFFFF7);	/* Set GPIO3 low */
	{ int volatile i; for (i = 0; i < 50000; i++); }
	outpw(REG_GPIO_DAT, inpw(REG_GPIO_DAT) | 0x00000008);	/* Set GPIO3 high */
	{ int volatile i; for (i = 0; i < 50000; i++); }
	
	
	//tt_msleep(100);
	//outpw(REG_HICBUF + 0x4, 0x02);	/* HICBUF1 reset */
	
	//outpw(REG_GPIO_OE, inpw(REG_GPIO_OE) & 0xFFFFFFF7);		/* Set GPIO3 output */
	//outpw(REG_GPIO_DAT, inpw(REG_GPIO_DAT) & 0xFFFFFFF7);	/* Set GPIO3 low */
	//tt_msleep(10);
	//outpw(REG_GPIO_DAT, inpw(REG_GPIO_DAT) | 0x00000008);	/* Set GPIO3 high */
#endif
}
예제 #9
0
INT  w5691StartPlay(AU_CB_FUNC_T *fnCallBack, INT nSamplingRate, 
						INT nChannels, INT pcm_format)
{


    UINT16	wTMV;
   	UINT8	byTMB = 0;
   	UINT8   byClockBase = 1;

	
	UINT8	eFormat = eSPEECH_FORMAT_SIGN_16BIT_PCM;
	INT 	nStatus;
	UINT8 byStartSpchCmd[8] = { 0x03, 0x03, 0x00, 0x00, 0x00, 0x00 , 0x7f, 0x40 };//GFIFO start play command
	
	if (_W5691_Playing)
		return ERR_W5691_PLAY_ACTIVE;
		
	if (_W5691_Playing == 0)
	{
		memset((CHAR *)&_tW5691, 0, sizeof(_tW5691));
		nStatus = w5691_init();
		if (nStatus < 0)
			return nStatus;	
	}
	

	
#ifdef ECOS
	cyg_interrupt_disable();
	sysSetInterruptType(GPIO_INT_NUM, LOW_LEVEL_SENSITIVE);
	cyg_interrupt_create(GPIO_INT_NUM, 1, 0, w5691_dma_isr, NULL, 
					&_tW5691.int_handle_play, &_tW5691.int_holder_play);
	cyg_interrupt_attach(_tW5691.int_handle_play);
	cyg_interrupt_unmask(AU_PLAY_INT_NUM);
	cyg_interrupt_enable();
#else	

	sysSetInterruptType(GPIO_INT_NUM, LOW_LEVEL_SENSITIVE);
	/* Install ISR */
	sysInstallISR(IRQ_LEVEL_1, GPIO_INT_NUM, (PVOID)w5691_dma_isr);
    /* enable CPSR I bit */
    sysSetLocalInterrupt(ENABLE_IRQ);
	/* Set AIC into SW mode */
//	sysSetAIC2SWMode();
	sysEnableInterrupt(GPIO_INT_NUM);
#endif
	outpw(REG_GPIO_OE, inpw(REG_GPIO_OE) | (1<<USED_GPIO_NUM));
	
	_tW5691.nPlaySamplingRate = nSamplingRate;
	_tW5691.fnPlayCallBack = fnCallBack;
	
	wTMV = (UINT16)(W5691_SYSTEM_CLOCK / _tW5691.nPlaySamplingRate) / byClockBase;
	while(wTMV > 511)
	{
		byClockBase <<= 1;
		wTMV >>= 1;
		byTMB++;
	}

	byStartSpchCmd[2] = (UINT8)eFormat | eSPEECH_FCH_PFIFO ;
	byStartSpchCmd[3] = (UINT8)(wTMV & 0xFF);
	byStartSpchCmd[4] = (UINT8)(wTMV >> 8);
	byStartSpchCmd[5] = byTMB;

	


	/* call back to fill DMA buffer*/
	_tW5691.bPlayLastBlock = _tW5691.fnPlayCallBack((UINT8 *)_uAuPlayBuffAddr,
										Play_FIFO_Trigger_Length*2);

	/* send PCM data to w5691*/									
	ComDrv_SendCommandWithData(eCOMMAND_SEND_SPEECH_DATA, 
								   (UINT8 *)_uAuPlayBuffAddr, Play_FIFO_Trigger_Length*2);


	ComDrv_SendCommand(eCOMMAND_ENABLE_SPEECH_INTERRUPT);




#ifdef SOFT_MODE
	ComDrv_SendFIFOData(CMD_COM_ID_GEN_FIFO,byStartSpchCmd,6);
#else
	outpw(REG_ACTL_M80SIZE, 6+1);
	outpw(REG_ACTL_M80DATA0, 0x55 | byStartSpchCmd[0]<<8 | (byStartSpchCmd[1]<<16) | (byStartSpchCmd[2]<<24) );
	outpw(REG_ACTL_M80DATA1, byStartSpchCmd[3] | (byStartSpchCmd[4]<<8) | (byStartSpchCmd[5]<<16));
	outpw(REG_ACTL_M80ADDR, CMD_COM_ID_GEN_FIFO);
	outpw(REG_ACTL_M80CON, inpw(REG_ACTL_M80CON) | W_GFIFO | W_IF12_ACT);
	while((inpw(REG_ACTL_M80CON)&W_IF12_ACT) != 0);
	outpw(REG_ACTL_M80CON, inpw(REG_ACTL_M80CON) & ~W_GFIFO );
	ComDrv_SendSimpleCommand(CMD_COM_ID_WAKE_UP,WAKE_UP_REG_INT);	
#endif	

	Delay(0x5000);
	
	ComDrv_SetInterruptMask(1);
#ifdef SOFT_MODE	
	soft_read_status_flag_reg();
#else	
	ComDrv_DisableInterrupt();
#endif	
	ComDrv_EnableInterrupt();
	_W5691_Playing=1;
	

	return 0;
}
예제 #10
0
파일: fontbypass.c 프로젝트: LucidOne/Rovio
int main(int argc, char *argv[])
{
	int fd_video,buf_len_video;
	int event = 0;
	int count = 0 ;
	int cnt = 0,flag=0;
    char *pcontent;
    unsigned long ulIPOldeth1 = -1, ulIPOldppp0 = -1;
    BOOL bIPEth1Change = FALSE, bIPPPP0Change = FALSE;
    
    //for font-->
	FONT_DEVICE_T fd;
	FONT_RECT_T rc;
	FONT_SIZE_T sz;
    
	cyg_interrupt_disable();
	cyg_interrupt_disable();
	cyg_interrupt_disable();
	
	cyg_interrupt_enable();
	VideoPhoneInit();
	
    fontAttrInit(&font_attr);
    //fontGetConf(&font_attr, FONT_CONF_PATH);
    fontFontSet(&fd, &font_attr);
    //for font end<--

	ControlBackLight(6, 0);
	wb702ConfigureLCM(320, 240, 2, 1, 3, 0, TRUE, 1);
	//wb702SetOSDColor(5, 0x00, 0x00, 0x00, 0xF8, 0xFC, 0xF8);
	ControlLcmTvPower(2);
	ControlBackLight(6, 1);	
#ifdef FONT_STANDALONE
	//wb702SetIoctlRW(fd_video, TRUE);//select ioctl method
	wb702EnableMotionDetect(TRUE, CMD_MOTION_DETECT_LOW);
	wb702Init(fd_video);
#endif
	
    drawLCDRGB(buf_video,font_attr.iScreenWidth*font_attr.iScreenHeight*2);
    //wb702BypassBitmap(font_attr.iScreen, buf_video, font_attr.iScreenWidth*font_attr.iScreenHeight*2);
    
    while(1)
    {
        drawLCDRGB(buf_video,font_attr.iScreenWidth*font_attr.iScreenHeight*2);

        //if(font_attr.bBackground == TRUE)
        {
            bmpconv(BMP_BACKGROUND_PATH, buf_video, font_attr.iScreenWidth, font_attr.iScreenHeight);
        }

        fontPrintContent(&fd, &font_attr, FONT_CONF_PATH);
		
		/*
        if(font_attr.bVersion == TRUE)
        {
            char versionbuf[32];
            char cmd[32];
            
            if(fontGetVersion(fd_video, versionbuf) == TRUE)
            {
                sprintf(cmd, "V%s", versionbuf);
                pcontent = cmd;
            }
            else
                pcontent = VERSION_DEFAULT;
            fontGetSize(&fd, (unsigned char*)pcontent, &sz);
            fontGetRC(&font_attr, &rc, &sz);
#ifdef FONT_DEBUG
            printf("Size: %d %d\n", sz.nWidth, sz.nHeight);
#endif
            fontPrint(&fd, (unsigned char*)pcontent, &rc, &sz);
            font_attr.rcThis.nTop += (sz.nHeight + LINE_SPACE);
        }
        */
        
        /*
        if(font_attr.bIpaddress == TRUE)
        {
            unsigned long ulIPeth1, ulIPppp0;
            BOOL ipresult;
            
            ulIPeth1 = GetIPAddress("eth1");
            if(ulIPeth1 != ulIPOldeth1)
            {
                bIPEth1Change = TRUE;
                ulIPOldeth1 = ulIPeth1;
                
                if(ulIPeth1 != 0)
                {
                    pcontent = malloc(20);
#ifdef SOCKET_BRIDGE
                    sprintf(pcontent, "ETH1: %s", inet_ntoa(*(struct in_addr*)&ulIPeth1, g_FontFuncBuffer, FONTFUNCBUFFER_SIZE));
#else
                    sprintf(pcontent, "ETH1: %s", inet_ntoa(*(struct in_addr*)&ulIPeth1));
#endif
                    fontGetSize(&fd, (unsigned char*)pcontent, &sz);
                    fontGetRC(&font_attr, &rc, &sz);
    #ifdef FONT_DEBUG
                    printf("Size: %d %d\n", sz.nWidth, sz.nHeight);
    #endif
                    fontPrint(&fd, (unsigned char*)pcontent, &rc, &sz);
                    font_attr.rcThis.nTop += (sz.nHeight + LINE_SPACE);
                    
                    free(pcontent);
                }
            }
            

            ulIPppp0 = GetIPAddress("ppp0");
            if(ulIPppp0 != ulIPOldppp0)
            {
                bIPPPP0Change = TRUE;
                ulIPOldppp0 = ulIPppp0;
                
                if(ulIPppp0 != 0)
                {
                    pcontent = malloc(20);
#ifdef SOCKET_BRIDGE
                    sprintf(pcontent, "PPP: %s", inet_ntoa(*(struct in_addr*)ulIPppp0, g_FontFuncBuffer, FONTFUNCBUFFER_SIZE));
#else
                    sprintf(pcontent, "PPP: %s", inet_ntoa(*(struct in_addr*)ulIPppp0));
#endif
                    fontGetSize(&fd, (unsigned char*)pcontent, &sz);
                    fontGetRC(&font_attr, &rc, &sz);
#ifdef FONT_DEBUG
                    printf("Size: %d %d\n", sz.nWidth, sz.nHeight);
#endif
                    fontPrint(&fd, (unsigned char*)pcontent, &rc, &sz);
                    font_attr.rcThis.nTop += (sz.nHeight + LINE_SPACE);
                
                    free(pcontent);
                }
            }
        }
        */
                {
                	bIPEth1Change = TRUE;
                    pcontent = malloc(20);
                    sprintf(pcontent, "ETH1: %s", "10.132.11.11");
                    fontGetSize(&fd, (unsigned char*)pcontent, &sz);
                    fontGetRC(&font_attr, &rc, &sz);
                    fontPrint(&fd, (unsigned char*)pcontent, &rc, &sz);
                    font_attr.rcThis.nTop += (sz.nHeight + LINE_SPACE);
                    
                    free(pcontent);
                }
        
        //if((bIPEth1Change==TRUE) || (bIPPPP0Change==TRUE))
        {
#ifdef FONT_DEBUG
            printf("wb702BypassBitmap!!!\n");
#endif
	        memcpy(vlcmGetLCMBuffer ()->aucData, buf_video, font_attr.iScreenWidth*font_attr.iScreenHeight*2);
           // wb702BypassBitmap(font_attr.iScreen, buf_video, font_attr.iScreenWidth*font_attr.iScreenHeight*2);
            bIPEth1Change = FALSE;
            bIPPPP0Change = FALSE;
        }
        
        fontRecoverRC(&font_attr);
        tt_msleep(5000);
    }
        

    return 0;
}