亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? platform.c

?? st 芯片的bootloader 源代碼和編譯好的文件
?? C
字號:
#include "platform.h"
#include "71x_lib.h"
#include <stdio.h>
#include <string.h>
#include <stdarg.h>

//Menu Constants
#define MENUEXIT 0x100       // Flag to cause menu loop to exit
#define MENUNUMBERMASK 0xFF // Test number field

/*
*******************************************************************************
*   DATA TYPES
*******************************************************************************
*/

//for parsing command line
enum ParseState {
	PS_WHITESPACE,
	PS_TOKEN,
	PS_STRING,
	PS_ESCAPE
};


/***********************************************************************
	Input/Output Functions
	
************************************************************************/

/*----------------------------------------------------------------------
 * Test to see if a key has been pressed on the input device.
 */
int SerialKeyPressed(char *key)
{
   	if (UARTX->SR & UART_RxBufFull)
   	{
   		*key = (char)UARTX->RBR;
   		return 1;
   	}
   	else 
   		return 0;
}

int KeyPressed(int *key)
{
	int ret=0;
	ret += SerialKeyPressed((char*)key);
	
	//if there is another input, we may check that here in this way:
	//ret += ButtonPressed(key);
	
	return ret; 
} 

/*----------------------------------------------------------------------
 * Get a key from the input device. 
 */
int GetKey(void)
{
    int key;

    //First clear Rx buffer
    UART_FifoReset(UARTX,UART_RxFIFO);    
	
	//then waiting for user input
    while (1)
    {
    	WaitMs(50);
    	if (SerialKeyPressed((char*)&key)) break;

		//
		//if there is another input, we may check that.
		//
    }
    
    return key;
}

/*----------------------------------------------------------------------
* Print a character  via the serial device
*/
void inline SerialPutChar(char c)
{
	UART_ByteSend(UARTX,(u8*)&c);
}

/*----------------------------------------------------------------------
 * Print a string via the serial device.
 */
void SerialPutString(char *s)
{
	
	while (*s != '\0')
	{
	   SerialPutChar(*s);
	   s ++;
	}
}

/*----------------------------------------------------------------------
 * Serial printf.
 */
void SerialPrintf (char * fmt, ...)
{
    char buffer[256];
    va_list ap;

    va_start(ap,fmt);
    //doPrint(buffer,fmt,ap);
    vsprintf(buffer, fmt, ap);
    SerialPutString(buffer);
}

/*----------------------------------------------------------------------
*  Get Input string from the console. 
*/
void GetInputString (char * buffP)
{
    int bytes_read = 0;
    char c;

    do {
    	c = GetKey();
    	if (c == '\r')   	break;
    	if (c == '\b')	//backspace
    	{
			if (bytes_read > 0)
			{
				SerialPutString("\b \b");
		    	bytes_read --;
    		}
    		continue;
    	}
    	if (bytes_read >= CMD_STRING_SIZE )
    	{
    		SerialPutString("Command string size overflow\r\n");
    		bytes_read = 0;
    		continue;
    	}
		
    	/*
    	if (c == UP_KEY || c==DOWN_KEY || c==LEFT_KEY ||c==RIGHT_KEY)
    	{
    		c = BEEP_KEY;
    		SerialPutChar(c);
    		continue;
    	}*/

    	if (c >= 0x20 && c<= 0x7E)
    	{
    		buffP[bytes_read++] = c;
    		SerialPutChar(c);
    	}	
    	
    }while (1);
    SerialPutString("\n\r");
    buffP[bytes_read] = '\0';

}

/*---------------------------------------------------------------------------
* This function replaces all the lower case charachters in the
*                    string to the upper case.
*/
#if 0
static
void ConvertToUpper (char * stringP)
{
    int i,j;
    char c;

    j = strlen(stringP);

    for (i = 0; i < j; ++i,++stringP)
    {
        c = *stringP;
        c = toupper(c);
        *stringP = c;
    }
}
#endif

