コード例 #1
0
/**
 * @brief  Set LIS302DL Initialization.
 * @param  LIS302DL_Config_Struct: pointer to a LIS302DL_Config_TypeDef structure 
 *         that contains the configuration setting for the LIS302DL.
 * @retval None
 */
void LIS302DL_Init(LIS302DL_InitTypeDef *LIS302DL_InitStruct) {
    uint8_t ctrl = 0x00;

    /* Configure the low level interface ---------------------------------------*/
    LIS302DL_LowLevel_Init();

    /* Configure MEMS: data rate, power mode, full scale, self test and axes */
    ctrl = (uint8_t) (LIS302DL_InitStruct->Output_DataRate | LIS302DL_InitStruct->Power_Mode | \
                    LIS302DL_InitStruct->Full_Scale | LIS302DL_InitStruct->Self_Test | \
                    LIS302DL_InitStruct->Axes_Enable);

    /* Write value to MEMS CTRL_REG1 regsister */
    LIS302DL_Write(&ctrl, LIS302DL_CTRL_REG1_ADDR, 1);
}
コード例 #2
0
void InitializeAccelerometer(void)
{
	LIS302DL_LowLevel_Init();

	SetAccelerometerMainConfig(
		LIS302DL_LOWPOWERMODE_ACTIVE|
		LIS302DL_DATARATE_100|
		LIS302DL_XYZ_ENABLE|
		LIS302DL_FULLSCALE_2_3|
		LIS302DL_SELFTEST_NORMAL);

	//Wait one second for data to stabilize
	Delay(100);

	SetAccelerometerFilterConfig(
		LIS302DL_FILTEREDDATASELECTION_BYPASSED|
		LIS302DL_HIGHPASSFILTER_LEVEL_1|
		LIS302DL_HIGHPASSFILTERINTERRUPT_1_2);

}