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

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

?? common.c

?? 基于STM32 的IAP升級庫
?? C
字號:
/******************** (C) COPYRIGHT 2007 STMicroelectronics ********************
* File Name          : common.c
* Author             : MCD Application Team
* Date First Issued  : 05/21/2007
* Description        : This file provides all the common functions.
********************************************************************************
* History:
* 05/21/2007: V0.1 
********************************************************************************
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include "common.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
pFunction Jump_To_Application;
u32 JumpAddress;
u32 BlockNbr = 0, UserMemoryMask = 0;
bool FlashProtection = FALSE;
extern u32 FlashDestination;

/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/*******************************************************************************
* Function Name  : Int2Str
* Description    : Convert an Integer to a string
* Input          : - str: The string
*                  - intnum: The intger to be converted
* Output         : None
* Return         : None
*******************************************************************************/
void Int2Str(u8* str, s32 intnum)
{
  u32 i, Div = 1000000000, j = 0, Status = 0;

  for (i = 0; i < 10; i++)
  {
    str[j++] = (intnum / Div) + 48;

    intnum = intnum % Div;
    Div /= 10;
    if ((str[j-1] == '0') & (Status == 0))
    {
      j = 0;
    }
    else
    {
      Status++;
    }
  }
}

/*******************************************************************************
* Function Name  : Str2Int
* Description    : Convert a string to an integer
* Input 1        : - inputstr: The string to be converted
*                  - intnum: The intger value
* Output         : None
* Return         : 1: Correct
*                  0: Error
*******************************************************************************/
u32 Str2Int(u8 *inputstr, s32 *intnum)
{
  u32 i = 0, res = 0;
  u32 val = 0;

  if (inputstr[0] == '0' && (inputstr[1] == 'x' || inputstr[1] == 'X'))
  {
    if (inputstr[2] == '\0')
    {
      return 0;
    }
    for (i = 2; i < 11; i++)
    {
      if (inputstr[i] == '\0')
      {
        *intnum = val;
		/* return 1; */
        res = 1; 
        break;
      }
      if (ISVALIDHEX(inputstr[i]))
      {
        val = (val << 4) + CONVERTHEX(inputstr[i]);
      }
      else
      {
        /* return 0, Invalid input */
        res = 0;
        break;
      }
    }
	/* over 8 digit hex --invalid */
    if (i >= 11)
	{
	  res = 0; 
	}
  }
  else /* max 10-digit decimal input */
  {
    for (i = 0;i < 11;i++)
    {
      if (inputstr[i] == '\0')
      {
        *intnum = val;
        /* return 1 */
        res = 1;
        break;
      }
      else if ((inputstr[i] == 'k' || inputstr[i] == 'K') && (i > 0))
      {
        val = val << 10;
        *intnum = val;
        res = 1;
        break;
      }
      else if ((inputstr[i] == 'm' || inputstr[i] == 'M') && (i > 0))
      {
        val = val << 20;
        *intnum = val;
        res = 1;
        break;
      }
      else if (ISVALIDDEC(inputstr[i]))
	  {
	    val = val * 10 + CONVERTDEC(inputstr[i]);
	  }
      else
      {
        /* return 0, Invalid input */
        res = 0;
        break;
      }
    }
	/* Over 10 digit decimal --invalid */
    if (i >= 11)
	{
	  res = 0;
	}  
  }

  return res;
}

/*******************************************************************************
* Function Name  : GetIntegerInput
* Description    : Get an integer from the HyperTerminal
* Input          : - num: The inetger
* Output         : None
* Return         : 1: Correct
*                  0: Error
*******************************************************************************/
u32 GetIntegerInput(s32 * num)
{
  u8 inputstr[16];

  while (1)
  {
    GetInputString(inputstr);
    if (inputstr[0] == '\0') continue;
    if ((inputstr[0] == 'a' || inputstr[0] == 'A') && inputstr[1] == '\0')
    {
      SerialPutString("User Cancelled \r\n");
      return 0;
    }

    if (Str2Int(inputstr, num) == 0)
    {
      SerialPutString("Error, Input again: \r\n");
    }
    else
    {
      return 1;
    }
  }
}

/*******************************************************************************
* Function Name  : SerialKeyPressed
* Description    : Test to see if a key has been pressed on the HyperTerminal
* Input          : - key: The key pressed
* Output         : None
* Return         : 1: Correct
*                  0: Error
*******************************************************************************/
u32 SerialKeyPressed(u8 *key)
{

  if ( USART_GetFlagStatus(USART1, USART_FLAG_RXNE) != RESET)
  {
    *key = (u8)USART1->DR;
    return 1;
  }
  else
  {
    return 0;
  }
}

