Skip to content

Commit

Permalink
use adxl_write for init (sets READ bit correctly in SPI)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alon Levy committed Sep 3, 2010
1 parent cc87684 commit 7402755
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions juggled/adxl345.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,29 @@ void adxl_init()
is_adxl_on = true;
spi_init();
// set power bit
//adxl_write(ADXL345_POWER_CTL, ADXL345_MEASURE);
adxl_write(ADXL345_POWER_CTL, ADXL345_MEASURE);

SPI_ENB();
spi_xfer_byte(ADXL345_POWER_CTL);
spi_xfer_byte(ADXL345_LINK | ADXL345_MEASURE);
SPI_DIS();
// bandwidth
adxl_write(ADXL345_BW_RATE, ADXL345_100HZ_OUTPUT);

//SPI_ENB();
//spi_xfer_byte(ADXL345_POWER_CTL);
//spi_xfer_byte(ADXL345_LINK | ADXL345_MEASURE);
//SPI_DIS();

// set full resolution
//adxl_write(ADXL345_DATA_FORMAT, 0x08);
SPI_ENB();
spi_xfer_byte(ADXL345_DATA_FORMAT);
spi_xfer_byte(0x08);
SPI_DIS();
adxl_write(ADXL345_DATA_FORMAT, ADXL345_FULLRES | ADXL345_8G);
//SPI_ENB();
//spi_xfer_byte(ADXL345_DATA_FORMAT);
//spi_xfer_byte(0x08);
//SPI_DIS();

// clear and disable the fifo
//adxl_write(ADXL345_FIFO_CTL, 0x00);
SPI_ENB();
spi_xfer_byte(ADXL345_FIFO_CTL);
spi_xfer_byte(0x00);
SPI_DIS();
adxl_write(ADXL345_FIFO_CTL, 0x00);
//SPI_ENB();
//spi_xfer_byte(ADXL345_FIFO_CTL);
//spi_xfer_byte(0x00);
//SPI_DIS();
}

// define the interface that will be used to access the ADXL345.
Expand Down

0 comments on commit 7402755

Please sign in to comment.