int main(){ LSM9DS1_LowLevel_Init(); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE); GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOE, &GPIO_InitStructure); GPIO_SetBits(GPIOE, GPIO_Pin_3); printf("PE3 %d\n", GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_3)); uint8_t byte_write = 96; //119 Hz and 2g range LSM9DS1_Write(&byte_write, LSM9DS1_CTRL_REG6_XL, 1); printf("Sent %d on the bus\n", byte_write); uint8_t byte_read = 0; LSM9DS1_Read(&byte_read, LSM9DS1_CTRL_REG6_XL, 1); printf("Received %d on the bus\n", byte_read); byte_write = 56; //enable all axes LSM9DS1_Write(&byte_write, LSM9DS1_CTRL_REG5_XL, 1); printf("Sent %d on the bus\n", byte_write); byte_read = 0; LSM9DS1_Read(&byte_read, LSM9DS1_CTRL_REG5_XL, 1); printf("Received %d on the bus\n", byte_read); int32_t accelerometer_out[3]; LSM9DS1_ReadACC(accelerometer_out); printf("%d %d %d\n", accelerometer_out[0],accelerometer_out[1],accelerometer_out[2]); // osKernelInitialize (); // initialize CMSIS-RTOS // display_mode = 0; // angle_to_draw = SHOW_ROLL; // // // initialize peripherals here // initialize_ADC_Temp(); // init_accelerometer(); // init_interrupts(); // init_7_segment(); // init_TIM3(); // init_TIM4(); // init_TIM5(); // EXTI_GenerateSWInterrupt(EXTI_Line0); // // // create 'thread' functions that start executing, // // example: tid_name = osThreadCreate (osThread(name), NULL); // temperature_reader_thread = osThreadCreate(osThread(temperature_reader),NULL); // display_refresher_thread = osThreadCreate(osThread(display_refresher),NULL); // accelerometer_reader_thread = osThreadCreate(osThread(accelerometer_reader),NULL); // keypad_detector_thread = osThreadCreate(osThread(keypad_detector),NULL); // // osKernelStart(); // start thread execution }
void readAccelerometer(float * Accelerometer_Data) { float raw_Accelerometer [3]; //LIS3DSH_ReadACC(raw_Accelerometer); LSM9DS1_ReadACC(raw_Accelerometer); float Matrix_calibration_Value; for(int i = 0; i < 3; i++) { Matrix_calibration_Value = 0; for(int j = 0; j < 3; j++) { Matrix_calibration_Value += raw_Accelerometer[j] * Cal1[i][j]; } Accelerometer_Data[i] = Matrix_calibration_Value + Cal2[i]; debug_d[i] = Accelerometer_Data[i]; } }