/*******************************************************************************
* Function Name  : GetKey
* Description    : Get a key from the HyperTerminal
* Input          : None
* Output         : None
* Return         : The Key Pressed
*******************************************************************************/
u8 GetKey(void)
{
  u8 key = 0;
  
  /* Waiting for user input */
  while (1)
  {
    if (SerialKeyPressed((u8*)&key)) break;
  }
  return key;

}

/*******************************************************************************
* Function Name  : SerialPutChar
* Description    : Print a character on the HyperTerminal
* Input          : - c: The character to be printed
* Output         : None
* Return         : None
*******************************************************************************/
void SerialPutChar(u8 c)
{
  USART_SendData(USART1, c);
  while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
}

/*******************************************************************************
* Function Name  : SerialPutString
* Description    : Print a string on the HyperTerminal
* Input          : - s: The string to be printed
* Output         : None
* Return         : None
*******************************************************************************/
void SerialPutString(u8 *s)
{
  while (*s != '\0')
  {
    SerialPutChar(*s);
    s ++;
  }
}

/*******************************************************************************
* Function Name  : GetInputString
* Description    : Get Input string from the HyperTerminal
* Input          : - buffP: The input string
* Output         : None
* Return         : None
*******************************************************************************/
void GetInputString (u8 * buffP)
{
  u32 bytes_read = 0;
  u8 c = 0;
  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 >= 0x20 && c <= 0x7E)
    {
      buffP[bytes_read++] = c;
      SerialPutChar(c);
    }
  }
  while (1);
  SerialPutString("\n\r");
  buffP[bytes_read] = '\0';
}

/*******************************************************************************
* Function Name  : FLASH_PagesMask
* Description    : Calculate the number of pages
* Input          : - Size: The image size
* Output         : None
* Return         : The number of pages
*******************************************************************************/
u32 FLASH_PagesMask(vu32 Size)
{
  u32 pagenumber = 0x0;
  u32 size = Size;

  if((size % 0x400) != 0)
  {
    pagenumber = (size / 0x400) + 1;
  }
  else
  {
    pagenumber = size / 0x400;
  }
  return pagenumber;

}

/*******************************************************************************
* Function Name  : FLASH_DisableWriteProtectionPages
* Description    : Disable the write protection of desired pages
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void FLASH_DisableWriteProtectionPages(void)
{
  u32 useroptionbyte = 0, WRPR = 0;
  u16 var1 = OB_IWDG_SW, var2 = OB_STOP_NoRST, var3 = OB_STDBY_NoRST;
  FLASH_Status status = FLASH_BUSY;

  WRPR = FLASH_GetWriteProtectionOptionByte();

  /* Test if user memory is write protected */
  if ((WRPR & UserMemoryMask) != UserMemoryMask)
  {
    useroptionbyte = FLASH_GetUserOptionByte();

    UserMemoryMask |= WRPR;

    status = FLASH_EraseOptionBytes();

    if(UserMemoryMask != 0xFFFFFFFF)
    {
      status = FLASH_EnableWriteProtection((u32)~UserMemoryMask);
    }

	/* Test if user Option Bytes are programmed */
	if((useroptionbyte & 0x07) != 0x07)
	{ /* Restore user Option Bytes */
	  if((useroptionbyte & 0x01) == 0x0)
	  {
	    var1 = OB_IWDG_HW;
	  }
	  if((useroptionbyte & 0x02) == 0x0)
	  {
	    var2 = OB_STOP_RST;
	  }
	  if((useroptionbyte & 0x04) == 0x0)
	  {
	    var3 = OB_STDBY_RST;
	  }

	  FLASH_UserOptionByteConfig(var1, var2, var3);	
	}

    if (status == FLASH_COMPLETE)
    {
      SerialPutString("Write Protection disabled...\r\n");
	
	  SerialPutString("...and a System Reset will be generated to re-load the new option bytes\r\n");

	  /* Enable WWDG clock */
      RCC_APB1PeriphClockCmd(RCC_APB1Periph_WWDG, ENABLE);

	  /* Generate a system Reset to re-load the new option bytes: enable WWDG and set
         counter value to 0x4F, as T6 bit is cleared this will generate a WWDG reset */
      WWDG_Enable(0x4F);
    }
    else
    {
      SerialPutString("Error: Flash write unprotection failed...\r\n");
    }
  }
  else
  {
    SerialPutString("Flash memory not write protected\r\n");
  }
}

