200 likes | 525 Views
I 2 C Bus Drivers for Windows 2K, XP. Pavel No vák Tomáš Ma toušek. I 2 C Basic Characteristics. Inter-Integrated Circuts Bus originally to interact within small num. of devs (radio/TV tuning, …) max. speeds: 100 kbps ( standard mode ) 400 kbps (fast mode) 3 . 4 Mbps (high-speed mode)
E N D
I2C Bus Driversfor Windows 2K, XP Pavel Novák Tomáš Matoušek
I2C Basic Characteristics • Inter-Integrated Circuts Bus • originally to interact within small num. of devs (radio/TV tuning, …) • max. speeds: • 100 kbps (standard mode) • 400 kbps (fast mode) • 3.4 Mbps (high-speed mode) • data transfers: serial, 8-bit oriented, bi-directional • master/slave relationships with multi-master option (arbitration) • master can operate as transmitter or receiver • addressing: 7bit or 10bit unique addresses
Wires and Signals • two-wired bus • serial data line (SDA) • serial clock line (SCL) • bit transfer • level triggered • one clock pulse per data bit • stable data during high clocks • data change during low clocks
Wired-AND Connection • open collectors, pull-up resistors • bus is free SDA and SCL are high
Frame Formats master-transmitter master-receiver (since second byte)
Addressing by 7 bits • the first byte transmitted by master: • 7 bits: address • 1 bit: direction (R/W) 0 … master writes data (W) – transmitter since next byte 1 … master reads data (R) – receiver since next byte • during the first byte transfer: • master is transmitter • addressed slave is receiver • data transfer terminated by a stop condition • master may generate repeated start and address another device
Microchip PIC16F628 • 8-bit 20MHz RISC microcontroller • USART • Rx, Tx, DTR, DSR for communication • RTS resetting, low voltage programming • memory • FLASH program (2048 x 14bit) • RAM data (224B) • EEPROM data (128B) • hardware stack (8 levels) • interrupts, 3 timers, 16 I/O pins • 35 instructions • single-cycled except for 2-cycled branches
Layered Drivers TCP/IP drivers TCP/IP drivers NDIS.sys NDIS.sys I2CNET.sys I2CNET.sys Ethernet over I2C I2C.sys I2C.sys link layer Serial.sys Serial.sys PC UART PC UART PIC16F628 PIC16F628 physical layer I2C bus I2C bus
Network Driver Interface Specification (NDIS) • Common interface for network drivers • specification not only for device drivers • includes: • Miniport drivers • Intermediate drivers • Protocol drivers
NDIS Miniport Implementation • DriverEntry() • driver initialization • calls NdisMRegisterMiniport() • informs NDIS about new Miniport driver • MiniportInitialize() • – called by NDIS for each instance of network controller device • MiniportHalt() • MiniportReset() • MiniportShutdown()
Information Transmission – To NDIS NDIS_STATUS MiniportQueryInformation(IN NDIS_HANDLEMiniportAdapterContext,IN NDIS_OIDOid,IN PVOIDInformationBuffer,…OUT PULONGBytesWritten,…); Oids:OID_GEN_MEDIA_SUPPORTED // EthernetOID_GEN_LINK_SPEEDOID_GEN_MEDIA_CONNECT_STATUSOID_PNP_CAPABILITIESOID_802_3_PERMANENT_ADDRESSOID_GEN_XMIT_OK…
Information Transmission – To Our Driver NDIS_STATUS MiniportSetInformation(IN NDIS_HANDLE MiniportAdapterContext,IN NDIS_OIDOid,IN PVOIDInformationBuffer,…OUT PULONGBytesRead,…); Oids:OID_GEN_NETWORK_LAYER_ADDRESSESOID_GEN_CURRENT_PACKET_FILTEROID_PNP_SET_POWER…
Data Transfer – To Network NDIS_STATUS MiniportSend(IN NDIS_HANDLE MiniportAdapterContext,IN PNDIS_PACKET Packet,…); NdisQueryPacket(Packet,…,&Buffer…);
Data Transfer – From Network VOID NdisMEthIndicateReceive(IN NDIS_HANDLE MiniportAdapterHandle,IN NDIS_HANDLE MiniportReceiveContext,IN PVOID HeaderBuffer,…IN PVOID LookaheadBuffer,…IN UINT PacketSize); NDIS_STATUS MiniportTransferData(OUT PNDIS_PACKETPacket,…IN NDIS_HANDLEMiniportAdapterContext,IN NDIS_HANDLEMiniportReceiveContext,……);
Further Information • The I2C Bus Specification, version 2.1, January 2000 www.semiconductors.philips.com/buses/i2c • Microchip PIC16F627/8 Data Sheet ww1.microchip.com/downloads/en/DeviceDoc/40300c.pdf • WinPic - A PIC Programmer for Windows www.qsl.net/dl4yhf/winpicpr.html • PIC C compiler www.ccsinfo.com/picc.shtml