Toto je starší verze dokumentu!
Author: Jiri Krivak
Calculate the roll and pitch values from a 3-axis accelerometer. Use the development board STM32F4DISCOVERY with LIS302DL / LIS3DSH devices. Consider any accelerometer position relative to the base, i.e. implement the compensation by de-rotation of input data vector as described in DT0076.
For the project, we selected Development Board from STMicroelectronics STM32F4 - Discovery
The application was created by using HAL Drivers, STM32F4-Discovery (to map PINs for Discovery), Driver for accelerometer from STMicroelectronics. Next, we use a Middleware library from STMicroelectronics to create Virtual Com Port. We also used ARM GCC Libraries: stdio.h, stdlib.h, math.h The app was designed for Em::Bitz and its integrated ARM GCC Compiler. Because we use function Printf with floats we need to give the GCC compiler flag that tells it that floats are used for string formatting we also use mathematical library math.h, so we need to give the linker flag to include mathematical libraries. GCC Compiler Flag: -u _printf_float Linker Flag: -lm
To create Virtual Com Port we used middleware libraries from STMicroelectronics. For easier communication, we remapped the Printf function so that when it is called we send data over the USB VCP. Remaping of Printf in ARM GCC is done by modificiation of _write function.
int _write(int fd, char * str, int len) { for (int i = 0; i < len; i++) { VCP_write(&str[i],1); } return len; }
We used Legacy Middleware library for USB so it is necessarz to instal VCP Driver from STMicroelectronics.