| BlueNRG-1 Peripherals drivers Examples

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

SPI_Master_w_Sensor_main.c
Go to the documentation of this file.
1
2 /******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
3 * File Name : SPI_Master_w_Sensor_main.c
4 * Author : VMA DIVISION
5 * Version : 1.0.0
6 * Date : 21-September-2015
7 * Description : Code demostrating the SPI master functionality using the inertial sensor
8 ********************************************************************************
9 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
10 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
11 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
12 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
13 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
14 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
15 *******************************************************************************/
16
179 /* Includes ------------------------------------------------------------------*/
180 #include "BlueNRG1.h"
181 #include <stdio.h>
182 #include "BlueNRG1_conf.h"
183 #include "BlueNRG1_it.h"
184 #include "SDK_EVAL_Config.h"
185 #include "LSM6DS3.h"
186
199 /* Private typedef -----------------------------------------------------------*/
200 typedef struct {
201 int32_t AXIS_X;
202 int32_t AXIS_Y;
203 int32_t AXIS_Z;
204 } AxesAccRaw_TypeDef, AxesGyrRaw_TypeDef;
205
206 /* Private define ------------------------------------------------------------*/
207 /* Private macro -------------------------------------------------------------*/
208 /* Private variables ---------------------------------------------------------*/
209 extern volatile FlagStatus GpioIrqFlag;
210 static IMU_6AXES_DrvTypeDef *Imu6AxesDrv = NULL;
211
212 /* Private function prototypes -----------------------------------------------*/
213 /* Private functions ---------------------------------------------------------*/
214 #include "LSM6DS3_hal.h"
215
219 int main(void)
220 {
221 AxesAccRaw_TypeDef pAccData;
222 AxesGyrRaw_TypeDef pGyrData;
223
224 /* System initialization function */
225 SystemInit();
226
227 /* Identify BlueNRG1 platform */
228 SdkEvalIdentification();
229
230 /* LEDS initialization */
231 SdkEvalLedInit(LED1);
232
233 /* UART initialization */
234 SdkEvalComUartInit(UART_BAUDRATE);
235
236 /* LSM6DS3 library setting */
237 IMU_6AXES_InitTypeDef InitStructure;
238 Imu6AxesDrv = &LSM6DS3Drv;
239
240 InitStructure.G_FullScale = 125.0f;
241 InitStructure.G_OutputDataRate = 13.0f;
242 InitStructure.G_X_Axis = 1;
243 InitStructure.G_Y_Axis = 1;
244 InitStructure.G_Z_Axis = 1;
245 InitStructure.X_FullScale = 2.0f;
246 InitStructure.X_OutputDataRate = 13.0f;
247 InitStructure.X_X_Axis = 1;
248 InitStructure.X_Y_Axis = 1;
249 InitStructure.X_Z_Axis = 1;
250
251 /* LSM6DS3 initiliazation */
252 Imu6AxesDrv->Init(&InitStructure);
253
254 printf("ACC_X, ACC_Y, ACC_Z, GYR_X, GYR_Y, GYR_Z\r\n");
255
256 /* Infinite loop */
257 while(1) {
258
259 /* Waiting for interrupt flag to be SET */
260 if(GpioIrqFlag == SET) {
261 GpioIrqFlag = RESET;
262
263 /* Read data from LSM6DS3 */
264 Imu6AxesDrv->Get_X_Axes((int32_t *)&pAccData);
265 Imu6AxesDrv->Get_G_Axes((int32_t *)&pGyrData);
266
267 printf("%d, %d, %d, %d, %d, %d\r\n", (int)pAccData.AXIS_X, (int)pAccData.AXIS_Y, (int)pAccData.AXIS_Z, (int)pGyrData.AXIS_X, (int)pGyrData.AXIS_Y, (int)pGyrData.AXIS_Z);
268 SdkEvalLedToggle(LED1);
269 }
270 else {
271 /* Clear first previous data */
272 Imu6AxesDrv->Get_X_Axes((int32_t *)&pAccData);
273 Imu6AxesDrv->Get_G_Axes((int32_t *)&pGyrData);
274 }
275
276 }
277
278 }
279
280
281
282 #ifdef USE_FULL_ASSERT
283
290 void assert_failed(uint8_t* file, uint32_t line)
291 {
292 /* User can add his own implementation to report the file name and line number,
293 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
294
295 /* Infinite loop */
296 while (1)
297 {
298 }
299 }
300
301 #endif
302
315 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/
AxesAccRaw_TypeDef
Definition: SPI_Master_w_Sensor_main.c:200
AxesGyrRaw_TypeDef
struct AxesAccRaw_TypeDef AxesGyrRaw_TypeDef
GpioIrqFlag
volatile FlagStatus GpioIrqFlag
main
int main(void)
Main program.
Definition: SPI_Master_w_Sensor_main.c:219
AxesAccRaw_TypeDef::AXIS_Y
int32_t AXIS_Y
Definition: SPI_Master_w_Sensor_main.c:202
AxesAccRaw_TypeDef::AXIS_Z
int32_t AXIS_Z
Definition: SPI_Master_w_Sensor_main.c:203
AxesAccRaw_TypeDef::AXIS_X
int32_t AXIS_X
Definition: SPI_Master_w_Sensor_main.c:201
UART_BAUDRATE
#define UART_BAUDRATE
Definition: ADC_PDM_main.c:225