#include "stm32f10x.h"\r
#include "i2c.h"\r
\r
+#define LSM_I2C_Speed 400000\r
#define Lsm303dlhcI2CInit() i2c_init(2, LSM_I2C_Speed)\r
#define Lsm303dlhcI2CBufferRead(dest, buffer, address, nb) i2c_get(dest, address, buffer, nb)\r
#define Lsm303dlhcI2CBufferWrite(dest, buffer, address, nb) i2c_set(dest, address, buffer, nb)\r
#include <stm32f10x.h>
#include <stm32f10x_gpio.h>
-#include <stm32f10x_rcc.h>
-#include <stm32f10x_i2c.h>
-#include <spi.h>
-#include <i2c.h>
#include <L3Gx.h>
#include <LSM303DLHC.h>
#ifdef GYRO
void initGyro()
{
+ L3gxCommInit();
+
L3GInit gyrodef;
/* Fill the gyro structure */
printf("Data update: %02x\n", gyroinfo.xDataUpdate);
printf("Endianness: %02x\n", gyroinfo.xEndianness);
}
-/*
+
static void gyroTask(void *p)
{
printf("Start gyro task\n");
vTaskDelay(1000);
}
free(values);
-}*/
+}
#endif
#ifdef ACCELERO
void initAccelero()
{
+ Lsm303dlhcI2CInit();
+
LSMAccInit accelerodef;
/* Fill the gyro structure */
return;
while (1)
{
- L3gxReadAngRate(values);
- printf("Gyro: x=%.4f y=%.4f z=%.4f\n", values[0], values[1], values[2]);
Lsm303dlhcAccReadAcc(values);
printf("Accelero: x=%.4f y=%.4f z=%.4f\n", values[0], values[1], values[2]);
vTaskDelay(1000);
{
init_malloc_wrapper();
-
#ifdef LEDS
printf("Init led\n");
initLed();
#endif
#ifdef GYRO
- printf("Init SPI2\n");
- spi_init(2);
printf("Init Gyro\n");
initGyro();
printf("Get Gyro Information\n");
getGyroInfo();
-// printf("Start gyroTask\n");
-// xTaskCreate(gyroTask, (const signed char *)NULL, configMINIMAL_STACK_SIZE, (void *)NULL, tskIDLE_PRIORITY, NULL);
+ printf("Start gyroTask\n");
+ xTaskCreate(gyroTask, (const signed char *)NULL, configMINIMAL_STACK_SIZE, (void *)NULL, tskIDLE_PRIORITY, NULL);
#endif
#ifdef ACCELERO
- printf("Init I2C2\n");
- i2c_init(2, 400000);
- printf("Get Accelero Information\n");
- getAcceleroInfo();
printf("Init Accelero\n");
initAccelero();
+ printf("Get Accelero Information\n");
+ getAcceleroInfo();
printf("Start acceleroTask\n");
xTaskCreate(acceleroTask, (const signed char *)NULL, configMINIMAL_STACK_SIZE, (void *)NULL, tskIDLE_PRIORITY, NULL);
#endif