Data can be received from the sensor in two different modes:
1- Normal Mode 2- FIFO Mode
In Normal Mode, data is received from the x, y and z axes at intervals determined by the selected initial (init) values.
In FIFO Mode, the sensor is operated for a short time, during this time the FIFO buffer is filled and the process is carried out in this way.
Configured to spi1 full duplex and dma mode
Then opened CS pin (Output) and Interrupt pin (E0)
If data will be sent from uart, uart can be opened
Necessary structure definitions are made
/* USER CODE BEGIN 0 */
LIS3DSH_InitTypeDef mySensor;
LIS3DSH_DataRaw DataRaw;
/* USER CODE END 0 */
than added init
/* USER CODE BEGIN 2 */
mySensor.SelectAxes = LIS3DSH_Select_XYZ_Axis;
mySensor.BDU_select = LIS3DSH_BDU_data_continue;
mySensor.OdrConfig = LIS3DSH_ODR_1600_HZ;
mySensor.FullScale = LIS3DSH_FULLSCALE_16;
mySensor.bandwidth = LIS3DSH_BW_400_HZ;
LIS3DSH_Init(&hspi1,&mySensor);
/* USER CODE END 2 */
1- Normal Mode
DataRaw = LIS3DSH_GetDataRaw();
2- FIFO Mode
HAL_Delay(750);
DataRaw = ReadFIFOData(&mySensor,&huart2);