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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? example_flash281x_api.c

?? TMS320F2812上電自動以串行方式將外部flash上的執(zhí)行程序搬移到片內(nèi)ram上的源碼
?? C
字號:
//###########################################################################
//
// FILE:  Example_Flash281x_API.c	
//
// TITLE: F281x Flash API Example
//
// NOTE:  This example runs from Flash.  First program the example
//        into flash.  The code will then copy the API's to RAM and 
//        modify the flash. 
//
//
//###########################################################################
// $TI Release: Flash281x API V2.10 $
// $Release Date: August 4, 2005 $
//###########################################################################


/*---- Flash API include file -------------------------------------------------*/
#include "Flash281x_API_Library.h"

/*---- example include file -------------------------------------------------*/
#include "Example_Flash281x_API.h"
#include "SCI_Boot.h"

extern Uint16 SCIA_GetByteData_app(void);
extern Uint16 SCIA_FIFO_GetWordData_swapEndian(void);
void SCIA_BlockProcessing(void);
extern void SCI_SendStatus(char *);
extern void SCIA_AutobaudLock(void);
extern void SCIA_Init(void);
int checksum_flash(void);
void initPLL(void);
void main2(void);
extern void	SCI_SendHexLong(Uint32);
extern	long Convert_HEXtoASCII(Uint16);



/*--- Global variables used to interface to the flash routines */
#define	CHECKSUM_EXPECTED 0x6E13

#if		FLASH_F2810
#define FLASH_RANGE       65535L
#define DEST_ADDR		  0x003E8000
#endif

#if		FLASH_F2811 | FLASH_F2812
#define FLASH_RANGE       131071L
#define DEST_ADDR		  0x003D8000
#endif

#define BLOCK_SIZE			FLASH_RANGE+1L
#define RAM_BUFFER_SIZE		4096


FLASH_ST EraseStatus;
FLASH_ST ProgStatus;
FLASH_ST VerifyStatus; 

#pragma DATA_SECTION(BlockBuffer1, "BlockTransferBuffer1");
#pragma DATA_SECTION(BlockBuffer2, "BlockTransferBuffer2");
Uint16 	BlockBuffer1[4096];
Uint16 	BlockBuffer2[4096];
Uint16	*BlockBufferPtr;
Uint32	BlockRemain;
Uint16	BufferIndexMax;
Uint32 MyCallbackCounter; // Just increment a counter in the callback function
Uint32	tempL;
Uint16 	i=0;
                               
/*--- Callback function.  Function specified by defining Flash_CallbackPtr */
void MyCallbackFunction(void); 
  
