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

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

?? flash.c

?? SOS操作系統用于無線傳感器網絡節點的源代碼
?? C
字號:
/******************************************************************************
*                                                                             *
*        **********                                                           *
*       ************                                                          *
*      ***        ***                                                         *
*     ***    ++    ***                                                        *
*     ***   +  +   ***                      CHIPCON                           *
*     ***   +                                                                 *
*     ***   +  +   ***                                                        *
*     ***    ++    ***                                                        *
*      ***        ***                                                         *
*       ************                                                          *
*        **********                                                           *
*                                                                             *
*******************************************************************************

Filename:     flash.c
Target:       cc2430
Author:       efu
Revised:      16/12-2005
Revision:     1.0

Description:

    This example reads data from the UART and stores it in a flash address
    space. The data is written to the LCD. The next time this example is run,
    the previously stored data is fetched and written to the LCD. Both DMA and
    CPU flash write is used.

    NOTE: The flash supports only a limited number of write/erase cycles,
    therefore, this function should not be used many times, as this may wear
    out the flash page used in this example.

******************************************************************************/
#include <stdio.h>
#include <string.h>
#include "app_ex.h"

// Prototypes
void writeFlashUsingDMA(BYTE* pSrcAddr, INT16 length, WORD flashAddress, BOOL erase);
BOOL flashUnused(BYTE* data, INT16 length);
void initFlash(void);
void flash_main(void);


#define STRING_LENGTH 50
#define PAGE_ADDRESS 0x7000
#define PAGE_NUMBER (PAGE_ADDRESS >> 11)


__no_init const char __code testData[2048] @ PAGE_ADDRESS;


volatile    DMA_DESC dmaChannel;

/******************************************************************************
* @fn  writeFlashUsingDMA
*
* @brief
*      Writes data to flash using DMA. Erases the page in advance if told to.
*
* Parameters:
*
* @param  BYTE* pSrcAddr
*         The start of the data to be written to flash.
*
*         INT16 length
*         The number of bytes to be written to flash.
*
*         WORD flashAddress
*         The address in flash the data is to be written to.
*
*         BOOL erase
*         Indicating whether the flash is to be erased or not.
*
* @return void
*
******************************************************************************/
void writeFlashUsingDMA(BYTE* pSrcAddr, INT16 length, WORD flashAddress, BOOL erase)
{
   BYTE oldPointerH = 0;
   BYTE oldPointerL = 0;
   BYTE status;
   BYTE buffer[10];

   status = IEN0;
   INT_GLOBAL_ENABLE(INT_OFF);


   // Setting up the flash address,
   // erasing the page if required.
   SET_WORD(FADDRH, FADDRL, (int)(flashAddress >> 2));
   if(erase == TRUE)
   {
      halFlashErasePage(buffer, PAGE_NUMBER);
   }

   halWait(0xFF);

   // Making sure a multiplum of 4 bytes is transferred.
   while(length & 0x0003){
      length++;
   }


   SET_WORD(dmaChannel.SRCADDRH, dmaChannel.SRCADDRL,   pSrcAddr);   // The start address of the segment
   SET_WORD(dmaChannel.DESTADDRH, dmaChannel.DESTADDRL, &X_FWDATA);  // Input of the AES module
   SET_WORD(dmaChannel.LENH, dmaChannel.LENL, length);               // Setting the length of the transfer (bytes)
   dmaChannel.VLEN      = VLEN_USE_LEN;      // Using the length field
   dmaChannel.PRIORITY  = PRI_HIGH;          // High priority
   dmaChannel.M8        = M8_USE_8_BITS;     // Transferring all 8 bits in each byte.
   dmaChannel.IRQMASK   = FALSE;             // The DMA complete interrupt flag is set at completion.
   dmaChannel.DESTINC   = DESTINC_0;         // The destination address is constant
   dmaChannel.SRCINC    = SRCINC_1;          // The address for data fetch is inremented by 1 byte
   dmaChannel.TRIG      = DMATRIG_FLASH;     // Setting the FLASH module to generate the DMA trigger
   dmaChannel.TMODE     = TMODE_SINGLE;      // A single byte is transferred each time.
   dmaChannel.WORDSIZE  = WORDSIZE_BYTE;     // Set to count bytes.

   // Storing old settings and setting up the DMA.
   // Clearing all DMA complete flags and arming the channel.
   oldPointerH = DMA0CFGH;
   oldPointerL = DMA0CFGL;
   DMA_SET_ADDR_DESC0(&dmaChannel);
   DMA_ABORT_CHANNEL(0);
   DMAIRQ &= ~DMA_CHANNEL_0;
   DMA_ARM_CHANNEL(0);


   // Starting to write
   FLASH_CONFIG(WRITE);

   // Waiting for the DMA to finish.
   while(!(DMAIRQ & DMA_CHANNEL_0));
   DMAIRQ &= ~DMA_CHANNEL_0;


   //Restoring old settings
   DMA0CFGH = oldPointerH;
   DMA0CFGL = oldPointerL;
   IEN0 = status;


   return;
}




