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

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

?? example_2833xi2c_rtc.c

?? DSPF28335基礎源碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
         // Once message has progressed past setting up the internal address
         // of the RTC, send a restart to read the data bytes from the
         // RTC. Complete the communique with a stop bit. MsgStatus is
         // updated in the interrupt service routine.
         else if(I2cMsgIn1.MsgStatus == I2C_MSGSTAT_RESTART)
         {
            DELAY_US(1000000);
			YEAR = (I2cMsgIn1.MsgBuffer[7] << 8) + I2cMsgIn1.MsgBuffer[5];
			MONTH = I2cMsgIn1.MsgBuffer[4];
			DAY = I2cMsgIn1.MsgBuffer[3];
			WEEK = I2cMsgIn1.MsgBuffer[6];
			HOUR = I2cMsgIn1.MsgBuffer[2];
			MINUTE = I2cMsgIn1.MsgBuffer[1];
			SECOND = I2cMsgIn1.MsgBuffer[0];

            // Read data portion
            while(I2CA_ReadData(&I2cMsgIn1) != I2C_SUCCESS)
            {
               // Maybe setup an attempt counter to break an infinite while
               // loop.
            }
            // Update current message pointer and message status
            CurrentMsgPtr = &I2cMsgIn1;
            I2cMsgIn1.MsgStatus = I2C_MSGSTAT_READ_BUSY;
         }
      }  // end of read section

   }   // end of for(;;)
}   // end of main


void I2CA_Init(void)
{
   // Initialize I2C
   I2caRegs.I2CMDR.all = 0x0000;	// Take I2C reset
   									// Stop I2C when suspended

   I2caRegs.I2CFFTX.all = 0x0000;	// Disable FIFO mode and TXFIFO
   I2caRegs.I2CFFRX.all = 0x0040;	// Disable RXFIFO, clear RXFFINT,

   #if (CPU_FRQ_150MHZ)             // Default - For 150MHz SYSCLKOUT
        I2caRegs.I2CPSC.all = 14;   // Prescaler - need 7-12 Mhz on module clk (150/15 = 10MHz)
   #endif
   #if (CPU_FRQ_100MHZ)             // For 100 MHz SYSCLKOUT
     I2caRegs.I2CPSC.all = 9;	    // Prescaler - need 7-12 Mhz on module clk (100/10 = 10MHz)
   #endif

   I2caRegs.I2CCLKL = 10;			// NOTE: must be non zero
   I2caRegs.I2CCLKH = 5;			// NOTE: must be non zero
   I2caRegs.I2CIER.all = 0x24;		// Enable SCD & ARDY interrupts

   I2caRegs.I2CMDR.all = 0x0020;	// Take I2C out of reset
   									// Stop I2C when suspended

   I2caRegs.I2CFFTX.all = 0x6000;	// Enable FIFO mode and TXFIFO
   I2caRegs.I2CFFRX.all = 0x2040;	// Enable RXFIFO, clear RXFFINT,

   return;
}


Uint16 I2CA_WriteData(struct I2CMSG *msg)
{
   Uint16 i;

   // Wait until the STP bit is cleared from any previous master communication.
   // Clearing of this bit by the module is delayed until after the SCD bit is
   // set. If this bit is not checked prior to initiating a new message, the
   // I2C could get confused.
   if (I2caRegs.I2CMDR.bit.STP == 1)
   {
      return I2C_STP_NOT_READY_ERROR;
   }

   // Setup slave address
   I2caRegs.I2CSAR = msg->SlaveAddress;

   // Check if bus busy
   if (I2caRegs.I2CSTR.bit.BB == 1)
   {
      return I2C_BUS_BUSY_ERROR;
   }

   // Setup number of bytes to send
   // MsgBuffer + Address
   I2caRegs.I2CCNT = msg->NumOfBytes+2;

   // Setup data to send
   I2caRegs.I2CDXR = msg->MemoryHighAddr;
   I2caRegs.I2CDXR = msg->MemoryLowAddr;
// for (i=0; i<msg->NumOfBytes-2; i++)
   for (i=0; i<msg->NumOfBytes; i++)

   {
      I2caRegs.I2CDXR = *(msg->MsgBuffer+i);
   }

   // Send start as master transmitter
   I2caRegs.I2CMDR.all = 0x6E20;

   return I2C_SUCCESS;
}