void main2(void)
{   
   	Uint16 ErrorFlag, temp, Status;

/*------------------------------------------------------------------
 To use the F2812, F2811 or F2810 Flash API, the following steps
 must be followed:

      1. Modify Flash281x_API.config.h for your targets operating
         conditions.
      2. Include Flash281x_API_Library.h in the application.
      3. Add the approparite Flash API library to the project.

  The user's code is responsible for the following:

      4. Initalize the PLL to the proper CPU operating frequency.
      5. If required, copy the flash API functions into on-chip zero waitstate
         RAM.  
      6. Initalize the Flash_CPUScaleFactor variable to SCALE_FACTOR 
      7. Initalize the flash callback function pointer. 
      8. Optional: Run the Toggle test to confirm proper frequency configuration
         of the API. 
      9. Optional: Unlock the CSM.  
     10. Call the API functions: Flash_Erase(), Flash_Program(), Flash_Verify()
         
  The API functions will:
      
       Disable the watchdog
       Check the device revision (REVID).  This API is for Revision C silicon
       Perform the desired operation and return status
------------------------------------------------------------------*/

	SCI_SendStatus("Communication kernel received and executing.");
	SCI_SendStatus("\n\rType 'a' to relock baud-rate: ");


/*------------------------------------------------------------------
 Initalize the PLLCR value before calling any of the F2810, F2811
 or F281x Flash API functions.
        
     Check to see if the PLL needs to changed
     PLLCR_VALUE is defined in Example_Flash281x_API.h
     1) Make the change
     2) Wait for the DSP to switch to the PLL clock
        This wait is performed to ensure that the flash API functions 
        will be executed at the correct frequency.
     3) While waiting, feed the watchdog so it will not reset. 
------------------------------------------------------------------*/

    initPLL();

/*------------------------------------------------------------------
  Initalize Flash_CPUScaleFactor.

   Flash_CPUScaleFactor is a 32-bit global variable that the flash
   API functions use to scale software delays. This scale factor 
   must be initalized to SCALE_FACTOR by the user's code prior
   to calling any of the Flash API functions. This initalization
   is VITAL to the proper operation of the flash API functions.  
   
   SCALE_FACTOR is defined in Example_Flash281x_API.h as   
     #define SCALE_FACTOR  1048576.0L*( (200L/CPU_RATE) )
     
   This value is calculated during the compile based on the CPU 
   rate, in nanoseconds, at which the algorithums will be run.
------------------------------------------------------------------*/
   
   Flash_CPUScaleFactor = SCALE_FACTOR;


/*------------------------------------------------------------------
  Initalize Flash_CallbackPtr.

   Flash_CallbackPtr is a pointer to a function.  The API uses
   this pointer to invoke a callback function during the API operations.
   If this function is not going to be used, set the pointer to NULL
   NULL is defined in <stdio.h>.  
------------------------------------------------------------------*/
   
   Flash_CallbackPtr = &MyCallbackFunction; 
   MyCallbackCounter = 0; // Increment this counter in the callback function

	//Prep SCI with new baud rate
	SCIA_Init();
	SCIARegs.SCIFFTX.bit.SCIFFENA = 0;
	SCIA_AutobaudLock();
	SCIARegs.SCICTL1.bit.SWRESET = 0;	
	SCIARegs.SCICTL1.bit.SWRESET = 1;
	SCIARegs.SCIFFTX.bit.SCIFFENA = 1;
	SCIARegs.SCIFFTX.all &= 0x7FFF;
	SCIARegs.SCIFFTX.all |= 0x8000;
	SCI_SendStatus(" baud-rate relocked\n\r\r ");

	//Erase flash
	temp = checksum_flash();			
	tempL = Convert_HEXtoASCII(temp);
	SCI_SendStatus("\n\n\rFlash Checksum = 0x");
	SCI_SendHexLong(tempL);
	if(temp==0)
		SCI_SendStatus("\n\rFLASH appears to be erased already.");
	else
		SCI_SendStatus("\n\rFLASH is not erased and should not be programmed until it is erased.");
	SCI_SendStatus("\n\n\rErase FLASH? (y/n): ");
	temp = SCIA_GetByteData_app(); 
    if( temp != 'n')
	{
		SCI_SendStatus("\n\rErasing ... please wait");
		#if FLASH_F2810
				Status = Flash_Erase(SECTOR_F2810,&EraseStatus);
		#endif

		#if FLASH_F2811 | FLASH_F2812
				Status = Flash_Erase(SECTOR_F2811,&EraseStatus);
		#endif
		if(Status != STATUS_SUCCESS) 
		{
		   SCI_SendStatus("\n\r Flash Erase Error ");
		   Example_Error(Status);
		}
		SCI_SendStatus(" ** erasing done\n\r");
	}
  
	//Transfer and program application code
	SCI_SendStatus("\n\rReady for application data transfer...\n\r");    
   	SCIA_BlockProcessing();

	//Calculate new checksum and compare with expected value
	SCI_SendStatus(" ** application programmed");
	temp = checksum_flash();
	tempL = Convert_HEXtoASCII(temp);
	SCI_SendStatus("\n\rFlash Checksum = 0x");
	SCI_SendHexLong(tempL);
	ErrorFlag = temp - CHECKSUM_EXPECTED;
	if(ErrorFlag)
   	{
		SCI_SendStatus("  ** checksum error ");
   		Example_Error(100);
	}
	SCI_SendStatus("  ** checksum verified ");

	//CKFA software done
	Example_Done();
}

int checksum_flash()
{
    unsigned long   j;
    unsigned int    sum = 0;
	unsigned int	*mem;

	mem = (unsigned int*)DEST_ADDR;
    for (j = 0; j <= FLASH_RANGE; j++)
		sum += *mem++;

	return sum;
}


