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

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

?? f31x_spi0_master.c

?? C8051F31系列單片機的例子
?? C
?? 第 1 頁 / 共 2 頁
字號:
   {
      // Write collision occurred
      WCOL = 0;                        // Clear the write collision flag

      Error_Flag = 1;
   }
   else
   {
      if (SPI0DAT == ERROR_OCCURRED)
      {
         // This example recognizes when an error occurs, but does not include
         // any error handling.  The transfer can be aborted or rescheduled,
         // if desired.
         Error_Flag = 1;
      }

      // When the Master enters the ISR, the SPIF flag should be set from
      // sending the Command byte.  This ISR handles the remaining steps of the
      // SPI transfer process.
      // <state> == 0: writing or reading 1 byte of data
      // <state> == 1: for READ commands (first time, only a dummy byte is
      //               sent but the second time, the data must be read from
      //               SPI0DAT)
      // <state> == 2: NSS = 1 to end the transfer, final byte read
      //
      // Note: SPI_WRITE_BUFFER is not handled here because it's done in
      // polled mode
      if (state == 0)
      {
         switch (Command)
         {
            case SLAVE_LED_ON:
            case SLAVE_LED_OFF:
               NSSMD0 = 1;             // Release the slave (not expecting
                                       // data back)

               break;

            case SPI_WRITE:
               SPI0DAT = SPI_Data;

               state = 2;              // Advance to the final state (only
                                       // writing one byte)

               break;

            case SPI_READ:
               SPI0DAT = 0xFF;         // Send a dummy byte so the Slave can
                                       // send the data

               state = 2;              // Advance to the final state (only
                                       // reading one byte)

               break;

            case SPI_READ_BUFFER:
               SPI0DAT = 0xFF;         // Send a dummy byte so the Slave can
                                       // start sending the data

               state = 1;              // Advance to the next state where the
                                       // data can be received
                                       // The data from the slave is not
                                       // available until after the second
                                       // transfer is completed.
                                       // The dummy byte allows the slave to
                                       // send data, since the Master controls
                                       // SCK.

               break;

            default:
               state = 2;              // Any errors in the Command parsing
                                       // should go to state 2 where NSSMD0
                                       // is de-asserted
         }
      }
      else if (state == 1)             // This state is for READ_ARRAY
      {                                // commands where the data must be read
                                       // after the first dummy byte is sent
         switch (Command)
         {
            case SPI_READ_BUFFER:
               SPI_Data_Array[array_index] = SPI0DAT;
               SPI0DAT = 0xFF;

               array_index++;

               if (array_index == (MAX_BUFFER_SIZE-1))
               {
                  state = 2;
               }

               break;
            default:
               state = 2;              // Any errors in the Command parsing
                                       // should go to state 2 where NSSMD0
                                       // is de-asserted
         }
      }
      else if (state == 2)
      {
         switch (Command)
         {
            case SPI_READ:
               SPI_Data = SPI0DAT;     // Read the data from the slave

               break;

            case SPI_READ_BUFFER:
               SPI_Data_Array[array_index] = SPI0DAT; // Read the last data
                                                      // without sending a
                                                      // dummy byte

               break;
         }

         NSSMD0 = 1;                   // De-select the Slave

         state = 0;                    // Reset the state
      }

      SPIF = 0;                        // Clear the SPIF flag
   }
}

//-----------------------------------------------------------------------------
// Support Routines
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// SPI_LED_On
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters   : None
//
// Turns the LED on the SPI Slave on.  The slave does not respond to this
// command, so the command consists of:
//
// Command = SLAVE_LED_ON
// Length = 1 byte (the command itself)
//
//-----------------------------------------------------------------------------
void SPI_LED_On (void)
{
   while (!NSSMD0);                    // Wait until the SPI is free, in case
                                       // it's already busy

   NSSMD0 = 0;

   Command = SLAVE_LED_ON;

   SPI0DAT = Command;

   // The rest of this command will be handled by the SPI ISR, which will
   // trigger when SPIF is set from sending the Command
}

