30.10.2014 Views

o_195h4n6al16jb186b1b2qs7fgssa.pdf

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Arguments: None<br />

Return Value None<br />

Remarks: This function will be in a wait state until Start Condition Enable bit,<br />

Stop<br />

Condition Enable bit, Receive Enable bit, Acknowledge Sequence<br />

Enable bit of I<br />

2<br />

CControl register and Transmit Status bit I<br />

2<br />

CStatus<br />

register are clear. The IdleI2C function is required since the hardware<br />

I<br />

2<br />

Cperipheral does not allow for spooling of bus sequence. The I<br />

2<br />

C<br />

peripheral must be in Idle state before an I<br />

2<br />

Coperation can be initiated<br />

or write collision will be generated.<br />

Source File: IdleI2C.c<br />

Code Example: IdleI2C();<br />

ConfigIntI2C (Continued)<br />

dsPIC Peripheral Libraries<br />

2004 Microchip Technology Inc. DS51456B-page 185<br />

MastergetsI2C<br />

Description: This function reads predetermined data string length from the I<br />

2<br />

Cbus.<br />

Include: i2c.h<br />

Prototype: unsigned int MastergetsI2C(unsigned int length,<br />

unsigned char *rdptr, unsigned int i2c_data_wait);<br />

Arguments: length Number of bytes to read from I<br />

2<br />

Cdevice.<br />

rdptr Character type pointer to dsPIC ram for storage of data<br />

read from I<br />

2<br />

Cdevice<br />

chức năng thực hiện các chức năng tương tự như MasterputcI2C.<br />

Source File: MasterWriteI2C.c<br />

Mã số Ví dụ: MasterWriteI2C ('a');<br />

NotAckI2C<br />

Mô tả: Tạo ra tôi<br />

2<br />

Cbus Không Thừa nhận điều kiện.<br />

Bao gồm: i2c.h<br />

Prototype: void NotAckI2C (void);<br />

Lập luận: Không<br />

Trở lại giá trị Không<br />

Bình luận: Chức năng này tạo ra một tôi<br />

2<br />

Cbus Không Thừa nhận điều kiện.<br />

Source File: NotAckI2C.c<br />

Mã số Ví dụ: NotAckI2C ();<br />

dsPIC Thư viện ngoại vi<br />

2004 Microchip Technology Inc DS51456B trang 187<br />

OpenI2C<br />

Mô tả: Cấu hình tôi<br />

2<br />

Cmodule.<br />

Bao gồm: i2c.h<br />

Prototype: void OpenI2C (int config1, int<br />

config2);<br />

Đối số: config1 này chứa các tham số cấu hình I2CCON<br />

đăng ký<br />

Tôi<br />

2<br />

Bit CEnable<br />

I2C_ON<br />

I2C_OFF<br />

Tôi<br />

2<br />

CStop trong chế độ nhàn rỗi bit<br />

I2C_IDLE_STOP<br />

I2C_IDLE_CON<br />

SCL phát hành kiểm soát bit<br />

I2C_CLK_REL

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!