/*******************************************************************************
* Function Name  : Main_Menu
* Description    : Display the Main Menu on to HyperTerminal
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Main_Menu(void)
{
  u8 key = 0;
  
  /* Get the number of block (4 pages) from where the user program will be loaded */
  BlockNbr = (FlashDestination - 0x08000000) >> 12;

  /* Compute the mask to test if the Flash memory, where the user program will be
     loaded, is write protected */
  UserMemoryMask = ((u32)~((1<<BlockNbr)-1));
  
  /* Test if any page of Flash memory where program user will be loaded is write protected */
  if ((FLASH_GetWriteProtectionOptionByte() & UserMemoryMask) != UserMemoryMask)
  {
    FlashProtection = TRUE;
    SerialPutString("\r\n================== Main Menu ============================\r\n\n");
	SerialPutString("  Download Image To the STM32F10x Internal Flash ------- 1\r\n\n");
    SerialPutString("  Execute The New Program ------------------------------ 2\r\n\n");
    SerialPutString("  Disable the write protection ------------------------- 3\r\n\n");
    SerialPutString("==========================================================\r\n\n");
  }
  else
  {
    FlashProtection = FALSE;
    SerialPutString("\r\n================== Main Menu ============================\r\n\n");
	SerialPutString("  Download Image To the STM32F10x Internal Flash ------- 1\r\n\n");
    SerialPutString("  Execute The New Program ------------------------------ 2\r\n\n");
    SerialPutString("==========================================================\r\n\n");
  }
    
  while (1)
  {
    key = GetKey();

    if (key == 0x31)
    {
      /* Download user application in the Flash */
      SerialDownload();
    }
    else if (key == 0x32)
    {
      JumpAddress = *(vu32*) (ApplicationAddress + 4);

      /* Jump to user application */
      Jump_To_Application = (pFunction) JumpAddress;
      Jump_To_Application();
    }
    else if ((key == 0x33)&& (FlashProtection == TRUE))
    {
      /* Disable the write protection of desired pages */
      FLASH_DisableWriteProtectionPages();
    }
  
  else
    {
	  if(FlashProtection == FALSE)
	  {
        SerialPutString("Invalid Number ! ==> The number should be either 1 or 2\r");
      }
	  else
	  {
        SerialPutString("Invalid Number ! ==> The number should be either 1, 2 or 3\r");
      }
    }
  }
}

