F1 Evaluation Platform User’s Guide
5.6
USING THE I 2 C? DRIVER
The supplied software includes an I 2 C Master mode driver with the following features:
1.
2.
3.
4.
5.
6.
Interrupt driven or polled
Queued requests
Minimum memory requirements
Uses Restart to maximize bus bandwidth
Multiple atomic I 2 C transactions allowed at each queue entry
Completion flag for each queued block of I 2 C commands.
5.6.1
I 2 C Data Structures
Two data structures are defined to simplify interactions with the I 2 C driver.
5.6.1.1 I2C_RESULTS_T
The I2C_RESULTS_T is an enumerated type with the following enumerations:
TABLE 5-1:
I2C_RESULTS_T
I2C_REQUEST_PENDING
I2C_REQUEST_COMPLETE
I2C_REQUEST_STUCK_START
I2C_REQUEST_ADDRESS_NO_ACK
I2C_REQUEST_DATA_NO_ACK
I2C_REQUEST_LOST_STATE
Request is in the queue or in process but it is not
done.
The request is finished successfully.
The request was aborted. The start condition did
not clear correctly.
The request was aborted. No ACK occurred on
the address, so the target device must not exist
or is not functioning.
The request was aborted. Not all of the data
could be sent because the device did not ACK a
byte.
The I 2 C state machine had a RAM corruption
and the default case caught the failure. This will
infinite loop so you should never see it.
The data completion flag for an I 2 C request is of type I2C_RESULTS_T . This flag will
be I2C_REQUEST_PENDING until the request is complete. If the request completed
without errors, the value will be I2C_REQUEST_COMPLETE . If there were errors, the
value will reflect one of the other 4 error conditions.
5.6.1.2 I2C_T
The I2C_T is a structure representing one transaction on the I 2 C bus. A transaction
contains the following elements:
1. A 7- or 10-bit address. Address type is determined automatically by the driver.
R/W mode is implicit in the address and specified by bit 0 .
2. An 8-bit baud rate. This is the value placed in SPADD. Predefined constants are
included that compute the SPADD value given an FOSC value. Set FOSC with
a #define before #including the I2C.h file.
3. A buffer_length . This is the number of bytes available for reading or writing
at the supplied data buffer.
4. A Buffer Pointer. Your application will allocate a block of memory for an I 2 C
transaction. Pass a pointer to this block via the Buffer Pointer. The block must
remain valid until the transaction is complete (i.e. if you allocate the block as a
non-static array within a function, you must not leave the function until the I 2 C
transaction is complete or the array may be reused by a different function).
DS41401A-page 22
? 2009 Microchip Technology Inc.
相关PDF资料
DV243003 KIT STARTER FOR SRL MEM PRODUCTS
DVA1001 ADAPTER FOR PIC16F716 18DIP
DVA1004 DEVICE ADAPTER 8/14/20DIP
E3R-D12GP-P RELAY RCVR PLUG-IN DIMMER
E3R-R12-3HOTP RCVR 3WIRE RELAY 120V
E3R-R12GP RCVR PLUG-IN RELAY
E3T-MICFP-40 CONVERTER 4-CH SLT SENSOR
E3T-R12-2INTP TRANSMITTER SWITCH LEG 120V
相关代理商/技术参数
DV164132 制造商:Microchip Technology Inc 功能描述:PIC12F1xxx/PIC16F1xxx F1 Evaluation Kit
DV164133 功能描述:电源管理IC开发工具 Energy Harvesting Development Tool RoHS:否 制造商:Maxim Integrated 产品:Evaluation Kits 类型:Battery Management 工具用于评估:MAX17710GB 输入电压: 输出电压:1.8 V
DV164136 功能描述:开发板和工具包 - PIC / DSPIC PIC18F DEV Kit (with PICkit 3) RoHS:否 制造商:Microchip Technology 产品:Starter Kits 工具用于评估:chipKIT 核心:Uno32 接口类型: 工作电源电压:
DV164139 功能描述:开发板和工具包 - PIC / DSPIC Lo PIn Count USB Dev Kit (w/PICkit 3) RoHS:否 制造商:Microchip Technology 产品:Starter Kits 工具用于评估:chipKIT 核心:Uno32 接口类型: 工作电源电压:
DV17K3225T 制造商:SEI Stackpole Electronics Inc 功能描述:- Tape and Reel 制造商:SEI Stackpole Electronics Inc 功能描述:Var MOV 17VAC/22VDC 100A 27V 3225 SMD T/R
DV17K4032T 制造商:SEI Stackpole Electronics Inc 功能描述:VAR 17VAC 22VDC 250A 27V 4032 SMD - Tape and Reel 制造商:SEI Stackpole Electronics Inc 功能描述:Var MOV 17VAC/22VDC 250A 27V 4032 SMD T/R
DV18-145MB-3K 功能描述:端子 PIN -DSC 22-18 145X032 VYL RED RoHS:否 制造商:AVX 产品:Junction Box - Wire to Wire 系列:9826 线规:26-18 接线柱/接头大小: 绝缘: 颜色:Red 型式:Female 触点电镀:Tin over Nickel 触点材料:Beryllium Copper, Phosphor Bronze 端接类型:Crimp
DV18-145M-C 功能描述:端子 MALE BLADE ADAPT RoHS:否 制造商:AVX 产品:Junction Box - Wire to Wire 系列:9826 线规:26-18 接线柱/接头大小: 绝缘: 颜色:Red 型式:Female 触点电镀:Tin over Nickel 触点材料:Beryllium Copper, Phosphor Bronze 端接类型:Crimp