void SCIA_BlockProcessing(void)
{
   struct HEADER {
     Uint32 BlockSize;
     Uint32 DestAddr;
   } BlockHeader;
  
	Uint16	BufferSize;
	Uint16 Status;
	Uint16 *Flash_ptr;     // Pointer to a location in flash
	Uint32 Length;         // Number of 16-bit values to be programmed

	//HW definitions, RAM buffer is constant, block size and dest
	//addr dependent on 2810 or 2811
	BufferSize = RAM_BUFFER_SIZE;
	BlockHeader.BlockSize = BLOCK_SIZE;
	BlockHeader.DestAddr = DEST_ADDR;

	//Init processing variables
	BlockRemain = BlockHeader.BlockSize;
	BufferIndexMax = BufferSize;
	BlockBufferPtr = BlockBuffer1;

	//Transfer anf program application code
	while(BufferIndexMax > 0)
	{
		SCI_SendStatus(".");
		for(i = 0; i <= (BufferIndexMax-1); i++)
		{
			//RAM Transfer
			*BlockBufferPtr++ = SCIA_FIFO_GetWordData_swapEndian();
			if(SCIARegs.SCIRXST.bit.RXERR || SCIARegs.SCIFFRX.bit.RXFFOVF)
			{
			    SCI_SendStatus("\n\rSerial-Comm Failure - 1");
		   		Example_Error(101);
			}
		}			                          
		
		//Program data block into flash at address specified at start of data block,
		//callback function continues transfer in other buffer

		//Config RAM buffer pointer for next RAM transfer
		if(BlockBufferPtr <= BlockBuffer2)
			BufferIndexMax = BlockBufferPtr - BlockBuffer1;
		else
			BufferIndexMax = BlockBufferPtr - BlockBuffer2;

		Flash_ptr = (Uint16 *)BlockHeader.DestAddr;
		Length = BufferIndexMax;
		BlockHeader.DestAddr += Length;

		//Callback function config
		MyCallbackCounter = 0; 
		BlockRemain -= BufferIndexMax;

		//Program flash
		if(BlockRemain < BufferSize) 
			BufferIndexMax = BlockRemain;
		else
			BufferIndexMax = BufferSize;

		if(BlockBufferPtr <= BlockBuffer2)
		{
			BlockBufferPtr = BlockBuffer2;
			Status = Flash_Program(Flash_ptr,BlockBuffer1,Length,&ProgStatus);
		}
		else
		{
			BlockBufferPtr = BlockBuffer1;
			Status = Flash_Program(Flash_ptr,BlockBuffer2,Length,&ProgStatus);
		}
		if(Status != STATUS_SUCCESS) 
		{
			SCI_SendStatus("\n\rFlash programming failure");
		   	Example_Error(Status);

		}

		//Receive the rest of data block not transferred by callback function
		// and store in buffer 2
		while((SCIARegs.SCIFFRX.bit.RXFIFST>1) && (BufferIndexMax>0))
		{
			*BlockBufferPtr++ = SCIA_FIFO_GetWordData_swapEndian();
			BufferIndexMax--;
		}
		if(SCIARegs.SCIRXST.bit.RXERR || SCIARegs.SCIFFRX.bit.RXFFOVF)
		{
			if(BlockRemain == 0)
			{
				SCI_SendStatus("\n\rChange configuration to 128 kW FLASH ");
				Example_Error(102);
			}
			else
			{
				SCI_SendStatus("\n\rSerial-Comm Failure - 2 ");
				Example_Error(103);
		   	}		   	
		}

	}	//end of IndexMax While-Loop

   return;
}


/*------------------------------------------------------------------
  Callback function - must be executed from outside flash/OTP
-----------------------------------------------------------------*/
//#pragma CODE_SECTION(MyCallbackFunction,"ramfuncs");
void MyCallbackFunction(void)
{       

	if(SCIARegs.SCIFFRX.bit.RXFIFST == 16)
	{
		while((SCIARegs.SCIFFRX.bit.RXFIFST>1) && (BufferIndexMax>0))
		{
			*BlockBufferPtr++ = SCIA_FIFO_GetWordData_swapEndian();
			BufferIndexMax--;
		}
		if(SCIARegs.SCIRXST.bit.RXERR || SCIARegs.SCIFFRX.bit.RXFFOVF)
		{
			if(BlockRemain == 0)
			{
				SCI_SendStatus("\n\rChange configuration to 128 kW FLASH ");
				Example_Error(104);
			}
			else
			{
				SCI_SendStatus("\n\rSerial-Comm Failure - 2 ");
				Example_Error(105);
		   	}		   	
		}

	}
    // Toggle pin, service external watchdog etc
    MyCallbackCounter++;
}


/*------------------------------------------------------------------
  Simple memory copy routine to move code out of flash into SARAM
-----------------------------------------------------------------*/

void Example_MemCopy(Uint16 *SourceAddr, Uint16* SourceEndAddr, Uint16* DestAddr)
{
    while(SourceAddr < SourceEndAddr)
    { 
       *DestAddr++ = *SourceAddr++;
    }
    return;
}


/*------------------------------------------------------------------
  For this example, if an error is found just stop here
-----------------------------------------------------------------*/
void Example_Error(Uint16 Status)
{

//  Error code will be in the AL register. 
    asm("    ESTOP0");
    asm("    SB 0, UNC");
}


