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
Package registry
Container 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
Emilio Corigliano
Skyward Boardcore
Commits
d7d0eb5d
Commit
d7d0eb5d
authored
5 years ago
by
Andrea Milluzzo
Browse files
Options
Downloads
Patches
Plain Diff
test-lsm9ds1 compiles
parent
83df466e
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
sbs.conf
+9
-1
9 additions, 1 deletion
sbs.conf
src/shared/sensors/LSM9DS1/LSM9DS1_AxelGyro.h
+5
-4
5 additions, 4 deletions
src/shared/sensors/LSM9DS1/LSM9DS1_AxelGyro.h
src/tests/drivers/test-lsm9ds1.cpp
+90
-0
90 additions, 0 deletions
src/tests/drivers/test-lsm9ds1.cpp
with
104 additions
and
5 deletions
sbs.conf
+
9
−
1
View file @
d7d0eb5d
...
@@ -491,3 +491,11 @@ BinName: test-l3gd20
...
@@ -491,3 +491,11 @@ BinName: test-l3gd20
Include
: %
shared
%
spi
Include
: %
shared
%
spi
Defines
:
Defines
:
Main
:
drivers
/
test
-
l3gd20
Main
:
drivers
/
test
-
l3gd20
[
test
-
lsm9ds1
]
Type
:
test
BoardId
:
stm32f429zi_stm32f4discovery
BinName
:
test
-
lsm9ds1
Include
: %
shared
%
spi
Defines
:
Main
:
drivers
/
test
-
lsm9ds1
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/shared/sensors/LSM9DS1/LSM9DS1_AxelGyro.h
+
5
−
4
View file @
d7d0eb5d
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#include
<miosix.h>
#include
<miosix.h>
#include
"drivers/spi/SPIDriver.h"
#include
"drivers/spi/SPIDriver.h"
#include
"Sensor.h"
#include
"
../
Sensor.h"
using
miosix
::
GpioPin
;
using
miosix
::
GpioPin
;
...
@@ -158,9 +158,9 @@ class LSM9DS1_XLG : public GyroSensor, public AccelSensor, public TemperatureSen
...
@@ -158,9 +158,9 @@ class LSM9DS1_XLG : public GyroSensor, public AccelSensor, public TemperatureSen
//FIFO setup: FIFO enabled in continous mode, decimation OFF, temperature on FIFO ON.
//FIFO setup: FIFO enabled in continous mode, decimation OFF, temperature on FIFO ON.
if
(
fifo_enabled
)
if
(
fifo_enabled
)
{
{
spi
.
write
(
regMapXLG
::
FIFO_CTRL
,
FIFO_CTRL_VAL
|
fifo_watermark
);
//FIFO continous mode + fifo watermark threshold setup
spi
.
write
(
regMapXLG
::
FIFO_CTRL
,
(
FIFO_CTRL_VAL
|
fifo_watermark
)
)
;
//FIFO continous mode + fifo watermark threshold setup
spi
.
write
(
regMapXLG
::
INT1_CTRL
,
INT1_CTRL_VAL
);
//interrupt on FIFO treshold
spi
.
write
(
regMapXLG
::
INT1_CTRL
,
INT1_CTRL_VAL
);
//interrupt on FIFO treshold
spi
.
write
(
regMapXLG
::
CTRL_REG9
,
CTRL_REG9_VAL
|
0x02
);
//DRDY_mask_bit ON, I2C OFF, FIFO ON
spi
.
write
(
regMapXLG
::
CTRL_REG9
,
(
CTRL_REG9_VAL
|
0x02
)
)
;
//DRDY_mask_bit ON, I2C OFF, FIFO ON
}
}
else
else
spi
.
write
(
regMapXLG
::
CTRL_REG9
,
CTRL_REG9_VAL
);
//DRDY_mask_bit ON, I2C OFF, FIFO OFF
spi
.
write
(
regMapXLG
::
CTRL_REG9
,
CTRL_REG9_VAL
);
//DRDY_mask_bit ON, I2C OFF, FIFO OFF
...
@@ -182,7 +182,7 @@ class LSM9DS1_XLG : public GyroSensor, public AccelSensor, public TemperatureSen
...
@@ -182,7 +182,7 @@ class LSM9DS1_XLG : public GyroSensor, public AccelSensor, public TemperatureSen
if
(
spi
.
read
(
regMapXLG
::
CTRL_REG8
)
!=
CTRL_REG8_VAL
)
return
false
;
if
(
spi
.
read
(
regMapXLG
::
CTRL_REG8
)
!=
CTRL_REG8_VAL
)
return
false
;
if
(
fifo_enabled
)
if
(
fifo_enabled
)
{
{
if
(
spi
.
read
(
regMapXLG
::
FIFO_CTRL
)
!=
FIFO_CTRL_VAL
|
fifo_watermark
)
return
false
;
if
(
spi
.
read
(
regMapXLG
::
FIFO_CTRL
)
!=
(
FIFO_CTRL_VAL
|
fifo_watermark
)
)
return
false
;
if
(
spi
.
read
(
regMapXLG
::
INT1_CTRL
)
!=
INT1_CTRL_VAL
)
return
false
;
if
(
spi
.
read
(
regMapXLG
::
INT1_CTRL
)
!=
INT1_CTRL_VAL
)
return
false
;
if
(
spi
.
read
(
regMapXLG
::
CTRL_REG9
)
!=
(
CTRL_REG9_VAL
|
0x02
))
return
false
;
if
(
spi
.
read
(
regMapXLG
::
CTRL_REG9
)
!=
(
CTRL_REG9_VAL
|
0x02
))
return
false
;
}
}
...
@@ -269,6 +269,7 @@ class LSM9DS1_XLG : public GyroSensor, public AccelSensor, public TemperatureSen
...
@@ -269,6 +269,7 @@ class LSM9DS1_XLG : public GyroSensor, public AccelSensor, public TemperatureSen
int16_t
temp
=
tempData
[
0
]
|
tempData
[
1
]
<<
8
;
int16_t
temp
=
tempData
[
0
]
|
tempData
[
1
]
<<
8
;
mLastTemp
=
tempZero
+
temp
/
tempSensistivity
;
//25°C + TEMP/S devo castare a float "temp"?
mLastTemp
=
tempZero
+
temp
/
tempSensistivity
;
//25°C + TEMP/S devo castare a float "temp"?
return
true
;
}
}
private
:
private
:
...
...
This diff is collapsed.
Click to expand it.
src/tests/drivers/test-lsm9ds1.cpp
0 → 100644
+
90
−
0
View file @
d7d0eb5d
/**
* test LSM9DS1 axel + gyro
* Copyright (c) 2020 Skyward Experimental Rocketry
* Authors: Andrea Milluzzo
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include
"drivers/spi/SPIDriver.h"
#include
"sensors/LSM9DS1/LSM9DS1_AxelGyro.h"
using
namespace
miosix
;
typedef
Gpio
<
GPIOA_BASE
,
5
>
GpioSck
;
//questi sono i pin SPI per f407_discovery
typedef
Gpio
<
GPIOA_BASE
,
6
>
GpioMiso
;
typedef
Gpio
<
GPIOA_BASE
,
7
>
GpioMosi
;
static
const
bool
FIFO_ENABLED
=
false
;
Vec3
adata
,
gdata
;
//SPI
SPIBus
bus
(
SPI1
);
SPIBusConfig
cfg
;
GpioPin
cs
(
GPIOE_BASE
,
7
);
int
main
(){
cfg
.
br
=
SPIBaudRate
::
DIV_64
;
//max 10MHz
{
FastInterruptDisableLock
dLock
;
RCC
->
APB2ENR
|=
RCC_APB2ENR_SPI1EN
;
//SPI1 ENABLE
GpioSck
::
mode
(
Mode
::
ALTERNATE
);
GpioMiso
::
mode
(
Mode
::
ALTERNATE
);
GpioMosi
::
mode
(
Mode
::
ALTERNATE
);
cs
.
mode
(
Mode
::
OUTPUT
);
GpioSck
::
alternateFunction
(
5
);
GpioMiso
::
alternateFunction
(
5
);
GpioMosi
::
alternateFunction
(
5
);
}
cs
.
high
();
LSM9DS1_XLG
lsm9ds1
(
bus
,
cs
,
LSM9DS1_XLG
::
AxelFSR
::
FS_8
,
LSM9DS1_XLG
::
GyroFSR
::
FS_245
,
LSM9DS1_XLG
::
ODR
::
ODR_952
);
while
(
!
lsm9ds1
.
init
()){}
Thread
::
sleep
(
500
);
long
long
first_tick
=
miosix
::
getTick
();
for
(;;)
{
long
long
tick
=
miosix
::
getTick
();
lsm9ds1
.
onSimpleUpdate
();
adata
=
*
(
lsm9ds1
.
accelDataPtr
());
gdata
=
*
(
lsm9ds1
.
gyroDataPtr
());
printf
(
"TIMESTAMP:%.3f
\t
axel:%.3f,%.3f,%.3f
\t
gyro:%.3f,%.3f,%.3f"
,
tick
-
first_tick
,
adata
.
getX
(),
adata
.
getY
(),
adata
.
getZ
(),
gdata
.
getX
(),
gdata
.
getY
(),
gdata
.
getZ
());
Thread
::
sleep
(
500
);
}
return
0
;
}
\ No newline at end of file
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