Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Arduino Core for SAMD21 CPU
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
josc941e
Arduino Core for SAMD21 CPU
Commits
e5166fb9
Commit
e5166fb9
authored
9 years ago
by
Sandeep Mistry
Browse files
Options
Downloads
Patches
Plain Diff
Use TX buffer for slave writes, empty on master read mode + DRDY IRQ
parent
214f990b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cores/arduino/SERCOM.cpp
+1
-4
1 addition, 4 deletions
cores/arduino/SERCOM.cpp
libraries/Wire/Wire.cpp
+29
-30
29 additions, 30 deletions
libraries/Wire/Wire.cpp
with
30 additions
and
34 deletions
cores/arduino/SERCOM.cpp
+
1
−
4
View file @
e5166fb9
...
...
@@ -557,11 +557,8 @@ bool SERCOM::sendDataSlaveWIRE(uint8_t data)
//Send data
sercom
->
I2CS
.
DATA
.
bit
.
DATA
=
data
;
//Wait data transmission successful
while
(
!
sercom
->
I2CS
.
INTFLAG
.
bit
.
DRDY
);
//Problems on line? nack received?
if
(
sercom
->
I2CS
.
STATUS
.
bit
.
RXNACK
)
if
(
!
sercom
->
I2CS
.
INTFLAG
.
bit
.
DRDY
||
sercom
->
I2CS
.
STATUS
.
bit
.
RXNACK
)
return
false
;
else
return
true
;
...
...
This diff is collapsed.
Click to expand it.
libraries/Wire/Wire.cpp
+
29
−
30
View file @
e5166fb9
...
...
@@ -153,27 +153,15 @@ uint8_t TwoWire::endTransmission()
size_t
TwoWire
::
write
(
uint8_t
ucData
)
{
if
(
sercom
->
isMasterWIRE
())
// No writing, without begun transmission or a full buffer
if
(
!
transmissionBegun
||
txBuffer
.
isFull
()
)
{
// No writing, without begun transmission or a full buffer
if
(
!
transmissionBegun
||
txBuffer
.
isFull
()
)
{
return
0
;
}
txBuffer
.
store_char
(
ucData
)
;
return
1
;
}
else
{
if
(
sercom
->
sendDataSlaveWIRE
(
ucData
))
{
return
1
;
}
return
0
;
}
return
0
;
txBuffer
.
store_char
(
ucData
)
;
return
1
;
}
size_t
TwoWire
::
write
(
const
uint8_t
*
data
,
size_t
quantity
)
...
...
@@ -246,9 +234,9 @@ void TwoWire::onService(void)
if
(
sercom
->
isMasterReadOperationWIRE
())
//Is a request ?
{
// wait for data ready flag,
// before calling request callback
while
(
!
sercom
->
isDataReadyWIRE
())
;
txBuffer
.
clear
();
transmissionBegun
=
true
;
//Calling onRequestCallback, if exists
if
(
onRequestCallback
)
...
...
@@ -257,18 +245,29 @@ void TwoWire::onService(void)
}
}
}
else
if
(
sercom
->
isDataReadyWIRE
())
//Received data
else
if
(
sercom
->
isDataReadyWIRE
())
{
if
(
rxBuffer
.
isFull
())
{
sercom
->
prepareNackBitWIRE
();
}
else
{
//Store data
rxBuffer
.
store_char
(
sercom
->
readDataWIRE
());
if
(
sercom
->
isMasterReadOperationWIRE
())
{
uint8_t
c
=
0xff
;
sercom
->
prepareAckBitWIRE
();
}
if
(
txBuffer
.
available
()
)
{
c
=
txBuffer
.
read_char
();
}
sercom
->
prepareCommandBitsWire
(
0x03
);
transmissionBegun
=
sercom
->
sendDataSlaveWIRE
(
c
);
}
else
{
//Received data
if
(
rxBuffer
.
isFull
())
{
sercom
->
prepareNackBitWIRE
();
}
else
{
//Store data
rxBuffer
.
store_char
(
sercom
->
readDataWIRE
());
sercom
->
prepareAckBitWIRE
();
}
sercom
->
prepareCommandBitsWire
(
0x03
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment