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

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

?? spi_x25.c

?? 調度器與SPI接口完美的結合,一種嶄新的編程思路
?? C
字號:
/*------------------------------------------------------------------*-

   SPI_X25.C (v1.00)

  ------------------------------------------------------------------

   Simple SPI library for Atmel AT89S53
   - allows data storage on Xicor X25138 EEPROM (or similar)


   COPYRIGHT
   ---------

   This code is from the book:

   PATTERNS FOR TIME-TRIGGERED EMBEDDED SYSTEMS by Michael J. Pont 
   [Pearson Education, 2001; ISBN: 0-201-33138-1].

   This code is copyright (c) 2001 by Michael J. Pont.
 
   See book for copyright details and other information.

-*------------------------------------------------------------------*/

#include "Main.H"
#include "Port.h"

#include "SPI_Core.h"
#include "SPI_X25.h"
#include "TimeoutH.h"

// ------ Public variable declarations -----------------------------

// Used to display the error code
// See Main.H for details of error codes
// See Port.H for details of the error port
extern tByte Error_code_G;

// ------ Private function prototypes ------------------------------

void SPI_Delay_T0(void);
void SPI_X25_Read_Status_Register(void);

/*------------------------------------------------------------------*-

  SPI_X25_Write_Byte()

  Store a byte of data on the EEPROM.

-*------------------------------------------------------------------*/
void SPI_X25_Write_Byte(const tWord ADDRESS, const tByte DATA)
   {
   // 0. We check the status register
   SPI_X25_Read_Status_Register();  
   
   // 1. Pin /CS is pulled low to select the device
   SPI_CS = 0;
  
   // 2. The 'Write Enable' instruction is sent (0x06)
   SPI_Exchange_Bytes(0x06);

   // 3. The /CS must now be pulled high
   SPI_CS = 1;

   // 4. Wait (briefly)
   SPI_Delay_T0();

   // 5. Pin /CS is pulled low to select the device
   SPI_CS = 0;
  
   // 6. The 'Write' instruction is sent (0x02)
   SPI_Exchange_Bytes(0x02);

   // 7. The address we wish to read from is sent.  
   //    NOTE: we send a 16-bit address: 
   //    - depending on the size of the device, some bits may be ignored.
   SPI_Exchange_Bytes((ADDRESS >> 8) & 0x00FF);  // Send MSB
   SPI_Exchange_Bytes(ADDRESS & 0x00FF);         // Send LSB

   // 8. The data to be written is shifted out on MOSI
   SPI_Exchange_Bytes(DATA);

   // 9. Pull the /CS pin high to complete the operation
   SPI_CS = 1;
   }


/*------------------------------------------------------------------*-

  SPI_X25_Read_Byte()

  Read a byte of data from the EEPROM.

-*------------------------------------------------------------------*/
tByte SPI_X25_Read_Byte(const tWord ADDRESS)
   {
   tByte Data;

   // 0. We check the status register
   SPI_X25_Read_Status_Register();  
   
   // 1. Pin /CS is pulled low to select the device
   SPI_CS = 0;
  
   // 2. The 'Read' instruction is sent (0x03)
   SPI_Exchange_Bytes(0x03);

   // 3. The address we wish to read from is sent.  
   // NOTE: we send a 16-bit address: 
   // depending on the size of the device, some bits may be ignored.
   SPI_Exchange_Bytes((ADDRESS >> 8) & 0x00FF);
   SPI_Exchange_Bytes(ADDRESS & 0x00FF);

   // 4. The data requested is shifted out on SO by sending a dummy byte
   Data = SPI_Exchange_Bytes(0x00);

   // 5. We pull the /CS pin high to complete the operation
   SPI_CS = 1;

   return Data; // Return SPI data byte
   }