/*
*******************************************************************************
*
*     This function is used to find a command structure in the
*     command list array. It converts all the charachters in the
*     input string to the upper case. It looks for the function
*     name of the command entry structure that matches the name
*     of the input string.
*
* INPUT PARAMETERS: cmdListP   is a pointer to the command list array.
*                   cmdStringP is a pointer to the command string.
*
* RETURNS:          a pointer  to command list entry structure in the command
*                              list array.
*                   NULL       if no match is found.
*
*******************************************************************************
*/
static
CommandListEntry_T * findCmd (CommandListEntry_T * command, char * cmdStringP)
{
    int i;

    for (i=0; command[i].name; i++)
    {
        if (strcmp(command[i].name, cmdStringP) == 0)
        {
            return &command[i];
        }
    }

    return NULL;
}
/*-----------------------------------------------------------------------
 * Parse user command line 
 */
static void parseargs(char *argstr, int *argc_p, char **argv, char** resid)
{
	int argc = 0;
	char c;
	enum ParseState stackedState;
	enum ParseState lastState = PS_WHITESPACE;

	/* tokenize the argstr */
	while ((c = *argstr) != 0) {
		enum ParseState newState;

		if (c == ';' && lastState != PS_STRING && lastState != PS_ESCAPE)
			break;

		if (lastState == PS_ESCAPE) {
			newState = stackedState;
		} else if (lastState == PS_STRING) {
			if (c == '"') {
				newState = PS_WHITESPACE;
				*argstr = 0;
			} else {
				newState = PS_STRING;
			}
		} else if ((c == ' ') || (c == '\t')) {
			/* whitespace character */
			*argstr = 0;
			newState = PS_WHITESPACE;
		} else if (c == '"') {
			newState = PS_STRING;
			*argstr++ = 0;
			argv[argc++] = argstr;
		} else if (c == '\\') {
			stackedState = lastState;
			newState = PS_ESCAPE;
		} else {
			/* token */
			if (lastState == PS_WHITESPACE) {
				argv[argc++] = argstr;
			}
			newState = PS_TOKEN;
		}

		lastState = newState;
		argstr++;
	}

#if 0 /* for debugging */
	{
		int i;
		putLabeledWord("parseargs: argc=", argc);
		for (i = 0; i < argc; i++) {
			putstr("   ");
			putstr(argv[i]);
			putstr("\r\n");
		}
	}
#endif
	
	argv[argc] = NULL;
	if (argc_p != NULL)
		*argc_p = argc;

	if (*argstr == ';') {
		*argstr++ = '\0';
	}
	*resid = argstr;
}

/*
*******************************************************************************
*
* FUNCTION:         ExecCommandline
*
* DESCRIPTION:      This function is used to process an input string, split the
*                   input string into command and parameter strings, find a command
*                   structure in the command list array and execute the command.
*
* INPUT PARAMETERS: cmdListP   is a pointer to the command list array.
*                   cmdStringP is a pointer to the input string.
*
* RETURNS:          none.
*******************************************************************************
*/
void ExecCommandline (CommandListEntry_T * cmdListP, char * inputStringP)
{
    CommandListEntry_T * cmdListEntryP;
	int argc;
	char *argv[16];
	char *resid;

	while (*inputStringP) {
		memset(argv, 0, sizeof(argv));
		parseargs(inputStringP, &argc, argv, &resid);
		if (argc > 0)
		{
		    if ((cmdListEntryP=findCmd(cmdListP, argv[0])) == NULL)
		    {
		        SerialPutString("Command is not found\r\n");
		    }
		    else
		    {
			    cmdListEntryP->func(argc, (const char **)argv);
		    }
		}	
		inputStringP = resid;
	}

}

/*
*******************************************************************************
*
* FUNCTION:         CommandMode
*
* DESCRIPTION:      This function enters command mode via serial port.
					It is used to get an input string, find a command
*                   structure in the command list array and execute the command.
*					It can be treated as a Menu handler directly.
*
* RETURNS:          none.
*
*******************************************************************************
*/

