summaryrefslogtreecommitdiff
path: root/nuttx/configs/vsn/src/sif.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-04-03 14:26:05 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-04-03 14:26:05 +0000
commit139456d3cb1a8c7be9e48d765eda23b15d8c8bad (patch)
treebeda77a9181d9e274d066c6c466423325b8d8f8a /nuttx/configs/vsn/src/sif.c
parentf5d629b65b9588ddae1333f06aa392083c284949 (diff)
downloadpx4-nuttx-139456d3cb1a8c7be9e48d765eda23b15d8c8bad.tar.gz
px4-nuttx-139456d3cb1a8c7be9e48d765eda23b15d8c8bad.tar.bz2
px4-nuttx-139456d3cb1a8c7be9e48d765eda23b15d8c8bad.zip
New LIS331DL driver and VSN updates from Uros
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3457 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/configs/vsn/src/sif.c')
-rw-r--r--nuttx/configs/vsn/src/sif.c47
1 files changed, 28 insertions, 19 deletions
diff --git a/nuttx/configs/vsn/src/sif.c b/nuttx/configs/vsn/src/sif.c
index c1813df83..a10072ac5 100644
--- a/nuttx/configs/vsn/src/sif.c
+++ b/nuttx/configs/vsn/src/sif.c
@@ -70,7 +70,7 @@
#include <nuttx/config.h>
#include <nuttx/fs.h>
-#include <nuttx/i2c.h>
+#include <nuttx/i2c/i2c.h>
#include <semaphore.h>
#include <stdio.h>
@@ -80,6 +80,7 @@
#include <errno.h>
#include "vsn.h"
+#include <nuttx/i2c/st_lis331dl.h>
/****************************************************************************
@@ -272,23 +273,6 @@ int sif_gpios_unlock(vsn_sif_state_t peripheral)
}
-/****************************************************************************
- * ST LIS331DL
- ****************************************************************************/
-
-void st_lis331dl_open(void)
-{
-}
-
-
-void st_lis331dl_config(void)
-{
-}
-
-
-void st_lis331dl_getreadings(void)
-{
-}
/****************************************************************************
@@ -518,7 +502,32 @@ int sif_main(int argc, char *argv[])
STM32_TIM_SETCOMPARE(vsn_sif.tim8, GPIO_OUT_PWRPWM_TIM8_CH, val);
return 0;
}
- else if (!strcmp(argv[1], "c")) {
+ else if (!strcmp(argv[1], "i2c") && argc == 3) {
+ int val = atoi(argv[2]);
+ struct st_lis331dl_dev_s * lis = st_lis331dl_init(vsn_sif.i2c1, val);
+
+ if (lis) {
+ struct st_lis331dl_vector_s * a;
+ int i;
+
+ /* Sample some values */
+
+ for (i=0; i<20; i++) {
+ if ( (a = st_lis331dl_getreadings(lis)) )
+ printf("%d %d %d\n", a->x, a->y, a->z);
+ else {
+ printf("Readings errno %d\n", errno);
+ break;
+ }
+ fflush(stdout);
+ usleep(100000);
+ }
+
+ st_lis331dl_deinit(lis);
+ }
+ else printf("Exit point: errno=%d\n", errno);
+
+ return 0;
}
}