惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
CERT Recently Published Vulnerability Notes
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
Stack Overflow Blog
Stack Overflow Blog
aimingoo的专栏
aimingoo的专栏
C
Check Point Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Tor Project blog
P
Proofpoint News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Latest news
Latest news
L
LINUX DO - 热门话题
罗磊的独立博客
T
Tenable Blog
The Hacker News
The Hacker News
美团技术团队
N
Netflix TechBlog - Medium
V
Vulnerabilities – Threatpost
阮一峰的网络日志
阮一峰的网络日志
Last Week in AI
Last Week in AI
博客园 - 司徒正美
Jina AI
Jina AI
Cyberwarzone
Cyberwarzone
云风的 BLOG
云风的 BLOG
S
Secure Thoughts
Cloudbric
Cloudbric
S
Security @ Cisco Blogs
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Security Blog
Microsoft Security Blog
Spread Privacy
Spread Privacy
U
Unit 42
雷峰网
雷峰网
C
CXSECURITY Database RSS Feed - CXSecurity.com
Webroot Blog
Webroot Blog
爱范儿
爱范儿
博客园 - 【当耐特】
Know Your Adversary
Know Your Adversary
P
Privacy International News Feed
P
Palo Alto Networks Blog
Google Online Security Blog
Google Online Security Blog
The Last Watchdog
The Last Watchdog
博客园 - 聂微东
Help Net Security
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
F
Full Disclosure
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Security Affairs
Project Zero
Project Zero

博客园 - lbq1221119

时间同步算法与Simple Ring-based election algorithm算法分析 SSCLI中GC垃圾回收源码分析(3) - GarbageCollectGeneration()与SuspendEE SSCLI中GC垃圾回收源码分析(2) - GarbageCollect()与Spin Lock SSCLI中GC源码分析(1) - EE与BCL之间的调用接口FCall (北京宇思信德科技公司)诚聘C#软件工程师 , Middle及Senior Level .Net Micro framework在开发过程中的bugs/problems及解决方案。 MF中使用GPRS:如何通过一个串口终端实现GPRS Modem拨号上网 博客园北京俱乐部第三次活动讲义PPT ValueType.Equals(null)的底层实现及CLR虚拟机对其结构支持 WebService传输数据流及数据交互解析 托管线程退出之后Dump文件特征 国外精品研究论文(持续更新) Random()中具体实现(含种子数组的实现) From double Click to Main: PAL initialization - lbq1221119 From double Click to Main: The initialization of Process in OS 使用CorDbg进行托管调试 CLR内核调试之:Malloc函数实现 Build SSCLI20 under VS2008 full Document (完全手册) MethodTable内存空间分配中加法运算算法解析
Microsoft Micro Framework 3.0对Serial Peripheral Interface 的支持
lbq1221119 · 2008-12-05 · via 博客园 - lbq1221119

         3.0Micro Framework中,咱可以使用SPISerial Peripheral Interface)来和外围设备进行通信了。SPI是一种串口总线系统,和I2CCANUSB一样。        

         使用SPI来进行串口通信中,从设备的通讯模式如下:

         两个数据口,一个进一个出,另外两个控制口。在标准SPI通信模式中,设备分为master设备和slave设备。Master设备决定clock信号和线路状态。多个slave设备之间可以串联:

         上图里面,这些串联的设备看起来象是一个设备,也可以这样连接:

         SPI MasterCPOL CPHA分别改变01的状态,就可以对应到SPI Device的四个状态:

SPI-Mode

CPOL

CPHA

0

0

0

1

0

1

2

1

0

3

1

1

         所以在Microsoft.SPOT.Hardware.SPI的实现中,就包含了以上四种状态。

         另外,外围设备有很多中,主要可以分为下面五种类型:

1.         Converters (ADC and DAC)

2.         Memories (EEPROM and FLASH)

3.         Real Time Clocks (RTC)

4.         Sensors (temperature, pressure)

5.         Others (signalmixer, potentiometer, LCD controller, UART, CAN controller, USB controller, amplifier)

前三种外围设备是最多的,后面两种就少多了。那什么时候适用SPI来进行通信呢?

存储设备,主要是EEPROM的变种,也有一些少量的SPI存储设备。容量从几个bits64Kbit不等。时钟频率可以到3MHZ。串行的EEPROMS SPI可以提供2.7V5V的电压,同时,保存的数据可以从10100年。每个组件,可以读写1000000次以上。

RTCs是比较适合用SPI来进行通信的。因为只有少量的数据需要传输。

OK,最后看看MicrosoftMF种实现的对SPI的支持为咱提供了什么功能:

Microsoft.SPOT.Hardware.SPI

public sealed class SPI : IDisposable

{

    // Fields

    private Configuration m_config;

    private OutputPort m_cs;

    private bool m_disposed;

    // Methods

    public SPI(Configuration config);

    public void Dispose();

    [MethodImpl(MethodImplOptions.Synchronized)]

    private void Dispose(bool fDisposing);

    protected override void Finalize();

    [MethodImpl(MethodImplOptions.InternalCall)]

    public extern void InternalWriteRead(byte[] writeBuffer, byte[] readBuffer, int readOffset);

    [MethodImpl(MethodImplOptions.InternalCall)]

    public extern void InternalWriteRead(ushort[] writeBuffer, ushort[] readBuffer, int readOffset);

    public void Write(byte[] writeBuffer);

    public void Write(ushort[] writeBuffer);

    public void WriteRead(byte[] writeBuffer, byte[] readBuffer);

    public void WriteRead(ushort[] writeBuffer, ushort[] readBuffer);

    public void WriteRead(byte[] writeBuffer, byte[] readBuffer, int readOffset);

    public void WriteRead(ushort[] writeBuffer, ushort[] readBuffer, int readOffset);

    // Properties

    public Configuration Config { get; set; }

    // Nested Types

    public class Configuration

    {

        // Fields

        public readonly bool ChipSelect_ActiveState;

        public readonly uint ChipSelect_HoldTime;

        public readonly Cpu.Pin ChipSelect_Port;

        public readonly uint ChipSelect_SetupTime;

        public readonly bool Clock_Edge;

        public readonly bool Clock_IdleState;

        public readonly uint Clock_RateKHz;

        public readonly SPI.SPI_module SPI_mod;

        // Methods

        public Configuration(Cpu.Pin ChipSelect_Port, bool ChipSelect_ActiveState, uint ChipSelect_SetupTime, uint ChipSelect_HoldTime, bool Clock_IdleState, bool Clock_Edge, uint Clock_RateKHz, SPI.SPI_module SPI_mod);

    }

    public enum SPI_module

    {

        SPI1,

        SPI2,

        SPI3,

        SPI4

    }

}

Lbq1221119@cnblogs.com Friday, December 05, 2008