//-----------------------------------------------------------------------------
// SPI_LED_Off
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters   : None
//
// Turns the LED on the SPI Slave off.  The slave does not respond to this
// command, so the command consists of:
//
// Command = SLAVE_LED_OFF
// Length = 1 byte (the command itself)
//
//-----------------------------------------------------------------------------
void SPI_LED_Off (void)
{
   while (!NSSMD0);                    // Wait until the SPI is free, in case
                                       // it's already busy

   NSSMD0 = 0;

   Command = SLAVE_LED_OFF;

   SPI0DAT = Command;

   // The rest of this command will be handled by the SPI ISR, which will
   // trigger when SPIF is set from sending the Command
}

//-----------------------------------------------------------------------------
// SPI_Byte_Write
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters   : None
//
// Note: SPI_Data must contain the data to be sent before calling this
// function.
//
// Writes a single byte to the SPI Slave.  The slave does not respond to this
// command, so the command consists of:
//
// Command = SPI_WRITE
// Length = 1 byte of command, 1 byte of data
//
//-----------------------------------------------------------------------------
void SPI_Byte_Write (void)
{
   while (!NSSMD0);                    // Wait until the SPI is free, in case
                                       // it's already busy

   NSSMD0 = 0;

   Command = SPI_WRITE;

   SPI0DAT = Command;

   // The rest of this command will be handled by the SPI ISR, which will
   // trigger when SPIF is set from sending the Command
}

//-----------------------------------------------------------------------------
// SPI_Byte_Read
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters   : None
//
// Note: SPI_Data will contain the data received after calling this function.
//
// Reads a single byte from the SPI Slave.  The command consists of:
//
// Command = SPI_READ
// Length = 1 byte of command, 1 byte of data
//
//-----------------------------------------------------------------------------
void SPI_Byte_Read (void)
{
   while (!NSSMD0);                    // Wait until the SPI is free, in case
                                       // it's already busy

   NSSMD0 = 0;

   Command = SPI_READ;

   SPI0DAT = Command;

   // The rest of this command will be handled by the SPI ISR, which will
   // trigger when SPIF is set from sending the Command
}

//-----------------------------------------------------------------------------
// SPI_Array_Write
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters   : None
//
// Note: SPI_Data_Array must contain the data to be sent before calling this
// function.
//
// Writes an array of values of size MAX_BUFFER_SIZE to the SPI Slave.  The
// command consists of:
//
// Command = SPI_WRITE_BUFFER
// Length = 1 byte of command, MAX_BUFFER_SIZE bytes of data
//
// Note: Polled mode is used for this function in order to buffer the data
// being sent using the TXBMT flag.
//
//-----------------------------------------------------------------------------
void SPI_Array_Write (void)
{
   unsigned char array_index;

   while (!NSSMD0);                    // Wait until the SPI is free, in case
                                       // it's already busy

   ESPI0 = 0;                          // Disable SPI interrupts

   NSSMD0 = 0;

   SPI0DAT = SPI_WRITE_BUFFER;         // Load the XMIT register
   while (TXBMT != 1)                  // Wait until the command is moved into
   {                                   // the XMIT buffer
   }

   for (array_index = 0; array_index < MAX_BUFFER_SIZE; array_index++)
   {
      SPI0DAT = SPI_Data_Array[array_index]; // Load the data into the buffer
      while (TXBMT != 1)               // Wait until the data is moved into
      {                                // the XMIT buffer
      }
   }
   SPIF = 0;
   while (SPIF != 1)                   // Wait until the last byte of the
   {                                   // data reaches the Slave
   }
   SPIF = 0;

   NSSMD0 = 1;                         // Diable the Slave

   ESPI0 = 1;                          // Re-enable SPI interrupts
}

