From d5917172bca6d7add8c7f7b17c77900c8b0fdac0 Mon Sep 17 00:00:00 2001 From: Rocco Marco Guglielmi Date: Sun, 10 Jul 2016 20:01:00 +0000 Subject: 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 --- testhal/STM32/STM32L4xx/SPI-L3GD20/main.c | 68 ++++++++----------------------- 1 file changed, 17 insertions(+), 51 deletions(-) (limited to 'testhal/STM32/STM32L4xx/SPI-L3GD20/main.c') 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} }; -- cgit v1.2.3