Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
cm-projects
RIOT
Commits
cbd7d42e
Commit
cbd7d42e
authored
9 years ago
by
Kaspar Schleiser
Browse files
Options
Downloads
Patches
Plain Diff
drivers: mpu9150: use xtimer
parent
3edc40e4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Makefile.dep
+4
-0
4 additions, 0 deletions
Makefile.dep
drivers/mpu9150/mpu9150.c
+11
-11
11 additions, 11 deletions
drivers/mpu9150/mpu9150.c
with
15 additions
and
11 deletions
Makefile.dep
+
4
−
0
View file @
cbd7d42e
...
@@ -350,3 +350,7 @@ endif
...
@@ -350,3 +350,7 @@ endif
ifneq
(,$(filter lm75a,$(USEMODULE)))
ifneq
(,$(filter lm75a,$(USEMODULE)))
USEMODULE
+=
xtimer
USEMODULE
+=
xtimer
endif
endif
ifneq
(,$(filter mpu9150,$(USEMODULE)))
USEMODULE
+=
xtimer
endif
This diff is collapsed.
Click to expand it.
drivers/mpu9150/mpu9150.c
+
11
−
11
View file @
cbd7d42e
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
#include
"mpu9150.h"
#include
"mpu9150.h"
#include
"mpu9150-regs.h"
#include
"mpu9150-regs.h"
#include
"periph/i2c.h"
#include
"periph/i2c.h"
#include
"
hw
timer.h"
#include
"
x
timer.h"
#define ENABLE_DEBUG (0)
#define ENABLE_DEBUG (0)
#include
"debug.h"
#include
"debug.h"
...
@@ -73,7 +73,7 @@ int mpu9150_init(mpu9150_t *dev, i2c_t i2c, mpu9150_hw_addr_t hw_addr,
...
@@ -73,7 +73,7 @@ int mpu9150_init(mpu9150_t *dev, i2c_t i2c, mpu9150_hw_addr_t hw_addr,
/* Reset MPU9150 registers and afterwards wake up the chip */
/* Reset MPU9150 registers and afterwards wake up the chip */
i2c_write_reg
(
dev
->
i2c_dev
,
dev
->
hw_addr
,
MPU9150_PWR_MGMT_1_REG
,
MPU9150_PWR_RESET
);
i2c_write_reg
(
dev
->
i2c_dev
,
dev
->
hw_addr
,
MPU9150_PWR_MGMT_1_REG
,
MPU9150_PWR_RESET
);
hw
timer_
wait
(
HWTIMER_TICKS
(
MPU9150_RESET_SLEEP_US
)
)
;
x
timer_
usleep
(
MPU9150_RESET_SLEEP_US
);
i2c_write_reg
(
dev
->
i2c_dev
,
dev
->
hw_addr
,
MPU9150_PWR_MGMT_1_REG
,
MPU9150_PWR_WAKEUP
);
i2c_write_reg
(
dev
->
i2c_dev
,
dev
->
hw_addr
,
MPU9150_PWR_MGMT_1_REG
,
MPU9150_PWR_WAKEUP
);
/* Release the bus, it is acquired again inside each function */
/* Release the bus, it is acquired again inside each function */
...
@@ -103,7 +103,7 @@ int mpu9150_init(mpu9150_t *dev, i2c_t i2c, mpu9150_hw_addr_t hw_addr,
...
@@ -103,7 +103,7 @@ int mpu9150_init(mpu9150_t *dev, i2c_t i2c, mpu9150_hw_addr_t hw_addr,
temp
&=
~
(
MPU9150_PWR_ACCEL
|
MPU9150_PWR_GYRO
);
temp
&=
~
(
MPU9150_PWR_ACCEL
|
MPU9150_PWR_GYRO
);
i2c_write_reg
(
dev
->
i2c_dev
,
dev
->
hw_addr
,
MPU9150_PWR_MGMT_2_REG
,
temp
);
i2c_write_reg
(
dev
->
i2c_dev
,
dev
->
hw_addr
,
MPU9150_PWR_MGMT_2_REG
,
temp
);
i2c_release
(
dev
->
i2c_dev
);
i2c_release
(
dev
->
i2c_dev
);
hw
timer_
wait
(
HWTIMER_TICKS
(
MPU9150_PWR_CHANGE_SLEEP_US
)
)
;
x
timer_
usleep
(
MPU9150_PWR_CHANGE_SLEEP_US
);
return
0
;
return
0
;
}
}
...
@@ -144,7 +144,7 @@ int mpu9150_set_accel_power(mpu9150_t *dev, mpu9150_pwr_t pwr_conf)
...
@@ -144,7 +144,7 @@ int mpu9150_set_accel_power(mpu9150_t *dev, mpu9150_pwr_t pwr_conf)
i2c_release
(
dev
->
i2c_dev
);
i2c_release
(
dev
->
i2c_dev
);
dev
->
conf
.
accel_pwr
=
pwr_conf
;
dev
->
conf
.
accel_pwr
=
pwr_conf
;
hw
timer_
wait
(
HWTIMER_TICKS
(
MPU9150_PWR_CHANGE_SLEEP_US
)
)
;
x
timer_
usleep
(
MPU9150_PWR_CHANGE_SLEEP_US
);
return
0
;
return
0
;
}
}
...
@@ -192,7 +192,7 @@ int mpu9150_set_gyro_power(mpu9150_t *dev, mpu9150_pwr_t pwr_conf)
...
@@ -192,7 +192,7 @@ int mpu9150_set_gyro_power(mpu9150_t *dev, mpu9150_pwr_t pwr_conf)
i2c_release
(
dev
->
i2c_dev
);
i2c_release
(
dev
->
i2c_dev
);
dev
->
conf
.
gyro_pwr
=
pwr_conf
;
dev
->
conf
.
gyro_pwr
=
pwr_conf
;
hw
timer_
wait
(
HWTIMER_TICKS
(
MPU9150_PWR_CHANGE_SLEEP_US
)
)
;
x
timer_
usleep
(
MPU9150_PWR_CHANGE_SLEEP_US
);
return
0
;
return
0
;
}
}
...
@@ -237,7 +237,7 @@ int mpu9150_set_compass_power(mpu9150_t *dev, mpu9150_pwr_t pwr_conf)
...
@@ -237,7 +237,7 @@ int mpu9150_set_compass_power(mpu9150_t *dev, mpu9150_pwr_t pwr_conf)
i2c_release
(
dev
->
i2c_dev
);
i2c_release
(
dev
->
i2c_dev
);
dev
->
conf
.
compass_pwr
=
pwr_conf
;
dev
->
conf
.
compass_pwr
=
pwr_conf
;
hw
timer_
wait
(
HWTIMER_TICKS
(
MPU9150_PWR_CHANGE_SLEEP_US
)
)
;
x
timer_
usleep
(
MPU9150_PWR_CHANGE_SLEEP_US
);
return
0
;
return
0
;
}
}
...
@@ -514,10 +514,10 @@ static int compass_init(mpu9150_t *dev)
...
@@ -514,10 +514,10 @@ static int compass_init(mpu9150_t *dev)
/* Configure Power Down mode */
/* Configure Power Down mode */
i2c_write_reg
(
dev
->
i2c_dev
,
dev
->
comp_addr
,
COMPASS_CNTL_REG
,
MPU9150_COMP_POWER_DOWN
);
i2c_write_reg
(
dev
->
i2c_dev
,
dev
->
comp_addr
,
COMPASS_CNTL_REG
,
MPU9150_COMP_POWER_DOWN
);
hw
timer_
wait
(
HWTIMER_TICKS
(
MPU9150_COMP_MODE_SLEEP_US
)
)
;
x
timer_
usleep
(
MPU9150_COMP_MODE_SLEEP_US
);
/* Configure Fuse ROM access */
/* Configure Fuse ROM access */
i2c_write_reg
(
dev
->
i2c_dev
,
dev
->
comp_addr
,
COMPASS_CNTL_REG
,
MPU9150_COMP_FUSE_ROM
);
i2c_write_reg
(
dev
->
i2c_dev
,
dev
->
comp_addr
,
COMPASS_CNTL_REG
,
MPU9150_COMP_FUSE_ROM
);
hw
timer_
wait
(
HWTIMER_TICKS
(
MPU9150_COMP_MODE_SLEEP_US
)
)
;
x
timer_
usleep
(
MPU9150_COMP_MODE_SLEEP_US
);
/* Read sensitivity adjustment values from Fuse ROM */
/* Read sensitivity adjustment values from Fuse ROM */
i2c_read_regs
(
dev
->
i2c_dev
,
dev
->
comp_addr
,
COMPASS_ASAX_REG
,
data
,
3
);
i2c_read_regs
(
dev
->
i2c_dev
,
dev
->
comp_addr
,
COMPASS_ASAX_REG
,
data
,
3
);
dev
->
conf
.
compass_x_adj
=
data
[
0
];
dev
->
conf
.
compass_x_adj
=
data
[
0
];
...
@@ -525,7 +525,7 @@ static int compass_init(mpu9150_t *dev)
...
@@ -525,7 +525,7 @@ static int compass_init(mpu9150_t *dev)
dev
->
conf
.
compass_z_adj
=
data
[
2
];
dev
->
conf
.
compass_z_adj
=
data
[
2
];
/* Configure Power Down mode again */
/* Configure Power Down mode again */
i2c_write_reg
(
dev
->
i2c_dev
,
dev
->
comp_addr
,
COMPASS_CNTL_REG
,
MPU9150_COMP_POWER_DOWN
);
i2c_write_reg
(
dev
->
i2c_dev
,
dev
->
comp_addr
,
COMPASS_CNTL_REG
,
MPU9150_COMP_POWER_DOWN
);
hw
timer_
wait
(
HWTIMER_TICKS
(
MPU9150_COMP_MODE_SLEEP_US
)
)
;
x
timer_
usleep
(
MPU9150_COMP_MODE_SLEEP_US
);
/* Disable Bypass Mode to configure MPU as master to the compass */
/* Disable Bypass Mode to configure MPU as master to the compass */
conf_bypass
(
dev
,
0
);
conf_bypass
(
dev
,
0
);
...
@@ -575,13 +575,13 @@ static void conf_bypass(mpu9150_t *dev, uint8_t bypass_enable)
...
@@ -575,13 +575,13 @@ static void conf_bypass(mpu9150_t *dev, uint8_t bypass_enable)
if
(
bypass_enable
)
{
if
(
bypass_enable
)
{
data
&=
~
(
BIT_I2C_MST_EN
);
data
&=
~
(
BIT_I2C_MST_EN
);
i2c_write_reg
(
dev
->
i2c_dev
,
dev
->
hw_addr
,
MPU9150_USER_CTRL_REG
,
data
);
i2c_write_reg
(
dev
->
i2c_dev
,
dev
->
hw_addr
,
MPU9150_USER_CTRL_REG
,
data
);
hw
timer_
wait
(
HWTIMER_TICKS
(
MPU9150_BYPASS_SLEEP_US
)
)
;
x
timer_
usleep
(
MPU9150_BYPASS_SLEEP_US
);
i2c_write_reg
(
dev
->
i2c_dev
,
dev
->
hw_addr
,
MPU9150_INT_PIN_CFG_REG
,
BIT_I2C_BYPASS_EN
);
i2c_write_reg
(
dev
->
i2c_dev
,
dev
->
hw_addr
,
MPU9150_INT_PIN_CFG_REG
,
BIT_I2C_BYPASS_EN
);
}
}
else
{
else
{
data
|=
BIT_I2C_MST_EN
;
data
|=
BIT_I2C_MST_EN
;
i2c_write_reg
(
dev
->
i2c_dev
,
dev
->
hw_addr
,
MPU9150_USER_CTRL_REG
,
data
);
i2c_write_reg
(
dev
->
i2c_dev
,
dev
->
hw_addr
,
MPU9150_USER_CTRL_REG
,
data
);
hw
timer_
wait
(
HWTIMER_TICKS
(
MPU9150_BYPASS_SLEEP_US
)
)
;
x
timer_
usleep
(
MPU9150_BYPASS_SLEEP_US
);
i2c_write_reg
(
dev
->
i2c_dev
,
dev
->
hw_addr
,
MPU9150_INT_PIN_CFG_REG
,
REG_RESET
);
i2c_write_reg
(
dev
->
i2c_dev
,
dev
->
hw_addr
,
MPU9150_INT_PIN_CFG_REG
,
REG_RESET
);
}
}
}
}
...
...
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