Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Iot_RIOT_Labs
RIOT_labs
Commits
2160a381
Commit
2160a381
authored
7 years ago
by
Oleg Artamonov
Browse files
Options
Download
Patches
Plain Diff
cpu/stm32l1: I2C bus timeout defined
parent
7b0eb20b
riot-master-pr-stm32-i2c
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cpu/stm32l1/periph/i2c.c
+5
-2
cpu/stm32l1/periph/i2c.c
with
5 additions
and
2 deletions
+5
-2
cpu/stm32l1/periph/i2c.c
+
5
−
2
View file @
2160a381
...
...
@@ -37,6 +37,10 @@
#define ENABLE_DEBUG (0)
#include
"debug.h"
#if !defined(I2C_TIMEOUT_USECS)
#define I2C_TIMEOUT_USECS (100000U)
#endif
/* static function definitions */
static
void
_i2c_init
(
I2C_TypeDef
*
i2c
,
int
ccr
);
static
int
_start
(
I2C_TypeDef
*
i2c
,
uint8_t
address
,
uint8_t
rw_flag
);
...
...
@@ -394,8 +398,7 @@ static int _start(I2C_TypeDef *i2c, uint8_t address, uint8_t rw_flag)
uint32_t
time_now
=
xtimer_now_usec
();
while
(
i2c
->
SR2
&
I2C_SR2_BUSY
)
{
/* 100 ms timeout */
if
(
xtimer_now_usec
()
-
time_now
>
100000
)
{
if
(
xtimer_now_usec
()
-
time_now
>
I2C_TIMEOUT_USECS
)
{
DEBUG
(
"Timeout waiting for device, resetting the bus
\n
"
);
_i2c_reset
(
i2c
);
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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
Menu
Explore
Projects
Groups
Topics
Snippets