I'm working on a design that incorporates an ADXL345 accelerometer. It's able to work either through I2C or SPI. What I'm trying to figure out is if there is a way to make that selectable by the end-user, perhaps by means of setting a jumper. For example, if the user wants to use the accelerometer as an I2C device they set a jumper or if they want to use it as an SPI device, they don't set the jumper (or move it between three pins, so that when pin 1 and 2 are shorted it's in one mode and when pins 2 and 3 are shorted, it's in the other.)
Note, this is *not* meant to be a running change. It's meant to be configured prior to turning the whole unit on and programming it. So is there some way to do this? Some way to switch how it communicates?
Relevant info on the ADXL345:
For SPI communications (4-wire), the pins are wired as follows:
CS (pin 7) -> Arduino SS
SDI (pin 13) -> Arduino MOSI
SDO (pin 12) -> Arduino MISO
SCLK (pin 14) -> Arduino SCK
For I2C communications, the pins are wired as follows:
CS (pin 7) -> VCC
SDA (pin 13) -> Arduino SDA
SCL (pin 14) -> Arduino SCL
Notice how in both setups, pins 7, 13, and 14 are used. If pin 7 is tied to VCC, the device will be in I2C mode, and if it's tied to SS, it'll work in SPI (4-wire) mode.
I can probably do this with a mechanical switch, but I'm hoping for a simpler (for the end-user) method, just using a jumper to switch things around. Much like there are some devices out there that have a jumper on them to switch between 3.3V or 5V operations.
So, help anyone? Schematic? Parts (if any)?