aboutsummaryrefslogtreecommitdiffstats
path: root/testhal/STM32/STM32F3xx/I2C-LSM303DLHC/main.c
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/I2C-LSM303DLHC/main.c
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/I2C-LSM303DLHC/main.c')
-rw-r--r--testhal/STM32/STM32F3xx/I2C-LSM303DLHC/main.c35
1 files changed, 20 insertions, 15 deletions
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;
}