AnsweredAssumed Answered

BlueNRG-2 SPI driver to access LSM6DS3 using direct register access methodology ?

Question asked by vikrant more on May 28, 2018

I want to access LSM6DS3 sensor which is present on STEVAL-IDB00BV2 board, using direct register methodology (no interrupt )

 

I tried to initialize SPI as follow. Am I on right track ?

 

void spi_init()
{
      CKGEN_SOC->CLOCK_EN |= (1 << 4);  //SPI module clock enable
    
      CLRB(SPI->CR1, 1); // SPI disable ....(as per 3.8.2.2 point mentioned in Datasheet of BlueNRG_2)
  

      GPIO->MODE0 = 0;
      GPIO->MODE0 |= 0x00004444; // IO0, IO1, IO2, IO3 set to mode serial0
    
      GPIO->OEN |= 0x00000007;
      CLRB(GPIO->OEN, 3);
      SETB(GPIO->PE, 3);

 

      SPI->CPSR |= 0x00000004;
    
      SPI->CR0 = 0x00000447; // 8-bit data, Steady-state of clock polarity is high, Steady-state of clock phase is low

                                                 // the slave 1 is selected, SCR = 4, Motorola SPI frame format, Full duplex mode

                                                 //
      SPI->CR1 = 0x00000000; // Master mode,

 

    SETB(SPI->CR1, 1);  // SPI enable

}

 

Now how to access, WHO_AM_I register (addr -> 0x0F ....for reading it should OR with 0x80) ?

 

 

Thank You !!

Outcomes