Component - I2C V3.1 Datasheet (Chinese).pdf

®
PSoC Creator™
I2C
/
/
3.1





NXP® I2C
SCL…† I2C
€•‚ƒ„SDA
100/400/1000 kbps
Š‹ API
‡
ˆ‰
Œ•Ž••‘
’“
I2C
–
I2C
¸–
I2C
Ÿ I2C
›
”•–I2C
¡¢£¤¥¦§¨©£¤
¬-ˆ‰Š® 1000 kbps–I2C
¹ º»¼›
½¾¿ÀÁ›ž
I2C ÂÃ
—˜ Philips ™š›œ•
ª«¬-–
†¯°±²³
´µ
›€
ž
´µ¶·
UDB »¼–
ŸÄÅÆÇÈÉŽ I2C
ÊËÌÍÎÏÐÑÒÓÔ›
Ó´à©ÍÎ
•´µÕ
Cypress Semiconductor Corporation
Document Number: 001-79275 Rev**
•
Ö׬§ÉŽ I2C
—ØÙ›Ú۳ܖËÝÞßÒ
Ð
› á–
198 Champion Court
•
San Jose, CA 95134-1709
• 408-943-2600
Revised May16, 2012
2
IC
/
®
PSoC Creator™
/
âã/â
âä‡
¼åæç I2C
›èÅâã
ä›ÆÇÈòóŸôìÔ–
âä‡
–I/O éêÔ›ëì (*) êíî I/O ÝïŸ I/O ðñÔé
âä
sda — âã/â
õ
(SDA) — I2C
¦ì–öÅ÷ø
ü sda ›‚ƒ”•©™ýþ¢ÿ!"–
¦ìŽ•ùâÐ
ú£¤
–ûî߇
âä
SCL — âã/â
õ ¬- (SCL) —
#$› I2C ¬-–%&
'(#$¬-¦ì§)*Ýɬ-+ Ÿ
Ð78©9–ûî߇ ü
ÿ!",-É
.0§1ü* µš2
Ð34/541Ø6
scl ›‚ƒ”•©™ýþ¢ÿ!"–
¬- — âã*
Ê Implementation„:;…<
磌 16 >[email protected]
´•© UDB ¬§ÝÞÉŽ¬-âã–UDB »¼
Ε¬-=
¬50 kbps
800 kHz
100 kbps
1.6 MHz
400 kbps
6.4 MHz
1000 kbps
16 MHz
BC — âã*
Ê Implementation„:;…< ´•© UDB ¬ÝÞÉŽBCâã–DEBC‚ƒ+ ŸFGŠ
!",-§H I2C ÂÃßI•BC,-§¨J¥? I2C Õ ›¥¦(.9–öKLŽ•ž BC–
MN OPÉŽ I2C_Stop()
I2C_Start() API Õ ÍQBC–BCâãŸRST‡ ›ÆÇÈû
UV–DEBC WRXć §H
ß©¯Y”Z FG 0–
1
2
NAK ©5Á34Ð[34›\]–I C ^_Ô¥ZÉŽ NACK§M¯°×`ÔÉŽ NAK–*a›bc¶d–
Page 2 of 47
Document Number: 001-79275 Rev**
®
2
PSoC Creator™
PSoC Creator
‡‹Œ•Ž• •‘ ’“
Š
Ÿ
¡‚
¢™Ž••š›œ• I2C
¢™”•ŠŽ•• UDB I2C
Document Number: 001-79275 Rev**
IC
I2C
”•–‚
/
/
€•‚ƒ„ …†‡ˆ‰Š
—˜‹Œ™š›œ•Š UDB ž • I2C
š›œ• I2C
Ž•
¢™”•ŠŽ•• UDB I2C
Page 3 of 47
2
IC
/
£
¤
¥ I2C
®
PSoC Creator™
/
¦§¨©•ª«¬
I2C
°
¤
-®¯°±² Configure³‹Œ´µ¶·‚
‚
³¸¹´
Mode³
º»¼½¾›
¿À•¸¹Á
Â
Â
Ã
³¸¹´
Mode³
ÄÅ
ÆǘÈ
Master³
´
Multi-Master
³
´
Multi-Master-Slave
³
´
Page 4 of 47
‚
ÆǘÈ
•Éʳ
•ÉÊ‚
¿ÀË̬—˜
Š
´‚
‚
•ÍÎÉÊ‚
Document Number: 001-79275 Rev**
®
2
PSoC Creator™
³
Data Rate³
IC
/
/
Ïд
º¤ ˜ÈªŒ I2C
ÏÐѳ½Ò 1000 kbps´Ó€ÔÏÕ½•Ö×Ƚ˜•”•ÏÕŠØÙ
´Â400 °à 1000 kbps‚Ÿá¥
ÚÛÜ™ ÝÍ‚Þß
ÏÐ2 50Â100³
Implementation³€•´ª UDB â UDB Clock Source³UDB ”•–´¤ ª External
Clock³ã䔕´ å½æç Data Rate³
Ïд¤ Ó
ÏÐ¥è 16x éꔕ¾›‚
ëì
Ē
¥îï• I2C ëì‚ŸáÝ»ð
ÉÊ åÖæ纤 ‚©½°»ðñÈ 0 ò
127³0x00 Š 0x7F´óô•
ëì
Ñ 8‚ºëì õµö• 7 ÷
ëì ¯Ý
…øù/ú÷‚©½°éêûüýÃûþüý•Ñ µÈûþüý Ñ ÿ!ëìó"#ê“0x”‚
Ÿá’“ 10 ÷
ëì 媫$%&—˜' ëì()• ISR *• 10 ÷ëì•+, .
()¿À‚
ۥ
º»¼½¾›Ÿ0!ª1¬€• I2C ž
‚
ۥ
ÄÅ
š›œ•
!
¬—˜š›œ•¸2³
UDB
! UDB 34*€• I C‚
´‚
2
ëì()
56º¤
©½°»ð' ëì()Þ ëì()‚µÈ
78• API •â9’:
ëì•;äØ<˜=>?Ä ¥@»ž ëì()‚ܵÈABCD–E)°FG
ž í
ëì•<˜=>ÜH å%&—˜' ëìFG‚ž
ªŒ‚Ÿá—• ž ëì()
I¸2ÖJKL ÝMÈJN•ëì ÜO’ CPU PQ‚¯Ö!R¨S¾ëìTJK*U CPU
•VW •¥ SCL ÌXÀ!YZ[ \ò CPU PQ ]‚
Ž•
º¤ ½¾›˜È SDA Š SCL
I2C1‚
Ñ Any‚
^ˆ‰•Ž•_`‚º¤
…†a
½»ÑÁAnyÂI2C0 Š
Any b¡5˜ I/O³GPIO à SIO´‚ŸáÝ’“ cd¸¹—•ef å<¥ Any ˜È SDA Š
SCL‚Ÿá’“ cd¸¹—•ef å%&—˜ I2C0 à I2C1 Ó—˜ I2C0 à I2C1 ©½°¥
I
‹Œ ! I2C ëìg‹”ef‚
2
š›œ•€•Æ¿À PSoC 3 ES2 Š PSoC 5
kbps •ÝÍ
ÏЗ˜×È UDB •€•‚
Document Number: 001-79275 Rev**
—˜Þß
ÏÐ 50Â100 à 400 kbps‚ܵhi½Ò 1000
Page 5 of 47
2
IC
/
I2C
®
PSoC Creator™
/
ÝjkFlŽ•Ø‹íLS¾‚
Ñ
Ž•
Any
56
I2C0
SCL = SIO Ž• P12[4]
I2C1
SCL=SIO Ž• P12[0]
ˆ‰•mn GPIO à SIO Ž•
SDA = SIO Ž• P12[5]
SDA=SIO Ž• P12[1]
cd¸¹—•ef
º»¼Ö!ëìg‹” cd¸¹efop‚º»¼Æ! Address Decode³ëì()´ª
Hardware³ž ´ •â SDA Š SCL ^ˆ‰ò SIO Ž•³I2C0 à I2C1´”q™r‚
s˜º»¼‚PSoC 3 ES2 Š PSoC 5
Ý¿Àº»¼‚
!tu¨cd¸¹T %&—•!
ëìg‹”½°—˜ I2C ?efª1‚ƒ:Éʽ56
v˜ I2C_Sleep() API ?wxÓyÿ¤z System Reference Guide³{op¤z|}~´*•!
ž ëìg‹”ef³!ž ëìg‹”ef´Š“Power Management APIs”³Z–• API
UDB
€•‚ ƒ„… 16 †
‡ˆ‰Š‹Œ • Internal ClockŽ
ŠPSoC Creator ••‘ Data RateŽ
’“
”•
–
External ClockŽ
—˜™Šš›œ•ž
Ÿ
•‘¡¢£¤
¥¦§¨
©ª•«
Œ • Internal ClockŽ
Š¬®¯•œ¥¦
°±
²³•
°±”•´µ¶
´µ²·¸•¹º» ¼½›—˜ ¾¿ÀÁ• -5% Â
+50%
«—˜™²Ã Ä€
‘ÅÆ—˜Š¾¿ÀÁ• -25%  +5% « Š Ç•—
˜™Ä€ÈÉ
ÊË
(1000 kbps) Š
ÌÍ‘ÎÉ‘ÏÐ
ŠŸœÌчÏÐ
Ò¬Š²ÓÔÕÖ× €•
ØÓ UDB ¼½›Ù¸Ú
²³Û‡«
•‚ÜÝÙ¸š›Ú Š³Þßà‘áâžÚ ™ š›ãÓ ‹Œ «
äŠå š›æ ç•Ù¸ ½› è¯é «
²•ž£¤Âš› êëº
êëº
•‚ìíš›ãÓ î¸ïð «•ñò ModeŽ—˜ Œ • SlaveŽ¼½› ó
ImplementationŽ§ô Œ • UDB õö÷ ¾¿øù™Šú¡«•ñ
š› Ù¸Ú ûü²ýþ ÿ “”ö!" Ê˶”#$Ž% &“'() *())+,ã
ŽUDB §ô ŽDC
AC )+,-ŽUDB §ô ./0123
4ƒ„ 56ã « Š7
²³ ÜÝ8å9: Œ’;<=>íÙ¸Ú Œ’?@ û˜ABÄ€Ù¸Ú
Page 6 of 47
Document Number: 001-79275 Rev**
®
PSoC Creator™ š›
2
I C Ç•F5Ç•F¼½›
DE
•‚
‹•‚
ŠPSoC Creator ’“”• –
GHÞß
š›ì’“”•
–
–
²Þß
4Ø¡ 1.6 MHz
õÓØ
I… 100 kbps
Ù¸JÓ—KØ¡ BUS_CLKŠìÛ‡¸ž½º–½L’“
‡ˆ‰ • 32ŠMNÅƇˆ‰ • 16
€OP
Q %RSTUV; W 49 ñ
I2C
Šì
”•
—K³
²³•XÐYZ[\¯
§ô4¡ æ
Ò¬Š
16 † $©Š•
16/32 ‡ˆ‰
Ž50 kbps
I2C Ù¸JÓ—KÞß”•
æ
³™
Œ ¡‘
æ Ø¡23](1) Address DecodeŽ^_/` Œ • SoftwareŽa
› b(2) cý•; Enable wakeup from Sleep ModeŽ¼de—˜ØÓfg bUDB Clock
SourceŽUDB
Œ • External ClockŽ
Ù¸ I2C —K¡‘Ù¸JÓ
æ
§ô
hi
2
API Oj½Žk
—˜
I C Ù¸ —K
mO
RAM
¼½›
1
916
22
2
Ç•
1
1737
20
2
5Ç•
1
1889
20
2
5Ç•¼½›
1
2550
34
2
Document Number: 001-79275 Rev**
êëŽlÝ
I/O
Page 7 of 47
2
IC
/
®
PSoC Creator™
/
UDB
API
RAM
ƒ„ …†
‡ˆ I/O‚
‚
962
18
4
1
1834
17
4
1
1
2007
17
4
1
2
2754
30
4
PLD
‹Œ •Ž
Control/ Count7
•Ž
1
12
1
2
2
14
1
2
18
2
32
‰Š
€ •‚
•
•‘’“”’•–
—˜™š‘•‘’“”’•– (API) ›’“œ•žŸ
ž¤©ª ™ «•¬-®¯°±²…†¥
¡
¢£¤…†¥
¦•–
§¨
³´µ¶
PSoC Creator ·¬ ¸¹º“I2C_1”» ¼½¾¿ÀÁ
¦ÂÆ ¸ —˜™¬
Ä ¸ÅƹÇÈÉÊËÈÌÍÎϦÐÑÒÃÓ
¸¹º·ÔÇ…†ÕÖ¥ ¹º×ØÙÚ
ÛÙÈܦÝÞ £ ˜ßàáâ
Áš‘¦ ¸¹ºÇ“I2C”
ãä API ¥
é
ð
¨ž
åæ¿ç I2C
ßñ
Ÿ·íîßñï
¾è
é
êëì
Ÿ·íîêëï
ò‘¥
ó•ôõ¤ I2C
ö
÷øò‘¦¥
¥
©ª
2
2
2
I2C_Start()
ùúû§šü I C
I2C_Stop()
"#ÿ• I C ò!
I2C_EnableInt()
šüÁý
%ˆ» I C ÷øå&'šüÁý
I2C_DisableInt()
$‘Áý
I2C_Stop() API ·()*žó÷ø
I2C_Sleep()
"# I C ÷ø §+ I C ,+- ¡.
$‘Áý‚ 01šü¤
2
456ü $‘ I C Áý‚ Ϙ™78*žœ°9: Ÿ45÷ø
I2C_Wakeup()
;< I C ,+-
I2C_Init()
š‘¾=
I2C_Enable()
AB I C C
Page 8 of 47
šü I C Áýþ
2
2
˜ÿ• I C ò!
2
$‘ I C Áý‚
2
2
2
Ä
2
¡.
2
§šü I C ÷ø
23
2
šü I C Áý‚
2
>?¦ùúÓ@ùúû I C .
§Dú*ž
÷ø
Document Number: 001-79275 Rev**
®
2
PSoC Creator™
IC
¥
/
/
©ª
2
2
I2C_SaveConfig()
+
I2C_RestoreConfig()
;<ð I2C_SaveConfig() ö I2C_Sleep() +
2
I C Áý‚
I C ,+-
$‘ I C Áý‚
¡.
2
¦ I C ,+-
¡.
šü
ÕÖØÙ
œ*žÃE÷øŸ
F&¤GHIØÙ
ØÙ
I2C_initVar
©ª
2
KLMNÔùúû ØÙ¬ùúûÇ 0 §œÂÃOP
I2C_initVar J I C
‘ I2C_Start() Ÿ¿¡Ç 1 HQ œÂÃOP‘ I2C_Start() ›’“þ
F
&ÅRùúûS˜ÅT
ϘœP‘ I2C_Start() ö I2C_Enable() ¥
0&ÅRùúû
I2C_Init() ¥
2
I2C_state
J I C ‹ŒU¦éÝ‹Œ
I2C_mstrStatus
JIC
I2C_mstrControl
2
¦éÝ‹Œ
òVîÔöWîÔ“"#”@
=÷ø¦
I2C_mstrRdBufPtr
ßñYZ[¦½\
I2C_mstrRdBufSize
ßñYZ[¦%]
I2C_mstrRdBufIndex
ßñYZ[Á¦éÝ^ƒ
I2C_mstrWrBufPtr
êëYZ[¦½\
I2C_mstrWrBufSize
êëYZ[¦%]
I2C_mstrWrBufIndex
êëYZ[Á¦éÝ^ƒ
2
¦éÝ‹Œ
2
¦_
I2C_slStatus
IC
I2C_slAddress
IC
X
°9
I2C_slRdBufPtr
ßñYZ[¦½\
I2C_slRdBufSize
ßñYZ[¦%]
I2C_slRdBufIndex
ßñYZ[Á¦éÝ^ƒ
I2C_slWrBufPtr
êëYZ[¦½\
I2C_slWrBufSize
êëYZ[¦%]
I2C_slWrBufIndex
êëYZ[Á¦éÝ^ƒ
Document Number: 001-79275 Rev**
ÝP‘
Page 9 of 47
2
IC
/
®
PSoC Creator™
/
ò‘¥
void I2C_Start(void)
©ª `
HKDú*ž
÷ø¦abcÍ I2C_Start() ·adP‘ I2C_Init() ¥
2
I2C_Enable() ¥
—fgœ*ž I C hi÷øjÝP‘ I2C_Start()
2
ó API ˜šü I C Áý
œP‘ó¥
2
%ˆ» I C ÷øå&'Áý
2
fg¿¡ I C
jÝ
œm šü‹Œno¿¡YZ[¦µ¶
2
I C ßñpq — rs 0xFF
¿¡ßñYZ[u
YZ[
™klœ¿¡YZ[Ÿßñöê눻
2
IC
¦žÇ¬0
tì¿¡ßñYZ[Ç#
2
I C êëpq — vwäxy@
•zì¦
I2C_SlaveInitWriteBuf() ¥ ¿¡ßñYZ[u
`
eþP‘
ãJ`
š‘ I2C_SlaveInitReadBuf() ¥
{’| NAK
š‘
F
rs Ó`
F
}ø ‘`
F
void I2C_Stop(void)
©ª `
2
ó¥ ˜$‘ I C C
FF
~•
ÚÁý
2
Production PSoC 3‚`01 I C
2
UDB
IC
€
•‚ ƒ
€
„… †
€
void I2C_EnableInt(void)
‡ˆ
‰Š
2
‹Œ• I C Ž•
•‘’“…”•–Ž•
€
•‚ ƒ
€
„… †
€
Page 10 of 47
Document Number: 001-79275 Rev**
®
PSoC Creator™ —
2
I C ›œ/•›œ/ž
˜™š
void I2C_DisableInt(void)
‡ˆ
2
‰Š ‹Œ• I C Ž•
©
Ÿ
¤ I2C_Stop() Š
¡¢£
¥†Ž•¦§¨•–‰Š
€
•‚ ƒ
€
2
2
2
¤ª« I C ¬-®¥† I C Ž•
„… †
‹•¯° I C
void I2C_Sleep(void)
‡ˆ
±²³´—
µ¶·¸¬¹º API
2
I C Ž•
¤Š
»†¦
¥†
Œ•¤¼½¾¿®ÀÁ
 ¤‰ API »†ÃÄŽÅ
“… ÊËÌÍ“…ΰϦЋƫ ¤‰
µ¶·¸
2
 ¬ÓÔ¦Õ I CŸÖ ¼½¾¿×
ÀÁÉØÙ
¥†¤¼½¾¿®ÀÁ
ÌÍÚŒ• API
ßÉ—
àỆ I2C_Stop() ⥆ɗ
2
I C äÞå¿æçß
Æ«ÇÈ
ÏÍ
˜“…
É
ÑÒʼn
2
ÝÞ
API ÛÜÌͬ I C —
㦠»† I2C_SaveConfig() âÞß
¤»† CyPmSleep() è CyPmHibernate() Š ÏÍé껆 I2C_Sleep() Š
íîïŠ ¬ð•Öñ ò ó PSoC Creator System Reference Guideôõ
÷øù
Ôëì
óö
€
•‚ ƒ
€
„… †
€
void I2C_Wakeup(void)
‡ˆ
±²
•
—
úûËüý»† I2C_Sleep() ®
¬¹º API
2
I C Ž•
¤Š
»†¦Œ
Œ•¤¼½¾¿®ÀÁ ‰ API Œ• I2C ›œþ•ô
¤·¸ÏÍÿ!"Œ•
2
2
¤Œ• I C Ž•¦ %Õµ«&¶¬ ˜“…
ù Ý¥† I C ´#»$
¥†¤¼½¾¿®ÀÁ ‰ API »† I2C_RestoreConfig() âúû I2C äÞå¿æç
ß
¤»† I2C_Sleep() Š ÏÍÚŒ•É—
I2C_Wakeup() '(Œ•É—
€
•‚ ƒ
€
„… †
¤»† I2C_Wakeup() Š
+,-«
Document Number: 001-79275 Rev**
Í)»† I2C_Sleep() è I2C_SaveConfig() Š
‹•
*
Page 11 of 47
2
®
I C ›œ/•›œ/ž
PSoC Creator™ —
˜™š
void I2C_Init(void)
‡ˆ
‰Š .˜ 0 Configureô¿æùÅ12
I2C_Init() 7 I2C_Start() API »†‰Š
:
æâ345èúû—
ÉŠ ²84Æ«—
6ۥȠ
“…¬¹º9
€
•‚ ƒ
€
„… †
ÓÔçß
æ
0
“¿æ”Å12Ž¬ƒ
void I2C_Enable(void)
‡ˆ
‰Š ;<= Ý84Æ«— “…
»†‰Š
ÉŠ ²84Æ«—
»† I2C_Start() è I2C_Init()
6ۥȠ I2C_Enable() 7 I2C_Start() API
“…¬¹º9:
–»†‰ API
>?¹ê
€
•‚ ƒ
€
„… †
€
void I2C_SaveConfig(void)
‡ˆ
2
Þß I C —
‰Š
äÞå¿æçß
2
Ý¥† I C Ž•
2
Œ•¤¼½¾¿®ÀÁ ‰ API ¥† I2C ›œ
‰ÍÚŒ• I2C
‹Œ• I C
´#»$
 ¤‰ API »†ÃÄŽÅ
Æ«ÇÈ“…
É“… ÊËÌÍ
2
µ¶·¸
Ï
¬ ˜“…Î°Ý I C @Aµ¶·¸¬³´Ï¦Ð‹Æ« ¤‰
2
Í
ÑÒÓÔ¦Õ¬ I C ŸÖ
¥†¤¼½¾¿®ÀÁ
ò ó›–‡ˆ
2
¥† I C Ž•®Ý¨BC"²ÑŒ•¼½¾¿®ÀÁ
€
•‚ ƒ
€
„… †
€
Page 12 of 47
Document Number: 001-79275 Rev**
®
2
PSoC Creator™
IC
/
/
void I2C_RestoreConfig(void)
2
IC
2
•‚ƒ„…†‡ I C ˆ‰…
API
…
†‡Š‹Œ• Ž••
2
„š›œ• I C žŸ
•
Š‹Œ•
I2C_Sleep()
Ž• •
¡¢£
2
†‡ I C
¤
†‡ I C ˆ‰Žœ¥¦§™¨©†‡‹Œ•
ª
«¬ -
ª
®¯
Š
¸¹º
™ I2C
•°
»¯‚
I2C_Sleep()
…Š
‘‡’“”Š•–€•—˜™†‡ƒ
…
2
¢
I2C_SaveConifg() €
••…
I2C_SaveConfig()
›±‡
¼†‡‚½¾¿±À†
ÁÂ
²³´µ¶·…
…
I2C_SlaveStatus()
«¬
I2C_SlaveClearReadStatus()
«¬Å¦ƒ„ÃÄœÆÇ
I2C_SlaveClearWriteStatus()
«¬ÈɃ„œÆÇ
I2C_SlaveSetAddress()
Ê
‹Œ›Ë-Ì™ 0 Í 127 (0x00 - 0x7F) €Î…
I2C_SlaveInitReadBuf()
Ê
ÏÐ
I2C_SlaveInitWriteBuf()
Ê
ÈÉÑÒÓ…’
I2C_SlaveGetReadBufSize()
«¬ÑÒÓ
ÔÕ
Ŧ‚Ö
…
I2C_SlaveGetWriteBufSize()
«¬ÑÒÓ
ÔÕ
ÈÉ‚Ö
…
ƒ„ÃÄ…
Ŧƒ„ÃÄ…
ÈɃ„ÃÄ…
I2C_SlaveClearReadBuf()
ŦÑÒÓ×
ÔÍØ…
I2C_SlaveClearWriteBuf()
ÈÉÑÒÓ×
ÔÍØ…
Document Number: 001-79275 Rev**
<-
ÑÒÓ…’
->
š
š
Page 13 of 47
2
IC
/
®
PSoC Creator™
/
uint8 I2C_SlaveStatus(void)
«¬
¢
ª
«¬ -
uint8
2
IC
ÙÚƒ„…
‚Û•ƒ„…
ƒ„ÜÝ
I2C_SSTAT_RD_CMPLT
3
I2C_SSTAT_RD_BUSY
çŠè¶
Ê ›œŠÊ
I2C_SSTAT_RD_ERR_OVFL
I2C_SSTAT_WR_CMPLT
4
I2C_SSTAT_WR_BUSY
I2C_SSTAT_WR_ERR_OVFL
®¯
ŦÞß¼àá…Š
áŦŽÊ …
ŦÞß…Š
ŦÀéŒ
RD_CMPLT ŽÆÇ…
êëŦìíÑÒÓÖ
ÈÉÞß¼àá…ŠÐ
çŠè¶
Ê ›œŠÊ
âã NAK äåÙæ¼à
‚Ö
Ž
…
“îï”ð
ŽÊ
…
ÈÉÞß…Š
ÈÉÀéŒ
WR_CMPLT ŽÆÇ…
ëñŠÑÒÓòóŽÈÉôõ…ÏЂÖ
©÷…
Ž
ö
ª
uint8 I2C_SlaveClearReadStatus(void)
±ÆÇŦƒ„ÃÄœ«¬ø-…øùƒ„ÃÄ¥ úûä…
¢
ª
«¬ -
uint8
®¯
ª
‚ەŦƒ„…üýÜÝ›¡¢£ I2C_SlaveStatus()
3
— þÿ! I2C_SSTAT_RD_CMPT "#· I2C_SSTAT_RD_CMPLT›À$%
)*þÿ›+¨ I2C_SSTAT_RD_CMPT ¦,† …
4
— þÿ! I2C_SSTAT_WR_CMPT "#· I2C_SSTAT_WR_CMPLT›À$%
)*þÿ›+¨ I2C_SSTAT_WR_CMPT ¦,† …
Page 14 of 47
…
Ŧàáþÿ…Ë
ÈÉàáþÿ…Ë
&Ž'(
&Ž'(
Document Number: 001-79275 Rev**
®
2
PSoC Creator™
IC
/
/
uint8 I2C_SlaveClearWriteStatus(void)
ÆÇÈɃ„ÃÄœ«¬ø-…øùƒ„ÃÄ¥
¢
ª
«¬ -
uint8
®¯
ª
úûä…
‚Û•ÈɃ„…üýÜÝ›¡¢- I2C_SlaveStatus()
…
void I2C_SlaveSetAddress(uint8 address)
±Ê
2
IC
‹Œ
2
¢
uint8 address
Êž‚ I C
´‹Œ… ‹Œ·012‚ 7 Ô
«¬ -
ª
®¯
ª
‹Œ… -±À· 0 Í 127 (0x00 - 0x7F) €Î‚.
‹Œ›—¥34Å/ÈÔ…
void I2C_SlaveInitReadBuf(uint8 * rdBuf, uint8 bufSize)
±Ê ÑÒÓ56œÊ ŦÑÒÓ‚78…
I2C_SlaveGetReadBufSize()
:«¬‚Þß× …
¢
uint8* rdBuf
uint8 bufSize
«¬ -
ª
®¯
“”Š>?
<DÔ ‚
Ŧ‚
2
;<= I C
»¯@Î
…
9
Ô
ÑÒÓ‚56…
‚ÑÒÓ‚78…
›A±‡ÞßB•ÑÒÓÔ
‚
ÀCÛ•ÑÒÓ
void I2C_SlaveInitWriteBuf(uint8 * wrBuf, uint8 bufSize)
±Ê ÑÒÓ56œÊ ÈÉÑÒÓ‚78…
I2C_SlaveGetWriteBufSize()
:«¬‚Þß× …
¢
uint8* wrBuf
uint8 bufSize
«¬ -
ª
®¯
“”Š>?
…
Document Number: 001-79275 Rev**
ÈÉ‚
2
9
Ô
ÑÒÓ‚56…
;<= I C
‚ÑÒÓ‚78…
»¯@Î
›A±‡
ŠB•‚ÑÒÓEÛ•‚ÑÒÓÔ
ÏÐ
Page 15 of 47
2
IC
/
®
PSoC Creator™
/
uint8 I2C_SlaveGetReadBufSize(void)
«¬è¶ I2C_SlaveInitReadBuf()
Ö
…
I2C_SlaveClearReadBuf()
2
ÕIC
Ŧ‚
F7«¬-·Å¦ÑÒÓ‚78…
¢
ª
«¬ -
uint8
®¯
ª
Ŧ‚Ö
…
uint8 I2C_SlaveGetWriteBufSize(void)
«¬è¶ I2C_SlaveInitWriteBuf()
É‚Ö
…
I2C_SlaveClearWriteBuf()
2
ÕIC
È
F7«¬-·ÈÉÑÒÓ‚78…
¢
ª
«¬ -
uint8
®¯
ª
ÈÉ‚Ö
…
void I2C_SlaveClearReadBuf(void)
Ŧ56 ÔÍŦÑÒÓˆ‚GHIÖ
ÒÓˆ‚GHIÖ …
¢
ª
«¬ -
ª
®¯
ª
…
Ŧ‚¿HIÖ
¨Å¦Ñ
…
ÈÉ‚¿HIÖ
¨ÈÉÑ
void I2C_SlaveClearWriteBuf(void)
ÈÉ56 ÔÍÈÉÑÒÓˆ‚GHIÖ
ÒÓˆ‚GHIÖ …
¢
ª
«¬ -
ª
®¯
ª
E
ÁÂ
JŠ†‡º
Page 16 of 47
KLŽM±
…
Document Number: 001-79275 Rev**
®
2
PSoC Creator™
IC
I2C_MasterStatus()
«¬
ƒ„…
I2C_MasterClearStatus()
«¬
ƒ„œÆǃ„ÃÄ…
I2C_MasterWriteBuf()
N ‚
ÑÒÓÈÉ
5þ‚
‹Œ…
I2C_MasterReadBuf()
5þ‚
‹ŒÅ¦
›œ
OÉN
/
/
‚ÑÒÓˆ…
I2C_MasterSendStart()
PQRþ‚‹Œâã“ST”…
I2C_MasterSendRestart()
PQ5þ‚‹Œâã“US”…
I2C_MasterSendStop()
³á“îï”ð
I2C_MasterWriteByte()
ÈÉVIÖ …Á¨HI TWX›—PåY I2C_MasterSendStart()
I2C_MasterSendRestart()
H&† …
I2C_MasterReadByte()
ŦVIÖ …Á¨HI TWX›—PåY I2C_MasterSendStart()
I2C_MasterSendRestart()
H&† …
I2C_MasterGetReadBufSize()
«¬
I2C_MasterClearReadBuf()
ÕŦ‚
Ö ×
…
I2C_MasterGetWriteBufSize()
«¬
I2C_MasterClearWriteBuf()
ÕÈÉ‚
Ö
…
…
I2C_MasterClearReadBuf()
ŦÑÒÓ56
ÔÍÑÒÓ‚<DÔ
…
I2C_MasterClearWriteBuf()
ÈÉÑÒÓ56
ÔÍÑÒÓ‚<DÔ
…
Document Number: 001-79275 Rev**
×
Page 17 of 47
2
IC
/
®
PSoC Creator™
/
uint8 I2C_MasterStatus(void)
±«¬
¢
ª
«¬ -
uint8
2
IC
ÙÚƒ„…
‚Û•ƒ„…±À
2
:ü‚ I C
ƒ„ÜÝHZ[¶“
”[\…
ƒ„ÜÝ
I2C_MSTAT_RD_CMPLT
ŦÞß¼àá…
]^_`abƒ¾Ô›Àc
á…
I2C_MSTAT_WR_CMPLT
ŦÞßdeà
ÈÉÞß¼àá…
]^_`abƒ¾Ô›Àc
á…
ÈÉÞßdeà
I2C_MSTAT_XFER_INP
çŠf¶Þß
I2C_MSTAT_XFER_HALT
Þß¼gï…I C >?h•˜™ijƒ„›ij
³á“US” “îï”ð …
2
I2C_MSTAT_ERR_SHORT_XFER abƒ¾
ó…
I2C_MSTAT_ERR_ADDR_NAK
abƒ¾
I2C_MSTAT_ERR_ARB_LOST
abƒ¾
o…
I2C_MSTAT_ERR_XFER
abƒ¾
-…
ŠÞßà:üÖ
€•ÈÉÞß¼ò
ªkc÷Ë‹Œ…
ŠY
f¶ÙÚŽlmn
Á¨pˆ:qabƒ¾‚“
“”abƒ¾Ôr¼ÆÇsÊ º
t
»¯uˆ‰…
®¯
”[\
Ô›AÞß
ª
uint8 I2C_MasterClearStatus(void)
±ÆÇ:üƒ„ÃÄœ«¬
¢
ª
«¬ -
uint8
®¯
ª
Page 18 of 47
ƒ„…
‚Û•ƒ„…üýÜÝ›¡¢- I2C_MasterSendStart()
…
Document Number: 001-79275 Rev**
®
2
PSoC Creator™
IC
/
/
uint8 I2C_MasterWriteBuf(uint8 slaveAddress, uint8 * wrData, uint8 cnt, uint8 mode)
zÖ
¢
vT wIÑÒ
KL¿{|Õ}‚
uint8 slaveAddress
ÈÉ
Êžˆ…
2
Þß…†‡ I C ˆ‰…
Þ߀՛xy‚ ISR Š
ST
012‚ 7
0
127
uint8 wrData
uint8 cnt
€
uint8 mode •‚ƒ„…†‡ (1) ˆ•‚‰Š‹Œ•Ž“••”‘ ’Œ•Ž““•”‘
•– (2) ˆ—˜™•Ž“š›”‘
œŒ•Žž•‚’Œš›ž•‚
ˆ•‚ƒ„Ÿ”
•¡¢
ƒ„£¤¥¦“§”¨©
ƒ„ £¤
ª«
I2C_MODE_COMPLETE_XFER
¬
I2C_MODE_REPEAT_START
I2C_MODE_NO_STOP
²³ ´
uint8 µ¶·¸
ÁÂ Ã
Ä
”
-¥¦•®
•‚
““¯••”°±Œ“••”
¥¦•‚”°±š›
¹º» I2C_MasterSendStart() ¼
½¾£¤¿À
uint8 I2C_MasterReadBuf(uint8 slaveAddress, uint8 * rdData, uint8 cnt, uint8 mode)
ª«
º
ż ƕǾ
ÈÉŸ
Ï €ƒ„ÐÑÒÓÐÔ
®Ê
•‚
uint8 slaveAddress
Ø¡Ù
7
uint8 rdData
ÚÛ
uint8 cnt
Ǿ
ż
ÕÖ I C Ÿ×
••
•‚Ë”ÌÍ
2
0
ISR Έ
127
€
uint8 mode •‚ƒ„…†‡ (1) ˆ•‚‰Š‹Œ•Ž“••”‘ ’Œ•Ž““•”‘
•– (2) ˆ—˜™•Ž“š›”‘
œŒ•Žž•‚’Œš›ž•‚
ˆ•‚ƒ„Ÿ”
•¡¢
ƒ„£¤¥¦“§”¨©
ƒ„ £¤
I2C_MODE_COMPLETE_XFER
I2C_MODE_REPEAT_START
I2C_MODE_NO_STOP
²³ ´
uint8 µ¶·¸
ÁÂ Ã
Ä
Document Number: 001-79275 Rev**
”
ª«
¬
-¥¦•® •‚
“¯••°±Œ••
¥¦•‚”°±š›
Ü£¤”¹º» I2C_MasterSendStart() ¼
Page 19 of 47
2
®
I C ÝÞ/ßÝÞ/
PSoC Creator™ à
áâ
uint8 I2C_MasterSendStart(uint8 slaveAddress, uint8 R_nW)
ª«
ż
º
uint8 slaveAddress
•Ž••‘
uint8 R_nW
²³ ´
ã
Í
2
åà I C Ÿ×
Ç/ä
7
Ø¡Ù
Èæç 0
0
äèéêëÈæçì 0 ´
Ǿéê
uint8 µ¶·¸
ƒ„ £¤
ÁÂ Ã
127
ª«
I2C_MSTR_NO_ERROR
íîĶ
I2C_MSTR_BUS_BUSY
—˜ðñ”ò•Ž••‘
I2C_MSTR_NOT_READY
—˜™
I2C_MSTR_ERR_LB_NAK
õö÷øËùÊ
I2C_MSTR_ERR_ARB_LOST
ˆ•Ž••‹ÝÞúûüý
ßÝÞ‹ÿ
I2C_MSTR_ABORT_XFER
! ••
ï°"›•Ž••‘
·¸þˆßÝÞ
ƒ„Ð
ż
(
•Ž¼
ÝÞÄ
툥¦#›ï”ã$ˆ I2C_CSR %&
ïÂ
”§óíˆô¦
ïÂ
€
Å·¸þˆÕÖ
ŸÈæ byte_complete
Å
œ±…'
uint8 I2C_MasterSendRestart(uint8 slaveAddress, uint8 R_nW)
ª«
ż •Ž“•‘
º
uint8 slaveAddress
uint8 R_nW
ã
Í
Ø¡Ù
Èæç 0
Ç/ä
7
äèéêëÈæçì 0 ´
²³ ´
uint8 µ¶·¸
ÁÂ Ã
ż 툥¦#›ï”ã$ˆ I2C_CSR %&
(
Page 20 of 47
0
127
Ǿéê
Ü£¤”¹º» I2C_MasterSendStart() ¼
ŸÈæ byte_complete
œ±…'
Document Number: 001-79275 Rev**
®
PSoC Creator™ à
2
I C ÝÞ/ßÝÞ/
áâ
uint8 I2C_MasterSendStop(void)
2
ª«
ż ˆ—˜™•Ž I C “š›”‘
ż ᥦ-.ïÂ
º
Ä
²³ ´
uint8 µ¶·¸
ÁÂ Ã
ż
)*ˆ+Ãż
üý”,
Ü£¤”¹º» I2C_MasterSendStart() éê
툥¦#›ï”ˆ01Ð2‘
ÝÞ
œ“••”§““•”‘
œ±…'(
ż ±…34•Ž“š›”‘
ßÝÞ5ßÝÞ
¦34
ˆ•Žš›‘
§ˆ ACK/NAK
™úûüý‹”ż
…ô
uint8 I2C_MasterWriteByte(uint8 theByte)
ª«
!ż Ú
)*ˆ+Ãż
º
uint8 theByte
²³ ´
uint8 µ¶·¸
ùÊ € ˆ+Ãż
œ67•Ž
“••”§““•”‘
œ“••”§““•”‘ üý”,ż ᥦ-.ïÂ
€
ƒ„ £¤
ÁÂ Ã
ª«
I2C_MSTR_NO_ERROR
íîĶ
I2C_MSTR_NOT_READY
—˜™
Â
I2C_MSTR_ERR_LB_NAK
õö÷øËùÊ
I2C_MSTR_ERR_ARB_LOST
ˆ•Ž“••”‹ÝÞúûüý
ˆÕÖßÝÞ‹ÿ
ż
(
•Ž¼
ÝÞÄ
툥¦#›ï”ã$ˆ I2C_CSR %&
ïÂ
”§ó툥¦
ï
€
ŸÈæ
Å·¸þ
byte_complete
œ±…'
uint8 I2C_MasterReadByte(uint8 acknNak)
ª«
ż
º
uint8 acknNak
9ç 0”,
²³ ´
uint8 Æ
ŸÇ¾
ÁÂ Ã
ż
(
Ǿ
Ÿ ùÊ €”ãî÷§ö÷ž•‚ ˆ+Ãż
œ67•Ž
“••”§““•”‘
)*ˆ+Ãż
œ“••”§““•”‘ üý”,ż α
¥¦-.ï”㲳ùÊç8 ´
NAKë9çì 0”,
€
툥¦#›ï”ã$ˆ I2C_CSR %&
Document Number: 001-79275 Rev**
ACK
ŸÈæ byte_complete
œ±…'
Page 21 of 47
2
®
I C ÝÞ/ßÝÞ/
PSoC Creator™ à
áâ
uint8 I2C_MasterGetReadBufSize(void)
²³ÕÃ I2C_MasterReadBuf() ¼ •‚
ª«
ż
º
Ä
²³ ´
uint8 •‚
ÁÂ Ã
Ä
€:
)*•‚;ò•Ž”ż
€
β³<
=>œõ•‚
€:
uint8 I2C_MasterGetWriteBufSize(void)
β³Õà I2C_MasterWriteBuf() ¼
ª«
ż
º
Ä
²³ ´
uint8 •‚
ÁÂ Ã
Ä
€:
•‚
€
)*•‚;ò•Ž”?β³<
=>œõ•‚
€:
void I2C_MasterClearReadBufSize(void)
ª«
ż ÎǾ
º
Ä
²³ ´
Ä
ÁÂ Ã
Ä
¯
=
Ÿ
@ùÊ
€
¯
=
Ÿ
@ùÊ
€
void I2C_MasterClearWriteBufSize(void)
ª«
ż Îäè
º
Ä
²³ ´
Ä
ÁÂ Ã
Ä
ßÝÞ
ßÝÞ
¼
ŒÎ
¼
5ßÝÞ¼
1ãˆùA
BCDEFGHI
I2C à
ÃÂBCDEFG
RSHI
Page 22 of 47
J¿à
ÕÕÐKæ
çLMNO=BCDEFG
J¿PQ
Document Number: 001-79275 Rev**
®
2
PSoC Creator™





IC
/
/
UDB
€
‹Œ
‹Œ•‘ ’
•‚ƒ„…†‡
ˆ‰Š
€ •‚ƒ„…†‡•Ž•
“Ž”
•–
‹Œˆ‰Š
”
—˜ƒ„™š›œ•• žŸ
¡¢ System Reference Guide‚£¤¥¡¢¦§¨‡©•
“Bootloader System”‚ƒ„™š›œ¤¥‡ˆªŠ
—˜ I2C «ž
•¬-žŸ
¡¢ƒ„™š›œ®¯€ I2C «ž
›œ®¯€ I2C «ž
²°±‡ˆªŠ
I2C
API ¹
³´µƒ„™š›œ¶·¸ˆ
•°±‚ƒ„™š
Š
¹
º»
2
¼´¬©½Š
2
¼¾µ¬©½Š
I2C_CyBtldrCommStart
´
I2C_CyBtldrCommStop
¾µ I C
I2C_CyBtldrCommReset
¿ÀÁÂÃÄ I C ÅÆDžȳÉÊËÌ
I2C_CyBtldrCommWrite
ÏÐѵ›œ¿
ÛÜÝÞ •
I2C_CyBtldrCommRead
ÏÐѵ›œÀÁƒ„™š›œ •©•
ÚÛßàá
ÙŠ
IC
2
Ãă„™š›œ
Š
¼´
ËÌÍΊ
•©ŠÒ¹
ŠÒ¹
¿ÓÔÕÖ
×Ø
¿ÓÔÕÖ
×
ÙÚ
•
void I2C_CyBtldrCommStart(void)
º»
â¹ ´
2
IC
2
ãäåÄ• C ÃÄ
¼´¬©½Š
æçè¿é³ƒ„™š›œ•ˆäêëŠ
샄™š›œíîïêëÜÝðñòó
OxFF
¡
ö
ôõ ÷
ö
øç µ
ö
Document Number: 001-79275 Rev**
2
ãäåÄ• I C ÀÁ
æçè¿ôõ
Page 23 of 47
2
IC
/
®
PSoC Creator™
/
void I2C_CyBtldrCommStop(void)
2
º»
â¹ ¾µ I C
¡
ö
ôõ ÷
ö
øç µ
ö
¼¾µ¬©½Š
void I2C_CyBtldrCommReset(void)
º»
â¹
¡
ö
ôõ ÷
ö
øç µ
ö
2
¿ I C ÅÆÇ•ÀÁÂÃÄæç…³ÉÊËÌ
¼¿
ËÌÍΊ
cystatus I2C_CyBtldrCommRead(uint8 * Data, uint16 size, uint16 * count, uint8 timeOut)
º»
â¹ ÏÐѵ›œÀÁƒ„™š›œ
ÚÛßàá
ÙŠ
¡
uint8 *Data: ÜÝÞ
•
•©•
ŠÒ¹ ¿ÓÔÕÖ
×
•
Ù•¦ù
uint16 size: úÃÄ•ûª
uint16 *count: µ
Ã
üÃÄûª
uint8 timeOut: ÿ!•"Î
•ýþ¦ù
‚#$³ 10 %&‡
ò'()*#+ôõ
ôõ ÷
cystatus: ,-.0á1234¿ôõ CYRET_SUCCESS 5ôõ 6789Ò34•
÷Š—˜• žŸ
¡¢ System Reference Guide‚£¤¥¡¢¦§¨‡©•“Return
Codes”‚ôõ:;‡ˆªŠ
øç µ
ö
Page 24 of 47
Document Number: 001-79275 Rev**
®
2
PSoC Creator™
IC
/
/
cystatus I2C_CyBtldrCommWrite(uint8 * Data, uint16 size, uint16 * count, uint8 timeOut)
º»
â¹ ÏÐѵ›œ¿
ÛÜÝÞ •
Š
¡
uint8 *Data: ÜÝÞ
Ãă„™š›œ
•
•©ŠÒ¹ ¿ÓÔÕÖ
×Ø
ÙÚ
Ù•¦ù
uint16 size: úÃÄ•ûª
uint16 *count: µ
Ã
üÃÄûª
uint8 timeOut: ÿ!•"Î
•ýþ¦ù
‚#$³ 10 %&‡
ò'()*#+ôõ
ôõ ÷
cystatus: ,-.0á1234¿ôõ CYRET_SUCCESS 5ôõ 6789Ò34•
÷Š—˜• žŸ
¡¢ System Reference Guide‚£¤¥¡¢¦§¨‡©•“Return
Codes”‚ôõ:;‡ˆªŠ
øç µ
ö
<:;=>
PSoC Creator ì Find Example Project‚?@=>”A‡BCD©¶·¸EþFGHÔIÂ:;
=>•=>:;ŠúJÁ
K •=>
LM
AN©•BCD5HÔI©•
>Š
úJÁ«µ•=>
LMMÊO‚Start Page‡5 File ‚P ‡Q"©•BCDŠR Sú
´µBCD©• Filter Options ‚TU Ž”‡ VW Ž”A•XYŠ
—˜•
žŸ
¡¢ PSoC Creator Z[©•“?@=>”A” 4Š
89
â
\] I2C
Â
^
^
•žŸŠ
Â
‘ÈŠ
_`ªa9¸,2´µ
^
b©½cd• )ââ
Súe´ Ûf©½Šg´â
Sú©½ e –
b I2C ’
Súí ISR‚©½hij›œ‡k™12:;ŠÒ
³•—©½‚
l凶·hi €e
•:;ö˜Š³âßmn‘•op ÅÆÇqr e•ñµ›œ€ I2C
/
ò$•s"t
umop Š
æç
ßm bop ©•väÅÆÇ w• ˆäÅÆǵ xo
ÃÄá
•
2
|îïÀÁÂÃÄ
yˆäÅÆǵ xo
©ÀÁ•
Š z{ ñ
IC
æçŠI2C
ÀÁÂÃÄÅÆÇ b _ÉÊ}êë|…È•Š~•êë–(n‘op
•
€•‚ƒ„…†‡
ˆ‰Š‹
Œ •Ž••ˆ‘
’“
”“• –—˜ ™š
‡›œ• ž
Ÿ ¡ ¢
Document Number: 001-79275 Rev**
Page 25 of 47
2
®
I C £¤/¥£¤/¦§
PSoC Creator™
¢¨©
void I2C_SlaveInitReadBuf(uint8 * rdBuf, uint8 bufSize)
void I2C_SlaveInitWriteBuf(uint8 * wrBuf, uint8 bufSize)
ª
«¬„´
» 1. ¦§
‹—˜ ™š
‡›‰µ¶Œ·
®
¯°
rdBuf ² wrBuf
ˆ‘¸ ” ¹º§
”±
²³
¼½
Memory
0xFFFF
uint8 rdBuf[10];
I2C_SlaveInitReadBuf(rdBuf, 10);
Index
0x1243
0x09
uint8 wrBuf[8];
I2C_SlaveInitWriteBuf(wrBuf, 8);
0x08
0x07
Index
0x06
I2C Read
Buffer
0x07
0x05
0x04
0x03
0x123A
0x06
0x1237
0x05
0x04 I2C Write
Buffer
0x03
0x02
0x01
0x02
0x1230
0x00
0x01
0x00
0x0000
¾¿ I2C_SlaveInitReadBuf() ² I2C_SlaveInitWriteBuf() - •‡
ÀÁ
®‹ rdBuf
2
wrBuf ÂÃ ¸
ÄÅÆÇ È I C £¤—˜²™š¯°•‡ÀÁ É ÊˇÌÍÎÏ
¯°
ДÑÒ• €—˜
™š
Âÿ I2C_SlaveGetReadBufSize()
² I2C_SlaveGetWriteBufSize() ÓÔÕÖ×Ø ¯°
—˜²™šÙÚ
¯°
¯°•‡
Û•ÜÝÞß àÞß
®¾¦§ á⯰ ‡”Ѫ I2C_SlaveStatus() API Ó—˜
àÞß
ã
ÀÁ
äÍ
åæ䮇œª
Ñçèé
void I2C_SlaveClearReadBuf(void)
void I2C_SlaveClearWriteBuf(void)
ÀÁ äÍê I2C £¤—˜²™š çÅƯ°ë‹
ìíèéî𗘲ñò
¢
ˆ
ÄÅƯ°
¾ª
I2C £¤ ¥ó—˜²™š ôõª
ÀÁÊ ‡Ìͪ ìí
èé‡ö÷
ÀÁ ø
2
»ÙÚ
» 2 ùú ‰ I C £¤ûƒüýó™š ¢þ– ú… ÄÅó™šþ–‹ 4
Ư°‡Äÿó™šþ–‹ 6 Ư° Äÿó ¢þ–
Ä 6 Ư°!"¦§ ö#‡$%ü
Page 26 of 47
Document Number: 001-79275 Rev**
®
PSoC Creator™
2
I C £¤/¥£¤/¦§
¢¨©
þ–!¼& '(£¤ø»¾Äÿó ¢þ– ™šÄ 7 Ư°‡²åæ¾Ä)ó
–•™š•*¯°‡÷+Ư°, "ö#-.0‡ÌÍ
ä‹1
¾ÄÅó ¢þ– ÀÁ äÍê-Û•Äÿó ¢þ–23ÄÅó ¢þ–
I2C_SlaveClearWriteBuf() œ• Ÿ5
ÜÝ•Œ .6 ¢ ¾
î§ ·ð7¡
¢
¢þ
¢4‡œª
ÀÁ ä
» 2. 89¹º§
System Memory
uint8 wrBuf[10];
0xFFFF
I2C_SlaveInitWriteBuf((uint8 *) wrBuf, 10);
Index
Read or Write
Buffer
Visible by
I2C Master
9
Trans2 Byte6
8
Trans2 Byte5
7
Trans2 Byte4
6
Trans2 Byte3
5
Trans2 Byte2
4
Trans2 Byte1
3
Trans1 Byte4
2
Trans1 Byte3
1
Trans1 Byte2
0
Trans1 Byte1
Transaction 2
Transaction 1
0x1239
0x1230
0x0000
—˜
™š
:;Æáâä”$ú×Ø<•=ž¾×Ø =
ÜÝ È×Øå敇
®>[email protected] È×Ø<••‡
®×Ø<•@A‡- ìí>[email protected] '(åæÄÿó
×؇÷”± “• ®>[email protected] ×Ø<[email protected] ç$Öú‹—˜ ™šáâ@A
¦§
áâB
Ç
C%
I2C_SSTAT_RD_CMPLT
0x01
¦§
I2C_SSTAT_RD_BUSY
0x02
ž¾ûƒ¦§
I2C_SSTAT_RD_OVFL
0x04
£¤Fø—˜ÙÚ
I2C_SSTAT_WR_CMPLT
0x10
¦§
I2C_SSTAT_WR_BUSY
0x20
ž¾ûƒ¦§
I2C_SSTAT_WR_OVFL
0x40
£¤ø»¾
—˜×Ø!<•
—˜×ØD>?E
G
¯°
™š×Ø!<•
™š×ØD>?E
¼&î4™š H
ÑçIJú…€™š
‚ƒüK憇L4³M×Ø <• ¾×Ø<•î4‡ ¢
ÅÆN–
¾O¥· PQ ‡ ¢Œ
ÄÿÆ䮇R‰”ѾSæ
Document Number: 001-79275 Rev**
Page 27 of 47
2
IC
/
®
PSoC Creator™
/
•Ž••‘
‹
›™•
Œ•Ž
’“”•–—
€•‚ƒ„
˜™ š
…†‡ˆ‰Š
‹
›•œ‚
Œ
uint8 wrBuf[10];
uint8 userArray[10];
uint8 byteCnt;
/* Initialize write buffer before call I2C_Start */
I2C_SlaveInitWriteBuf((uint8 *) wrBuf, 10);
/* Start I2C Slave operation */
I2C_Start();
/* Wait for I2C master to complete a write */
for(;;) /* loop forever */
{
/* Wait for I2C master to complete a write */
if(0u != (I2C_SlaveStatus() & I2C_SSTAT_WR_CMPLT))
{
byteCnt = I2C_SlaveGetWriteBufSize();
I2C_SlaveClearWriteStatus();
for(i=0; i < byteCnt; i++)
{
userArray[i] = wrBuf[i]; /* Transfer data */
}
I2C_SlaveClearWriteBuf();
}
}
/
žŸ
5,6
Œ
¡¢£‚ƒ•¢¤€žŸ¥¦§¨ƒ …
©ª«žŸ¬•-®¯¬°±
²³´•²µ³´ ¶·¸ ¹ º
’“» ¹ º
¼½ …¾¿ÀÁ«•Â®ÃÄÅšÆÇžŸÈÉ•ÊËÌ“ÍÎÍÎ
žŸ Â-®Ï²µÐÑÒ•ÓÔ¹ º
Õ¡³´•ÖÂÒÏ×ØÙÚ
Ûܺ‚ƒ„
…
©ª«•’݃¬Í΢º
ÓÔÞß¾¿ÀÁ•à› º
˜áâãä ÃÄ…åºæç™èÈÉ˱² ¶•é¾¿ÀÁ
Ïêα²¾¿ÀÁ•ë
…áâãäËÞ•ÙÚì¯
5
ÓÔí …“ÍÎ”î „Ëïð×Ø“ñò”î •Ö…
ó
©ª«•PSoC 3 ES2 Œ PSoC 5 €ôõö“÷
雀©ø˜ßÉ“ñò”î
§ùÀÁ˜…úûæüýÓÔ
•Þþ 0xFFÿ„ËÞß•!¬¬"´#$%&
'( %)*¾¿ÀÁ•+,…Í΄Ëïð×Ø“ñò”î -.0™è ºæç•ë…Þþ NAK ó ACK 쯄Ç
×Øñòî
6
ôõö“÷é‚1$2õ3€³´î
Page 28 of 47
%4ò§ùÀÁ•’5•6Š¥† UDB €÷é
Document Number: 001-79275 Rev**
®
2
PSoC Creator™
IC
…7 I2C
žŸ¬’
Ó«89: ÎŒêÎ …êΩª›•Ï;<
™è
…7
žŸ¬•
[email protected]Þþ€
ÓÔê
‡ˆCD ºE?
FGH€
ˆ…êΩª›˜æç
/
/
•#=>?
•Ö.0
•+‰ŠÝ«‹
uint8 I2C_MasterWriteBuf(uint8 slaveAddress, uint8 * xferData, uint8 cnt, uint8
mode)
slaveAddress IŽ
ºJKL€ 7 M
úû•àÒN† 0 . 127 „O
API ÏêΘ
PQRSšúûæç€ LSb › ÛܺT xferData UVˆ™è€
Cnt T W
ˆ™è€æç
XË ºT “modeý©ªÿ”˜Yõ™èZ[Œ\]€^ª ’݉Š“Restart
ý_Íÿ”œ‚ “StartýÍÎÿ”•Z[
žŸ•ó…“ñò”®`„Çaò
žŸ ¾b8c˜
de7 fKf™è•à›XË º™è‚ÏÞþ“Stopýñòÿ”gh•œ« º™èÏÞþ
“Restartý_Íÿ”œ‚ “StartýÍÎÿ”gh
žŸ
žŸ
i
‰Šj?¨ƒ•Ž€¨ƒT
uint8 I2C_MasterReadBuf(uint8 slaveAddress, uint8 * xferData, uint8 cnt, uint8
mode);
¾¢º‹ kÏÐÑlm ?n I2C_MasterStatus() ‹ ÐÑÒ€½o•+TplmW q†…
Œ
™èÏ…ËuÈÉ•v!’݉Š I2C_MasterStatus() ‹ •YõÂ
I2C ›r5stO
™èw¬ÈÉ Ý«> 5sü K
€xy
I2C_MasterClearStatus(); /* Clear any previous status */
I2C_MasterWriteBuf(0x08, (uint8 *) wrData, 10, I2C_MODE_COMPLETE_XFER);
for(;;)
{
if(0u != (I2C_MasterStatus() & I2C_MSTAT_WR_CMPLT))
{
/* Transfer complete. Check Master status to make sure that transfer
completed without errors. */
break;
}
}
z’݉Š
º|C
Î^ª7
I2C
žŸ
…!©ª›•˜‰Š{ºgh•7
žŸ€å
status = I2C_MasterSendStart(0x08, I2C_WRITE_XFER_MODE);
if(status == I2C_MSTR_NO_ERROR)
/* Check if transfer completed without errors */
{
/* Send array of 5 bytes */
for(i=0; i<5; i++)
{
status = I2C_MasterWriteByte(userArray[i]);
if(status != I2C_MSTR_NO_ERROR)
{
Document Number: 001-79275 Rev**
Page 29 of 47
2
IC
/
®
PSoC Creator™
/
break;
}
}
}
I2C_MasterSendStop();
/* Send Stop */
€•‚ƒ„
…†
‡ˆ‰
status = I2C_MasterSendStart(0x08, I2C_READ_XFER_MODE);
if(status == I2C_MSTR_NO_ERROR)
/* Check if transfer completed without errors */
{
/* Read array of 5 bytes */
for(i=0; i<5; i++)
{
if(i < 4)
{
userArray[i] = I2C_MasterReadByte(I2C_ACK_DATA);
}
else
{
userArray[i] = I2C_MasterReadByte(I2C_NAK_DATA);
}
}
}
I2C_MasterSendStop();
/* Send Stop */
Š‹Œ•Ž••‘
’•‘“
Œ•‘¢£
³´‰
”€•–Š‹Œ—•Ž•
’•‘“ ¤‹Œ ¥•
µ¶•Ž•¥•“·
¸¹‹Œ—•Ž•
‰‚ƒ
˜™•”€ š•Ž•›œ•
ž•Ÿ ¡ ‹
¦§¨©ª«¬ -•®Ÿ¯°•Ž••‘ ±²
º»¼•Ž•
—‹Œ/Š‹Œ
uint8 userArray[10];
uint8 byteCnt;
/* Initialize write buffer before call I2C_Start */
I2C_SlaveInitWriteBuf((uint8 *) wrBuf, 10);
/* Start I2C Slave operation */
I2C_Start();
/* Wait for I2C master to complete a write */
for(;;) /* loop forever */
{
/* Wait for I2C master to complete a write */
if(0u != (I2C_SlaveStatus() & I2C_SSTAT_WR_CMPLT))
{
byteCnt = I2C_SlaveGetWriteBufSize();
Page 30 of 47
Document Number: 001-79275 Rev**
®
PSoC Creator™ ™•
2
I C ‹Œ/Š‹Œ/•Ž•
½
I2C_SlaveClearWriteStatus();
for(i=0; i < byteCnt; i++)
{
userArray[i] = wrBuf[i]; /* Transfer data */
}
I2C_SlaveClearWriteBuf();
}
}
‹Œ/Š‹Œ
¾
¿
ÀÁ-•¥•Â쥕
¨©ÄÅÆÇÈ‹Œ ¥•
É •Ž•œ• µ¶
ÊËÌÍ• Î “·‰Ï ®Ð
”€Ö×ØÙ”ÁÚ
Û Ü× -•¥•ÂìÝÞßÁ
Î
‰Ï
I2C_MasterSendStart()
¦§¨©ª« •Ž•¥•“·
°¨©ª«ÑÒ Ó•¥•ÔÕ
à…დâã†äå‰ÑÒæç
è銋Œ•Ž•¢£
ÀꊋŒ•Ž•¬ ”€ ëì¬íî•Ž•œ• ¤ïð
ñòÑÒ¬ Š‹Œóôõö
¬§÷øùúûüýÁµ¶“¡ ”þ•
’¦§ ÿ!®î•Ž•œ• ±"’#$Š‹Œ
%&'•–•Ž•
º(ó)*“·•Ž•
+ µ¶¡ þ•,$
2
œ•.0 1 óô2ê I C “· ’
À3”€“$Š‹Œ
±äå¡ •Ž•
2
2ê I C “· ”Á 4µ•5ÑÍÆ

µ¶“¡ ” 1ïð678•Ž•
ä -–“ 9:ÊË;æä<êïð= Š‹Œ>?
2
•Ž•
@ &'-– I2C_MasterWriteBuf()A
µ¶“¡ ”þ• ÀÁ I C “·
I2C_MasterReadBuf() 9 I2C_MasterSendStart() ‰BêCDÑÒ I2C_MSTR_BUS_BUSY

µ¶“¡ ” 1 ïð
ñòÑÒ ÀÁ I2C “·
Š‹Œ ïð൶“¡ ”þ•
@ &' I2C_MasterWriteBuf()A I2C_MasterReadBuf() 9 I2C_MasterSendStart() ‰B
êCDÑÒ I2C_MSTR_NO_ERROR

µ¶“¡ ” 1 ïð
ñòÑÒ Š‹ŒEFµ¶“¡ ”þ•
’ 1G Š‹Œî•
Ž•œ• ’¬ïð®- 67ÑÒ “¡ ”þ•µ¶®5 H5 I 2ê† I2C “· •
Ž•
#$ œ•.0 . ÀÁ I2C “·
H5“‰Š‹Œ
®› Ö •Ž•
®&'-– I2C_MasterWriteBuf() 9 I2C_MasterReadBuf() ‰Bêšî’ JK
%
CD I2C_MSTR_NO_ERROR Š‹Œ
› Ö
I2C_MasterStatus() CD
I2C_MSTAT_WR_CMPLT 9
CD I2C_MSTAT_RD_CMPLT —
I2C_MSTAT_ERR_XFER 8ÊËL¸MNÑÍOPQR×= I2C_MasterSendStart() ‰Bê
CDMNÑÒ I2C_MSTR_ABORT_XFER
“·Ï

I2C_MasterWriteBuf();
Document Number: 001-79275 Rev**
Page 31 of 47
2
®
I C ‹Œ/Š‹Œ/•Ž•

PSoC Creator™ ™•
½
I2C_MasterReadBuf();
I2C_MasterClearStatus();
/* Clear any previous status */
I2C_DisableInt();
/* Disable interrupt */
status = I2C_MasterWriteBuf(0x08, (uint8 *) wrData, 10, I2C_MODE_COMPLETE_XFER);
/* Try to generate, start. The disabled I2C interrupt halt the transaction on
address stage in case of Slave addressed or Master generates start condition */
I2C_EnableInt();
transaction */
/* Enable interrupt and proceed Master or Slave
for(;;)
{
if(0u != (I2C_MasterStatus() & I2C_MSTAT_WR_CMPLT))
{
/* Transfer complete. Check Master status to make sure that transfer
completed without errors. */
break;
}
}
if (0u != (I2C_MasterStatus() & I2C_MSTAT_ERR_XFER))
{
/* Error occurred while transfer, clean up Master status and
retry the transfer */
}
Ï
Š‹Œ
ST I2C “·Q›2ê
ÊU
ø‰÷?
VꀕW,XYÆ
I2C_DisableInt();
/* Disable interrupt */
status = I2C_MasterSendStart(0x08, I2C_WRITE_XFER_MODE);;
/* Try to generate
start condition */
if (status == I2C_MSTR_NO_ERROR)
/* Check if start generation completed without
errors */
{
/* Proceed the write operation */
/* Send array of 5 bytes */
for (i=0; i<5; i++)
{
status = I2C_MasterWriteByte(userArray[i]);
if (status != I2C_MSTR_NO_ERROR)
{
break;
}
}
I2C_MasterSendStop();
/* Send Stop */
}
I2C_EnableInt();
/* Enable interrupt, if it was enabled before */
Page 32 of 47
Document Number: 001-79275 Rev**
®
2
PSoC Creator™
IC
€•‚



I2C
‰Š€‹Œ•
Υ I2C
I2C
…†Ž
ƒ„…†
‡
/
ˆ
…†‹
••‹
SIO ‘’“” SCL • SDA –— ˜™ šŒ•›œ•‘ˆI2C0 — SCL P12[4]
P12[5] — I2C1 — SCL P12[0] SDA P12[1]‹
I2C
˜™
/
™žŸ
¡
¢£¤¥¦§
›œ•
SDA
¡‹
¨©ª«
I2C …¬-‘ƒ„…† • I2C ®¯•
°©±²³´‹
µ¶•
·
¸
2
IC ¹º»‹¼¹
½¾¿
šÀÁ
º» –— SCL -ÂÃÄÅÆÇÈ‹
¼º»
–— CPU œ˜É
°©š• ÊË°©Ì -½•Í ACK ´Î‹
•
ÏÐÑ
I2C
- Ò̓„…† Š ÏÐÑ‹ÓÔÕÖ׺»š•Ø
Ï ÙÌÚ€ÛÜ I2C
°©‹ ±¶ƒ„ÇÈÝÞ-½ßà I2C šÀ –—á âà I2C_Wakeup() ã ÌÚ½Š€
¹šÀ‹
•äåâà I2C_Wakeup() •æç SCL ¯-ÂÃÄÅÆÇÈ‹
èéêëˆ
…
I2C_Sleep();
CyPmSaveClocks();
/* Go to Sleep and disable I2C interrupt */
/* Save clocks settings */
CyPmSleep(PM_SLEEP_TIME_NONE, PM_SLEEP_SRC_I2C);
CyPmRestoreClocks();
/* Restore clocks */
I2C_Wakeup();
/* Wakeup, enable I2C interrupt and ACK the address, until
end of this call the SCL is pulled low */
…
Document Number: 001-79275 Rev**
Page 33 of 47
2
IC
/
®
PSoC Creator™
/
¥ìíîïðñò· I2C óô
•õö
¥ìíîïðñò©÷øùúû¶
°©ü•³´úýþ
°©ü±²ÿ!‹
"•Íøù#¥ìíîïð•$´Î• ç%&øù•'² ç‹¥ìíîïð• I2C óô
&(
)†±²*+•ˆ¼ ",-´Î–—¥ìíîïð. '²øù
¹´Î÷
0xFF‹
Š€ˆI2C ¥ìíîïðóô
01“2¹øù –—345#ÊË
ýþ
°©7-8$ 0xFF‹Ø û¶
°©7-9÷øù‹
6•´Î‹
"'²•Ø
¥ìíîïð:ïˆ "-ó;ÊËû¶
°©•Íøù –<=>?Á@þ´Î‹ ¥ìí
îïðAB 6´ÎÝÞ 7-Šà 0xFF Á´Î I2C óô
‹“2 0x01 ÝÌ
"ÔÕC'
²ÊDýþÚ @5³´•EF N – 1 ËGH‹ IDýþJKÝÌ ä -±²L– MKJ
N•³´£‹
"ÔÕýþÊËGHÁ'²>? ýþ ËGH €½OP´Î‹ 0xFF 0x01 0x03 ÷ëú
"Øýþ•&³´š•IËGH Q&¢&ÊËGHü RÃ 0x01 • 0x03 ‰ýþJS JN³
´• ÊDýþ½8$IËT6U‹
VWX>?ˆ´Y º»*ÂúCPU Z[\]^ •]^ _`abüÁ•cøù'² ç
(Tcom_ex) d´Î*Â ç (Tans_set)‹ "ÔÕ ¹ ç;Ì,-³´‹øù'² ç½e
¢f•øùQ Øg` eh´¹Œ•ij• ç‹
>?•f ±² ÏÐшI2C óô
•øùïð² (0x39) k-ßàšÀ‹
‚ ÏÐÑ‹
Page 34 of 47
±²°© k-Š€šÀ‹-ʲlm
“nɹ
ßàšÀ•f I2C óô
û¶
½•
Document Number: 001-79275 Rev**
®
2
PSoC Creator™
IC
/
/
VWX ÏÐшkWX ÏÐÑ ´Y º»*ÂúCPU Z[\]^ •]^ _`abü
Á•cøùïð² (0x39) '² ç (Tcom_ex)‹ "ÔÕ ¹ ç;Ì,-³´‹
opÅq’“
I2C ®¯skopžtÅu‹žtÅu (RP) þvÃwÅÅx\ Ïyz•®¯Å{‹
3 mA
VOLmax = 0.4V
€ 5V •‚
ƒ„ …†‡ˆ 1.5 k ‰Š RP
‹†Œ• Ž• •‘
’“”• – Ž• • 150 pF
5V •‚—ƒ„ … ˜™ 6 k
š›œ•ƒ„ …‘žŸ
¡Ž•¢£‹
¤¥¦§—¨©ª NXP «¬ (www.nxp.com) ƒ The I2C -Bus
Specification I2C — Ž•¢£
r 3 Øê
- 3.
® I2C Ž•
¯°
±
²³„´ žµ¶·¸¹ žº»¼½¾¿ÀÁÂà I2C Ä —ŹÆÇ Philips I2C ÈÉÊ
µ¶»Ë¸¹—ÌÍ I2C •‚ºÎÏ ÐÄ —ÑÒÓÔÕ•‚Ö× Philips ØÙ I2C ÚÛ¢
£ Ü 2006 Ý 10 Þ 1 ßà—áÉâãäåæçèÏ»¼é êÚëì — NXP ãäå
Document Number: 001-79275 Rev**
Page 35 of 47
2
IC
/¥
®
PSoC Creator™ Ä
/
íÇîï
ºðñòóôõ
ºðñòóôõÔÄ
!"#$



ö÷øùÎÏ
ôõ—ú
%Ï&'()
؈*+,•‘ØÙ
-.
0123
Û$4Œ567
!"8•‚
Ï&'()
I2C Ä ¹–‹9·!"ûϺð:íÇ!";<
ºðCD
E‹F% G Ð@í)
¥






ûÕ–žüýþÿ
=’¤é
–;<4Œ‘>?@íÓAB
)
I2C_MasterStatus()
I2C_MasterClearStatus()
I2C_MasterGetReadBufSize()
I2C_MasterGetWriteBufSize()
I2C_MasterClearReadBuf()
I2C_MasterClearWriteBuf()
)









I2C_SlaveStatus()
I2C_SlaveClearReadStatus()
I2C_SlaveClearWriteStatus()
I2C_SlaveInitReadBuf()
I2C_SlaveInitWriteBuf()
I2C_SlaveGetReadBufSize()
I2C_SlaveGetWriteBufSize()
I2C_SlaveClearReadBuf()
I2C_SlaveClearWriteBuf()
Page 36 of 47
Document Number: 001-79275 Rev**
®
PSoC Creator™ Ä
2
IC
íÇîï
/¥
/
HI
JÓA @íKL‹9·ûÏôõJM NÏOý’@í Ì HI ©P¦§ QRÏ&ÓA
GST UV I2C_Data HI WMÎÏÕ API—͹X° íÇYZ[Ž•º
¹\–ÎÏ
CPU
DMA ]^š_`
a¼ I2C Ä
¹Ï
b
HI
/
cØd\
ÆÇ"
cØd\eÔ UDB üýfgh·Ä
HI
š› ÐHI
¤¥¦§—¨©PÕij kl©Pîï (TRM)
(*) hop-.[ Production PSoC3 ijº Jšq
%ØÙº—
ÎÏmn
I2C_XCFG
¹ÌÎÏcØd\r





stº
uvb
HI
hb
r
q
7
6
5
4
†
csr_clk_en
i2c_on*
ready_to_sleep*
force_nak*
csr_clk_en)Ï
Î\cØd\styz{|
'( I2C st"
i2c_on*)Ï
01sw‘’“x
3
2
1
RSVD
0
hw_addr_en
›ð
}~x
ready_to_sleep*
force_nak*
hw_addr_en
€
•
I2C_ADDR
‚ƒ
“

„…†
•”•–‰Š
—
7
˜
RSVD
slave_address
‡ˆ‰Š
‹ŒŠ•
€
•Ž••‘’ XCFG ‹ŒŠ‡
Š
6
5
4
3
2
1
0
slave_address
•
Document Number: 001-79275 Rev**
€
•…™ 7 —‰Š
Page 37 of 47
2
IC
/
®
PSoC Creator™
/
I2C_CFG
€







•
7
6
5
4
‚
sio_select
pselect
bus_error_ie
stop_ie
sio_selectƒ
pselectƒ
clock_rate[1:0]
„… SCL † SDA ‰‡ˆ SIO ’“” DSI •–
„… bus_error
„œ•ž•Ÿ
clock_rateƒ
en_mstrƒ
2
„… SCL † SDA ‡ˆ SIO1 † SIO2 ‰Š‹Œ…••Ž
bus_error_ieƒ
stop_ieƒ
3
en_mstr
en_slave
pselect ••‘€
GPIO/SIO —˜€
™š›€
„‡ˆ 16 •” 32 •¢£¤€Production PSoC 3 ¥
en_slaveƒ
0
™š›€
¡
„
1
bit2€
¦€
„
¦€
I2C_CSR
§†¨©
§†¨©®¯€
•
7
6
5
4
3
2
1
0
‚
bus_error
lost_arb*
stop_status
ack
address
transmit
lrb
byte_complete




bus_errorƒ°‰±²Ÿ



addressƒËÌ¡ÍÄ·

ª«¬«-
¨©•€³‹Œ´“0”µ¶·•••
¸¹€
lost_arb*ƒº»¼½Ÿ ¨©•€
stop_statusƒ•žŸ
¨©•€³‹Œ´“0”µ¶·••
ackƒ¾¿ §•€À¾¿ÁÂÃÄ
ÆÇÈŠ‹Œ´ÊŽ …“0”€
transmitƒ
Ó‚
¸¹€
ÅÆÇÈŠ‹Œ´••Ž
ÇÈÎÏÐÇÈŠÑÒŽ
ÔÇÈÕÖ
…“1”ŠÀÉ¿ÁÂÃÄ
Å
Ó‚€
×Ø€
lrbƒÁÂÃÄ ÅÆ• ¨©€••ÙÚÃÄ
(ACK/NACK) ßà ¨©€
ÛÁÂÕÖ
ÅÆÇÈÜÝ
Þ9•
byte_completeƒÕÖ”ÃÄÁÂÅáâã•
¨©€œÕÖ ¦ Š••ÙÚä
ÁÂÅáâã
åÕÖæ 8 •
† ACK/NAK à瀜ÃÄ ¦ Š••ÙÚäÁÂÅá
âã•
åÃÄæ 8 •
€
Page 38 of 47
Document Number: 001-79275 Rev**
®
2
PSoC Creator™
IC
/
/
I2C_DATA
ª«¬«-ÕÖ†
•
7
6
5
4
3
2
1
0
data
‚

ÃÄ€
dataƒœÕÖ ¦ ŠÒ
ÕÖ
byte_complete ¨©èâã•
µ¶•
€œÃÄ
¦
Š´œÄ·
€
I2C_MCSR
§†¨©
ª«
¦éÝ
¬«-
§†¨©®
¯€
•
7

5
RSVD
‚




6
4
3
2
stop_gen*
bus_busy
stop_gen*ƒËÌŽ Ó‚ŠêÇÈÕÖëì-´œ
bus_busyƒÙÚ°‰¨©€0 ÙÚåŸ
master_modeƒÙÚåš›•‘
“ðñ”ï
¦
š›“•ž”
Š1 ÙÚåŸ
·“ðñ”ï
Š
restart_genƒ §
œ°‰¡óô“õð”ï
Ž Óï ù›¨úûüýÂÝ…â㨩þ€
Ý…°‰
€
start_genƒ §
œ°‰¡óô“ðñ”ï €
Ž Óï ù›¨úûüýÂÝ…â㨩þ€
0
master_mode restart_gen
íî
·“•ž”ï
1
start_gen
€
òœ¬«€
´œ“õð”ö÷¸¹••ø
œ
´œ“ðñ”ö÷¸¹••ø
œ
UDB
UDB
ÔÎ
¦ö÷ Verilog€
I2C
Verilog ö÷ÿš
Š•!³"
Ô
#
$%Š&'()
I2C_CFG
UDB ö÷
•
‚

7
§
6
Û
5
start_gen stop_gen restart_gen
start_genƒŽ… 1
••€
ª«¬«4
3
2
1
0
ack
RSVD
transmit
en_master
RSVD
œ°‰¡š›“ðñ”ï
Document Number: 001-79275 Rev**
§€
€‹Œœ*+,èÅÆ
éÝý-–
¸¹
Page 39 of 47
2
IC
/
®
PSoC Creator™
/

stop_genƒŽ… 1
••€


restart_genƒŽ… 1

transmitƒŽ… 1 Ò´ê- ¦Ž …ÕÖŠ”¸3
”ÃÄ
éÝý-–
¸¹••€

en_masterƒŽ… 1 Ò
œ°‰¡š›“•ž”ï
€‹Œœ*+,èÅÆ
œ°‰¡š›“õð”ï
ackƒŽ… 1 Ò.0èÅÆâãÇÈ€¸¹
¸¹••€
€‹Œœš›“õð”ï
éÝý-–
–
¸¹
¸¹••€
¾¿èÅÆâãÇÈ€‹Œ–1„ÇÈý2
ÃÄ
ÇÈ€‹ŒœðñèÅÆÕÖ
€
I2C_CSR
œ UDB ö÷
¨©
–
4ãö-¨©®¯€œ5
Ö¶-67Š89´
Ê
… mode = 1 :;• ¨©
€³"•Î<= >œ?áâ㨩
¸¹€Ü
•Ê@•A
… mode = 0Š>B
’ô³"• Ö¶âã·¨©
€CDEÎ<=
•ŠF•œâã-EÒ¸¹€œèG Ô ŠÜ•
… mode = 1 •A HI (*) ÙÚ€
•
7
‚
RSVD
6
5
4
lost_arb* stop_status* bus_busy
3
2
1
0
address
master_mode
lrb
byte_complete






lost_arb*ƒËÌŽ

byte_completeƒÕÖ”ÃÄÁÂÅáâã•
¨©€œÕÖ ¦ Š••ÙÚä
ÁÂÅáâã
åÕÖæ 8 •
† ACK/NAK à瀜ÃÄ ¦ Š••ÙÚäÁÂÅá
âã•
åÃÄæ 8 •
€
Ó‚ŠÑÙÚº»¼½ø
†
stop_status*ƒËÌŽ Ó‚ŠÑÙÚ地‰¡Ÿ
bus_busyƒËÌŽ
addressƒÏП
¦þ€
·“•ž”ï
€
Ó‚ŠÑÙÚ°‰JK€L-òœÕÖ”ÃÄ
€ËÌŽ
€
Ó‚ŠÑÙÚåíîÏÐÇÈ€
master_modeƒÙÚš›ÅÆ•‘“ðñ”ï
ŠM-
lbrƒÁÂÃÄ ÅÆ•€ÙÚÁÂÃÄ ÅÆ•
ACK/NAKþ€Cleared = ACK † set = NAK€
ŽN¬«…°‰
¨©ø…ÁÂÕÖ
€
ÅÆÇÈOÄ·
I2C_INT_MASK
UDB ö÷
I2C_CSR
¨©
Page 40 of 47
™PQ
´R"¨©•
… ™S€
•U Ôª« 1 Û 1 •!VŠ´WX¨©
•
T¡Í
… ™S€
Document Number: 001-79275 Rev**
®
2
PSoC Creator™
IC
/
/
I2C_ADDRESS
UDB ö÷

•
7
‚
RSVD
ÏÐ
6
…
YZ
5
¦
4
ŽNÏЀ
3
2
1
0
slave_address
slave_addressƒ „…
ÏÐYZ
Ô7•
¦
ÏЀ
I2C_DATA
UDB ö÷
•
ª«¬«-ÕÖ†
7
6
5
4
3
2
1
0
data
‚

ÃÄ€
dataƒœÕÖ ¦ ŠÒ
ÕÖ
byte_complete ¨©èâã•
µ¶•
€œÃÄ
¦
Š´œÄ·
€
I2C_GO
œ
[«ÕÖéÝ-ŠGo
Go
Ò\§ÃÄ
^´µ¶RÆ‚€
Ò\§ÕÖ
€Û•
[«
€œ
[«ÃÄéÝ-Š
WXµ¶AÒ\§[«•éÝŠ]
UDB
UDB
ÔÎ
¦ö÷ Verilog€
I2C
Verilog ö÷ÿš
€•!³"
Ô
#
$%Š&'()
I2C_CFG
UDB ö÷
§
Û
ª«¬«-
§€
•
7
6
5
4
3
2
1
0
‚
RSVD
RSVD
RSVD
nak
any_address
transmit
RSVD
en_slave

nakƒËÌŽ
••€

any_addressƒËÌŽ Ó‚ŠC´ „
I2C_ADDRESS _` aÅÏЀ

transmitƒ „Ž ÕÖ”ÃÄ
transmit † cleared = receive€
Ó‚ŠC´ „É¿ÁÂÃÄ
Document Number: 001-79275 Rev**
ÅÆÇÈ€‹Œ–1„ÇÈý2
ßàCÃÄ
¦€‹Œ–1„ÇÈý2
WX
¸¹
ÏЊOE¥Î
¸¹••€Set =
Page 41 of 47
2
IC

/
®
PSoC Creator™
/
en_slaveƒŽ… 1 Ò
€
I2C_CSR
§†¨©
ª«¬«- §†¨©®¯€œ5
Ö¶
-67Š89´
Ê
… mode = 1 :;• ¨©
€³"•Î<= >œ?áâ㨩
¸¹€Ü•Ê@•A
… mode = 0Š>B
’ô³"• Ö¶âã·¨©
€CDEÎ<=•ŠF•œâã-EÒ¸¹€œèG Ô ŠÜ•
… mode = 1 •A H
I (*) ÙÚ€
•
7
6
5
4
3
2
1
0
‚
RSVD
RSVD
stop*
RSVD
address
RSVD
lrb
byte_complete



stop*ƒËÌŽ
Ó‚ŠÑÙÚ地‰¡Ÿ
ÏЃÏП
€ËÌŽ

byte_completeƒÕÖ”ÃÄÁÂÅáâã•
¨©€œÕÖ ¦ Š••ÙÚä
ÁÂÅáâã
åÕÖæ 8 •
† ACK/NAK€œÃÄ ¦ Š••ÙÚäÁÂÅáâã
•
åÃÄæ 8 •
€
·“•ž”ï
€
Ó‚ŠÑÙÚåÃÄÏÐÇÈ€
lbrƒÁÂÃÄ ÅÆ•€ÙÚÁÂÃÄ ÅÆ•
ACK/NAKþ€Cleared = ACK † set = NAK€
¨©ø…ÁÂÕÖ
ÅÆÇÈOÄ·
I2C_INT_MASK
UDB ö÷
™PQ
´R"¨©•
… ™S€
I2C_CSR
¨©
•U Ôª« 1 Û 1 •!VŠ´WX¨©
•
b2Ü
™Sƒbyte_complete †•ž€
T
… ™S€éÝ
I2C_ADDRESS
UDB ö÷

•
7
‚
RSVD
slave_addressƒ
Page 42 of 47
ÏÐ
6
…
5
YZ
4
¦
ŽNÏЀ
3
2
1
0
slave_address
„…
ÏÐYZ
¦
Ô7•
ÏЀ
Document Number: 001-79275 Rev**
®
2
PSoC Creator™
IC
/
/
I2C_DATA
UDB
‚
ۥ
7
6
5
4
3
1
0
data
ƒ

2
data„…
† ‡ˆ
byte_complete ••‘’“Œ
‰Š‹Œ
•…
€
†
‡•…€Ž
•
I2C_GO
…
”
—˜
¡¢£
Ի
•– ‡Go
€
•™Œ
ˆ—˜
”
•…
€ ‡Go
š›Š‹œˆ—˜” Œ•–‡•žŠ‹Ÿ ƒ•
¤¢££¥¦§¨FF
©
ƒ«¬-®¯§°‡±²³´µ¶¦§
•
I2C ¡¢£·¸
¹
º»
£¢ÃÄ
¼
½¾ ƒ
¿À ƒ
½Á ƒ
‚
Å
°‡Æ™ 100 kbps
ÇÈ
--
--
250
A
Å
°‡Æ™ 400 kbps
ÇÈ
--
--
260
A
--
--
30
A
½¾ ƒ
¿À ƒ
½Á ƒ
‚
--
--
1
Mbps
ÉÊ
†ËÌ
I2C ¤¢£·¸
¹
º»
¼
ͦÎ
¡¢£
Ի
¤¢££¥¦§¨UDB
ƒ«¬-®¯§°‡±²³´µ¶¦§
©
•
Ϧ§“Ð
ÐÑÒÓ ½Áƒ”
¹
fSCL
º»
SCL
½¾ ƒ
¿À ƒ
½Á ƒ
‚
ÔÕÎ
Document Number: 001-79275 Rev**
Page 43 of 47
2
IC
/
®
PSoC Creator™
/
¹
º»
7
¿À ƒ
½Á ƒ
‚
Ö×
†
100
kHz
ØÙ
†
400
kHz
1000
kHz
16 × fSCL
kHz
Ú—ÀØÙ
fCLOCK
½¾ ƒ
‹
ÔÕÎ
†
tLOW
SCL
Ô
Û£ÜÝÞ
8
tCY_clock
7
tHIGH
SCL
Ô
ߣÜÝÞ
8
tCY_clock
7
tHD_STA
àá â¨ãä©åæ¼
15
tCY_clock
tSU_STA
ãä START ¼
9
tCY_clock
çè
â
tHD_DAT
àá
â
1
tCY_clock
tSU_DAT
çè
â
7
tCY_clock
tSU_STO
STOP ¼
9
tCY_clock
tBUF
STOP
32
tCY_clock
tRESET
ä‚îïðñ
2
tCY_clock
çè
START ¼ éâ
tCY_clock = 1/fCLOCK•òóôõ
ø 4.
ùú
â
ÔÝÞ
êëìí
ö÷
â
â
Ïø
SDA
tLOW
tHIGH
tSU_DAT
tBUF
tHD_STA
SCL
tHD_STA
S
û›• STA üý
SR
P
S
´¦§
þÿÒÓ½Áƒô!"
#• Ï$% (STA)
ý-‘.0123 4¯¯5½Áƒ•
…Ð67
tSU_STO
tSU_STA
tHD_DAT
&'()€*
•+
ü,
STA ü
Ô
Ô8ê
Ïüý 9:- fCLOCK ½Á
ÔÕΕ½Á
Ô;˜2 fCLOCK =
16 × fSCL = 16 × 1000 kHz = 16 MHz‡<Œ STA =>?° ´@AôBCD-=> ½Á ÔÕΨ½Á
ÕΩ•‘ªô _timing.html E
Ô;˜ ¬F„
Page 44 of 47
Document Number: 001-79275 Rev**
®
2
PSoC Creator™
IC
GH¹ ¦ÿ´
NO•
‡…
¯5•I2C
Ôö÷
2
- 2007 I 6 J
tSCL
½ß • I C
Ù΃ÿP2 1000 kbpsQÖ×
ÔU°V“ÐS
ÙΕ
tLOW
SCL
Ô
Û£ÜÝÞ•
WX 50 % YìÍ
Ôö÷•
tHIGH
SCL
Ô
ߣÜÝÞ•
WX 50 % YìÍ
Ôö÷•
ÙÎ2 50R100R400
/
/
I2C êë·¸KLM 3
1000 kbps•ST 16x
‹
tHD_STA … SDA 2-WX“å攼 ) ߣÜZúŽÛ£Üé[ SCL \]2ߣÜ
^•_"Œ â`é[‡ˆWXaõ
Ôîï•
½¾
â
tSU_STA … SDA 2-WX“å攼
^•
½¾
â
)
ߣÜZúŽÛ£Üéb SCL \]2ߣÜ
tHD_DAT SCL \]
‘cd[
efÑg
½¾
â^•
tSU_DAT SCL \]
òhdb
efÑg
½¾
â^•
tSU_STO … SDA \]2-WXij¼
¾ â^•
tBUF
tRESET
…ij¼
[êëk2ìí
STlö÷ðñ
Document Number: 001-79275 Rev**
)
Û£ÜZúŽß£Üéb SCL \]ef2ߣÜ
½
â`•
ä‚\]•
Page 45 of 47
2
IC
/
®
PSoC Creator™
/
mn
opqr
-
bMosÍ
Mo
3.1
Tmn•
mn/u
uvw<
mn º»
•ÿPÓ I2C_SSTAT_RD_CMPT mn
2 I2C_SSTAT_RD_CMPLT
•ÿPÓ I2C_SSTAT_WR_CMPL mn
2 I2C_SSTAT_WR_CMPLT
.cyre
CYREENTRANT
API
x…y,’“
Š‹zXÖ{
ÿP•|
I2C_SSTAT_RD_CMPT
I2C_SSTAT_WR_CMPT
API
„…†‡ˆ‰ Š‹
Œ•Ž••‘
›œ•žŸ
3.0.a
«‰¬„-§®¯°•±
3.0
›œ®
³—
´µ
›
2
I2C_Start() Í
®« UDB ÎÏ
ÓI C
ž
Ü
å滼çè
UDB ÎÏ
®«
žôçè
“Ä+, — З
³—
1
ðñ
”Ì•
23•±
Page 46 of 47
I&0
š
ÝÞߌ I2C_Start() àÍ
Ó
Ü»á
î
*¹+,
œ4®
§
5
2
ÄÅ I C
òóêÓüý
õöŒ¿÷
çèðñ
cy_boot v2.21 úû
³
ÿ‰¬
è»!
³—
З
”êÓ
´µ
ø
ù
×-.§
0
å½
;<Œ%&ðñ-òà=©É78>?
žô
AB/ SCL èCDE
2
@ I C ðñ
òó
®GH‰¬
«‰¬„-§®¯°•±
/
•–—˜™
©ª
§
çè/“Ä+, — З
2
2.0.a
ÛÚÊËÌ•‘
ìí
òó
›œ® I C ðñ
òóžô
6³78» »¼9:
F‰¬„
ˆ‰
§¨
ºéêÓ
ÛÚ®Œþ¹ÿ‰¬ è»! ‰¬"#
Ÿò $Àãä %&' ()
2.10
Š‹ ”
£¤¥¦
¶µ·¸¹
ŒÐ— Ì•‘
â…ãä
ë“®ˆ‰ I2C_SlaveGetWriteByte()
I2C_SlavePutReadByte()
2.20
’“
¡¢
‚ƒ
ÁÂëÄÅÆÀÇ…»¼˜™
ŒÈÉÊËÌ•Í FF ÎÏ
ŸÐ“Enable from Sleep”ÑÐÒË
ÓÔÕÖ×ØÙÚÆÀ
ά
API ۥ
~•l
›²
® UDB »¼½¾¿À
º
}
JK
›²
L•
M
Document Number: 001-79275 Rev**
®
PSoC Creator™
2
I C +,QÄ+,QЗ
‰¬OP
RS
›œ/T
TUVW
›œ 23
«‰¬„-§®¯°•±
2.0
®ÒË/XY
Z[\/
›²
Ó API
çèCê]Ì•
Z[\
Ó
›²®
à 5çè Production
PSoC 3 de›fRS ›²®
ConfigureÑÆÀÔ«gh
2
“Œ I C opqÆ»XY”êÓ
I2C ðrs_t` ÆÀ
›²®‰¬OP
®Ã«
²-
çè
®
ìíßî
_`
5ab,³cĉ
²º®çè Production PSoC 3 —
2.0 R
RS 1.xx çè PSoC 3 ES2
2
IC
ij WklŠ®²
PSoC 5 mnRS
2
/ÓuŒ I C opqÆ»ÐÒËÌ•XY—
›²®v‰
Ï
©
2012
™•Žš˜›œ•™ž• Ÿ ¡¢‹Œ£
•¤¥
¦§œ¨
Å·ÆÇÈÉÊËÌÍŠ•ÎÏÐÑÒÓÔ ·¸¹ºÕÖ
âã
äåæ ͨ¯
ç²à áèé‹Œê¾
PSoC ë
®
â^-
¿Àw»¼Õx5dy€Õx
{|®…}~•
ãä
õö Ý-§G
API
²-
5zÏ UDB Î
Ñ;<ši
²-
Ô
€ •
‚ƒ „…†‡ˆ‰
Š‹Œ•Ž†‡ ••‘’‹Œ“‹ ” •–—˜
©ª«¬ -®
‚ƒ ¯° ±•²™³•²´µ¶·¸¹º¶»·¶¼½¾¿™ÀÁ•ÃÄ
‰ Š²
¡š×•‚ƒ•Ø ÙÕÖ ¼½ÚÛ Ü×
‚ƒ•²·¸¹ºÕÖÝ ®Þ•¿Ïßב’à Ù••á
PSoC Creator™ Ê Programmable System-on-Chip™ ë
ßî
ï•
ä•Žßî™ìíßîð•ñò äó
ä
äôõö÷øÛÊ/™ùÛúûð
÷
ú ä ÍèÁü—˜ýþ÷ÿ Êÿ ›‰ —˜ýþú¶ÿ !šý›" #$%þ& ¯'Ê%(
– )*£
ó¡¢³•²+, ¶¤-./¶
Ç0 £
•›1¿¶••¶2 ¶34
ôõö 5·Øƒ¶67
ôõöÊ5·Øƒ Í8•9 : ë34ò&;øÛÊ /™ùÛ
›¹º*£ ó<ו*= ‚ƒ>?³•«¬þ& Ÿ ¥
@І‡AB•• •CDê& •Eˆ‰ FG
œ¨©ª£
=Š ÙôõöH ‹Œ1¿¶2 ¶ÇI¶
67™J•
ç“KœL
š˜
¼½ÚÛ Ü×
‚ƒ••
賕
MŠ NOPQ‹ŒÙR œ•™ž•¯°
S÷T <U²úMŠV&•E ³W/ʳ•/ ž•¯°
¯XY
Š
Dˆ‹Œ‚ƒ™†‡ •™••‘’‹Œ“‹ Š²
Å·ÆÇÈÉÊËÌÍŠ•ÎÏÐÑÒÓÔ ·¸¹ºÕÖ
‚ƒ•²·¸¹ºÕÖÝ ®Þ•¿Ïßב’à Ù••áâã
äåæ ͨ¯
ç²à áèé‹Œê¾
øÛ£
Z[
€
\]^Š
DNOH
¡š×•‚ƒ•Ø ÙÕÖ
«¬U¿
Document Number: 001-79275 Rev**
Page 47 of 47
Similar pages