//-----------------------------------------------------------------------------
// SPI_Array_Read
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters   : None
//
// Note: SPI_Data_Array will contain the data received after calling this
// function.
//
// Reads a single byte from the SPI Slave.  The command consists of:
//
// Command = SPI_READ_BUFFER
// Length = 1 byte of command, MAX_BUFFER_SIZE bytes of data
//
//-----------------------------------------------------------------------------
void SPI_Array_Read (void)
{
   while (!NSSMD0);                    // Wait until the SPI is free, in case
                                       // it's already busy

   NSSMD0 = 0;

   Command = SPI_READ_BUFFER;

   SPI0DAT = Command;

   // The rest of this command will be handled by the SPI ISR, which will
   // trigger when SPIF is set from sending the Command
}

//-----------------------------------------------------------------------------
// Delay
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters   : None
//
// Delay for little while (used for blinking the LEDs)
//
//-----------------------------------------------------------------------------
void Delay (void)
{
   unsigned long count;

   for (count = 200000; count > 0; count--);
}

//-----------------------------------------------------------------------------
// End Of File
//-----------------------------------------------------------------------------

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩精品一区二区在线| 一本色道久久综合亚洲aⅴ蜜桃| 欧美性高清videossexo| 亚洲欧美aⅴ...| 色综合天天在线| 亚洲国产成人va在线观看天堂| 色94色欧美sute亚洲线路一ni | 国产精品一级片在线观看| 欧美日韩成人激情| 久久精品国产一区二区三区免费看| 日韩欧美国产综合在线一区二区三区 | 日韩高清不卡一区二区| 日韩美一区二区三区| 高清久久久久久| 一区二区三区蜜桃网| 日韩欧美亚洲国产另类| 国产成人超碰人人澡人人澡| 国产精品国产三级国产普通话蜜臀| 91国偷自产一区二区三区观看| 视频一区欧美日韩| 久久久一区二区三区| 色婷婷综合久久久久中文| 婷婷国产在线综合| 国产女主播一区| 欧美日韩一区二区在线观看| 韩国一区二区视频| 亚洲伦理在线免费看| 精品国产99国产精品| 成人小视频免费在线观看| 亚洲成人久久影院| 久久精品视频在线免费观看| 欧美影视一区二区三区| 国产麻豆精品久久一二三| 一区二区理论电影在线观看| www国产成人| 欧美私模裸体表演在线观看| 国产丶欧美丶日本不卡视频| 亚洲国产成人av网| 国产精品伦一区二区三级视频| 3751色影院一区二区三区| zzijzzij亚洲日本少妇熟睡| 男男gaygay亚洲| 一区二区三区四区亚洲| 久久久久国产成人精品亚洲午夜| 欧美性三三影院| 99re这里只有精品首页| 国产呦精品一区二区三区网站| 一区二区三区产品免费精品久久75| 精品不卡在线视频| 717成人午夜免费福利电影| 国产91精品一区二区麻豆网站| 日韩av不卡一区二区| 亚洲免费三区一区二区| 国产三级精品视频| 欧美不卡视频一区| 欧美丰满高潮xxxx喷水动漫| 色先锋久久av资源部| voyeur盗摄精品| 成人综合激情网| 精品一区二区三区影院在线午夜 | 国产欧美日韩视频在线观看| 欧美在线一二三| 色婷婷综合五月| 国产成人av影院| 极品尤物av久久免费看| 日本人妖一区二区| 视频一区在线播放| 日韩电影一区二区三区四区| 一区二区三区小说| 亚洲综合在线第一页| 亚洲视频资源在线| 中文字幕一区在线观看视频| 国产欧美日韩精品a在线观看| 精品99一区二区| 亚洲精品一线二线三线| 日韩视频国产视频| 日韩欧美美女一区二区三区| 91精品在线免费| 日韩情涩欧美日韩视频| 欧美www视频| 亚洲精品一区二区三区影院 | 欧美性猛交xxxxxx富婆| 欧洲生活片亚洲生活在线观看| 91视频精品在这里| 色悠悠亚洲一区二区| 欧美性高清videossexo| 91超碰这里只有精品国产| 欧美日韩国产欧美日美国产精品| 欧美卡1卡2卡| 日韩午夜在线播放| www国产亚洲精品久久麻豆| 久久久久久电影| 国产精品污网站| 亚洲免费观看在线视频| 亚洲网友自拍偷拍| 日本aⅴ免费视频一区二区三区| 日本va欧美va精品发布| 久久国产综合精品| 成人免费看片app下载| 97久久精品人人做人人爽| 色菇凉天天综合网| 欧美一区二区三区小说| 精品久久一区二区三区| 欧美国产97人人爽人人喊| 亚洲人成在线观看一区二区| 亚洲一区在线视频观看| 日产国产高清一区二区三区| 国产一区二区三区精品视频| av在线一区二区| 欧美在线视频全部完| 欧美成人a视频| 中文字幕视频一区二区三区久| 亚洲成人精品一区| 国产精品一区2区| 欧美三级午夜理伦三级中视频| 欧美一级午夜免费电影| 国产精品美女久久久久av爽李琼 | 久久精品久久99精品久久| 成人涩涩免费视频| 欧美男人的天堂一二区| 国产视频一区二区在线| 亚洲第一搞黄网站| 国产宾馆实践打屁股91| 精品国产污网站| 国产精品色眯眯| 久久精品国产网站| 色偷偷88欧美精品久久久| 久久久久九九视频| 午夜电影一区二区三区| 成人性色生活片| 日韩美女在线视频| 亚洲精品视频观看| 国产精品1区二区.| 欧美男生操女生| 亚洲欧美精品午睡沙发| 国产美女娇喘av呻吟久久| 在线观看视频一区| 中文字幕一区二区三区四区不卡| 视频在线观看一区二区三区| 91影院在线免费观看| 国产午夜精品一区二区三区嫩草 | 亚洲精品乱码久久久久| 国产91富婆露脸刺激对白| 91精品欧美一区二区三区综合在 | 丁香天五香天堂综合| 欧美一级午夜免费电影| 亚洲成a人v欧美综合天堂| 一本一道久久a久久精品| 久久久久久亚洲综合影院红桃| 男女男精品视频| 欧美亚男人的天堂| 亚洲欧美成人一区二区三区| 从欧美一区二区三区| 久久久精品免费网站| 日本午夜精品视频在线观看| 欧美三级电影在线看| 一区二区在线观看视频| 99久久99久久精品免费观看| 国产精品人成在线观看免费| 九九精品一区二区| 精品国产第一区二区三区观看体验| 日韩精品免费专区| 欧美电影一区二区| 视频一区欧美精品| 欧美高清视频一二三区| 亚洲国产wwwccc36天堂| 欧美日韩精品电影| 午夜精品福利视频网站| 欧美三区免费完整视频在线观看| 一区二区久久久久| 91黄色激情网站| 亚洲国产日韩a在线播放| 欧美日韩国产a| 性欧美大战久久久久久久久| 欧美区一区二区三区| 首页综合国产亚洲丝袜| 欧美高清dvd| 美女视频免费一区| 精品久久久影院| 国产超碰在线一区| 综合婷婷亚洲小说| 欧美唯美清纯偷拍| 日韩—二三区免费观看av| 欧美变态凌虐bdsm| 狠狠色丁香婷婷综合久久片| 国产三级精品三级| 一本大道av伊人久久综合| 日日摸夜夜添夜夜添国产精品| 日韩欧美在线观看一区二区三区| 韩国精品久久久| 亚洲婷婷综合久久一本伊一区| 在线中文字幕一区| 久久国产精品99精品国产| 久久综合久久综合久久| 91在线免费播放| 日韩精品一级中文字幕精品视频免费观看| 欧美一级免费观看| 福利电影一区二区| 亚洲成人在线网站| 欧美精品一区二区三区蜜臀|