Updated LSM303DLHC STM32F3 Discovery demo
git-svn-id: https://svn.code.sf.net/p/chibios/svn2/trunk@11592 110e8d01-0319-4d1e-a829-52ad28d1bb01
This commit is contained in:
parent
4e4b7ef08e
commit
118f847cba
|
@ -5,7 +5,7 @@
|
|||
|
||||
# Compiler options here.
|
||||
ifeq ($(USE_OPT),)
|
||||
USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16
|
||||
USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
|
||||
endif
|
||||
|
||||
# C specific options here (added to USE_OPT).
|
||||
|
@ -87,6 +87,9 @@ PROJECT = ch
|
|||
|
||||
# Imported source files and paths
|
||||
CHIBIOS = ../../../..
|
||||
|
||||
# Licensing files.
|
||||
include $(CHIBIOS)/os/license/license.mk
|
||||
# Startup files.
|
||||
include $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32f3xx.mk
|
||||
# HAL-OSAL files (optional).
|
||||
|
@ -97,8 +100,9 @@ include $(CHIBIOS)/os/hal/osal/rt/osal.mk
|
|||
# RTOS files (optional).
|
||||
include $(CHIBIOS)/os/rt/rt.mk
|
||||
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
|
||||
# Other files (optional).
|
||||
# EX files (optional).
|
||||
include $(CHIBIOS)/os/ex/ST/lsm303dlhc.mk
|
||||
# Other files (optional).
|
||||
include $(CHIBIOS)/os/hal/lib/streams/streams.mk
|
||||
|
||||
# Define linker script file here
|
||||
|
@ -106,20 +110,13 @@ LDSCRIPT= $(STARTUPLD)/STM32F303xC.ld
|
|||
|
||||
# C sources that can be compiled in ARM or THUMB mode depending on the global
|
||||
# setting.
|
||||
CSRC = $(STARTUPSRC) \
|
||||
$(KERNSRC) \
|
||||
$(PORTSRC) \
|
||||
$(OSALSRC) \
|
||||
$(HALSRC) \
|
||||
$(PLATFORMSRC) \
|
||||
$(BOARDSRC) \
|
||||
$(LSM303DLHCSRC) \
|
||||
$(STREAMSSRC) \
|
||||
CSRC = $(ALLCSRC) \
|
||||
$(TESTSRC) \
|
||||
main.c
|
||||
|
||||
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
|
||||
# setting.
|
||||
CPPSRC =
|
||||
CPPSRC = $(AllCPPSRC)
|
||||
|
||||
# C sources to be compiled in ARM mode regardless of the global setting.
|
||||
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||
|
@ -145,10 +142,11 @@ TCPPSRC =
|
|||
ASMSRC =
|
||||
ASMXSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
|
||||
|
||||
INCDIR = $(CHIBIOS)/os/license \
|
||||
$(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
|
||||
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(LSM303DLHCINC) \
|
||||
$(STREAMSINC) $(SHELLINC)
|
||||
# List ASM source files here
|
||||
ASMSRC = $(ALLASMSRC)
|
||||
ASMXSRC = $(ALLXASMSRC)
|
||||
|
||||
INCDIR = $(ALLINC) $(TESTINC)
|
||||
|
||||
#
|
||||
# Project, sources and paths
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "hal.h"
|
||||
|
||||
#include "chprintf.h"
|
||||
|
||||
#include "lsm303dlhc.h"
|
||||
|
||||
#define cls(chp) chprintf(chp, "\033[2J\033[1;1H")
|
||||
|
@ -47,7 +46,9 @@ static const I2CConfig i2ccfg = {
|
|||
0
|
||||
};
|
||||
|
||||
static const LSM303DLHCAccConfig lsm303dlhcacccfg = {
|
||||
static const LSM303DLHCConfig lsm303dlhccfg = {
|
||||
&I2CD1,
|
||||
&i2ccfg,
|
||||
NULL,
|
||||
NULL,
|
||||
LSM303DLHC_ACC_FS_4G,
|
||||
|
@ -58,9 +59,6 @@ static const LSM303DLHCAccConfig lsm303dlhcacccfg = {
|
|||
LSM303DLHC_ACC_BDU_BLOCK,
|
||||
LSM303DLHC_ACC_END_LITTLE,
|
||||
#endif
|
||||
};
|
||||
|
||||
static const LSM303DLHCCompConfig lsm303dlhccompcfg = {
|
||||
NULL,
|
||||
NULL,
|
||||
LSM303DLHC_COMP_FS_1P3GA,
|
||||
|
@ -70,13 +68,6 @@ static const LSM303DLHCCompConfig lsm303dlhccompcfg = {
|
|||
#endif
|
||||
};
|
||||
|
||||
static const LSM303DLHCConfig lsm303dlhccfg = {
|
||||
&I2CD1,
|
||||
&i2ccfg,
|
||||
&lsm303dlhcacccfg,
|
||||
&lsm303dlhccompcfg
|
||||
};
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Generic code. */
|
||||
/*===========================================================================*/
|
||||
|
@ -132,28 +123,28 @@ int main(void) {
|
|||
lsm303dlhcStart(&LSM303DLHCD1, &lsm303dlhccfg);
|
||||
|
||||
/*
|
||||
* Normal main() thread activity, spawning shells.
|
||||
* Normal main() thread activity, printing MEMS data on the serial driver 1.
|
||||
*/
|
||||
while (true) {
|
||||
accelerometerReadRaw(&(LSM303DLHCD1.accelerometer_if), accraw);
|
||||
lsm303dlhcAccelerometerReadRaw(&LSM303DLHCD1, accraw);
|
||||
chprintf(chp, "LSM303DLHC Accelerometer raw data...\r\n");
|
||||
for(i = 0; i < LSM303DLHC_ACC_NUMBER_OF_AXES; i++) {
|
||||
chprintf(chp, "%c-axis: %d\r\n", axisID[i], accraw[i]);
|
||||
}
|
||||
|
||||
compassReadRaw(&(LSM303DLHCD1.compass_if), compraw);
|
||||
lsm303dlhcCompassReadRaw(&LSM303DLHCD1, compraw);
|
||||
chprintf(chp, "LSM303DLHC Compass raw data...\r\n");
|
||||
for(i = 0; i < LSM303DLHC_COMP_NUMBER_OF_AXES; i++) {
|
||||
chprintf(chp, "%c-axis: %d\r\n", axisID[i], compraw[i]);
|
||||
}
|
||||
|
||||
accelerometerReadCooked(&(LSM303DLHCD1.accelerometer_if), acccooked);
|
||||
lsm303dlhcAccelerometerReadCooked(&LSM303DLHCD1, acccooked);
|
||||
chprintf(chp, "LSM303DLHC Accelerometer cooked data...\r\n");
|
||||
for(i = 0; i < LSM303DLHC_ACC_NUMBER_OF_AXES; i++) {
|
||||
chprintf(chp, "%c-axis: %.3f\r\n", axisID[i], acccooked[i]);
|
||||
}
|
||||
|
||||
compassReadCooked(&(LSM303DLHCD1.compass_if), compcooked);
|
||||
lsm303dlhcCompassReadCooked(&LSM303DLHCD1, compcooked);
|
||||
chprintf(chp, "LSM303DLHC Compass cooked data...\r\n");
|
||||
for(i = 0; i < LSM303DLHC_COMP_NUMBER_OF_AXES; i++) {
|
||||
chprintf(chp, "%c-axis: %.3f\r\n", axisID[i], compcooked[i]);
|
||||
|
|
Loading…
Reference in New Issue