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

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

?? iap.c

?? 最新的LPC214X IAP驅動程序
?? C
字號:
////  $Id: iap.c 188 2008-10-19 14:36:39Z jcw $//  $Revision: 188 $//  $Author: jcw $//  $Date: 2008-10-19 10:36:39 -0400 (Sun, 19 Oct 2008) $//  $HeadURL: http://tinymicros.com/svn_public/arm/lpc2148_demo/trunk/iap/iap.c $//#include "FreeRTOS.h"#include <string.h>#include "../cpu/cpu.h"#include "iap.h"//////#define CPUCLK_IN_KHZ 48000#define IRQ_MASK  0x00000080#define FIQ_MASK  0x00000040#define INTs_MASK (IRQ_MASK | FIQ_MASK)//////typedef struct flashSectorToAddress_s{  unsigned long address;  int sizeInBytes;}flashSectorToAddress_t;static flashSectorToAddress_t flashSectorToAddress [] = {  { 0x00000000, 4096 },   // 0  { 0x00001000, 4096 },   // 1  { 0x00002000, 4096 },   // 2  { 0x00003000, 4096 },   // 3  { 0x00004000, 4096 },   // 4  { 0x00005000, 4096 },   // 5  { 0x00006000, 4096 },   // 6  { 0x00007000, 4096 },   // 7  { 0x00008000, 32768 },  // 8  { 0x00010000, 32768 },  // 9  { 0x00018000, 32768 },  // 10  { 0x00020000, 32768 },  // 11  { 0x00028000, 32768 },  // 12  { 0x00030000, 32768 },  // 13  { 0x00038000, 32768 },  // 14  { 0x00040000, 32768 },  // 15  { 0x00048000, 32768 },  // 16  { 0x00050000, 32768 },  // 17  { 0x00058000, 32768 },  // 18  { 0x00060000, 32768 },  // 19  { 0x00068000, 32768 },  // 20  { 0x00070000, 32768 },  // 21  { 0x00078000, 4096 },   // 22  { 0x00079000, 4096 },   // 23  { 0x0007a000, 4096 },   // 24  { 0x0007b000, 4096 },   // 25  { 0x0007c000, 4096 },   // 26};typedef struct iapErrnoStr_s{  int errno;  const char *text;}iapErrnoStr_t;static iapErrnoStr_t iapErrnoStr [] ={  { IAP_RESULT_CMD_SUCCESS,         "success" },  { IAP_RESULT_INVALID_COMMAND,     "invalid command" },  { IAP_RESULT_SRC_ADDR_ERROR,      "source address error" },  { IAP_RESULT_DST_ADDR_ERROR,      "destination address error" },  { IAP_RESULT_SRC_ADDR_NOT_MAPPED, "source address not mapped" },  { IAP_RESULT_DST_ADDR_NOT_MAPPED, "destination address not mapped" },  { IAP_RESULT_COUNT_ERROR,         "count error" },  { IAP_RESULT_INVALID_SECTOR,      "invalid sector" },  { IAP_RESULT_SECTOR_NOT_BLANK,    "sector not blank" },  { IAP_RESULT_SECTOR_NOT_PREPARED, "sector not prepared" },  { IAP_RESULT_COMPARE_ERROR,       "compare error" },  { IAP_RESULT_BUSY,                "busy" },  { IAP_RESULT_PARAM_ERROR,         "parameter error" },  { IAP_RESULT_ADDR_ERROR,          "address error" },  { IAP_RESULT_ADDR_NOT_MAPPED,     "address not mapped" },  { IAP_RESULT_CMD_LOCKED,          "command locked" },  { IAP_RESULT_INVALID_CODE,        "invalid code" },  { IAP_RESULT_INVALID_BAUD_RATE,   "invalid baud rate" },  { IAP_RESULT_ANVALID_STOP_BIT,    "invalid stop bit" },  { IAP_RESULT_CRP_ENABLED,         "CRP enabled" },  { IAP_RESULT_X_NOTSAFEREGION,     "sector or address not in safe region" },  { IAP_RESULT_X_NOSAFEREGIONAVAIL, "no safe sectors available (all of memory used?)" },};//////static unsigned int iapCommands [5];static unsigned int iapResults [2];static int iapErrno = 0;extern unsigned long __end_of_text__;static unsigned int end_of_text = (unsigned int) &__end_of_text__;//////void iapInit (void){}//////int iapSectorToAddress (int sectorNumber, unsigned long *address, int *sectorSize){  if (sectorNumber >= (int) arrsizeof (flashSectorToAddress))    return -1;  if (address)    *address = flashSectorToAddress [sectorNumber].address;  if (sectorSize)    *sectorSize = flashSectorToAddress [sectorNumber].sizeInBytes;  return 0;}////  Convert address to sector, or -1 if address not in flash area//int iapAddressToSector (unsigned long address){  int i;  for (i = 0; i < (int) arrsizeof (flashSectorToAddress); i++)    if (address < (flashSectorToAddress [i].address + flashSectorToAddress [i].sizeInBytes))      return i;  iapErrno = IAP_RESULT_INVALID_SECTOR;  return -1;}////  1 == address in safe region, 0 if not//int iapIsSafeAddress (unsigned long address){  int eotSector;  int addressSector;  if ((eotSector = iapAddressToSector (end_of_text)) == -1)    return 0;  if ((addressSector = iapAddressToSector (address)) == -1)    return 0;  if (addressSector <= eotSector)  {    iapErrno = IAP_RESULT_X_NOTSAFEREGION;    return 0;  }  return 1;}////  0 == not safe sector, 1 == safe (not in a code sector)//int iapIsSafeSector (int sector){  int eotSector;  if ((eotSector = iapAddressToSector (end_of_text)) == -1)    return 0;  if (sector <= eotSector)  {    iapErrno = IAP_RESULT_X_NOTSAFEREGION;    return 0;  }  return 1;}////  Returns a safe sector number or -1 if none available//int iapFindSafeSector (void){  unsigned int i;  for (i = 0; i < arrsizeof (flashSectorToAddress); i++)    if (iapIsSafeSector (i))      return i;  iapErrno = IAP_RESULT_X_NOSAFEREGIONAVAIL;  return -1;}////  1 == sector is safe, 0 == not safe//int iapIsValidSector (int sector){  if ((sector < 0) || (sector >= (int) arrsizeof (flashSectorToAddress)))  {    iapErrno = IAP_RESULT_INVALID_SECTOR;    return 0;  }  return 1;}//////int iapGetErrno (void){  return iapErrno;}const char *iapStrerror (int err){  unsigned int i;  for (i = 0; i < arrsizeof (iapErrnoStr); i++)    if (iapErrnoStr [i].errno == err)      return iapErrnoStr [i].text;  return NULL;}//////static void iapCall (void) __attribute ((naked));static void iapCall (void){  register void *pFP0 asm("r0") = iapCommands;  register void *pFP1 asm("r1") = iapResults;  asm volatile(" bx  %[iapLocation]"               :               : "r" (pFP0), "r" (pFP1), [iapLocation] "r" (IAP_LOCATION) );}//////static inline unsigned __get_cpsr (void){  unsigned long retval;  asm volatile (" mrs  %0, cpsr" : "=r" (retval) : /* no inputs */  );  return retval;}static inline void __set_cpsr (unsigned val){  asm volatile (" msr  cpsr, %0" : /* no outputs */ : "r" (val)  );}static unsigned disableInts (void){  unsigned _cpsr;  _cpsr = __get_cpsr ();  do    __set_cpsr (_cpsr | INTs_MASK);  while ((__get_cpsr () ^ INTs_MASK) & INTs_MASK);  return _cpsr;}static unsigned restoreInts (unsigned oldCPSR){  unsigned _cpsr;  _cpsr = __get_cpsr();  do    __set_cpsr ((_cpsr & ~INTs_MASK) | (oldCPSR & INTs_MASK));  while ((__get_cpsr () ^ oldCPSR) & INTs_MASK);  return _cpsr;}//////int iapPrepareSectors (int startingSector, int endingSector){  unsigned int cpsr;  if (!iapIsSafeSector (startingSector) || !iapIsSafeSector (endingSector))    return -1;  iapCommands [0] = IAP_CMD_PREPARE;  iapCommands [1] = startingSector;  iapCommands [2] = endingSector;  cpsr = disableInts ();  iapCall ();  restoreInts (cpsr);  return ((iapErrno = iapResults [0]) == IAP_RESULT_CMD_SUCCESS) ? 0 : -1;}////  IAP_CMD_COPYRAMTOFLASH can span multiple sectors (2, at any rate, since bufferLen//  must be 256, 512, 1024 or 4096, and the smallest sectors are 4096 bytes).  Although//  more than 2 sectors can be prepared for writing, it's useless to do so, since//  after each IAP_CMD_COPYRAMTOFLASH, the sectors are re-locked.//int iapWriteSectors (unsigned int address, unsigned char *buffer, int bufferLen){  unsigned int cpsr;  iapCommands [0] = IAP_CMD_COPYRAMTOFLASH;  iapCommands [1] = address;  iapCommands [2] = (int) buffer;  iapCommands [3] = bufferLen;  iapCommands [4] = CPUCLK_IN_KHZ;  cpsr = disableInts ();  iapCall ();  restoreInts (cpsr);  if ((iapErrno = iapResults [0]) != IAP_RESULT_CMD_SUCCESS)    return -1;  return 0;}int iapFillSectors (int startingSector, int endingSector, int byte){  int sector;  unsigned char buffer [256];  if (!iapIsSafeSector (startingSector) || !iapIsSafeSector (endingSector))    return -1;  memset (buffer, byte, sizeof (buffer));  for (sector = startingSector; sector <= endingSector; sector++)  {    int i;    unsigned long address;    int sectorSize;    if (iapSectorToAddress (sector, &address, &sectorSize))      return -1;    for (i = 0; i < sectorSize; i += sizeof (buffer))    {      if (iapPrepareSectors (sector, sector) == -1)        return -1;      if (iapWriteSectors (address + i, buffer, sizeof (buffer)) == -1)        return -1;      if (iapCompare (address + i, buffer, sizeof (buffer)) == -1)        return -1;    }  }  return 0;}int iapEraseSectors (int startingSector, int endingSector){  unsigned int cpsr;  if (!iapIsSafeSector (startingSector) || !iapIsSafeSector (endingSector))    return -1;  if (iapPrepareSectors (startingSector, endingSector) == -1)    return -1;  iapCommands [0] = IAP_CMD_ERASE;  iapCommands [1] = startingSector;  iapCommands [2] = endingSector;  iapCommands [3] = CPUCLK_IN_KHZ;  cpsr = disableInts ();  iapCall ();  restoreInts (cpsr);  return ((iapErrno = iapResults [0]) == IAP_RESULT_CMD_SUCCESS) ? 0 : -1;}//// -1 = error (iapErrno set)//  0 = sector blank//  1 = sector not blank//int iapBlankCheckSectors (int startingSector, int endingSector){  unsigned int cpsr;  if (!iapIsValidSector (startingSector) || !iapIsValidSector (endingSector))    return -1;  iapCommands [0] = IAP_CMD_BLANKCHECK;  iapCommands [1] = startingSector;  iapCommands [2] = endingSector;  cpsr = disableInts ();  iapCall ();  restoreInts (cpsr);  if ((iapErrno = iapResults [0]) == IAP_RESULT_CMD_SUCCESS)    return 0;  if (iapResults [0] == IAP_RESULT_SECTOR_NOT_BLANK)    return 1;  return -1;}//////unsigned int iapReadPartID (void){  unsigned int cpsr;  iapCommands [0] = IAP_CMD_READPARTID;  cpsr = disableInts ();  iapCall ();  restoreInts (cpsr);  return iapResults [1];}//////unsigned int iapReadBootCodeVersion (void){  unsigned int cpsr;  iapCommands [0] = IAP_CMD_READBOOTCODEVER;  cpsr = disableInts ();  iapCall ();  restoreInts (cpsr);  return iapResults [1];}//////int iapCompare (unsigned int address, unsigned char *buffer, int bufferLen){  unsigned int cpsr;  iapCommands [0] = IAP_CMD_COMPARE;  iapCommands [1] = address;  iapCommands [2] = (int) buffer;  iapCommands [3] = bufferLen;  cpsr = disableInts ();  iapCall ();  restoreInts (cpsr);  return ((iapErrno = iapResults [0]) == IAP_RESULT_CMD_SUCCESS) ? 0 : -1;}//////void iapISP (void){  int i;  REG32 *p;  portDISABLE_INTERRUPTS ();  VIC_IntEnClr = VIC_IntEnClr_MASK;  SCB_PLLCON = 0;  SCB_PLLCFG = 0;  SCB_PLLFEED = SCB_PLLFEED_FEED1;  SCB_PLLFEED = SCB_PLLFEED_FEED2;  USB_PLLCON = 0;   USB_PLLCFG = 0;   USB_PLLFEED = USB_PLLFEED_FEED1;  USB_PLLFEED = USB_PLLFEED_FEED2;  for (p = (REG32 *) T1_BASE_ADDR, i = 0; i< 0x74 / 4; i++)    *p++ = 0;  T1_IR = 0xff;  SCB_PCONP = SCB_PCONP_ATRESET;  UART0_IER = 0x00;   UART0_LCR = 0x80;   UART0_DLL = 0x01;   UART0_DLM = 0x00;  UART0_LCR = 0x00;   UART0_FCR = 0x06;   UART0_FDR = 0x10;  SCB_MEMMAP = 0;  SCB_VPBDIV = 0;  PCB_PINSEL0 = PCB_PINSEL0_ALL_GPIO;  PCB_PINSEL1 = PCB_PINSEL1_ALL_GPIO;    GPIO0_FIODIR = 0x00004000;  GPIO0_FIOCLR = 0x00004000;  WD_TC = 0x0ffffff;   WD_MOD = 0;  WD_FEED = WD_FEED_FEED1;  WD_FEED = WD_FEED_FEED2;  iapCommands [0] = IAP_CMD_REINVOKEISP;  // disableInts ();  // cpuPLLDisable ();  // cpuT1Disable ();  iapCall ();}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
粉嫩欧美一区二区三区高清影视| 亚洲男人都懂的| 免费成人深夜小野草| 日韩三级av在线播放| 久久超碰97人人做人人爱| 精品sm在线观看| 粉嫩aⅴ一区二区三区四区 | 欧美日韩在线播放三区| 亚洲自拍偷拍av| 欧美一区二区三区免费大片 | 欧美美女视频在线观看| 蜜臀va亚洲va欧美va天堂| 精品国产伦理网| 成人激情午夜影院| 一区二区在线免费观看| 91麻豆精品国产自产在线观看一区| 秋霞电影一区二区| 国产精品国产三级国产普通话三级| 欧美中文字幕一二三区视频| 麻豆成人久久精品二区三区红 | 成人欧美一区二区三区黑人麻豆| 欧美最新大片在线看| 麻豆国产欧美日韩综合精品二区| 久久精品在线观看| 欧美视频完全免费看| 韩国中文字幕2020精品| 成人欧美一区二区三区在线播放| 欧美日韩精品欧美日韩精品| 精品一区二区三区视频| 国产精品免费久久| 91精品国产综合久久久久久久久久| 国产精品综合av一区二区国产馆| 亚洲欧美日韩在线| 久久综合中文字幕| 日本韩国欧美一区| 国产1区2区3区精品美女| 亚洲国产乱码最新视频| 国产欧美日韩三级| 9191成人精品久久| 91视视频在线观看入口直接观看www | 激情深爱一区二区| 一区二区三区四区乱视频| 欧美岛国在线观看| 色哟哟欧美精品| 国产成人8x视频一区二区| 亚洲一区在线观看视频| 国产精品乱子久久久久| 日韩精品一区二区三区蜜臀| 色乱码一区二区三区88| 国产成人欧美日韩在线电影| 日韩影院在线观看| 亚洲人精品午夜| 欧美国产欧美综合| 日韩免费成人网| 欧美日韩的一区二区| 91麻豆123| 99热精品一区二区| 成人精品免费网站| 国产精品中文字幕日韩精品| 日本视频免费一区| 亚洲一区二区三区在线播放| 亚洲特级片在线| 国产精品第13页| 中文字幕乱码亚洲精品一区| 26uuu国产电影一区二区| 日韩一区二区麻豆国产| 欧美高清dvd| 欧美日韩综合在线免费观看| 一本色道久久综合精品竹菊| 丰满亚洲少妇av| 国产成人自拍网| 国产精品一区二区三区99| 精品一区二区三区在线播放视频| 免费成人美女在线观看| 毛片av一区二区| 久久精品国内一区二区三区| 日本免费在线视频不卡一不卡二| 五月综合激情网| 日韩专区欧美专区| 免费不卡在线观看| 久久精品国产免费看久久精品| 麻豆极品一区二区三区| 国产在线视视频有精品| 国产毛片精品视频| 成人精品一区二区三区四区| 91美女在线视频| 欧美性感一区二区三区| 欧美肥妇free| 欧美大片在线观看| 久久精品日产第一区二区三区高清版 | 亚洲一级电影视频| 偷拍一区二区三区| 国产一区二区三区最好精华液| 国产一区二区在线看| 成人三级伦理片| 97精品久久久久中文字幕| 欧美在线免费观看亚洲| 欧美一卡在线观看| 国产欧美一区二区精品性| 中文字幕一区在线| 亚洲成va人在线观看| 精品一区二区久久久| www.亚洲人| 欧美老年两性高潮| 精品免费国产一区二区三区四区| 国产欧美在线观看一区| 亚洲精品日韩一| 奇米888四色在线精品| 国产aⅴ精品一区二区三区色成熟| 91亚洲精品久久久蜜桃网站| 欧美日韩精品免费| 国产日韩v精品一区二区| 亚洲免费高清视频在线| 蜜臀精品一区二区三区在线观看 | 99久久婷婷国产综合精品| 欧美性感一类影片在线播放| 久久午夜国产精品| 亚洲自拍偷拍九九九| 国产在线视频一区二区| 日本精品一区二区三区高清| 精品欧美黑人一区二区三区| 亚洲精品久久久蜜桃| 激情深爱一区二区| 欧美又粗又大又爽| 久久精品视频在线看| 天天综合色天天综合| 成人午夜激情片| 日韩久久久久久| 亚洲免费av高清| 国产精品原创巨作av| 777亚洲妇女| 一区二区三区在线观看动漫| 国产一区二区三区四区在线观看 | 99国产精品视频免费观看| 欧美一区二区观看视频| 亚洲精选视频在线| 高清视频一区二区| 精品日韩欧美在线| 日韩精品久久久久久| 色网综合在线观看| 日本一区二区成人在线| 久久er精品视频| 91精品婷婷国产综合久久竹菊| 成人欧美一区二区三区小说| 国产精品一线二线三线| 精品日产卡一卡二卡麻豆| 三级在线观看一区二区| 欧美影院一区二区| 亚洲男人的天堂网| av亚洲精华国产精华精| 国产亚洲一区二区三区四区| 另类专区欧美蜜桃臀第一页| 777久久久精品| 一区二区三区四区精品在线视频| av亚洲产国偷v产偷v自拍| 国产亚洲va综合人人澡精品 | 国产成人av一区二区| 精品国产一区二区三区忘忧草| 日韩av一二三| 欧美精品在线一区二区| 视频一区国产视频| 欧美精品自拍偷拍| 日韩国产欧美三级| 欧美电影在哪看比较好| 午夜国产不卡在线观看视频| 91久久香蕉国产日韩欧美9色| 国产精品传媒视频| 一本色道久久加勒比精品| 一区二区三区四区在线免费观看| 91麻豆免费看片| 一级精品视频在线观看宜春院 | 欧美夫妻性生活| 日韩av不卡一区二区| 日韩欧美中文字幕公布| 老司机免费视频一区二区| 久久亚区不卡日本| 成人免费不卡视频| 亚洲色欲色欲www| 欧美综合视频在线观看| 午夜精品一区二区三区免费视频 | 日韩影院在线观看| 日韩女同互慰一区二区| 国产精品综合在线视频| 国产精品丝袜91| 色久综合一二码| 视频一区中文字幕国产| 欧美成人国产一区二区| 成人免费视频免费观看| 亚洲精品精品亚洲| 欧美电影一区二区| 国产成人免费视频网站高清观看视频| 中文在线免费一区三区高中清不卡| jvid福利写真一区二区三区| 亚洲精品乱码久久久久久 | 黄页网站大全一区二区| 久久久激情视频| 99re亚洲国产精品| 婷婷激情综合网| 久久久99久久| 91久久一区二区|