/*------------------------------------------------------------------*-

  SPI_X25_Read_Status_Register()

  We read the status register only to make sure that previous
  'Write' operations (if any) are now complete.

  To do this, we check the WIP ('Write In Progress') flag.

  *** NB: THE INTERNAL EEPROM WRITE OPERATION TAKES UP 10ms ***
  *** Schedule writes (and reads after writes) at sensible ***
  *** intervals - or you will get task jitter ***

  We timeout after ~15ms.

  Uses T0 for (hardware) timeout - see Chapter 15.

-*------------------------------------------------------------------*/
void SPI_X25_Read_Status_Register()
   {
   tByte Data;
   bit Wip;

   // Configure Timer 0 as a 16-bit timer 
   TMOD &= 0xF0; // Clear all T0 bits (T1 left unchanged)
   TMOD |= 0x01; // Set required T0 bits (T1 left unchanged) 

   ET0 = 0;  // No interrupts

   // Simple timeout feature - approx 15ms
   TH0 = T_15ms_H; // See TimeoutH.H for T_ details
   TL0 = T_15ms_L;
   TF0 = 0; // Clear flag
   TR0 = 1; // Start timer

   do {
      // 0. Pin /CS is pulled low to select the device
      SPI_CS = 0;

      // 1. The 'RDSR' instruction is sent (0x05)
      SPI_Exchange_Bytes(0x05);

      // 2. The contents of the ROM status register are read
      Data = SPI_Exchange_Bytes(0x00);

      // 3. Pull the /CS pin high to complete the operation
      SPI_CS = 1;

      // Check the WIP flag
      Wip = (Data & 0x01);
      } while ((Wip != 0) && (TF0 != 1));

   TR0 = 0;  

   if (TF0 == 1)
      {
      // ROM timed out
      Error_code_G = ERROR_SPI_X25_TIMEOUT;
      }
   } 

/*------------------------------------------------------------------*-

  SPI_Delay_T0()

  A delay of approx 50 祍 using 'timeout' code.

-*------------------------------------------------------------------*/
void SPI_Delay_T0(void)
   {
   // Configure Timer 0 as a 16-bit timer 
   TMOD &= 0xF0; // Clear all T0 bits (T1 left unchanged)
   TMOD |= 0x01; // Set required T0 bits (T1 left unchanged) 

   ET0 = 0;  // No interrupts

   // Simple timeout feature - approx 50 祍
   TH0 = T_50micros_H; // See TimeoutH.H for T_ details
   TL0 = T_50micros_L;
   TF0 = 0; // Clear flag
   TR0 = 1; // Start timer

   while (!TF0);

   TR0 = 0;  
   }
  
