aboutsummaryrefslogtreecommitdiffstats
path: root/testhal
diff options
context:
space:
mode:
authorRocco Marco Guglielmi <roccomarco.guglielmi@live.com>2016-07-10 20:01:00 +0000
committerRocco Marco Guglielmi <roccomarco.guglielmi@live.com>2016-07-10 20:01:00 +0000
commitd5917172bca6d7add8c7f7b17c77900c8b0fdac0 (patch)
tree02cb83b19d571082799be559abb12acdd82399c7 /testhal
parent724eef04f372d36f8c3893bbd4111a912a954d02 (diff)
downloadChibiOS-d5917172bca6d7add8c7f7b17c77900c8b0fdac0.tar.gz
ChibiOS-d5917172bca6d7add8c7f7b17c77900c8b0fdac0.tar.bz2
ChibiOS-d5917172bca6d7add8c7f7b17c77900c8b0fdac0.zip
Removed measurement unit management from L3GD20 driver.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9699 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'testhal')
-rw-r--r--testhal/STM32/STM32F3xx/SPI-L3GD20/main.c68
-rw-r--r--testhal/STM32/STM32F4xx/SPI-L3GD20/main.c75
-rw-r--r--testhal/STM32/STM32L4xx/SPI-L3GD20/main.c68
3 files changed, 51 insertions, 160 deletions
diff --git a/testhal/STM32/STM32F3xx/SPI-L3GD20/main.c b/testhal/STM32/STM32F3xx/SPI-L3GD20/main.c
index e76b62441..fb21b0af8 100644
--- a/testhal/STM32/STM32F3xx/SPI-L3GD20/main.c
+++ b/testhal/STM32/STM32F3xx/SPI-L3GD20/main.c
@@ -35,7 +35,6 @@ static int32_t rawdata[L3GD20_NUMBER_OF_AXES];
static float cookeddata[L3GD20_NUMBER_OF_AXES];
static char axisID[L3GD20_NUMBER_OF_AXES] = {'X', 'Y', 'Z'};
-static char unit[4] = "dps";
static uint32_t i;
static const SPIConfig spicfg = {
@@ -51,7 +50,6 @@ static L3GD20Config l3gd20cfg = {
&spicfg, /* Pointer to SPI Configuration.*/
{0, 0, 0}, /* Use default sensitivity.*/
{0, 0, 0}, /* Use default bias.*/
- L3GD20_UNIT_DPS, /* Measurement unit DPS.*/
L3GD20_FS_250DPS, /* Full scale value.*/
L3GD20_ODR_760HZ, /* Output data rate.*/
#if L3GD20_USE_ADVANCED || defined(__DOXYGEN__)
@@ -104,7 +102,7 @@ static void cmd_read(BaseSequentialStream *chp, int argc, char *argv[]) {
gyroscopeReadCooked(&L3GD20D1, cookeddata);
chprintf(chp, "L3GD20 Gyroscope cooked data...\r\n");
for(i = 0; i < L3GD20_NUMBER_OF_AXES; i++) {
- chprintf(chp, "%c-axis: %.4f %s\r\n", axisID[i], cookeddata[i], unit);
+ chprintf(chp, "%c-axis: %.4f DPS\r\n", axisID[i], cookeddata[i]);
}
}
else {
@@ -115,62 +113,30 @@ static void cmd_read(BaseSequentialStream *chp, int argc, char *argv[]) {
chprintf(chp, "Stopped\r\n");
}
-static void cmd_set(BaseSequentialStream *chp, int argc, char *argv[]) {
+static void cmd_fullscale(BaseSequentialStream *chp, int argc, char *argv[]) {
(void)argv;
- if (argc < 1) {
- chprintf(chp, "Usage: set [fs|unit] [value]\r\n");
+ if (argc != 1) {
+ chprintf(chp, "Usage: fullscale [250|500|2000]\r\n");
return;
}
- if (!strcmp (argv[0], "fs")) {
#if CHPRINTF_USE_ANSI_CODE
chprintf(chp, "\033[2J\033[1;1H");
#endif
- if (argc != 2) {
- chprintf(chp, "Usage: set fs [250|500|2000]\r\n");
- return;
- }
- if(!strcmp (argv[1], "250")) {
- gyroscopeSetFullScale(&L3GD20D1, L3GD20_FS_250DPS);
- chprintf(chp, "L3GD20 Gyroscope full scale set to 250 dps...\r\n");
- }
- else if(!strcmp (argv[1], "500")) {
- gyroscopeSetFullScale(&L3GD20D1, L3GD20_FS_500DPS);
- chprintf(chp, "L3GD20 Gyroscope full scale set to 500 dps...\r\n");
- }
- else if(!strcmp (argv[1], "2000")) {
- gyroscopeSetFullScale(&L3GD20D1, L3GD20_FS_2000DPS);
- chprintf(chp, "L3GD20 Gyroscope full scale set to 2000 dps...\r\n");
- }
- else {
- chprintf(chp, "Usage: set fs [250|500|2000]\r\n");
- return;
- }
+ if(!strcmp (argv[0], "250")) {
+ gyroscopeSetFullScale(&L3GD20D1, L3GD20_FS_250DPS);
+ chprintf(chp, "L3GD20 Gyroscope full scale set to 250 dps...\r\n");
}
- else if (!strcmp (argv[0], "unit")) {
-#if CHPRINTF_USE_ANSI_CODE
- chprintf(chp, "\033[2J\033[1;1H");
-#endif
- if (argc != 2) {
- chprintf(chp, "Usage: set unit [dps|rps]\r\n");
- return;
- }
- if(!strcmp (argv[1], "dps")) {
- gyroscopeSetMeasurementUnit(&L3GD20D1, L3GD20_UNIT_DPS);
- strcpy(unit, "dps");
- chprintf(chp, "L3GD20 Gyroscope unit set to degrees per second...\r\n");
- }
- else if(!strcmp (argv[1], "rps")) {
- gyroscopeSetMeasurementUnit(&L3GD20D1, L3GD20_UNIT_RPS);
- strcpy(unit, "rps");
- chprintf(chp, "L3GD20 Gyroscope unit set to radians per second...\r\n");
- }
- else {
- chprintf(chp, "Usage: set unit [dps|rps]\r\n");
- return;
- }
+ else if(!strcmp (argv[0], "500")) {
+ gyroscopeSetFullScale(&L3GD20D1, L3GD20_FS_500DPS);
+ chprintf(chp, "L3GD20 Gyroscope full scale set to 500 dps...\r\n");
+ }
+ else if(!strcmp (argv[0], "2000")) {
+ gyroscopeSetFullScale(&L3GD20D1, L3GD20_FS_2000DPS);
+ chprintf(chp, "L3GD20 Gyroscope full scale set to 2000 dps...\r\n");
}
else {
- chprintf(chp, "Usage: set [fs|unit] [value]\r\n");
+ chprintf(chp, "Usage: fullscale [250|500|2000]\r\n");
+ return;
}
}
@@ -211,7 +177,7 @@ static void cmd_bias(BaseSequentialStream *chp, int argc, char *argv[]) {
static const ShellCommand commands[] = {
{"read", cmd_read},
- {"set", cmd_set},
+ {"fullscale", cmd_fullscale},
{"bias", cmd_bias},
{NULL, NULL}
};
diff --git a/testhal/STM32/STM32F4xx/SPI-L3GD20/main.c b/testhal/STM32/STM32F4xx/SPI-L3GD20/main.c
index f43ffcbe8..ae30c6c98 100644
--- a/testhal/STM32/STM32F4xx/SPI-L3GD20/main.c
+++ b/testhal/STM32/STM32F4xx/SPI-L3GD20/main.c
@@ -35,7 +35,6 @@ static int32_t rawdata[L3GD20_NUMBER_OF_AXES];
static float cookeddata[L3GD20_NUMBER_OF_AXES];
static char axisID[L3GD20_NUMBER_OF_AXES] = {'X', 'Y', 'Z'};
-static char unit[4] = "dps";
static uint32_t i;
static const SPIConfig spicfg = {
@@ -51,7 +50,6 @@ static L3GD20Config l3gd20cfg = {
&spicfg, /* Pointer to SPI Configuration.*/
{0, 0, 0}, /* Use default sensitivity.*/
{0, 0, 0}, /* Use default bias.*/
- L3GD20_UNIT_DPS, /* Measurement unit DPS.*/
L3GD20_FS_250DPS, /* Full scale value.*/
L3GD20_ODR_760HZ, /* Output data rate.*/
#if L3GD20_USE_ADVANCED || defined(__DOXYGEN__)
@@ -68,13 +66,6 @@ static L3GD20Config l3gd20cfg = {
/* Command line related. */
/*===========================================================================*/
-
-
-
-
-
-
-
/* Enable use of special ANSI escape sequences.*/
#define CHPRINTF_USE_ANSI_CODE TRUE
#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048)
@@ -104,7 +95,7 @@ static void cmd_read(BaseSequentialStream *chp, int argc, char *argv[]) {
gyroscopeReadCooked(&L3GD20D1, cookeddata);
chprintf(chp, "L3GD20 Gyroscope cooked data...\r\n");
for(i = 0; i < L3GD20_NUMBER_OF_AXES; i++) {
- chprintf(chp, "%c-axis: %.4f %s\r\n", axisID[i], cookeddata[i], unit);
+ chprintf(chp, "%c-axis: %.4f DPS\r\n", axisID[i], cookeddata[i]);
}
}
else {
@@ -115,62 +106,30 @@ static void cmd_read(BaseSequentialStream *chp, int argc, char *argv[]) {
chprintf(chp, "Stopped\r\n");
}
-static void cmd_set(BaseSequentialStream *chp, int argc, char *argv[]) {
+static void cmd_fullscale(BaseSequentialStream *chp, int argc, char *argv[]) {
(void)argv;
- if (argc < 1) {
- chprintf(chp, "Usage: set [fs|unit] [value]\r\n");
+ if (argc != 1) {
+ chprintf(chp, "Usage: fullscale [250|500|2000]\r\n");
return;
}
- if (!strcmp (argv[0], "fs")) {
#if CHPRINTF_USE_ANSI_CODE
chprintf(chp, "\033[2J\033[1;1H");
#endif
- if (argc != 2) {
- chprintf(chp, "Usage: set fs [250|500|2000]\r\n");
- return;
- }
- if(!strcmp (argv[1], "250")) {
- gyroscopeSetFullScale(&L3GD20D1, L3GD20_FS_250DPS);
- chprintf(chp, "L3GD20 Gyroscope full scale set to 250 dps...\r\n");
- }
- else if(!strcmp (argv[1], "500")) {
- gyroscopeSetFullScale(&L3GD20D1, L3GD20_FS_500DPS);
- chprintf(chp, "L3GD20 Gyroscope full scale set to 500 dps...\r\n");
- }
- else if(!strcmp (argv[1], "2000")) {
- gyroscopeSetFullScale(&L3GD20D1, L3GD20_FS_2000DPS);
- chprintf(chp, "L3GD20 Gyroscope full scale set to 2000 dps...\r\n");
- }
- else {
- chprintf(chp, "Usage: set fs [250|500|2000]\r\n");
- return;
- }
+ if(!strcmp (argv[0], "250")) {
+ gyroscopeSetFullScale(&L3GD20D1, L3GD20_FS_250DPS);
+ chprintf(chp, "L3GD20 Gyroscope full scale set to 250 dps...\r\n");
}
- else if (!strcmp (argv[0], "unit")) {
-#if CHPRINTF_USE_ANSI_CODE
- chprintf(chp, "\033[2J\033[1;1H");
-#endif
- if (argc != 2) {
- chprintf(chp, "Usage: set unit [dps|rps]\r\n");
- return;
- }
- if(!strcmp (argv[1], "dps")) {
- gyroscopeSetMeasurementUnit(&L3GD20D1, L3GD20_UNIT_DPS);
- strcpy(unit, "dps");
- chprintf(chp, "L3GD20 Gyroscope unit set to degrees per second...\r\n");
- }
- else if(!strcmp (argv[1], "rps")) {
- gyroscopeSetMeasurementUnit(&L3GD20D1, L3GD20_UNIT_RPS);
- strcpy(unit, "rps");
- chprintf(chp, "L3GD20 Gyroscope unit set to radians per second...\r\n");
- }
- else {
- chprintf(chp, "Usage: set unit [dps|rps]\r\n");
- return;
- }
+ else if(!strcmp (argv[0], "500")) {
+ gyroscopeSetFullScale(&L3GD20D1, L3GD20_FS_500DPS);
+ chprintf(chp, "L3GD20 Gyroscope full scale set to 500 dps...\r\n");
+ }
+ else if(!strcmp (argv[0], "2000")) {
+ gyroscopeSetFullScale(&L3GD20D1, L3GD20_FS_2000DPS);
+ chprintf(chp, "L3GD20 Gyroscope full scale set to 2000 dps...\r\n");
}
else {
- chprintf(chp, "Usage: set [fs|unit] [value]\r\n");
+ chprintf(chp, "Usage: fullscale [250|500|2000]\r\n");
+ return;
}
}
@@ -212,7 +171,7 @@ static void cmd_bias(BaseSequentialStream *chp, int argc, char *argv[]) {
static const ShellCommand commands[] = {
{"read", cmd_read},
- {"set", cmd_set},
+ {"fullscale", cmd_fullscale},
{"bias", cmd_bias},
{NULL, NULL}
};
diff --git a/testhal/STM32/STM32L4xx/SPI-L3GD20/main.c b/testhal/STM32/STM32L4xx/SPI-L3GD20/main.c
index 7a54839e0..644a155f6 100644
--- a/testhal/STM32/STM32L4xx/SPI-L3GD20/main.c
+++ b/testhal/STM32/STM32L4xx/SPI-L3GD20/main.c
@@ -34,7 +34,6 @@ static int32_t rawdata[L3GD20_NUMBER_OF_AXES];
static float cookeddata[L3GD20_NUMBER_OF_AXES];
static char axisID[L3GD20_NUMBER_OF_AXES] = {'X', 'Y', 'Z'};
-static char unit[4] = "dps";
static uint32_t i;
static const SPIConfig spicfg = {
@@ -50,7 +49,6 @@ static L3GD20Config l3gd20cfg = {
&spicfg, /* Pointer to SPI Configuration.*/
{0, 0, 0}, /* Use default sensitivity.*/
{0, 0, 0}, /* Use default bias.*/
- L3GD20_UNIT_DPS, /* Measurement unit DPS.*/
L3GD20_FS_250DPS, /* Full scale value.*/
L3GD20_ODR_760HZ, /* Output data rate.*/
#if L3GD20_USE_ADVANCED || defined(__DOXYGEN__)
@@ -103,7 +101,7 @@ static void cmd_read(BaseSequentialStream *chp, int argc, char *argv[]) {
gyroscopeReadCooked(&L3GD20D1, cookeddata);
chprintf(chp, "L3GD20 Gyroscope cooked data...\r\n");
for(i = 0; i < L3GD20_NUMBER_OF_AXES; i++) {
- chprintf(chp, "%c-axis: %.4f %s\r\n", axisID[i], cookeddata[i], unit);
+ chprintf(chp, "%c-axis: %.4f DPS\r\n", axisID[i], cookeddata[i]);
}
}
else {
@@ -114,62 +112,30 @@ static void cmd_read(BaseSequentialStream *chp, int argc, char *argv[]) {
chprintf(chp, "Stopped\r\n");
}
-static void cmd_set(BaseSequentialStream *chp, int argc, char *argv[]) {
+static void cmd_fullscale(BaseSequentialStream *chp, int argc, char *argv[]) {
(void)argv;
- if (argc < 1) {
- chprintf(chp, "Usage: set [fs|unit] [value]\r\n");
+ if (argc != 1) {
+ chprintf(chp, "Usage: fullscale [250|500|2000]\r\n");
return;
}
- if (!strcmp (argv[0], "fs")) {
#if CHPRINTF_USE_ANSI_CODE
chprintf(chp, "\033[2J\033[1;1H");
#endif
- if (argc != 2) {
- chprintf(chp, "Usage: set fs [250|500|2000]\r\n");
- return;
- }
- if(!strcmp (argv[1], "250")) {
- gyroscopeSetFullScale(&L3GD20D1, L3GD20_FS_250DPS);
- chprintf(chp, "L3GD20 Gyroscope full scale set to 250 dps...\r\n");
- }
- else if(!strcmp (argv[1], "500")) {
- gyroscopeSetFullScale(&L3GD20D1, L3GD20_FS_500DPS);
- chprintf(chp, "L3GD20 Gyroscope full scale set to 500 dps...\r\n");
- }
- else if(!strcmp (argv[1], "2000")) {
- gyroscopeSetFullScale(&L3GD20D1, L3GD20_FS_2000DPS);
- chprintf(chp, "L3GD20 Gyroscope full scale set to 2000 dps...\r\n");
- }
- else {
- chprintf(chp, "Usage: set fs [250|500|2000]\r\n");
- return;
- }
+ if(!strcmp (argv[0], "250")) {
+ gyroscopeSetFullScale(&L3GD20D1, L3GD20_FS_250DPS);
+ chprintf(chp, "L3GD20 Gyroscope full scale set to 250 dps...\r\n");
}
- else if (!strcmp (argv[0], "unit")) {
-#if CHPRINTF_USE_ANSI_CODE
- chprintf(chp, "\033[2J\033[1;1H");
-#endif
- if (argc != 2) {
- chprintf(chp, "Usage: set unit [dps|rps]\r\n");
- return;
- }
- if(!strcmp (argv[1], "dps")) {
- gyroscopeSetMeasurementUnit(&L3GD20D1, L3GD20_UNIT_DPS);
- strcpy(unit, "dps");
- chprintf(chp, "L3GD20 Gyroscope unit set to degrees per second...\r\n");
- }
- else if(!strcmp (argv[1], "rps")) {
- gyroscopeSetMeasurementUnit(&L3GD20D1, L3GD20_UNIT_RPS);
- strcpy(unit, "rps");
- chprintf(chp, "L3GD20 Gyroscope unit set to radians per second...\r\n");
- }
- else {
- chprintf(chp, "Usage: set unit [dps|rps]\r\n");
- return;
- }
+ else if(!strcmp (argv[0], "500")) {
+ gyroscopeSetFullScale(&L3GD20D1, L3GD20_FS_500DPS);
+ chprintf(chp, "L3GD20 Gyroscope full scale set to 500 dps...\r\n");
+ }
+ else if(!strcmp (argv[0], "2000")) {
+ gyroscopeSetFullScale(&L3GD20D1, L3GD20_FS_2000DPS);
+ chprintf(chp, "L3GD20 Gyroscope full scale set to 2000 dps...\r\n");
}
else {
- chprintf(chp, "Usage: set [fs|unit] [value]\r\n");
+ chprintf(chp, "Usage: fullscale [250|500|2000]\r\n");
+ return;
}
}
@@ -208,7 +174,7 @@ static void cmd_bias(BaseSequentialStream *chp, int argc, char *argv[]) {
static const ShellCommand commands[] = {
{"read", cmd_read},
- {"set", cmd_set},
+ {"fullscale", cmd_fullscale},
{"bias", cmd_bias},
{NULL, NULL}
};