void CommandMode(void * arg, char * dummyP)
{
    char inputString[CMD_STRING_SIZE];
    
    inputString[CMD_STRING_SIZE-1]= '\0';

	SerialPutString("Command line mode...:\r\n");
	while(1)
	{
		SerialPutChar('>');

        // Process a command string.
		GetInputString (inputString);
        if (strcmp(inputString,"EXIT")==0 || strcmp(inputString,"exit")==0)
        	return;
		ExecCommandline (PlatformCmdList, inputString);
	}
}
/*
*******************************************************************************
*
* FUNCTION:         TranslateMenuToCmd
*
* DESCRIPTION:      This function is used by the menu system. It is passed the
*                   string from menu entry structure. It splits the string into
*                   the command and parameter strings, finds a command in the
*                   command list array structure and executes the command.
*
* INPUT PARAMETERS: arg          is a pointer to the command list.
*                   inputStringP is a pointer to the the command string from menu
*                                entry structure.
*
* RETURNS:          none.
*
*******************************************************************************
*/

void TranslateMenuToCmd(void* arg, char * inputStringP)
{
    CommandListEntry_T * cmdListP = (CommandListEntry_T *) arg;
    char buff[CMD_STRING_SIZE], * buffP;

    buffP = buff;
    strcpy(buffP, inputStringP);
    buff[CMD_STRING_SIZE - 1] = '\0';

    ExecCommandline(cmdListP, buffP);
}


/*********************************************************************
	Menu functions
**********************************************************************/

/*----------------------------------------------------------------------
 * Translate a key to an index.
 */
static int translateKey(char key)
{
    if (ISVALIDHEX(key))
        return(CONVERTHEX(key));
    else return -1;
}

/*----------------------------------------------------------------------
 * draw a Menu including the title and menu items
 */

static 
void drawMenu(Menu_T * menuP,int selItemRow)
{
	int i;

    //Menu Title.
    SerialPrintf("\r\n%s\r\n",menuP->banner);

    for (i=0; i < 16; i++)
    {
        int num = menuP->menuList[i].selectionChar & MENUNUMBERMASK;
        if (menuP->menuList[i].displayedString == NULL)
            break;

        // Display the menu item.
		if (selItemRow == i)//selected menu item
		{
	        Printf("*%X=%-s\r\n",num,menuP->menuList[i].displayedString);
		}
		else {
	        Printf(" %X=%-s\r\n",num,menuP->menuList[i].displayedString);
		}
        
    }
}
/*----------------------------------------------------------------------
 * Find the menu entry that matches the number specified.
 */
static
int findMenu(int testNum, MenuItem_T * menuListP)
{
    int i = 0;

    do {
        if ((menuListP[i].selectionChar & MENUNUMBERMASK) == testNum)
            return i;
    } while (menuListP[i++].displayedString != 0) ;
    return -1;
}

/*---------------------------------------------------------------------
* Build a menu and Handle user selection
*/
void BuildMenu(void * menuP,char * dummyP)
{
	short int menuItemCount=0;
	int key,index;
    static int menulevel=0;
	MenuItem_T *menulistP = ((Menu_T *)menuP)->menuList;

    while(menulistP[menuItemCount].displayedString != 0)
        menuItemCount++;

	index = 0;
   	menulevel ++;
	do
    {
        if (index < 0 || index >= menuItemCount) index = 0;
        
		drawMenu((Menu_T *)menuP,index);

		//Wait for any key pressed
waitkey:
		key = GetKey();
		
		if (ISCONTROLKEY(key))
		{
			if (key == KEY_UP)
			{
				index --;
				if (index < 0)
				{
					index = menuItemCount -1;
				}
				continue;
			}
			else if (key == KEY_DOWN)
			{
				index ++;
				if (index >= menuItemCount) 
				{
					index = 0;
				}
				continue;
			}
			else if (key == KEY_ACTION)
			{
	            ;
			}
			else if (key == KEY_BACK)
			{
				//to upper level menu
	         if (menulevel > 1)
				break;
			 else goto waitkey;	
			}
			else if (key == KEY_UNKNOWN)
	      	{
	        	goto waitkey;
	      	}
		}
		else
		{
			//user activate the menu handler thru selection char(e.g. press number)
			index = findMenu(translateKey(key),menulistP);
			if (index == -1) goto waitkey;	//invalid selection, just do nothing
		}
		
    	if (menulistP[index].func)
        	menulistP[index].func(menulistP[index].arg,menulistP[index].cmdlineString);
    	else
    	{
            break;//exit the current menu
	    }

	}while(1);

   menulevel --;
}



