/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); palSetLineMode(LINE_ARD_D14, PAL_MODE_ALTERNATE(4) | PAL_STM32_OSPEED_HIGH); palSetLineMode(LINE_ARD_D15, PAL_MODE_ALTERNATE(4) | PAL_STM32_OSPEED_HIGH); /* * Activates the serial driver 2 using the driver default configuration. */ sdStart(&SD2, NULL); /* * L3GD20 Object Initialization */ lsm6ds0ObjectInit(&LSM6DS0D1); lsm6ds0Start(&LSM6DS0D1, &lsm6ds0cfg); while (TRUE) { palToggleLine(LINE_LED_GREEN); sensorReadRaw(&LSM6DS0D1, rawdata); sensorReadCooked(&LSM6DS0D1, cookeddata); gyroscopeGetTemp(&LSM6DS0D1, &temp); chprintf(chp, "ACCELEROMETER DATA\r\n"); for(i = 0; i < LSM6DS0_ACC_NUMBER_OF_AXES; i++) chprintf(chp, "RAW-%c:%d\t\t", axesID[i], rawdata[i]); chprintf(chp, "\r\n"); for(i = 0; i < LSM6DS0_ACC_NUMBER_OF_AXES; i++) chprintf(chp, "COOKED-%c:%.3f g\t", axesID[i], cookeddata[i]); chprintf(chp, "\r\nGYROSCOPE DATA\r\n"); for(i = 0; i < LSM6DS0_GYRO_NUMBER_OF_AXES; i++) chprintf(chp, "RAW-%c:%d\t\t", axesID[i], rawdata[i + 3]); chprintf(chp, "\r\n"); for(i = 0; i < LSM6DS0_GYRO_NUMBER_OF_AXES; i++) chprintf(chp, "COOKED-%c:%.3f dps\t", axesID[i], cookeddata[i + 3]); chprintf(chp, "\r\n"); chprintf(chp, "TEMPERATURE DATA\r\n"); chprintf(chp, "LSM6DS0:%.3f C°\t", temp); chprintf(chp, "\r\n"); chThdSleepMilliseconds(100); #if CHPRINTF_USE_ANSI_CODE chprintf(chp, "\033[2J\033[1;1H"); #endif } }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); palSetLineMode(LINE_ARD_D15, PAL_MODE_ALTERNATE(4) | PAL_STM32_OSPEED_HIGH); palSetLineMode(LINE_ARD_D14, PAL_MODE_ALTERNATE(4) | PAL_STM32_OSPEED_HIGH); /* * Activates the serial driver 2 using the driver default configuration. */ sdStart(&SD2, NULL); /* * Creates the blinker thread. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO + 1, Thread1, NULL); /* * LSM6DS0 Object Initialization */ lsm6ds0ObjectInit(&LSM6DS0D1); /* * Activates the LSM6DS0 driver. */ lsm6ds0Start(&LSM6DS0D1, &lsm6ds0cfg); /* * Shell manager initialization. */ shellInit(); while(TRUE) { thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE, "shell", NORMALPRIO + 1, shellThread, (void *)&shell_cfg1); chThdWait(shelltp); /* Waiting termination. */ chThdSleepMilliseconds(1000); } lsm6ds0Stop(&LSM6DS0D1); return 0; }