aboutsummaryrefslogtreecommitdiffstats
path: root/testhal/STM32/STM32F3xx
diff options
context:
space:
mode:
authorRocco Marco Guglielmi <roccomarco.guglielmi@live.com>2016-09-29 15:02:05 +0000
committerRocco Marco Guglielmi <roccomarco.guglielmi@live.com>2016-09-29 15:02:05 +0000
commita3728946f8a57b3f4bbc1642d082866517f8038b (patch)
tree9ca84e39dd2021423839a99157434aff295a327d /testhal/STM32/STM32F3xx
parent501dce6dc591f065acdf3e83b2de29e9bf7af4a4 (diff)
downloadChibiOS-a3728946f8a57b3f4bbc1642d082866517f8038b.tar.gz
ChibiOS-a3728946f8a57b3f4bbc1642d082866517f8038b.tar.bz2
ChibiOS-a3728946f8a57b3f4bbc1642d082866517f8038b.zip
Improved LSM303DLHC driver and related demos: improved bias and sensitivity handling.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9823 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'testhal/STM32/STM32F3xx')
-rw-r--r--testhal/STM32/STM32F3xx/I2C-LSM303DLHC/Makefile5
-rw-r--r--testhal/STM32/STM32F3xx/I2C-LSM303DLHC/chconf.h12
-rw-r--r--testhal/STM32/STM32F3xx/I2C-LSM303DLHC/halconf.h2
-rw-r--r--testhal/STM32/STM32F3xx/I2C-LSM303DLHC/main.c35
-rw-r--r--testhal/STM32/STM32F3xx/I2C-LSM303DLHC/mcuconf.h2
-rw-r--r--testhal/STM32/STM32F3xx/I2C-LSM303DLHC/readme.txt9
6 files changed, 35 insertions, 30 deletions
diff --git a/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/Makefile b/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/Makefile
index 707dd7bd5..00d84bee6 100644
--- a/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/Makefile
+++ b/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/Makefile
@@ -71,7 +71,7 @@ endif
# Enables the use of FPU (no, softfp, hard).
ifeq ($(USE_FPU),)
- USE_FPU = hard
+ USE_FPU = no
endif
#
@@ -201,7 +201,8 @@ CPPWARN = -Wall -Wextra -Wundef
# List all user C define here, like -D_DEBUG=1
UDEFS = -DCHPRINTF_USE_FLOAT=1 -DSHELL_CMD_TEST_ENABLED=0 \
- -DLSM303DLHC_ACC_USE_ADVANCED=0 -DLSM303DLHC_COMP_USE_ADVANCED=0
+ -DLSM303DLHC_ACC_USE_ADVANCED=0 -DLSM303DLHC_COMP_USE_ADVANCED=0 \
+ -DLSM303DLHC_SHARED_I2C=0
# Define ASM defines here
UADEFS =
diff --git a/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/chconf.h b/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/chconf.h
index ad6b53ade..00eb395ec 100644
--- a/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/chconf.h
+++ b/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/chconf.h
@@ -328,7 +328,7 @@
*
* @note The default is @p FALSE.
*/
-#define CH_DBG_SYSTEM_STATE_CHECK FALSE
+#define CH_DBG_SYSTEM_STATE_CHECK TRUE
/**
* @brief Debug option, parameters checks.
@@ -337,7 +337,7 @@
*
* @note The default is @p FALSE.
*/
-#define CH_DBG_ENABLE_CHECKS FALSE
+#define CH_DBG_ENABLE_CHECKS TRUE
/**
* @brief Debug option, consistency checks.
@@ -347,7 +347,7 @@
*
* @note The default is @p FALSE.
*/
-#define CH_DBG_ENABLE_ASSERTS FALSE
+#define CH_DBG_ENABLE_ASSERTS TRUE
/**
* @brief Debug option, trace buffer.
@@ -355,7 +355,7 @@
*
* @note The default is @p CH_DBG_TRACE_MASK_DISABLED.
*/
-#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED
+#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_ALL
/**
* @brief Trace buffer entries.
@@ -374,7 +374,7 @@
* @note The default failure mode is to halt the system with the global
* @p panic_msg variable set to @p NULL.
*/
-#define CH_DBG_ENABLE_STACK_CHECK FALSE
+#define CH_DBG_ENABLE_STACK_CHECK TRUE
/**
* @brief Debug option, stacks initialization.
@@ -384,7 +384,7 @@
*
* @note The default is @p FALSE.
*/
-#define CH_DBG_FILL_THREADS FALSE
+#define CH_DBG_FILL_THREADS TRUE
/**
* @brief Debug option, threads profiling.
diff --git a/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/halconf.h b/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/halconf.h
index 6e145cea1..2c4cb557a 100644
--- a/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/halconf.h
+++ b/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/halconf.h
@@ -139,7 +139,7 @@
* @brief Enables the SERIAL subsystem.
*/
#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
-#define HAL_USE_SERIAL TRUE
+#define HAL_USE_SERIAL FALSE
#endif
/**
diff --git a/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/main.c b/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/main.c
index 24ffabef4..55935b568 100644
--- a/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/main.c
+++ b/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/main.c
@@ -24,8 +24,9 @@
#include "lsm303dlhc.h"
+
/*===========================================================================*/
-/* LSM303DLHC related. */
+/* LSM303DLHC related. */
/*===========================================================================*/
/* LSM303DLHC Driver: This object represent an LSM303DLHC instance */
@@ -48,8 +49,8 @@ static const I2CConfig i2ccfg = {
};
static const LSM303DLHCAccConfig lsm303dlhcacccfg = {
- {0, 0, 0}, /* Use default sensitivity.*/
- {0, 0, 0}, /* Use default bias.*/
+ NULL, /* Use default sensitivity.*/
+ NULL, /* Use default bias.*/
LSM303DLHC_ACC_FS_4G, /* Full scale value 2g.*/
LSM303DLHC_ACC_ODR_100Hz, /* Output data rate 100 Hz.*/
#if LSM303DLHC_ACC_USE_ADVANCED || defined(__DOXYGEN__)
@@ -61,6 +62,8 @@ static const LSM303DLHCAccConfig lsm303dlhcacccfg = {
};
static const LSM303DLHCCompConfig lsm303dlhccompcfg = {
+ NULL, /* Use default sensitivity.*/
+ NULL, /* Use default bias.*/
LSM303DLHC_COMP_FS_1P3GA, /* Full scale value 1.3 Gauss.*/
LSM303DLHC_COMP_ODR_30HZ, /* Output data rate 30 Hz.*/
#if LSM303DLHC_COMP_USE_ADVANCED || defined(__DOXYGEN__)
@@ -88,7 +91,7 @@ static const LSM303DLHCConfig lsm303dlhccfg = {
/* Enable use of special ANSI escape sequences */
#define CHPRINTF_USE_ANSI_CODE TRUE
-#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048)
+#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048)
static void cmd_read(BaseSequentialStream *chp, int argc, char *argv[]) {
(void)argv;
@@ -280,11 +283,11 @@ static const ShellConfig shell_cfg1 = {
};
/*===========================================================================*/
-/* Main code. */
+/* Generic code. */
/*===========================================================================*/
/*
- * LED blinker thread, times are in milliseconds.
+ * Red LED blinker thread, times are in milliseconds.
*/
static THD_WORKING_AREA(waThread1, 128);
static THD_FUNCTION(Thread1, arg) {
@@ -334,11 +337,16 @@ int main(void) {
usbConnectBus(serusbcfg.usbp);
/*
- * Creates the blinker thread.
+ * Shell manager initialization.
*/
- chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO + 1, Thread1, NULL);
+ shellInit();
/*
+ * Creates the blinker thread.
+ */
+ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
+
+ /*
* LSM303DLHC Object Initialization
*/
lsm303dlhcObjectInit(&LSM303DLHCD1);
@@ -347,13 +355,11 @@ int main(void) {
* Activates the LSM303DLHC driver.
*/
lsm303dlhcStart(&LSM303DLHCD1, &lsm303dlhccfg);
-
+
/*
- * Shell manager initialization.
- */
- shellInit();
-
- while(TRUE) {
+ * Normal main() thread activity, spawning shells.
+ */
+ while (true) {
if (SDU1.config->usbp->state == USB_ACTIVE) {
thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE,
"shell", NORMALPRIO + 1,
@@ -363,5 +369,4 @@ int main(void) {
chThdSleepMilliseconds(1000);
}
lsm303dlhcStop(&LSM303DLHCD1);
- return 0;
}
diff --git a/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/mcuconf.h b/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/mcuconf.h
index 51072e1d6..4c96a5450 100644
--- a/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/mcuconf.h
+++ b/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/mcuconf.h
@@ -192,7 +192,7 @@
/*
* SERIAL driver system settings.
*/
-#define STM32_SERIAL_USE_USART1 TRUE
+#define STM32_SERIAL_USE_USART1 FALSE
#define STM32_SERIAL_USE_USART2 FALSE
#define STM32_SERIAL_USE_USART3 FALSE
#define STM32_SERIAL_USE_UART4 FALSE
diff --git a/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/readme.txt b/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/readme.txt
index d19c66ffd..a8e89bca9 100644
--- a/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/readme.txt
+++ b/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/readme.txt
@@ -1,19 +1,18 @@
*****************************************************************************
-** ChibiOS/HAL + ChibiOS/EX - SPI + LSM303DLHC demo for STM32F3xx. **
+** ChibiOS/HAL - USB-CDC driver demo for STM32F3xx. **
*****************************************************************************
** TARGET **
-The demo runs on an STM32F3 Discovery board.
+The demo runs on an ST STM32F3-Discovery board.
** The Demo **
-The demo flashes the board LED using a thread, read data from LSM303DLHC
-printing it on a BaseSequentialStream (SDU1, mapped on USB virtual COM port).
+The application demonstrates the use of the STM32F3xx USB driver.
** Build Procedure **
-The demo has been tested by using the free Codesourcery GCC-based toolchain
+The demo has been tested using the free Codesourcery GCC-based toolchain
and YAGARTO.
Just modify the TRGT line in the makefile in order to use different GCC ports.