Uint16 I2CA_ReadData(struct I2CMSG *msg)
{
   // Wait until the STP bit is cleared from any previous master communication.
   // Clearing of this bit by the module is delayed until after the SCD bit is
   // set. If this bit is not checked prior to initiating a new message, the
   // I2C could get confused.
   if (I2caRegs.I2CMDR.bit.STP == 1)
   {
      return I2C_STP_NOT_READY_ERROR;
   }

   I2caRegs.I2CSAR = msg->SlaveAddress;

   if(msg->MsgStatus == I2C_MSGSTAT_SEND_NOSTOP)
   {
      // Check if bus busy
      if (I2caRegs.I2CSTR.bit.BB == 1)
      {
         return I2C_BUS_BUSY_ERROR;
      }
      I2caRegs.I2CCNT = 2;
      I2caRegs.I2CDXR = msg->MemoryHighAddr;
      I2caRegs.I2CDXR = msg->MemoryLowAddr;
      I2caRegs.I2CMDR.all = 0x2620;			// Send data to setup RTC address
   }
   else if(msg->MsgStatus == I2C_MSGSTAT_RESTART)
   {
      I2caRegs.I2CCNT = msg->NumOfBytes;	// Setup how many bytes to expect
      I2caRegs.I2CMDR.all = 0x2C20;			// Send restart as master receiver
   }

   return I2C_SUCCESS;
}

interrupt void i2c_int1a_isr(void)     // I2C-A
{
   Uint16 IntSource, i;

   // Read interrupt source
   IntSource = I2caRegs.I2CISRC.all;

   // Interrupt source = stop condition detected
   if(IntSource == I2C_SCD_ISRC)
   {
      // If completed message was writing data, reset msg to inactive state
      if (CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_WRITE_BUSY)
      {
         CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_INACTIVE;
      }
      else
      {
         // If a message receives a NACK during the address setup portion of the
         // RTC read, the code further below included in the register access ready
         // interrupt source code will generate a stop condition. After the stop
         // condition is received (here), set the message status to try again.
         // User may want to limit the number of retries before generating an error.
         if(CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_SEND_NOSTOP_BUSY)
         {
            CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_SEND_NOSTOP;
         }
         // If completed message was reading RTC data, reset msg to inactive state
         // and read data from FIFO.
         else if (CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_READ_BUSY)
         {
            CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_SEND_NOSTOP;//I2C_MSGSTAT_INACTIVE;
            for(i=0; i < CurrentMsgPtr->NumOfBytes; i++)
            {
              CurrentMsgPtr->MsgBuffer[i] = I2caRegs.I2CDRR;
            }
		 }
      }
   }  // end of stop condition detected

   // Interrupt source = Register Access Ready
   // This interrupt is used to determine when the RTC address setup portion of the
   // read data communication is complete. Since no stop bit is commanded, this flag
   // tells us when the message has been sent instead of the SCD flag. If a NACK is
   // received, clear the NACK bit and command a stop. Otherwise, move on to the read
   // data portion of the communication.
   else if(IntSource == I2C_ARDY_ISRC)
   {
      if(I2caRegs.I2CSTR.bit.NACK == 1)
      {
         I2caRegs.I2CMDR.bit.STP = 1;
         I2caRegs.I2CSTR.all = I2C_CLR_NACK_BIT;
      }
      else if(CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_SEND_NOSTOP_BUSY)
      {
         CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_RESTART;
      }
   }  // end of register access ready

   else
   {
      // Generate some error due to invalid interrupt source
      asm("   ESTOP0");
   }

   // Enable future I2C (PIE Group 8) interrupts
   PieCtrlRegs.PIEACK.all = PIEACK_GROUP8;
}