/*------------------------------------------------------------------
  For this example, once we are done just stop here
-----------------------------------------------------------------*/
//#pragma CODE_SECTION(Example_Done,"ramfuncs");
void Example_Done(void)
{
    asm("    ESTOP0");
    asm("    SB 0, UNC");
}


void initPLL(void)
{
    int	i;
    if(*PLLCR != PLLCR_VALUE) 
    {
       EALLOW;
       *PLLCR = PLLCR_VALUE;
       
       // Wait for PLL to lock
       // Each time through this loop takes ~14 cycles
       // PLL Lock time is 131072 Cycles
       for(i= 0; i< 131072/14; i++){
           *WDKEY = 0x0055;
           *WDKEY = 0x00AA;
       }
       for(i= 0; i< 131072/14; i++){
           *WDKEY = 0x0055;
           *WDKEY = 0x00AA;
       }
       EDIS;
    }

	return;
}

/*------------------------------------------------------------------
   Example_ToggleTest
  
   This function shows example calls to the ToggleTest.  

   This test is used to Toggle a GPIO pin at a known rate and thus 
   confirm the frequency configuration of the API functions.
   
   Common output pins are supported here, however the user could
   call the function with any GPIO mux register and pin mask.
   
   A pin should be selected based on the hardware being used. 
   
   Parameters: Uint16 PinNumber

   Return Value: The toggle test does not return.  It will loop 
                 forever and is used only for testing purposes.
        
   Notes:
----------------------------------------------------------------*/
/*
void Example_ToggleTest(Uint16 PinNumber)
{

       switch(PinNumber) {
          case 0:
             break;
          case 1:
             Flash_ToggleTest(GPFMUX,GPFTOGGLE,GPIOF14_XF_MASK);
             break;
          case 2:
             Flash_ToggleTest(GPAMUX,GPATOGGLE,GPIOA0_PWM1_MASK);
             break;
          case 3:
             Flash_ToggleTest(GPFMUX,GPFTOGGLE,GPIOF4_SCITXDA_MASK);
             break;
          case 4:
             Flash_ToggleTest(GPGMUX,GPGTOGGLE,GPIOG4_SCITXDB_MASK);
             break;
          case 5:
             Flash_ToggleTest(GPFMUX,GPFTOGGLE,GPIOF12_MDXA_MASK);
             break;
          default:
             break;
       }          
}


*/


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产欧美日韩另类综合| 欧美一级久久久| 激情文学综合丁香| 亚洲最快最全在线视频| 国产亚洲一区二区在线观看| 欧美日韩国产一区二区三区地区| 懂色av一区二区三区蜜臀| 午夜精品久久久久久不卡8050| 中文字幕亚洲成人| 精品国产乱码久久久久久免费| 欧美日韩在线精品一区二区三区激情 | 日本系列欧美系列| 亚洲高清不卡在线观看| 亚洲一区视频在线| 欧美国产精品一区二区| 久久九九久精品国产免费直播| 欧美老人xxxx18| 欧美三级韩国三级日本三斤 | 18欧美乱大交hd1984| 国产精品毛片a∨一区二区三区| 久久久久久亚洲综合影院红桃| 777久久久精品| 日韩视频免费观看高清在线视频| 欧美日韩视频在线第一区 | 欧美四级电影网| 欧美日韩视频在线一区二区| 欧美日韩五月天| 欧美一区二区三区喷汁尤物| 日韩精品中文字幕一区| 欧美日韩精品专区| 日韩一区二区免费视频| 欧美电视剧免费全集观看| 精品国产一区二区国模嫣然| 欧美精品一区二区三区视频| 国产日产欧美一区二区视频| 亚洲欧美日韩国产一区二区三区 | 久久国产夜色精品鲁鲁99| 九一久久久久久| 成人福利视频在线看| 色综合婷婷久久| 69av一区二区三区| 久久久国产午夜精品| 亚洲特黄一级片| 午夜精品一区二区三区免费视频 | 欧美三级韩国三级日本三斤| 日韩欧美一二三四区| 亚洲国产精品av| 亚欧色一区w666天堂| 久久精品久久精品| aaa国产一区| 日韩一二三四区| 亚洲欧美另类综合偷拍| 日本va欧美va精品发布| 99免费精品在线| 欧美一区二区免费| 亚洲免费视频中文字幕| 久久99精品久久久久久久久久久久| 99精品国产热久久91蜜凸| 日韩欧美激情一区| 亚洲国产成人高清精品| 1区2区3区国产精品| 国产欧美一区二区三区网站| 性欧美疯狂xxxxbbbb| 东方欧美亚洲色图在线| 777午夜精品视频在线播放| 最新国产の精品合集bt伙计| 久久草av在线| 91精品国产综合久久精品app| 成人免费在线视频观看| 国产精品99久久久久久宅男| 在线不卡a资源高清| 亚洲女人小视频在线观看| 岛国av在线一区| 精品国产成人系列| 日韩不卡一二三区| 中文一区二区完整视频在线观看| 亚洲欧美aⅴ...| av一区二区三区黑人| 亚洲国产精品成人综合 | 91久久奴性调教| ...xxx性欧美| 91亚洲资源网| 综合欧美亚洲日本| 99久久精品国产毛片| **性色生活片久久毛片| 99精品国产99久久久久久白柏| 国产精品全国免费观看高清| 成人黄色片在线观看| 国产欧美日韩另类一区| 国产精品99久久久久| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ原创 | 福利91精品一区二区三区| 久久婷婷国产综合精品青草| 高清国产一区二区| 亚洲视频免费在线观看| 欧美体内she精视频| 一区二区三区美女视频| 欧美日本一区二区在线观看| 爽好久久久欧美精品| 精品电影一区二区三区| 国产精品一区二区你懂的| 国产精品丝袜久久久久久app| 不卡的电影网站| 午夜日韩在线电影| 欧美va亚洲va在线观看蝴蝶网| 国产精品一二三四五| 亚洲九九爱视频| 日韩午夜激情免费电影| 国产精品1区二区.| 18成人在线观看| 亚洲免费看黄网站| 欧洲国内综合视频| 美腿丝袜在线亚洲一区| 国产日韩欧美不卡在线| 欧美在线影院一区二区| 日韩综合小视频| 国产欧美一区二区在线| 欧美老肥妇做.爰bbww| 国产成人av一区二区三区在线观看| 一区二区三区欧美在线观看| 欧美精品一区二区三| 欧美色综合久久| 丁香啪啪综合成人亚洲小说| 亚洲高清免费视频| 国产精品视频线看| 日韩三区在线观看| www.欧美色图| 狠狠狠色丁香婷婷综合久久五月| 亚洲欧洲日韩女同| 精品国产一区二区三区忘忧草| 粉嫩aⅴ一区二区三区四区| 日韩av电影一区| 亚洲一区二区三区四区在线观看 | 亚洲男人的天堂在线aⅴ视频 | 欧美一级片在线观看| 在线中文字幕不卡| 成人a免费在线看| 国产真实乱对白精彩久久| 天天综合网天天综合色| 一区二区三区.www| 1000精品久久久久久久久| 久久久另类综合| 国产亚洲欧美中文| 中文字幕一区二区三| 久久久久九九视频| 久久精品免费在线观看| 久久先锋资源网| 久久一区二区视频| 2020日本不卡一区二区视频| 精品国产乱子伦一区| www国产成人免费观看视频 深夜成人网| 欧美日韩你懂得| 91麻豆精品国产自产在线| 欧美顶级少妇做爰| 欧美videos大乳护士334| 欧美成人vps| 国产亚洲精品7777| 国产精品福利电影一区二区三区四区 | 欧美日韩美少妇| 在线不卡a资源高清| 欧美videofree性高清杂交| 久久久精品天堂| 日韩码欧中文字| 亚洲成a天堂v人片| 青青草国产成人99久久| 国内成人精品2018免费看| 成人午夜碰碰视频| 91成人网在线| 精品电影一区二区三区| 成人免费在线视频| 天堂成人免费av电影一区| 国产一区二区三区四区五区入口| 国产成人免费视频网站 | 国模无码大尺度一区二区三区| 国产乱码精品一区二区三| 91色|porny| 亚洲一二三专区| 蜜桃视频在线一区| jlzzjlzz亚洲日本少妇| 精品视频一区二区三区免费| 久久欧美中文字幕| 亚洲精品视频在线观看免费| 看电视剧不卡顿的网站| 91小视频在线| www日韩大片| 亚洲一区二区三区视频在线| 国产成人精品一区二区三区四区 | 亚洲日本一区二区| 九九热在线视频观看这里只有精品| 99热99精品| 久久女同性恋中文字幕| 日本中文字幕不卡| 91香蕉视频mp4| 国产日韩精品一区二区三区| 五月天精品一区二区三区| 99久久免费精品| 国产欧美精品一区二区色综合朱莉 | 欧美色视频在线观看| 中文字幕在线不卡视频| 国产一区二区网址|