Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Skyward Boardcore
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
Model registry
Analyze
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
Avionics
Software Development
Skyward Boardcore
Commits
4165fd59
Commit
4165fd59
authored
2 years ago
by
Giulia Ghirardini
Committed by
Alberto Nidasio
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[LIS2MDL] Fixed selfTest register issue and added some comments
parent
840e57fb
No related branches found
No related tags found
1 merge request
!121
[LIS2MDL] Driver for the LIS2MDL magnetometer
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/shared/sensors/LIS2MDL/LIS2MDL.cpp
+8
-14
8 additions, 14 deletions
src/shared/sensors/LIS2MDL/LIS2MDL.cpp
with
8 additions
and
14 deletions
src/shared/sensors/LIS2MDL/LIS2MDL.cpp
+
8
−
14
View file @
4165fd59
...
...
@@ -46,9 +46,7 @@ bool LIS2MDL::init()
}
{
// Important! It is imperative to get the 4WSPI enabled (set to the
// value of 1) due to the four-wire connection for SPI and the I2C_DIS
// disabled. selfTest bit still not enabled.
// The 4WSPI enabled, I2C_DIS is disabled and selfTest is disabled.
SPITransaction
spi
(
mSlave
);
spi
.
writeRegister
(
CFG_REG_C
,
(
1
<<
2
)
|
(
1
<<
5
));
}
...
...
@@ -97,15 +95,11 @@ bool LIS2MDL::selfTest()
// Set configuration for selfTest procedure. selfTest still not enabled
{
SPITransaction
spi
(
mSlave
);
// CFG_REG_A: 10001100
// continuous mode, odr = 100 Hz, enable temperature compensation
// Continuous mode, odr = 100 Hz, enable temperature compensation
spi
.
writeRegister
(
CFG_REG_A
,
140
);
// CFG_REG_B: 00000010
// offset cancellation
// Offset cancellation
spi
.
writeRegister
(
CFG_REG_B
,
spi
.
readRegister
(
CFG_REG_B
)
|
(
1
<<
1
));
// CFG_REG_C: 001(1)0110
// BDU enabled. only add the value in parenthesis otherwise overwrite
// data
// BDU enabled
spi
.
writeRegister
(
CFG_REG_C
,
spi
.
readRegister
(
CFG_REG_C
)
|
(
1
<<
4
));
}
miosix
::
Thread
::
sleep
(
20
);
...
...
@@ -158,8 +152,9 @@ bool LIS2MDL::selfTest()
SPITransaction
spi
(
mSlave
);
spi
.
writeRegister
(
CFG_REG_C
,
spi
.
readRegister
(
CFG_REG_C
)
&
~
(
1
<<
1
));
// Set idle mode
spi
.
writeRegister
(
CFG_REG_A
,
spi
.
readRegister
(
CFG_REG_A
)
&
~
((
1
<<
0
)
|
(
1
<<
1
)));
uint16_t
reg
=
spi
.
readRegister
(
CFG_REG_A
);
reg
|=
0b11
;
spi
.
writeRegister
(
CFG_REG_A
,
reg
);
}
return
true
;
...
...
@@ -190,8 +185,7 @@ LIS2MDLData LIS2MDL::sampleImpl()
}
SPITransaction
spi
(
mSlave
);
// check STATUS_REG to see if new data is available. If Zyxda = 1 (true) a
// new set of data is available.
// Check STATUS_REG (Zyxda) to see if new data is available.
if
(
!
(
spi
.
readRegister
(
STATUS_REG
)
|
(
1
<<
4
)))
{
lastError
=
NO_NEW_DATA
;
...
...
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