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
a2949d50
Commit
a2949d50
authored
9 years ago
by
Sandeep Mistry
Browse files
Options
Downloads
Patches
Plain Diff
Wait for idle or bus owner state in startTransmissionWIRE instead of storing repeated start state.
parent
9977fa34
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
cores/arduino/SERCOM.cpp
+7
-7
7 additions, 7 deletions
cores/arduino/SERCOM.cpp
cores/arduino/SERCOM.h
+1
-1
1 addition, 1 deletion
cores/arduino/SERCOM.h
libraries/Wire/Wire.cpp
+2
-4
2 additions, 4 deletions
libraries/Wire/Wire.cpp
libraries/Wire/Wire.h
+0
-1
0 additions, 1 deletion
libraries/Wire/Wire.h
with
10 additions
and
13 deletions
cores/arduino/SERCOM.cpp
+
7
−
7
View file @
a2949d50
...
...
@@ -476,17 +476,12 @@ void SERCOM::prepareCommandBitsWire(SercomMasterCommandWire cmd)
}
bool
SERCOM
::
startTransmissionWIRE
(
uint8_t
address
,
SercomWireReadWriteFlag
flag
)
{
return
startTransmissionWIRE
(
address
,
flag
,
false
);
}
bool
SERCOM
::
startTransmissionWIRE
(
uint8_t
address
,
SercomWireReadWriteFlag
flag
,
bool
repeatedStart
)
{
// 7-bits address + 1-bits R/W
address
=
(
address
<<
0x1ul
)
|
flag
;
// Wait idle bus mode
while
(
!
repeatedStart
&&
!
isBus
Idle
WIRE
());
// Wait idle
or owner
bus mode
while
(
!
isBusIdleWIRE
()
&&
!
isBus
Owner
WIRE
()
);
// Send start and address
sercom
->
I2CM
.
ADDR
.
bit
.
ADDR
=
address
;
...
...
@@ -580,6 +575,11 @@ bool SERCOM::isBusIdleWIRE( void )
return
sercom
->
I2CM
.
STATUS
.
bit
.
BUSSTATE
==
WIRE_IDLE_STATE
;
}
bool
SERCOM
::
isBusOwnerWIRE
(
void
)
{
return
sercom
->
I2CM
.
STATUS
.
bit
.
BUSSTATE
==
WIRE_OWNER_STATE
;
}
bool
SERCOM
::
isDataReadyWIRE
(
void
)
{
return
sercom
->
I2CS
.
INTFLAG
.
bit
.
DRDY
;
...
...
This diff is collapsed.
Click to expand it.
cores/arduino/SERCOM.h
+
1
−
1
View file @
a2949d50
...
...
@@ -194,12 +194,12 @@ class SERCOM
void
prepareAckBitWIRE
(
void
)
;
void
prepareCommandBitsWire
(
SercomMasterCommandWire
cmd
);
bool
startTransmissionWIRE
(
uint8_t
address
,
SercomWireReadWriteFlag
flag
)
;
bool
startTransmissionWIRE
(
uint8_t
address
,
SercomWireReadWriteFlag
flag
,
bool
repeatedStart
)
;
bool
sendDataMasterWIRE
(
uint8_t
data
)
;
bool
sendDataSlaveWIRE
(
uint8_t
data
)
;
bool
isMasterWIRE
(
void
)
;
bool
isSlaveWIRE
(
void
)
;
bool
isBusIdleWIRE
(
void
)
;
bool
isBusOwnerWIRE
(
void
)
;
bool
isDataReadyWIRE
(
void
)
;
bool
isStopDetectedWIRE
(
void
)
;
bool
isRestartDetectedWIRE
(
void
)
;
...
...
This diff is collapsed.
Click to expand it.
libraries/Wire/Wire.cpp
+
2
−
4
View file @
a2949d50
...
...
@@ -68,7 +68,7 @@ uint8_t TwoWire::requestFrom(uint8_t address, size_t quantity, bool stopBit)
size_t
byteRead
=
0
;
if
(
sercom
->
startTransmissionWIRE
(
address
,
WIRE_READ_FLAG
,
repeatedStart
))
if
(
sercom
->
startTransmissionWIRE
(
address
,
WIRE_READ_FLAG
))
{
// Read first data
rxBuffer
.
store_char
(
sercom
->
readDataWIRE
());
...
...
@@ -83,7 +83,6 @@ uint8_t TwoWire::requestFrom(uint8_t address, size_t quantity, bool stopBit)
sercom
->
prepareNackBitWIRE
();
// Prepare NACK to stop slave transmission
//sercom->readDataWIRE(); // Clear data register to send NACK
repeatedStart
=
!
stopBit
;
if
(
stopBit
)
{
sercom
->
prepareCommandBitsWire
(
WIRE_MASTER_ACT_STOP
);
// Send Stop
...
...
@@ -117,7 +116,7 @@ uint8_t TwoWire::endTransmission(bool stopBit)
transmissionBegun
=
false
;
// Start I2C transmission
if
(
!
sercom
->
startTransmissionWIRE
(
txAddress
,
WIRE_WRITE_FLAG
,
repeatedStart
)
)
if
(
!
sercom
->
startTransmissionWIRE
(
txAddress
,
WIRE_WRITE_FLAG
)
)
{
sercom
->
prepareCommandBitsWire
(
WIRE_MASTER_ACT_STOP
);
return
2
;
// Address error
...
...
@@ -134,7 +133,6 @@ uint8_t TwoWire::endTransmission(bool stopBit)
}
}
repeatedStart
=
!
stopBit
;
if
(
stopBit
)
{
sercom
->
prepareCommandBitsWire
(
WIRE_MASTER_ACT_STOP
);
...
...
This diff is collapsed.
Click to expand it.
libraries/Wire/Wire.h
+
0
−
1
View file @
a2949d50
...
...
@@ -67,7 +67,6 @@ class TwoWire : public Stream
uint8_t
_uc_pinSCL
;
bool
transmissionBegun
;
bool
repeatedStart
;
// RX Buffer
RingBuffer
rxBuffer
;
...
...
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