void pass()
{
    asm("   ESTOP0");
    for(;;);
}

void fail()
{
    asm("   ESTOP0");
    for(;;);
}

void WriteData(struct I2CMSG *msg,Uint16 *MsgBuffer,Uint16 MemoryAdd,Uint16 NumOfBytes)
{
	Uint16 i,Error;
	for(i = 0; i < NumOfBytes; i++)
	{
		msg->MsgBuffer[i] = MsgBuffer[i];		
	}
	msg->MemoryHighAddr = MemoryAdd >> 8;
	msg->MemoryLowAddr = MemoryAdd & 0xff;
	msg->NumOfBytes = NumOfBytes;
	Error = I2CA_WriteData(&I2cMsgOut1);

	if (Error == I2C_SUCCESS)
	{
		CurrentMsgPtr = &I2cMsgOut1;
		I2cMsgOut1.MsgStatus = I2C_MSGSTAT_WRITE_BUSY;
	}
	while(I2cMsgOut1.MsgStatus != I2C_MSGSTAT_INACTIVE);
	DELAY_US(1000);
}

//===========================================================================
// No more.
//===========================================================================

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色综合久久久久久久久| 国产大陆亚洲精品国产| 久久日韩精品一区二区五区| 99re热这里只有精品免费视频| 亚洲高清免费在线| 久久精品在线免费观看| 欧美亚一区二区| 国产馆精品极品| 日韩1区2区3区| 亚洲免费在线观看视频| 国产欧美一区二区在线| 欧美高清dvd| 色婷婷久久一区二区三区麻豆| 国产酒店精品激情| 免费在线观看不卡| 亚洲va韩国va欧美va| 国产精品视频观看| 欧美不卡在线视频| 91精品国产综合久久精品app| 99久久久无码国产精品| 国产电影精品久久禁18| 精品中文字幕一区二区| 青青草97国产精品免费观看| 亚洲一区二区av在线| 亚洲欧美在线观看| 国产婷婷一区二区| wwwwww.欧美系列| 日韩一区二区三区免费看 | 制服丝袜中文字幕亚洲| 91视频.com| 波多野结衣91| 成人在线视频一区| 国产99久久精品| 国产成人精品综合在线观看| 韩国欧美国产1区| 久久国产尿小便嘘嘘尿| 日本亚洲视频在线| 日韩国产欧美在线观看| 天天色 色综合| 视频一区二区国产| 日韩和欧美一区二区三区| 婷婷中文字幕一区三区| 天堂av在线一区| 午夜精品久久久久久久99樱桃| 亚洲一二三四在线观看| 亚洲国产精品久久人人爱| 亚洲国产日韩a在线播放| 亚洲无人区一区| 丝袜美腿亚洲综合| 蜜桃视频一区二区| 国产原创一区二区三区| 国产不卡在线播放| 99久久精品一区二区| 色悠悠久久综合| 欧美伊人久久大香线蕉综合69| 欧美日韩精品是欧美日韩精品| 欧美色精品天天在线观看视频| 欧美三级电影在线看| 欧美日韩国产美| 日韩免费一区二区三区在线播放| 日韩免费一区二区| 国产欧美1区2区3区| 亚洲视频你懂的| 亚洲尤物在线视频观看| 日韩精品福利网| 激情久久五月天| 国产成人综合在线观看| 色综合久久天天综合网| 欧美精选一区二区| 久久久夜色精品亚洲| 成人欧美一区二区三区黑人麻豆 | 亚洲高清久久久| 日韩av电影免费观看高清完整版 | 国产精品性做久久久久久| 成人久久18免费网站麻豆| 日本高清不卡在线观看| 在线成人小视频| 久久久久久亚洲综合影院红桃| 亚洲欧美日韩中文播放| 日韩高清不卡一区二区| 国产乱码精品一品二品| 色综合色综合色综合| 日韩精品一区二区三区在线| 国产女同性恋一区二区| 亚洲国产精品一区二区尤物区| 久久99精品网久久| 99久久精品99国产精品| 欧美一级在线视频| 日韩一区欧美小说| 久久精品国产成人一区二区三区| av日韩在线网站| 91精品婷婷国产综合久久性色| 欧美高清在线精品一区| 五月天国产精品| 99视频精品在线| 日韩欧美电影在线| 亚洲精品一二三四区| 国产中文一区二区三区| 欧美伊人久久大香线蕉综合69 | 亚洲成人在线免费| 国产黑丝在线一区二区三区| 在线成人免费视频| 中文字幕亚洲欧美在线不卡| 久久91精品国产91久久小草| 91麻豆国产精品久久| 久久品道一品道久久精品| 午夜精品影院在线观看| 99re视频这里只有精品| 久久九九久久九九| 日本91福利区| 欧美日韩一本到| 国产精品初高中害羞小美女文| 久久se这里有精品| 欧美高清视频在线高清观看mv色露露十八 | 国产98色在线|日韩| 日韩一区二区电影| 亚洲国产视频一区| 91在线丨porny丨国产| 国产免费观看久久| 激情五月播播久久久精品| 欧美区一区二区三区| 亚洲男人的天堂在线观看| 成人免费毛片高清视频| 国产午夜精品一区二区三区四区| 蜜桃av一区二区三区电影| 欧美日韩国产一二三| 亚洲综合视频在线| 91免费在线播放| 国产精品国产三级国产aⅴ中文| 国产乱国产乱300精品| 亚洲精品一区二区三区在线观看| 日本欧美一区二区三区乱码| 欧美日韩一区二区三区在线看| 亚洲精品精品亚洲| 色综合久久久久综合99| 亚洲精品国产成人久久av盗摄| 成人福利电影精品一区二区在线观看| 久久亚洲一级片| 国产在线日韩欧美| 久久亚洲免费视频| 国产成人免费视频网站| 国产三级一区二区三区| 国产成人av电影在线播放| 国产日韩欧美a| 岛国av在线一区| 欧美韩日一区二区三区四区| 国产成a人无v码亚洲福利| 国产精品二区一区二区aⅴ污介绍| 成人看片黄a免费看在线| 亚洲人成伊人成综合网小说| 日本韩国欧美国产| 午夜精品福利一区二区三区蜜桃| 欧美日韩在线精品一区二区三区激情| 亚洲影院理伦片| 91精品国产综合久久婷婷香蕉| 久久精品99国产精品| 国产亚洲一本大道中文在线| 成人ar影院免费观看视频| 亚洲欧美另类在线| 欧美日本在线观看| 国内精品免费**视频| 国产精品视频一二三区| 在线精品亚洲一区二区不卡| 天涯成人国产亚洲精品一区av| 日韩欧美一区二区不卡| 国产精品18久久久久久久久| 一色桃子久久精品亚洲| 91丨porny丨户外露出| 日韩一区精品视频| 久久久影院官网| 91黄色免费观看| 麻豆91小视频| 中文字幕日韩一区二区| 欧美日韩一区三区| 国产一区二区剧情av在线| 日韩毛片在线免费观看| 欧美日韩日本视频| 国产乱码精品1区2区3区| 一区二区三区不卡视频| 欧美mv日韩mv| 色噜噜狠狠色综合欧洲selulu| 日韩福利电影在线| 成人欧美一区二区三区在线播放| 在线观看91精品国产麻豆| 国产成人高清视频| 午夜精品视频在线观看| 国产日韩欧美一区二区三区乱码| 一本色道久久综合亚洲aⅴ蜜桃| 麻豆精品一区二区综合av| 国产精品成人免费| 91精品国产一区二区| 色综合久久久久综合99| 激情文学综合丁香| 亚洲成人动漫在线观看| 欧美高清在线视频| 日韩欧美在线网站| 在线国产亚洲欧美| 国产69精品一区二区亚洲孕妇| 天天射综合影视| 亚洲色图制服诱惑 |