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

Made select pin adjustable #3

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 4 additions & 3 deletions ADXL362.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <ADXL362.h>
#include <SPI.h>

const int slaveSelectPin = 10;
static uint8_t slaveSelectPin = 10;
const bool debugSerial = 1;

ADXL362::ADXL362() {
Expand All @@ -28,7 +28,8 @@ ADXL362::ADXL362() {
// begin()
// Initial SPI setup, soft reset of device
//
void ADXL362::begin() {
void ADXL362::begin(uint8_t csPin) {
slaveSelectPin = csPin;
pinMode(slaveSelectPin, OUTPUT);
SPI.begin();
SPI.setDataMode(SPI_MODE0); //CPHA = CPOL = 0 MODE = 0
Expand Down Expand Up @@ -195,7 +196,7 @@ void ADXL362::checkAllControlRegs(){
digitalWrite(slaveSelectPin, LOW);
SPI.transfer(0x0B); // read instruction
SPI.transfer(0x20); // Start burst read at Reg 20
Serial.println("Start Burst Read of all Control Regs - Library version 6-24-2012:");
Serial.println("Start Burst Read of all Control Regs - Library version 2014-04-23:");
Serial.print("Reg 20 = "); Serial.println(SPI.transfer(0x00), HEX);
Serial.print("Reg 21 = "); Serial.println(SPI.transfer(0x00), HEX);
Serial.print("Reg 22 = "); Serial.println(SPI.transfer(0x00), HEX);
Expand Down
2 changes: 1 addition & 1 deletion ADXL362.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ADXL362
//
// Basic Device control and readback functions
//
void begin();
void begin(uint8_t csPin = 10);
void beginMeasure();
int readXData();
int readYData();
Expand Down