Ejemplo n.º 1
0
void read_adxl(U8* dat)
{
    int i;
    SPI_ENB();
    spi_xfer_byte(0xf2);

    for (i=0; i<6; i++)
    {
        dat[i] = spi_xfer_byte(0);
    }
    SPI_DIS();
}
Ejemplo n.º 2
0
void draw_square()
{
   int count = 0;

   if(change_duty) {
      square_wave_init();
      change_duty = 0;
   }
   while(count < NUM_DIVISIONS) {
      if (timeCount > oldTimeCount) {
         oldTimeCount = timeCount;
         spi_csl();
         spi_xfer_byte((squareVals[count] | 0x1000) >> 8);
         spi_xfer_byte(squareVals[count++] & 0xFF);
         spi_csh();
      }
   }
Ejemplo n.º 3
0
void adxl_init()
{
    is_adxl_on = true;
    // set power bit
    SPI_ENB();
    spi_xfer_byte(0x2d);
    spi_xfer_byte(0x28);
    SPI_DIS();

    // set full resolution
    SPI_ENB();
    spi_xfer_byte(0x31);
    spi_xfer_byte(0x08);
    SPI_DIS();

    // clear fifo
    SPI_ENB();
    spi_xfer_byte(0x38);
    spi_xfer_byte(0x00);
    SPI_DIS();
}