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

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

?? f32x_spi0_master.c

?? 8051 SPI code ans 8051 ADC code
?? 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:
               array_index = 0;        // Clear the data counter

               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 = 100000; count > 0; count--);
}

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

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
午夜精品久久久久久久久| 欧美一级在线免费| 亚洲狠狠丁香婷婷综合久久久| 豆国产96在线|亚洲| 久久久久久久久久久99999| 国产在线观看一区二区| 亚洲女子a中天字幕| 91精品福利视频| 久久成人18免费观看| 久久久不卡网国产精品一区| 国产99久久久久久免费看农村| 亚洲免费观看高清完整| 日韩一区二区三区av| 韩国av一区二区三区| 国产精品毛片大码女人| 欧美日韩国产综合一区二区三区| 成人性生交大片免费看在线播放 | 免费在线视频一区| 国产精品久久久久影院亚瑟 | 极品少妇xxxx精品少妇偷拍| 久久久久久久av麻豆果冻| 在线观看日韩国产| 成人免费三级在线| 国内精品不卡在线| 亚洲成人福利片| 中文字幕国产一区二区| 精品久久久久av影院| 欧美日韩亚洲丝袜制服| 91麻豆成人久久精品二区三区| 婷婷开心久久网| 美女网站视频久久| av激情亚洲男人天堂| 日韩激情av在线| 亚洲国产精品人人做人人爽| 亚洲毛片av在线| 日韩高清欧美激情| 精品无人码麻豆乱码1区2区 | 一区二区三区电影在线播| 欧美国产成人精品| 国产精品少妇自拍| 亚洲大片精品永久免费| 亚洲精品视频一区二区| 国产精品久久一卡二卡| 亚洲欧洲av另类| 午夜亚洲国产au精品一区二区| 国产伦精品一区二区三区免费| 91麻豆精品国产91久久久久久| 水蜜桃久久夜色精品一区的特点 | 韩国三级中文字幕hd久久精品| 精品国产伦一区二区三区免费| 国产在线国偷精品免费看| 久久精品一区二区三区四区| 成人丝袜18视频在线观看| 国产精品久久久久影院亚瑟| 欧美怡红院视频| 三级影片在线观看欧美日韩一区二区| 欧美精品乱码久久久久久| 久久99精品国产.久久久久久| ww亚洲ww在线观看国产| 成人动漫在线一区| 亚州成人在线电影| 久久影院电视剧免费观看| 不卡视频一二三| 爽爽淫人综合网网站| 欧美videofree性高清杂交| 国产在线乱码一区二区三区| 欧美国产在线观看| 欧美嫩在线观看| 久久精品72免费观看| 2023国产精品| 91在线一区二区| 亚洲成av人片在线| 欧美丰满一区二区免费视频| 国产伦精一区二区三区| 欧美一区2区视频在线观看| 懂色av一区二区三区免费看| 一区二区三区高清不卡| 久久精品视频一区二区三区| 国产寡妇亲子伦一区二区| 亚洲图片自拍偷拍| 欧美日韩二区三区| 91蝌蚪porny| 一区二区三区四区激情| 久久久精品综合| 99久久精品国产精品久久 | 欧美精品久久久久久久多人混战| 国产成人亚洲综合a∨婷婷| 亚洲精品国产视频| 国产亚洲一本大道中文在线| 91视频在线看| 成人在线一区二区三区| 午夜精品福利一区二区三区av| 日韩午夜电影av| 日本久久电影网| 免费亚洲电影在线| 亚洲欧美日韩国产综合| 欧美精品一区二区蜜臀亚洲| 欧美精品 国产精品| 粉嫩嫩av羞羞动漫久久久 | 日韩av电影免费观看高清完整版| 成人欧美一区二区三区在线播放| 欧美日韩国产综合久久| 91女厕偷拍女厕偷拍高清| 黑人巨大精品欧美一区| 性做久久久久久免费观看| 国产精品国产a| 亚洲国产精品ⅴa在线观看| 日韩一级片网站| 6080国产精品一区二区| 99久久精品免费看| 99久久er热在这里只有精品15| 老色鬼精品视频在线观看播放| 偷拍一区二区三区| 亚洲乱码国产乱码精品精可以看 | 玉足女爽爽91| 国产精品国产三级国产三级人妇| 欧美成人福利视频| 欧美精三区欧美精三区| eeuss国产一区二区三区| 国产一区二区三区四区五区入口| 丝袜国产日韩另类美女| 亚洲网友自拍偷拍| 亚洲午夜视频在线| 综合久久给合久久狠狠狠97色| 国产精品久久久久一区 | 最近中文字幕一区二区三区| 亚洲精品一区二区三区影院| 欧美一级xxx| 欧美一区二区三区四区五区| 欧美日本不卡视频| 波多野结衣一区二区三区| 国产91在线观看| 国产精品一区二区在线看| 国产精品一区二区三区乱码| 国产精品99久久久久久有的能看| 日本一区中文字幕| 五月天丁香久久| 日韩 欧美一区二区三区| 蜜桃传媒麻豆第一区在线观看| 日本不卡免费在线视频| 日本大胆欧美人术艺术动态| 精品一区二区三区免费毛片爱| 精品一区二区三区日韩| 国产成人精品免费一区二区| 91视频国产观看| 成人av午夜影院| 欧美高清激情brazzers| 日韩欧美电影一区| www.爱久久.com| 欧美一级日韩不卡播放免费| 欧美日韩小视频| 91麻豆精品一区二区三区| 91麻豆高清视频| 欧美乱熟臀69xxxxxx| 日韩视频不卡中文| 国产午夜亚洲精品不卡| 中文字幕高清不卡| 午夜久久久影院| 国产一区二区三区美女| 99精品久久99久久久久| 一本色道**综合亚洲精品蜜桃冫| 欧美视频日韩视频在线观看| 日韩一区二区在线播放| 国产欧美日韩亚州综合| 一区二区三区免费看视频| 亚洲图片你懂的| 视频在线观看国产精品| 日本女优在线视频一区二区| 粉嫩在线一区二区三区视频| 正在播放亚洲一区| 亚洲欧洲av在线| 美女视频黄免费的久久| 色婷婷综合在线| 久久色成人在线| 国产欧美日韩亚州综合| 亚洲一区二区三区四区在线免费观看 | 国内成+人亚洲+欧美+综合在线| 久久电影国产免费久久电影| 91在线视频网址| 日韩亚洲欧美成人一区| 久久久国产午夜精品| 亚洲天堂成人在线观看| 亚洲国产成人精品视频| 国产69精品久久久久777| 欧美夫妻性生活| 一区二区三区 在线观看视频 | 免费成人小视频| 国产成人精品一区二区三区网站观看| 欧美综合色免费| 国产精品成人一区二区三区夜夜夜| 日韩国产精品久久久| 色噜噜久久综合| 中文字幕精品—区二区四季| 蜜桃av噜噜一区| 欧美精品乱人伦久久久久久| 亚洲午夜私人影院| 成人妖精视频yjsp地址| 久久只精品国产| 婷婷激情综合网| 91玉足脚交白嫩脚丫在线播放|