Beispiel #1
0
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 
	
}
Beispiel #2
0
/**
  * @brief  Set LSM9DS1 Initialization.
  * @param  LSM9DS1_Config_Struct: pointer to a LSM9DS1_Config_TypeDef structure 
  *         that contains the configuration setting for the LSM9DS1.
  * @retval None
  */
void LSM9DS1_Init(LSM9DS1_InitTypeDef *init)
{
	// Configure the low level interface 
  LSM9DS1_LowLevel_Init();
	
	// Configure acclerometer data rate and scale
  uint8_t ctrl_reg_5_xl = init->XL_DataRate | init->XL_Scale; 
	LSM9DS1_Write(&ctrl_reg_5_xl,LSM9DS1_CTRL_REG6_XL, 1);
	
	// Configure accelerometer axes
	uint8_t ctrl_reg_6_xl = init->XL_Axes; 
	LSM9DS1_Write(&ctrl_reg_6_xl,LSM9DS1_CTRL_REG5_XL, 1);
	
	// Configure gyro data rate and scale
  uint8_t ctrl_reg1_g = init->G_DataRate | init->G_Scale; 
	LSM9DS1_Write(&ctrl_reg1_g,LSM9DS1_CTRL_REG1_G, 1);
	
	// Configure gyro axes
	uint8_t ctrl_reg_4 = init->G_Axes; 
	LSM9DS1_Write(&ctrl_reg_4,LSM9DS1_CTRL_REG4, 1);
  
}
Beispiel #3
0
void LSM9DS1_Init(LSM9DS1_InitTypeDef *LSM9DS1_InitStruct)
{
  uint8_t ctrl = 0x00;
 
  /* Configure the low level interface ---------------------------------------*/
  LSM9DS1_LowLevel_Init();
  
  /* Configure MEMS: data rate, update mode and axes */
  ctrl = (uint8_t) (LSM9DS1_InitStruct->Power_Mode_Output_DataRate  | \
										LSM9DS1_InitStruct->Full_Scale           				| \
										LSM9DS1_InitStruct->Filter_Mode									| \
										LSM9DS1_InitStruct->AA_Filter_BW);
                    
  /* Write value to MEMS CTRL_REG4 regsister */
  LSM9DS1_Write(&ctrl, LSM9DS1_CTRL_REG6, 1);
	
	/* Configure MEMS: Anti-aliasing filter, full scale, self test  */
	ctrl = (uint8_t) (LSM9DS1_InitStruct->Decimation | \
										LSM9DS1_InitStruct->Axes_Enable);
	
	/* Write value to MEMS CTRL_REG5 regsister */
	LSM9DS1_Write(&ctrl, LSM9DS1_CTRL_REG5, 1);
	
}