Skip to content

Commit 9eb6464

Browse files
author
Elias Santistevan
committed
Changes SPI set bit order to include a check for ESP32 so that it properly compiles when using ESP32
* Moves includes to header file * Replaces include of "stdint.h" with more inclusive "arduino.h"
1 parent 12bd942 commit 9eb6464

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/SparkFunLSM6DS3.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ Distributed as-is; no warranty is given.
2828

2929
#include "SparkFunLSM6DS3.h"
3030
#include "stdint.h"
31-
3231
#include "Wire.h"
3332
#include "SPI.h"
3433

@@ -78,7 +77,11 @@ status_t LSM6DS3Core::beginCore(void)
7877
// Maximum SPI frequency is 10MHz, could divide by 2 here:
7978
SPI.setClockDivider(SPI_CLOCK_DIV4);
8079
// Data is read and written MSb first.
80+
#ifdef ESP32
81+
SPI.setBitOrder(SPI_MSBFIRST);
82+
#else
8183
SPI.setBitOrder(MSBFIRST);
84+
#endif
8285
// Data is captured on rising edge of clock (CPHA = 0)
8386
// Base value of the clock is HIGH (CPOL = 1)
8487

@@ -212,7 +215,7 @@ status_t LSM6DS3Core::readRegisterRegion(uint8_t *outputPointer , uint8_t offset
212215
//****************************************************************************//
213216
status_t LSM6DS3Core::readRegister(uint8_t* outputPointer, uint8_t offset) {
214217
//Return value
215-
uint8_t result;
218+
uint8_t result = 0;
216219
uint8_t numBytes = 1;
217220
status_t returnError = IMU_SUCCESS;
218221

src/SparkFunLSM6DS3.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ Distributed as-is; no warranty is given.
2727
#ifndef __LSM6DS3IMU_H__
2828
#define __LSM6DS3IMU_H__
2929

30-
#include "stdint.h"
30+
#include "Arduino.h"
31+
#include "Wire.h"
32+
#include "SPI.h"
3133

3234
#define I2C_MODE 0
3335
#define SPI_MODE 1

0 commit comments

Comments
 (0)