Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced Operating Systems The I 2 C Bus. Inter-Integrated Circuit Bus Designed for low-cost, medium data rate applications. Characteristics: –Synchronous;

Similar presentations


Presentation on theme: "Advanced Operating Systems The I 2 C Bus. Inter-Integrated Circuit Bus Designed for low-cost, medium data rate applications. Characteristics: –Synchronous;"— Presentation transcript:

1 Advanced Operating Systems The I 2 C Bus

2 Inter-Integrated Circuit Bus Designed for low-cost, medium data rate applications. Characteristics: –Synchronous; – serial; –multiple-master; –fixed-priority arbitration. Several microcontrollers come with built-in I 2 C controllers. –PC based version is called SMBus I 2 C bus

3 I 2 C physical layer master 1master 2 slave 1slave 2 SCL SDL data line clock line

4 I 2 C data format SCL SDL... MSBstart... ack...

5 I 2 C electrical interface SDL + SCL +

6 I 2 C signaling Sender pulls down bus for 0. Sender listens to bus---if it tried to send a 1 and heard a 0, someone else is simultaneously transmitting. Transmissions occur in 8-bit bytes.

7 I 2 C data link layer Every device has an address (7 bits in standard, 10 bits in extension). –Bit 8 of address signals read or write. General call address allows broadcast.

8 I 2 C bus arbitration Sender listens while sending address. When sender hears a conflict, if its address is higher, it stops signaling. Low-priority senders relinquish control early enough in clock cycle to allow bit to be transmitted reliably.

9 I 2 C transmissions multi-byte write read from slave write, then read Sadrs0data P Sadrs1dataP Sadrs0dataSadrs1dataP

10 I2C on the Puppeteer I2C is used on the puppeteer board Used to control VNRAM on an EEPROM –ATMEL AT24C02AN Also used for clock RTC-8563SA/JE Has two external connection – via liberator connector & via the expansion socket at the end of the board The BSP use I 2 C for setting up the boards setting – user access is through config and config commit

11 I 2 C on the Puppeteer The use of I 2 C on the Puppeteer is instructive The onboard eeprom holds non-volatile data –Boot settings –Default uarts –Ethernet MAC address –FPGA set up code base address Why not use Flash?

12 I 2 C on the Puppeteer The SDA and SCL lines are connected through the StrongARM’s General Purpose IO lines –SDA 15 –SDC 14 There is some set up required to make sure that these pins are for this dedicated function.

13 #define GPIO_BASE 0x90040000 struct gpioreg { int gplr; // R int gpdr; // RW int gpsr; // W int gpcr; // W int grer; // RW int gfer; // RW int gedr; // RW int gafr; // RW }; /* * I2C data (SDA) and clock (SCL) lines. craig */ #define BIT1 0x02 #define BIT14 0x4000 #define BIT15 0x8000 #define I2C_SDA BIT14 /* GPIO 14 */ #define I2C_SCL BIT15 /* GPIO 15 */

14 *------------------------------------------------------------------- * FUNCTION NAME : Init * ARGUMENTS : I2CLineDriver_t* pThis - Pointer to driver. * RETURNS : - * DESCRIPTION : Initialises hardware related to the * : I2C data and clock lines. *------------------------------------------------------------------*/ static void Init( I2CLineDriver_t* pThis) { volatile struct gpioreg* pGPIORegs = (volatile struct gpioreg*)GPIO_BASE; /************************************************ * * Check arguments. * ***********************************************/ if (!pThis) return; /************************************************ * * Return if routine has already been called. * ***********************************************/

15 if (pThis->bInitialised) return; /************************************************ * If required, configure the I2C clock and * data pins as GPIO lines in the alternate * function register (GAFR) ***********************************************/ if (I2C_SCL > BIT1) pGPIORegs->gafr &= ~(I2C_SCL); if (I2C_SDA > BIT1) pGPIORegs->gafr &= ~(I2C_SDA); /************************************************ * Initially set the pins up as inputs (no drive * from CPU, hence should be pulled high by the * external resistors). ***********************************************/ pGPIORegs->gpdr &= ~(I2C_SCL | I2C_SDA); /************************************************ * Set the initialised flag. * ***********************************************/ pThis->bInitialised = TRUE; } /* end Init */

16 *------------------------------------------------------------------- * FUNCTION NAME : GetData * ARGUMENTS : I2CLineDriver_t* pThis - Pointer to driver. * RETURNS : - * DESCRIPTION : Returns the state of the I2C data line. *------------------------------------------------------------------*/ static BOOL GetData(I2CLineDriver_t* pThis) { volatile struct gpioreg* pGPIORegs = (volatile struct gpioreg*)GPIO_BASE; if (!pThis) return FALSE; /************************************************ * Ensure that the driver has been initialised. ***********************************************/ if (!pThis->bInitialised) pThis->Init(pThis); /************************************************ * Configure the I2C data line as an input. ***********************************************/ pGPIORegs->gpdr &= ~(I2C_SDA); /************************************************ * Sample the data line. ***********************************************/ if (pGPIORegs->gplr & I2C_SDA) return TRUE; else return FALSE; } /* end GetData */


Download ppt "Advanced Operating Systems The I 2 C Bus. Inter-Integrated Circuit Bus Designed for low-cost, medium data rate applications. Characteristics: –Synchronous;"

Similar presentations


Ads by Google