Part Number: DRV8889-Q1
hi Team,
my customer use DRV8889-Q1, and have a question on coding.
- do they need to shift left 9bits(SPI_ADDRESS_POS)? For example, the register address 0x07=(00000111), so they need to send (1000 1110 0000 0000)?
- the right format is |R/W|A6|A5|A4|A3|A2|A1|A0| D7|D6|D5|D4|D3|D2|D1|D0| OR |R/W|A4|A3|A2|A1|A0|*|*| D7|D6|D5|D4|D3|D2|D1|D0|?
that is to say how about A6|A5 coding?
- please help check the below code comments are right or not:
/* Register format |R/W|A4|A3|A2|A1|A0|*|*| D7|D6|D5|D4|D3|D2|D1|D0|
* Ax is address bit, Dx is data bits and R/W is read write bit.
* For read R/W bit should be 1 */
uint16_t SPI_readRegister(uint8_t address)
{
。。。。。。。。
reg_value |= SPI_RW_BIT_MASK; /*Set R/W bit*/
reg_value |= ((address << SPI_ADDRESS_POS) & SPI_ADDRESS_MASK); /* Configure register address value*/
。。。。。。。。
}
/* Register format |R/W|A4|A3|A2|A1|A0|*|*|D7|D6|D5|D4|D3|D2|D1|D0|
* Ax is address bit, Dx is data bits and R/W is read write bit.
* For write R/W bit should 0. */
uint16_t SPI_writeRegister(uint8_t address, uint16_t data)
{
。。。。
volatile uint16_t reg_value = 0;
reg_value |= ((address << SPI_ADDRESS_POS) & SPI_ADDRESS_MASK); /* Adding register address value*/
reg_value |= ((data << SPI_DATA_POS) & SPI_DATA_MASK); /*Adding data value */
。。。。
}
thanks.