diff --git a/os/ex/ST/l3gd20.c b/os/ex/ST/l3gd20.c index 255026fba..60aeee8cf 100644 --- a/os/ex/ST/l3gd20.c +++ b/os/ex/ST/l3gd20.c @@ -264,18 +264,6 @@ static msg_t set_full_scale(void *ip, l3gd20_fs_t fs) { return MSG_OK; } -static l3gd20_fs_t get_full_scale(void *ip) { - if(((L3GD20Driver *)ip)->fullscale == L3GD20_250DPS) { - return L3GD20_FS_250DPS; - } - else if(((L3GD20Driver *)ip)->fullscale == L3GD20_500DPS) { - return L3GD20_FS_500DPS; - } - else { - return L3GD20_FS_2000DPS; - } -} - static msg_t set_meas_unit(void *ip, l3gd20_unit_t unit) { unsigned i; if(unit != ((L3GD20Driver *)ip)->meas_unit) { @@ -294,11 +282,6 @@ static msg_t set_meas_unit(void *ip, l3gd20_unit_t unit) { return MSG_OK; } -static l3gd20_unit_t get_meas_unit(void *ip) { - - return ((L3GD20Driver *)ip)->meas_unit; -} - static const struct BaseSensorVMT vmt_basesensor = { get_axes_number, read_raw, read_cooked }; @@ -313,8 +296,7 @@ static const struct L3GD20VMT vmt_l3gd20 = { get_axes_number, read_raw, read_cooked, sample_bias, set_bias, reset_bias, set_sensivity, reset_sensivity, - set_full_scale, get_full_scale, - set_meas_unit, get_meas_unit + set_full_scale, set_meas_unit }; /*===========================================================================*/ @@ -353,7 +335,7 @@ void l3gd20Start(L3GD20Driver *devp, const L3GD20Config *config) { osalDbgCheck((devp != NULL) && (config != NULL)); osalDbgAssert((devp->state == L3GD20_STOP) || (devp->state == L3GD20_READY), - "l3gd20Start(), invalid state"); + "l3gd20Start(), invalid state"); devp->config = config; @@ -403,7 +385,7 @@ void l3gd20Start(L3GD20Driver *devp, const L3GD20Config *config) { cr[4] = L3GD20_CTRL_REG5_HPEN; if(devp->config->lp2mode != L3GD20_LP2M_BYPASSED) { cr[4] |= L3GD20_CTRL_REG5_INT1_SEL1 | - L3GD20_CTRL_REG5_OUT_SEL1; + L3GD20_CTRL_REG5_OUT_SEL1; } else { cr[4] |= L3GD20_CTRL_REG5_INT1_SEL0 | @@ -416,7 +398,7 @@ void l3gd20Start(L3GD20Driver *devp, const L3GD20Config *config) { 5, cr); #if L3GD20_SHARED_SPI spiReleaseBus((devp)->config->spip); -#endif /* L3GD20_SHARED_SPI */ +#endif /* L3GD20_SHARED_SPI */ #endif /* L3GD20_USE_SPI */ /* Storing sensitivity information according to full scale and unit value */ @@ -498,7 +480,7 @@ void l3gd20Stop(L3GD20Driver *devp) { spiStop((devp)->config->spip); #if L3GD20_SHARED_SPI spiReleaseBus((devp)->config->spip); -#endif /* L3GD20_SHARED_SPI */ +#endif /* L3GD20_SHARED_SPI */ } #endif /* L3GD20_USE_SPI */ devp->state = L3GD20_STOP; diff --git a/os/ex/ST/l3gd20.h b/os/ex/ST/l3gd20.h index 5d21f6a76..1b3f2993a 100644 --- a/os/ex/ST/l3gd20.h +++ b/os/ex/ST/l3gd20.h @@ -40,22 +40,22 @@ /** * @brief L3GD20 driver version string. */ -#define EX_L3GD20_VERSION "1.0.0" +#define EX_L3GD20_VERSION "1.0.0" /** * @brief L3GD20 driver version major number. */ -#define EX_L3GD20_MAJOR 1 +#define EX_L3GD20_MAJOR 1 /** * @brief L3GD20 driver version minor number. */ -#define EX_L3GD20_MINOR 0 +#define EX_L3GD20_MINOR 0 /** * @brief L3GD20 driver version patch number. */ -#define EX_L3GD20_PATCH 0 +#define EX_L3GD20_PATCH 0 /** @} */ /** @@ -490,12 +490,8 @@ typedef struct L3GD20Driver L3GD20Driver; _base_gyroscope_methods \ /* Change full scale value of L3GD20 .*/ \ msg_t (*set_full_scale)(void *instance, l3gd20_fs_t fs); \ - /* Get full scale value of L3GD20 .*/ \ - l3gd20_fs_t (*get_full_scale)(void *instance); \ /* Change measurement unit of L3GD20 .*/ \ msg_t (*set_meas_unit)(void *instance, l3gd20_unit_t unit); \ - /* Get measurement unit of L3GD20 .*/ \ - l3gd20_unit_t (*get_meas_unit)(void *instance); /** * @extends BaseGyroscopeVMT @@ -547,7 +543,7 @@ struct L3GD20Driver { /*===========================================================================*/ /** - * @brief Change initial fullscale value. + * @brief Change gyroscope fullscale value. * * @param[in] ip pointer to a @p BaseGyroscope class. * @param[in] fs the new full scale value. diff --git a/testhal/STM32/STM32F3xx/SPI-L3GD20/main.c b/testhal/STM32/STM32F3xx/SPI-L3GD20/main.c index beb2b6927..2f2199fc6 100644 --- a/testhal/STM32/STM32F3xx/SPI-L3GD20/main.c +++ b/testhal/STM32/STM32F3xx/SPI-L3GD20/main.c @@ -28,7 +28,7 @@ /* L3GD20 related. */ /*===========================================================================*/ -/* L3GD20 Driver: This object represent an L3GD20 instance */ +/* L3GD20 Driver: This object represent an L3GD20 instance.*/ static L3GD20Driver L3GD20D1; static int32_t rawdata[L3GD20_NUMBER_OF_AXES]; @@ -40,20 +40,20 @@ static uint32_t i; static const SPIConfig spicfg = { NULL, - GPIOE, /* port of L3GD20 CS */ - GPIOE_L3GD20_CS, /* pin of L3GD20 CS */ - SPI_CR1_BR | SPI_CR1_CPOL | SPI_CR1_CPHA, /* CR1 register */ - 0 /* CR2 register */ + GPIOE, /* port of L3GD20 CS.*/ + GPIOE_L3GD20_CS, /* pin of L3GD20 CS.*/ + SPI_CR1_BR | SPI_CR1_CPOL | SPI_CR1_CPHA, /* CR1 register.*/ + 0 /* CR2 register.*/ }; static L3GD20Config l3gd20cfg = { - &SPID1, /* Pointer to SPI Driver */ - &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 */ + &SPID1, /* Pointer to SPI Driver.*/ + &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__) L3GD20_BDU_CONTINUOUS, L3GD20_END_LITTLE, @@ -75,9 +75,9 @@ static L3GD20Config l3gd20cfg = { #define usb_lld_connect_bus(usbp) #define usb_lld_disconnect_bus(usbp) -/* Enable use of special ANSI escape sequences */ -#define CHPRINTF_USE_ANSI_CODE TRUE -#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048) +/* Enable use of special ANSI escape sequences.*/ +#define CHPRINTF_USE_ANSI_CODE TRUE +#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048) static void cmd_get(BaseSequentialStream *chp, int argc, char *argv[]) { (void)argv; @@ -259,9 +259,7 @@ int main(void) { halInit(); chSysInit(); - /* - * Initializes a serial-over-USB CDC driver. - */ + /* Initializes a serial-over-USB CDC driver.*/ sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); @@ -275,24 +273,16 @@ int main(void) { usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); - /* - * Creates the blinker thread. - */ + /* Creates the blinker thread.*/ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO + 1, Thread1, NULL); - /* - * L3GD20 Object Initialization - */ + /* L3GD20 Object Initialization.*/ l3gd20ObjectInit(&L3GD20D1); - /* - * Activates the L3GD20 driver. - */ + /* Activates the L3GD20 driver.*/ l3gd20Start(&L3GD20D1, &l3gd20cfg); - /* - * Shell manager initialization. - */ + /* Shell manager initialization.*/ shellInit(); while(TRUE) { diff --git a/testhal/STM32/STM32F4xx/SPI-L3GD20/main.c b/testhal/STM32/STM32F4xx/SPI-L3GD20/main.c index af0cdcae9..e93e21a32 100644 --- a/testhal/STM32/STM32F4xx/SPI-L3GD20/main.c +++ b/testhal/STM32/STM32F4xx/SPI-L3GD20/main.c @@ -28,7 +28,7 @@ /* L3GD20 related. */ /*===========================================================================*/ -/* L3GD20 Driver: This object represent an L3GD20 instance */ +/* L3GD20 Driver: This object represent an L3GD20 instance.*/ static L3GD20Driver L3GD20D1; static int32_t rawdata[L3GD20_NUMBER_OF_AXES]; @@ -40,20 +40,20 @@ static uint32_t i; static const SPIConfig spicfg = { NULL, - GPIOE, /* port of L3GD20 CS */ - GPIOE_L3GD20_CS, /* pin of L3GD20 CS */ - SPI_CR1_BR_0 | SPI_CR1_CPOL | SPI_CR1_CPHA,/* CR1 register*/ - 0 /* CR2 register */ + GPIOE, /* port of L3GD20 CS.*/ + GPIOE_L3GD20_CS, /* pin of L3GD20 CS.*/ + SPI_CR1_BR_0 | SPI_CR1_CPOL | SPI_CR1_CPHA,/* CR1 register.*/ + 0 /* CR2 register.*/ }; static L3GD20Config l3gd20cfg = { - &SPID1, /* Pointer to SPI Driver */ - &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 */ + &SPID1, /* Pointer to SPI Driver.*/ + &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__) L3GD20_BDU_CONTINUOUS, L3GD20_END_LITTLE, @@ -68,9 +68,16 @@ 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) + + + + + + + +/* Enable use of special ANSI escape sequences.*/ +#define CHPRINTF_USE_ANSI_CODE TRUE +#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048) static void cmd_get(BaseSequentialStream *chp, int argc, char *argv[]) { (void)argv; @@ -179,14 +186,15 @@ static void cmd_bias(BaseSequentialStream *chp, int argc, char *argv[]) { #endif chprintf(chp, "Please don't move the device while Green LED is on!\r\n"); chprintf(chp, "Press a key to start...\r\n"); - while (chnGetTimeout((BaseChannel *)chp, 500) == Q_TIMEOUT) { + while (chnGetTimeout((BaseChannel *)chp, 500) == Q_TIMEOUT) ; - } palSetLine(LINE_LED4); + chThdSleepMilliseconds(1000); gyroscopeSampleBias(&L3GD20D1); palClearLine(LINE_LED4); + chprintf(chp, "Procedure completed!\r\n"); } else if(!strcmp (argv[0], "reset")) { @@ -252,9 +260,7 @@ int main(void) { halInit(); chSysInit(); - /* - * Initializes a serial-over-USB CDC driver. - */ + /* Initializes a serial-over-USB CDC driver.*/ sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); @@ -268,24 +274,16 @@ int main(void) { usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); - /* - * Creates the blinker thread. - */ + /* Creates the blinker thread.*/ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO + 1, Thread1, NULL); - /* - * L3GD20 Object Initialization - */ + /* L3GD20 Object Initialization.*/ l3gd20ObjectInit(&L3GD20D1); - /* - * Activates the L3GD20 driver. - */ + /* Activates the L3GD20 driver.*/ l3gd20Start(&L3GD20D1, &l3gd20cfg); - /* - * Shell manager initialization. - */ + /* Shell manager initialization.*/ shellInit(); while(TRUE) { diff --git a/testhal/STM32/STM32L4xx/SPI-L3GD20/main.c b/testhal/STM32/STM32L4xx/SPI-L3GD20/main.c index 403f78916..d2147de31 100644 --- a/testhal/STM32/STM32L4xx/SPI-L3GD20/main.c +++ b/testhal/STM32/STM32L4xx/SPI-L3GD20/main.c @@ -27,7 +27,7 @@ /* L3GD20 related. */ /*===========================================================================*/ -/* L3GD20 Driver: This object represent an L3GD20 instance */ +/* L3GD20 Driver: This object represent an L3GD20 instance.*/ static L3GD20Driver L3GD20D1; static int32_t rawdata[L3GD20_NUMBER_OF_AXES]; @@ -39,20 +39,20 @@ static uint32_t i; static const SPIConfig spicfg = { NULL, - GPIOD, /* port of L3GD20 CS */ - GPIOD_GYRO_CS, /* pin of L3GD20 CS */ - SPI_CR1_BR | SPI_CR1_CPOL | SPI_CR1_CPHA, /* CR1 register */ - 0 /* CR2 register */ + GPIOD, /* port of L3GD20 CS.*/ + GPIOD_GYRO_CS, /* pin of L3GD20 CS.*/ + SPI_CR1_BR | SPI_CR1_CPOL | SPI_CR1_CPHA, /* CR1 register.*/ + 0 /* CR2 register.*/ }; static L3GD20Config l3gd20cfg = { - &SPID2, /* Pointer to SPI Driver */ - &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 */ + &SPID2, /* Pointer to SPI Driver.*/ + &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__) L3GD20_BDU_CONTINUOUS, L3GD20_END_LITTLE, @@ -74,9 +74,9 @@ static L3GD20Config l3gd20cfg = { #define usb_lld_connect_bus(usbp) #define usb_lld_disconnect_bus(usbp) -/* Enable use of special ANSI escape sequences */ -#define CHPRINTF_USE_ANSI_CODE TRUE -#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048) +/* Enable use of special ANSI escape sequences.*/ +#define CHPRINTF_USE_ANSI_CODE TRUE +#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048) static void cmd_get(BaseSequentialStream *chp, int argc, char *argv[]) { (void)argv; @@ -253,29 +253,19 @@ int main(void) { halInit(); chSysInit(); - /* - * Activates the serial driver 2 using the driver default configuration. - */ + /* Activates the serial driver 2 using the driver default configuration.*/ sdStart(&SD2, NULL); - /* - * Creates the blinker thread. - */ + /* Creates the blinker thread.*/ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO + 1, Thread1, NULL); - /* - * L3GD20 Object Initialization - */ + /* L3GD20 Object Initialization.*/ l3gd20ObjectInit(&L3GD20D1); - /* - * Activates the L3GD20 driver. - */ + /* Activates the L3GD20 driver.*/ l3gd20Start(&L3GD20D1, &l3gd20cfg); - /* - * Shell manager initialization. - */ + /* Shell manager initialization.*/ shellInit(); while(TRUE) {