/*******************************************************************************
*		Time Functions
********************************************************************************/

//NOTE: Now We set PCLK2 = 12MHz, so the max period is 65536*256/12M = 1398101us

void WaitMs(int msVal)
{
	WDG->CR = 0x00;
	while (msVal > 1024)
	{
		WDG_PeriodValueConfig(1024000);
		msVal -= 1024;

		WDG_CntOnOffConfig(ENABLE);	
		while(!(WDG->SR & 0x1));
		WDG->SR = 0x0000;
		WDG_CntOnOffConfig(DISABLE);
	}
	
	WDG_PeriodValueConfig(msVal*1000);
	WDG_CntOnOffConfig(ENABLE);	
	while(!(WDG->SR & 0x1));
	WDG->SR = 0x0000;
	WDG_CntOnOffConfig(DISABLE);

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久99精品久久久久久动态图| 久久九九99视频| 亚洲男人的天堂av| 国产成人一级电影| 久久久久久综合| 国产一区高清在线| www国产精品av| 蜜桃视频在线观看一区| 7777精品伊人久久久大香线蕉 | 欧美人与禽zozo性伦| 亚洲视频免费观看| 91免费版在线看| 亚洲日本在线天堂| 色94色欧美sute亚洲线路二| 国产欧美日产一区| 国产精品911| 国产精品久久午夜| 不卡的电影网站| 亚洲三级小视频| 日本道在线观看一区二区| 一区二区三区中文免费| 欧美色涩在线第一页| 亚洲成人综合视频| 欧美日韩精品欧美日韩精品| 免费在线观看日韩欧美| 精品国产sm最大网站免费看| 粉嫩欧美一区二区三区高清影视 | 久久97超碰国产精品超碰| 精品嫩草影院久久| 久久超碰97人人做人人爱| 国产嫩草影院久久久久| 91在线免费看| 偷窥少妇高潮呻吟av久久免费| 91麻豆精品国产自产在线观看一区 | 亚洲成人综合在线| 欧美一区二区视频网站| 国产精品一区一区| 亚洲乱码中文字幕综合| 欧美一区二区三区在线观看视频| 黑人巨大精品欧美一区| 亚洲欧洲精品一区二区精品久久久| 日本高清成人免费播放| 日韩电影网1区2区| 国产欧美一区二区精品秋霞影院| 高清不卡在线观看av| 亚洲精品高清在线观看| 精品成人一区二区| 99这里只有久久精品视频| 婷婷综合五月天| 欧美国产精品v| 777午夜精品视频在线播放| 国产成a人亚洲| 性久久久久久久久| 国产欧美日韩三级| 欧美一级黄色片| 91视频观看视频| 狠狠色综合色综合网络| 一区二区在线免费| 国产日韩精品一区二区三区在线| 成人av中文字幕| 另类综合日韩欧美亚洲| 一区二区成人在线| 久久综合中文字幕| 欧美麻豆精品久久久久久| 波多野结衣的一区二区三区| 久久97超碰国产精品超碰| 亚洲综合免费观看高清完整版在线 | 亚洲免费看黄网站| 欧美久久久久久久久久| 国产成人免费在线观看| 日本sm残虐另类| 亚洲精品中文在线| 国产婷婷色一区二区三区四区| 日本道色综合久久| 黄色日韩三级电影| 老司机午夜精品99久久| 亚洲二区在线视频| 一区二区三区四区高清精品免费观看| 2019国产精品| 精品国内二区三区| 欧美视频精品在线观看| 99re6这里只有精品视频在线观看| 精品一区二区三区视频| 日日嗨av一区二区三区四区| 一区二区三区在线视频播放 | 久久久久久夜精品精品免费| 91麻豆精品国产91久久久资源速度| a4yy欧美一区二区三区| 顶级嫩模精品视频在线看| 韩国精品一区二区| 国产一区在线观看视频| 久久精品国产精品亚洲红杏| 午夜精品久久久久影视| 亚洲一线二线三线久久久| 最新国产の精品合集bt伙计| 国产精品久久久久婷婷| 日本一区二区视频在线| 中文字幕精品三区| 国产欧美1区2区3区| 久久精品免费在线观看| 国产精品私人影院| 精品国产一区二区精华| 26uuu色噜噜精品一区| 国产亚洲综合性久久久影院| 国产欧美一区二区三区鸳鸯浴 | 玉足女爽爽91| 秋霞影院一区二区| 国产福利不卡视频| 色噜噜狠狠色综合欧洲selulu| 欧美日韩激情在线| 精品av综合导航| 亚洲欧美国产毛片在线| 裸体在线国模精品偷拍| av男人天堂一区| 欧美裸体一区二区三区| 欧美国产一区在线| 午夜国产不卡在线观看视频| 国产精品中文字幕日韩精品 | 蜜桃一区二区三区在线| 波波电影院一区二区三区| 91精品综合久久久久久| 国产日韩精品一区二区浪潮av| 一区二区三区**美女毛片| 国产在线一区观看| 欧美日韩大陆一区二区| 中文字幕国产一区| 午夜电影网亚洲视频| www.视频一区| 日韩欧美一区二区久久婷婷| 亚洲女性喷水在线观看一区| 精品亚洲欧美一区| 欧美性淫爽ww久久久久无| 国产日韩欧美a| 美女高潮久久久| 欧美三级一区二区| 亚洲欧洲综合另类| 国产盗摄视频一区二区三区| 欧美一区三区二区| 亚洲一区二区在线免费看| 成人小视频在线| 精品国产一区二区三区久久久蜜月| 亚洲一级在线观看| 91蝌蚪porny| 国产欧美精品国产国产专区| 麻豆国产欧美日韩综合精品二区| 在线观看亚洲a| 亚洲欧美另类久久久精品| 高清不卡一区二区| 国产欧美日韩中文久久| 国产呦精品一区二区三区网站| 91精品国产91久久久久久一区二区| 亚洲黄色小视频| 色综合久久中文字幕综合网| 日本一区二区高清| 国产精品99久久久久久久女警| 精品国产第一区二区三区观看体验| 午夜久久久久久久久| 欧美午夜精品一区二区蜜桃| 亚洲蜜臀av乱码久久精品| av中文字幕亚洲| 亚洲国产精品激情在线观看| 国产乱码精品一品二品| 久久老女人爱爱| 国产精品一区二区三区99| 国产亚洲一区二区三区四区| 国产福利91精品一区二区三区| 久久色在线视频| 国产综合久久久久久久久久久久| 精品国产免费人成在线观看| 久久精品国产99国产精品| 亚洲精品一区二区三区99 | 成人av网站免费观看| 国产日产精品1区| 丁香婷婷综合五月| 亚洲三级电影网站| 91国产丝袜在线播放| 亚洲一区二区精品3399| 欧美精品在线观看一区二区| 青青青伊人色综合久久| 26uuu色噜噜精品一区| 成人久久18免费网站麻豆 | av高清不卡在线| 综合av第一页| 欧美日韩在线三级| 奇米影视在线99精品| 久久综合九色综合欧美亚洲| 成人ar影院免费观看视频| 伊人婷婷欧美激情| 日韩一区二区视频在线观看| 狠狠色2019综合网| 中日韩免费视频中文字幕| 欧美性做爰猛烈叫床潮| 卡一卡二国产精品| 国产精品欧美极品| 欧美日韩成人一区| 精品亚洲porn| 中文字幕视频一区二区三区久| 欧美影院午夜播放| 狠狠网亚洲精品| 玉米视频成人免费看|