Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for SPI constructor to enable Hardware SPI #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Adafruit_ADXL345_U.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,22 @@ Adafruit_ADXL345_Unified::Adafruit_ADXL345_Unified(uint8_t clock, uint8_t miso,
SPI_BITORDER_MSBFIRST, SPI_MODE1);
}

/**************************************************************************/
/*!
@brief Instantiates a new ADXL345 class in SPI mode
@param theSPI The SPI bus to use
@param cs The pin number for CS, the SPI Chip Select line
@param sensorID A unique ID to use to differentiate the sensor from others
*/
/**************************************************************************/
Adafruit_ADXL345_Unified::Adafruit_ADXL345_Unified(SPIClass *theSPI, uint8_t cs,
int32_t sensorID) {
_sensorID = sensorID;
_range = ADXL345_RANGE_2_G;
spi_dev = new Adafruit_SPIDevice(cs, 1000000, SPI_BITORDER_MSBFIRST,
SPI_MODE1, theSPI);
}

/**************************************************************************/
/*!
@brief Setups the HW (reads coefficients values, etc.)
Expand Down
1 change: 1 addition & 0 deletions Adafruit_ADXL345_U.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class Adafruit_ADXL345_Unified : public Adafruit_Sensor {
Adafruit_ADXL345_Unified(int32_t sensorID = -1);
Adafruit_ADXL345_Unified(uint8_t clock, uint8_t miso, uint8_t mosi,
uint8_t cs, int32_t sensorID = -1);
Adafruit_ADXL345_Unified(SPIClass *theSPI, uint8_t cs, int32_t sensorID = -1);
~Adafruit_ADXL345_Unified();

bool begin(uint8_t addr = ADXL345_DEFAULT_ADDRESS);
Expand Down