/*------------------------------------------------------------------*-
  ---- END OF FILE -------------------------------------------------
-*------------------------------------------------------------------*/ 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品香蕉一区二区三区| 亚洲老妇xxxxxx| 99视频热这里只有精品免费| 丝袜美腿高跟呻吟高潮一区| 国产目拍亚洲精品99久久精品| 一本一道综合狠狠老| 蜜臀av性久久久久蜜臀aⅴ流畅 | 国产女同互慰高潮91漫画| 91福利视频在线| 国产成人精品aa毛片| 天堂av在线一区| 中文字幕一区二| 日韩美女在线视频| 欧美中文字幕一区二区三区| 国产福利精品一区| 老司机免费视频一区二区三区| 一区二区三区鲁丝不卡| 国产欧美一区视频| 26uuu国产电影一区二区| 欧美精品丝袜中出| 色丁香久综合在线久综合在线观看| 国产一区二区精品久久91| 午夜私人影院久久久久| 亚洲蜜桃精久久久久久久| 国产精品久线在线观看| 久久一区二区三区四区| 日韩一区二区中文字幕| 欧美性猛交xxxx乱大交退制版| 成人app在线观看| 国产麻豆精品在线观看| 精品夜夜嗨av一区二区三区| 日本美女视频一区二区| 亚洲高清在线视频| 亚洲已满18点击进入久久| 亚洲欧洲综合另类| 最新不卡av在线| 自拍偷在线精品自拍偷无码专区| 国产精品亲子乱子伦xxxx裸| 日本一二三不卡| 国产精品视频一二| 国产精品每日更新| 国产精品伦理在线| 国产精品色婷婷久久58| 国产精品午夜在线观看| 中文字幕二三区不卡| 国产精品无圣光一区二区| 中文字幕av免费专区久久| 国产欧美一区二区三区沐欲| 久久免费精品国产久精品久久久久| 3d成人动漫网站| 欧美体内she精视频| 岛国精品一区二区| 国产精品一二三四| 国内精品伊人久久久久影院对白| 欧美96一区二区免费视频| 天堂蜜桃一区二区三区| 午夜影院在线观看欧美| 婷婷国产v国产偷v亚洲高清| 亚洲国产另类av| 午夜激情一区二区三区| 天天色综合成人网| 三级影片在线观看欧美日韩一区二区 | 日韩电影在线观看一区| 日韩中文字幕一区二区三区| 日韩精品国产精品| 免费亚洲电影在线| 精品一区二区成人精品| 麻豆成人免费电影| 亚洲一二三区不卡| 亚洲自拍偷拍网站| 亚洲一级电影视频| 日韩二区在线观看| 精品在线播放免费| 国产久卡久卡久卡久卡视频精品| 成人午夜精品在线| 97se亚洲国产综合自在线| 91麻豆视频网站| 欧洲视频一区二区| 在线一区二区三区四区| 欧美猛男超大videosgay| 666欧美在线视频| 久久天天做天天爱综合色| 国产精品毛片久久久久久久| 亚洲一区二区影院| 久久99精品国产| 成人免费高清在线| 欧美日韩色一区| 日韩免费一区二区| 久久久久久久综合色一本| 国产精品乱人伦中文| 亚洲一区二区三区四区在线免费观看 | 欧美国产视频在线| 亚洲精品国产无套在线观| 日韩av一二三| 精品制服美女久久| 欧美视频中文字幕| 久久蜜桃香蕉精品一区二区三区| 亚洲视频在线观看三级| 奇米一区二区三区| 成人免费的视频| 欧美日本精品一区二区三区| 欧美激情在线一区二区| 亚洲国产视频直播| 国产一区二区精品久久91| 成人午夜在线播放| 精品奇米国产一区二区三区| 亚洲午夜久久久| 成人高清视频免费观看| 精品国产欧美一区二区| 亚洲欧美日韩一区二区 | 91精品国产综合久久福利| 久久色成人在线| 亚洲一级片在线观看| 国产成人综合亚洲网站| 欧美日韩午夜影院| 亚洲欧美影音先锋| 久久不见久久见免费视频7| 一本色道亚洲精品aⅴ| 欧美电影精品一区二区| 亚洲精品日产精品乱码不卡| 国产一区二区电影| 欧美伦理电影网| 国产精品美日韩| 国产一区二区福利| 欧美一级二级在线观看| 亚洲午夜av在线| caoporen国产精品视频| 日韩亚洲欧美在线| 日本不卡视频在线| 欧美日韩精品电影| 一区二区欧美在线观看| 不卡的av网站| 久久精品欧美一区二区三区不卡| 激情六月婷婷综合| 日韩精品一区二区三区中文不卡 | 国产精品一区二区三区网站| 欧美一级高清片在线观看| 日韩二区三区四区| 欧美日本一道本| 亚洲综合无码一区二区| 91免费看片在线观看| 中文av一区特黄| 国产精品911| 久久精品一区二区三区av| 久久不见久久见免费视频1| 在线精品国精品国产尤物884a| 亚洲精品日日夜夜| 色噜噜狠狠色综合欧洲selulu| 国产精品久久久久婷婷 | 色婷婷狠狠综合| 日本一区二区三区在线不卡| 国产精品资源网站| 久久精品一二三| 国产.欧美.日韩| 欧美高清在线视频| 国产精品一二三四五| 中文字幕亚洲在| 91玉足脚交白嫩脚丫在线播放| 中文字幕第一页久久| 99久久久久久| 国产女同互慰高潮91漫画| 成人免费精品视频| 成人欧美一区二区三区黑人麻豆 | 男女激情视频一区| 91精品国产手机| 日韩精品乱码免费| 久久久国产精品麻豆| 菠萝蜜视频在线观看一区| 亚洲天堂网中文字| 欧美性色综合网| 三级欧美韩日大片在线看| 欧美电视剧免费观看| 国产福利精品导航| 亚洲素人一区二区| 欧美日韩国产免费| 国产一区二区三区免费观看| 国产精品久久久久桃色tv| 色哟哟国产精品| 天天av天天翘天天综合网色鬼国产| 欧美老女人第四色| 老司机精品视频在线| 中文字幕国产精品一区二区| 色国产精品一区在线观看| 亚洲精品乱码久久久久久久久| 精品视频在线免费观看| 麻豆精品一二三| 国产精品视频yy9299一区| 欧美色倩网站大全免费| 久久机这里只有精品| 国产精品三级电影| 欧美天堂一区二区三区| 久久国产成人午夜av影院| 久久久精品免费观看| 在线视频国产一区| 九九国产精品视频| 亚洲美女淫视频| 精品成人佐山爱一区二区| 91免费视频网| 国产综合久久久久久鬼色| 一区二区激情小说|