/******************************************************************************
* @fn  flashUnused
*
* @brief
*      Checks whether the given flash area is uninitialized (0xFF).
*
* Parameters:
*
* @param  BYTE* data
*         The start of the data to be investigated.
*
*         INT16 length
*         The number of bytes to be insvestigated.
*
* @return BOOL
*         Indicating if flash was unused (TRUE) or not (FALSE).
*
******************************************************************************/
BOOL flashUnused(BYTE* data, INT16 length)
{
   while((data[--length] == 0xFF) && (length));

   if(length == 0)return TRUE;
   else return FALSE;
}


/******************************************************************************
* @fn  initFlash
*
* @brief
*      Initializes components for use with the Flash application example.
*
* Parameters:
*
* @param  void
*
* @return void
*
******************************************************************************/
void initFlash(void)
{
   initLcd();

   INIT_BUTTON();
   INIT_GLED();
   INIT_YLED();

}


/******************************************************************************
* @fn  flash_main
*
* @brief
*      Main function.
*
* Parameters:
*
* @param  void
*
* @return void
*
******************************************************************************/
#ifdef COMPLETE_APPLICATION
void flash_main(void){
#else
void main(void){
#endif
   BYTE buffer[30];
   char inputBuffer[STRING_LENGTH];
   INT8 pointer = 0;
   BOOL stop = FALSE;
   BOOL write = FALSE;
   char c;
   char *menuText[] = {(char*)" CPU write?", (char*)" DMA write?"};
   BYTE command;
   BOOL unUsed;

   initFlash();

   // Clearing buffers
   memset(buffer,0,sizeof(buffer));
   memset(inputBuffer,0,sizeof(inputBuffer));

   // Setting up UART
   UART_SETUP(0,57600,HIGH_STOP);
   UTX0IF = 1;  // Set UART 0 TX interrupt flag

   while(getJoystickDirection() != CENTRED);

   //Displaying the stored flash message.
   lcdUpdateLine(LINE1,(char*)"Last written:");
   if((unUsed = flashUnused((BYTE*)testData, STRING_LENGTH)))
   {
      scrollText((char*) "The flash function has not previously been used!", STRING_LENGTH);
   }
   else
   {
      scrollText((char*) testData, STRING_LENGTH);
   }

   while(getJoystickDirection() != CENTRED);
   while(getJoystickDirection() == CENTRED);
   while(getJoystickDirection() != CENTRED);


   // User decides whether to use CPU or DMA to write flash or to abort.
   command = lcdMenu(menuText,2);
   if(command == ABORT_MENU)
   {
      return;
   }


   // Uart communication
   lcdUpdate((char*)"Enter data", (char*)"using UART");
   printf((char*)"\n\n**************Flash Programming **************\n");
   printf((char*)"Chipcon.com\n\n\n");

   printf((char*)"Press a key to start\n\n");
   uartGetkey (); // wait for a key to be pressed or the application to be ended
   if (stopApplication() ) return;
   else
   {
      inputBuffer[0] = U0DBUF;
      halWait(5);
      USART0_FLUSH();
      inputBuffer[1] = U0DBUF;
   }

   // Printing the previously written data
   printf((char*)"\nPreviously written:\n");
   if(unUsed)
   {
      printf((char*)"The flash function has not previously been used!\n");
   }
   else
   {
      printf((char*)"%s\n",&testData);
   }

   //Aquiring new data:
   printf((char*)"\n\nType data to be written to flash.\nData will be printed to the LCD next time this example is run.");
   printf((char*)"\n(ENTER to store in flash, ESC to abort)\n\n");
   memset(inputBuffer,0,STRING_LENGTH);

   while(!stop)
   {
      c = getkey();
      U0DBUF = c;

      switch (c){
      case ENTER:
         inputBuffer[pointer] = 0;
         printf((char*)"\n\nThis string will be written to flash: %s\nPress ENTER if OK.\n",inputBuffer);
         if(getkey() == ENTER)
         {
            // Write data to flash;
            stop = TRUE;
            write = TRUE;
         }
         else
         {
            // Reaquire data.
            printf((char*)"\nEnter new text:\n");
            pointer = 0;
         }
         break;
      case BACK_SPACE:
         // Erasing the last typed data.
         if (pointer > 0)
         {
            pointer--;
            inputBuffer[pointer] = ' ';
         }
         break;
      case ESC:
         // Abort Flash write.
         stop = TRUE;
         write = FALSE;
         break;
      default:
         // Add typed data to buffer.
         if (pointer < STRING_LENGTH-1)
         {
            inputBuffer[pointer] = c;
            pointer++;
         }
         break;
      }
   }

  INT_GLOBAL_ENABLE(INT_OFF);

   // Updating the flash if asked to.
   if(write == TRUE)
   {
      if(command == 0)
      {
         halFlashWritePage((BYTE*) &inputBuffer, buffer, PAGE_NUMBER);
      }
      else
      {
         writeFlashUsingDMA((BYTE*) &inputBuffer, STRING_LENGTH, PAGE_ADDRESS, TRUE);
      }
      printf((char*)"\nPage updated with:");
      printf((char*)" %s\n",(char __code*) (PAGE_NUMBER << 11));
      lcdUpdate((char*)"FLASH updated!", (char*)"LEFT to continue");
   }
   else
   {
      printf((char*)"\nPage not updated...\n");
      lcdUpdate((char*)"Not updated", (char*)"LEFT to continue");
   }


   // Done
   haltApplicationWithLED();

   return;
}


/******************************************************************************
* @fn  flash_init
*
* @brief
*      Initializes the Flash application example.
*
* Parameters:
*
* @param  APPLICATION *a
*         Main application
*
* @return void
*
******************************************************************************/
#ifdef COMPLETE_APPLICATION
void flash_init(APPLICATION *a)
{
   a->menuText = (char*)"Flash Writing";
   a->description = (char*)"57600 8-N-1";
   a->main_func = flash_main;
}
#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩免费不卡视频一区二区三区| 午夜精品免费在线| 日韩一区二区免费视频| 欧美在线免费播放| 欧美在线free| 欧美三日本三级三级在线播放| 色综合久久久久综合体| 99国产精品久久| 97精品国产露脸对白| 色香蕉成人二区免费| 91官网在线免费观看| 欧美日韩国产成人在线免费| 欧美剧情片在线观看| 日韩欧美亚洲另类制服综合在线| 日韩一级片在线播放| 日韩三级在线免费观看| 欧美精品一区二区三区高清aⅴ| 欧美精品一区二区三区蜜臀| 国产亚洲一区二区在线观看| 国产精品国产三级国产专播品爱网| 中文字幕一区三区| 亚洲成人av电影在线| 久久狠狠亚洲综合| 国产99久久久精品| 一本大道久久a久久精品综合| 欧美午夜一区二区| 自拍av一区二区三区| 亚洲一区在线视频观看| 麻豆视频一区二区| 成人不卡免费av| 精品视频在线视频| 欧美激情一区二区三区蜜桃视频| 中文字幕在线免费不卡| 午夜欧美一区二区三区在线播放| 美国欧美日韩国产在线播放| 成人精品一区二区三区四区 | 五月婷婷综合网| 奇米色一区二区三区四区| 国产精品888| 欧美日韩一区在线| 国产午夜精品福利| 石原莉奈在线亚洲二区| 风间由美性色一区二区三区| 欧美天天综合网| 国产亚洲一区字幕| 日产国产欧美视频一区精品| av电影在线观看完整版一区二区| 欧美裸体bbwbbwbbw| 国产精品私人影院| 激情综合色播激情啊| 91成人免费网站| 国产精品入口麻豆原神| 美女尤物国产一区| 91精品国产91久久久久久一区二区| 中文字幕欧美激情| 久久av资源站| 欧美日韩一级视频| 亚洲精品国产一区二区三区四区在线| 久久99九九99精品| 91精品国产欧美一区二区18| 一区二区三区自拍| 不卡的电视剧免费网站有什么| 精品入口麻豆88视频| 亚洲成人免费看| 91捆绑美女网站| 国产精品蜜臀在线观看| 国产综合色视频| 精品久久久久久无| 免费在线欧美视频| 欧美男男青年gay1069videost| 亚洲欧美自拍偷拍| 99天天综合性| 亚洲国产精品精华液2区45| 国产一区二区主播在线| 精品成人a区在线观看| 精品在线一区二区三区| 日韩一区二区高清| 九九视频精品免费| 26uuu久久天堂性欧美| 精品一区二区三区免费| 欧美成人三级电影在线| 久久精品72免费观看| 精品国产91九色蝌蚪| 国产乱国产乱300精品| 久久精品欧美一区二区三区麻豆| 久久国产精品色婷婷| 26uuu亚洲综合色| 国产福利精品导航| 18涩涩午夜精品.www| 色狠狠桃花综合| 日韩专区欧美专区| 成人欧美一区二区三区| 91在线小视频| 舔着乳尖日韩一区| 日韩欧美aaaaaa| 高清不卡一二三区| 亚洲欧美日韩久久| 欧美巨大另类极品videosbest | 91亚洲精品乱码久久久久久蜜桃| 亚洲人午夜精品天堂一二香蕉| 91美女精品福利| 婷婷久久综合九色综合绿巨人| 精品毛片乱码1区2区3区| 国产夫妻精品视频| 一区二区三区四区蜜桃| 欧美妇女性影城| 国产伦精品一区二区三区免费迷 | 中文字幕一区二区三区色视频| 91丨九色丨蝌蚪丨老版| 午夜精品久久久久久久久| 精品福利一二区| 91麻豆swag| 国产精品亚洲一区二区三区妖精 | 国产精品国产三级国产aⅴ中文| 91蜜桃在线免费视频| 日韩av一区二区三区| 国产欧美视频在线观看| 欧美日韩国产综合一区二区三区| 国产在线精品一区二区夜色 | 日韩福利电影在线观看| 国产三级一区二区| 在线播放亚洲一区| 成人v精品蜜桃久久一区| 免费看精品久久片| 亚洲欧美另类小说| 国产色综合一区| 欧美一级国产精品| 色噜噜狠狠色综合中国| 国产成人免费在线观看| 日韩国产精品大片| 亚洲国产日韩一级| 成人欧美一区二区三区小说| 久久久夜色精品亚洲| 91精品一区二区三区久久久久久 | 欧美午夜片在线观看| 成人一区二区三区在线观看| 美女视频免费一区| 亚洲一区二区三区中文字幕在线| 欧美激情一区在线观看| 日韩久久久精品| 91精品国产入口在线| 日本精品一级二级| 不卡的电视剧免费网站有什么| 精品一区二区三区免费观看| 视频在线观看一区| 香蕉久久一区二区不卡无毒影院 | 777a∨成人精品桃花网| 欧美性大战xxxxx久久久| 不卡一区二区在线| 成人精品一区二区三区中文字幕| 精品一区二区精品| 国产一区二区三区精品视频| 免费看日韩精品| 久久爱www久久做| 精品一区二区免费在线观看| 精品在线一区二区| 国产精品一区二区在线观看不卡| 裸体一区二区三区| 99re6这里只有精品视频在线观看| 激情综合色综合久久| 国产永久精品大片wwwapp| 国产一区二区不卡老阿姨| 国产麻豆精品久久一二三| 国产一区二区不卡| 成人性生交大片免费看在线播放 | 亚洲欧美日韩国产手机在线| 亚洲免费av在线| 亚洲最大成人综合| 午夜精品福利一区二区蜜股av| 午夜精品久久久久久| 日韩国产欧美在线播放| 狠狠色综合日日| 成人91在线观看| 欧美视频日韩视频在线观看| 91超碰这里只有精品国产| 久久综合狠狠综合| 国产精品久久毛片a| 亚洲午夜私人影院| 久久精品国产久精国产| 成人免费精品视频| 欧美综合天天夜夜久久| 日韩三级精品电影久久久| 欧美激情综合五月色丁香小说| 亚洲欧洲av一区二区三区久久| 亚洲成a人片在线不卡一二三区 | 2020国产成人综合网| 国产精品天天看| 亚洲一区二区在线视频| 久久91精品国产91久久小草| 成人h动漫精品| 欧美撒尿777hd撒尿| 久久色在线观看| 亚洲影视资源网| 国产乱码精品一区二区三| 欧美性猛交一区二区三区精品| 日韩欧美一区二区久久婷婷| 亚洲视频 欧洲视频| 看电影不卡的网站| 色就色 综合激情| 久久影院午夜论|