Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
multipass
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
derf
multipass
Commits
ed0c9e21
Commit
ed0c9e21
authored
6 years ago
by
Birte Kristina Friesel
Browse files
Options
Downloads
Patches
Plain Diff
blinkenrocket i2c: Add optional no-interrupt I2C
parent
f4b31b88
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/arch/blinkenrocket/driver/i2c.cc
+9
-2
9 additions, 2 deletions
src/arch/blinkenrocket/driver/i2c.cc
with
9 additions
and
2 deletions
src/arch/blinkenrocket/driver/i2c.cc
+
9
−
2
View file @
ed0c9e21
...
@@ -5,10 +5,16 @@
...
@@ -5,10 +5,16 @@
inline
void
await_twint
(
unsigned
char
twcr_values
)
inline
void
await_twint
(
unsigned
char
twcr_values
)
{
{
#if 1
TWCR
=
twcr_values
|
_BV
(
TWINT
)
|
_BV
(
TWIE
);
TWCR
=
twcr_values
|
_BV
(
TWINT
)
|
_BV
(
TWIE
);
while
(
!
(
TWCR
&
_BV
(
TWINT
)))
{
while
(
!
(
TWCR
&
_BV
(
TWINT
)))
{
arch
.
idle
();
arch
.
idle
();
}
}
#endif
#if 0
TWCR = twcr_values | _BV(TWINT);
while (!(TWCR & _BV(TWINT))) ;
#endif
}
}
/*
/*
...
@@ -21,8 +27,8 @@ static signed char i2c_start_read(unsigned char addr)
...
@@ -21,8 +27,8 @@ static signed char i2c_start_read(unsigned char addr)
if
(
!
(
TWSR
&
0x18
))
// 0x08 == START ok, 0x10 == RESTART ok
if
(
!
(
TWSR
&
0x18
))
// 0x08 == START ok, 0x10 == RESTART ok
return
-
1
;
return
-
1
;
// Note:
The R byte
("... | 1") causes the TWI momodule
to switch to
// Note:
An adress with read bit set
("... | 1") causes the TWI momodule
// Master Receive mode
//
to switch to
Master Receive mode
TWDR
=
(
addr
<<
1
)
|
1
;
TWDR
=
(
addr
<<
1
)
|
1
;
await_twint
(
_BV
(
TWEN
));
await_twint
(
_BV
(
TWEN
));
if
(
TWSR
!=
0x40
)
// 0x40 == SLA+R transmitted, ACK receveid
if
(
TWSR
!=
0x40
)
// 0x40 == SLA+R transmitted, ACK receveid
...
@@ -55,6 +61,7 @@ static signed char i2c_start_write(unsigned char addr)
...
@@ -55,6 +61,7 @@ static signed char i2c_start_write(unsigned char addr)
static
signed
char
i2c_stop
()
static
signed
char
i2c_stop
()
{
{
TWCR
=
_BV
(
TWINT
)
|
_BV
(
TWSTO
)
|
_BV
(
TWEN
);
TWCR
=
_BV
(
TWINT
)
|
_BV
(
TWSTO
)
|
_BV
(
TWEN
);
return
0
;
}
}
/*
/*
...
...
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