/*******************(C)COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
激情图区综合网| 国产成人午夜电影网| 日本aⅴ亚洲精品中文乱码| 国产高清视频一区| 欧美三级在线看| 国产精品亲子乱子伦xxxx裸| 免费精品视频在线| 色婷婷综合在线| 中文字幕的久久| 国产一区二区精品久久99| 在线区一区二视频| 中文字幕在线不卡视频| 国产精品自拍网站| 日韩欧美中文字幕公布| 亚洲电影第三页| 日本精品视频一区二区三区| 欧美激情一区三区| 国产乱人伦精品一区二区在线观看| 欧美福利视频一区| 亚洲高清免费视频| 日本久久电影网| 亚洲免费伊人电影| 成人h版在线观看| 久久精品亚洲乱码伦伦中文| 秋霞影院一区二区| 欧美一区二区在线观看| 亚洲成人高清在线| 精品视频一区 二区 三区| 一区二区三区资源| 在线观看日韩电影| 一区二区三区在线视频观看58| 91亚洲男人天堂| ●精品国产综合乱码久久久久| 懂色av中文字幕一区二区三区| 久久综合99re88久久爱| 国内精品视频一区二区三区八戒| 欧美一二三四区在线| 久久爱另类一区二区小说| 精品国产三级电影在线观看| 国产精品亚洲第一区在线暖暖韩国| 久久久蜜臀国产一区二区| 国产丶欧美丶日本不卡视频| 国产精品麻豆欧美日韩ww| 97国产一区二区| 一区二区欧美国产| 欧美顶级少妇做爰| 久久精品二区亚洲w码| 久久久久国产精品厨房| 成人精品在线视频观看| 亚洲黄色av一区| 91精品国产综合久久福利| 老司机免费视频一区二区三区| 精品国产欧美一区二区| 国产99久久久久| 亚洲精品国产高清久久伦理二区| 欧美日韩国产欧美日美国产精品| 免费人成精品欧美精品| 国产欧美日产一区| 欧美私人免费视频| 蜜臀久久99精品久久久久久9| 久久综合丝袜日本网| 菠萝蜜视频在线观看一区| 亚洲一区在线播放| 日韩精品自拍偷拍| av不卡一区二区三区| 亚洲第一激情av| 久久久国产午夜精品| 91行情网站电视在线观看高清版| 丝袜脚交一区二区| 国产欧美日韩在线| 欧美日韩亚洲综合| 国产91精品精华液一区二区三区 | √…a在线天堂一区| 欧美亚洲动漫另类| 国产中文字幕一区| 亚洲中国最大av网站| 久久亚洲精精品中文字幕早川悠里| 成人高清视频在线| 毛片av一区二区三区| 成人欧美一区二区三区视频网页| 欧美一区二区三区男人的天堂| 国产白丝精品91爽爽久久| 爽好多水快深点欧美视频| 中文一区二区完整视频在线观看 | 精品夜夜嗨av一区二区三区| |精品福利一区二区三区| 精品美女一区二区| 欧美色综合影院| 福利电影一区二区三区| 欧美a级一区二区| 一区二区三区欧美| 中文一区二区在线观看| 精品国产凹凸成av人导航| 欧美日韩免费一区二区三区视频| 成人免费不卡视频| 国产乱对白刺激视频不卡| 日韩极品在线观看| 亚洲尤物在线视频观看| 欧美国产乱子伦| 精品不卡在线视频| 欧美va亚洲va香蕉在线| 欧美人妇做爰xxxⅹ性高电影| 色视频一区二区| 91在线观看免费视频| 成年人国产精品| 国产成人免费在线观看不卡| 久久成人久久鬼色| 免费黄网站欧美| 卡一卡二国产精品| 免费成人在线播放| 麻豆成人久久精品二区三区红| 亚洲成人先锋电影| 午夜欧美在线一二页| 亚洲一区二区不卡免费| 亚洲精品菠萝久久久久久久| 成人免费在线观看入口| 中文字幕在线观看一区| 国产精品拍天天在线| 中文一区在线播放| 国产精品久99| 伊人一区二区三区| 亚洲国产成人porn| 日韩精品欧美精品| 久久丁香综合五月国产三级网站| 狠狠色狠狠色综合系列| 国产福利一区在线| 成人av网站在线观看| 99天天综合性| 欧美色网一区二区| 91麻豆精品国产91久久久| 日韩欧美国产高清| 久久先锋资源网| 中文字幕亚洲一区二区va在线| 亚洲日本在线看| 亚洲国产精品一区二区久久恐怖片 | 亚洲欧美国产高清| 亚洲综合色婷婷| 免费久久精品视频| caoporm超碰国产精品| 欧美亚洲综合另类| 日韩视频国产视频| 国产精品久久久久久久久免费桃花| 亚洲久草在线视频| 久久福利资源站| 91农村精品一区二区在线| 欧美精品第1页| 国产精品三级久久久久三级| 亚洲在线观看免费| 国产精品91xxx| 欧美午夜精品免费| 国产色产综合产在线视频| 一区二区三区在线看| 国内精品伊人久久久久av影院 | 亚洲成人福利片| 国产**成人网毛片九色| 欧美中文一区二区三区| 久久久久国产精品麻豆ai换脸| 亚洲国产一区二区三区青草影视 | 91视频免费看| 日韩欧美国产高清| 亚洲永久免费av| 成人黄色在线看| 在线综合+亚洲+欧美中文字幕| 亚洲国产成人自拍| 精品午夜一区二区三区在线观看| 色婷婷av一区二区三区之一色屋| 久久久久一区二区三区四区| 亚洲成人精品一区二区| 91老师国产黑色丝袜在线| 久久只精品国产| 麻豆精品视频在线观看免费| 欧洲一区二区三区在线| 国产精品人人做人人爽人人添| 久久99热国产| 欧美乱妇一区二区三区不卡视频| 亚洲欧美一区二区三区极速播放 | 日韩欧美国产综合一区 | 678五月天丁香亚洲综合网| 国产精品久久久久久福利一牛影视| 免费成人结看片| 欧美日本国产一区| 亚洲一区二区3| 色综合久久中文综合久久牛| 国产女人aaa级久久久级 | 国产欧美一区二区精品仙草咪| 美女视频一区二区| 制服.丝袜.亚洲.另类.中文| 亚洲国产欧美日韩另类综合| 色综合视频一区二区三区高清| 日本一区免费视频| 国产成人免费视| 久久久久久久久岛国免费| 美腿丝袜亚洲综合| 制服丝袜成人动漫| 免费成人你懂的| 日韩欧美中文字幕一区| 久久er99热精品一区二区| 日韩一区二区视频在线观看| 日韩av电影天堂| 日韩精品在线一区|