Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ArduinoCore-avr
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ArduinoCore-avr
Commits
eab6601e
Commit
eab6601e
authored
Aug 25, 2015
by
Sandeep Mistry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement Wire.end() for AVR core
parent
c25e80e2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
0 deletions
+26
-0
libraries/Wire/Wire.cpp
libraries/Wire/Wire.cpp
+5
-0
libraries/Wire/Wire.h
libraries/Wire/Wire.h
+4
-0
libraries/Wire/utility/twi.c
libraries/Wire/utility/twi.c
+16
-0
libraries/Wire/utility/twi.h
libraries/Wire/utility/twi.h
+1
-0
No files found.
libraries/Wire/Wire.cpp
View file @
eab6601e
...
...
@@ -75,6 +75,11 @@ void TwoWire::begin(int address)
begin
((
uint8_t
)
address
);
}
void
TwoWire
::
end
(
void
)
{
twi_disable
();
}
void
TwoWire
::
setClock
(
uint32_t
frequency
)
{
TWBR
=
((
F_CPU
/
frequency
)
-
16
)
/
2
;
...
...
libraries/Wire/Wire.h
View file @
eab6601e
...
...
@@ -27,6 +27,9 @@
#define BUFFER_LENGTH 32
// WIRE_HAS_END means Wire has end()
#define WIRE_HAS_END 1
class
TwoWire
:
public
Stream
{
private:
...
...
@@ -49,6 +52,7 @@ class TwoWire : public Stream
void
begin
();
void
begin
(
uint8_t
);
void
begin
(
int
);
void
end
();
void
setClock
(
uint32_t
);
void
beginTransmission
(
uint8_t
);
void
beginTransmission
(
int
);
...
...
libraries/Wire/utility/twi.c
View file @
eab6601e
...
...
@@ -90,6 +90,22 @@ void twi_init(void)
TWCR
=
_BV
(
TWEN
)
|
_BV
(
TWIE
)
|
_BV
(
TWEA
);
}
/*
* Function twi_disable
* Desc disables twi pins
* Input none
* Output none
*/
void
twi_disable
(
void
)
{
// disable twi module, acks, and twi interrupt
TWCR
&=
~
(
_BV
(
TWEN
)
|
_BV
(
TWIE
)
|
_BV
(
TWEA
));
// deactivate internal pullups for twi.
digitalWrite
(
SDA
,
0
);
digitalWrite
(
SCL
,
0
);
}
/*
* Function twi_slaveInit
* Desc sets slave address and enables interrupt
...
...
libraries/Wire/utility/twi.h
View file @
eab6601e
...
...
@@ -39,6 +39,7 @@
#define TWI_STX 4
void
twi_init
(
void
);
void
twi_disable
(
void
);
void
twi_setAddress
(
uint8_t
);
uint8_t
twi_readFrom
(
uint8_t
,
uint8_t
*
,
uint8_t
,
uint8_t
);
uint8_t
twi_writeTo
(
uint8_t
,
uint8_t
*
,
uint8_t
,
uint8_t
,
uint8_t
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment