I have problems trying to read specific register from i2c device. First I transmit address and register to request reading from device, but when I try to send start (repeated start) it still expects new TX data.. I am not sure what should I send to specify I want to read now...
This is the sample code I am trying to use:
if (!waitForState(MasterStates::Idle)) return false;
m_peripheral->MSTDAT = m_address; //send address of slave and set start
m_peripheral->MSTCTL = MSTSTART;
if (!waitForState(MasterStates::TxRdy)) return false;
m_peripheral->MSTDAT = a_reg; // send address of register i want to read and send continue
m_peripheral->MSTCTL = MSTCONTINUE;
if (!waitForState(MasterStates::TxRdy)) return false;
m_peripheral->MSTDAT = m_address | 1; //set read flag on address and send start (i hoped it would be repeated start)
m_peripheral->MSTCTL = MSTSTART;
if (!waitForState(MasterStates::RxRdy)) return false; //<<<<<<--- this is where I still get TxRdy instead of RxRdy
tmp = m_peripheral->MSTDAT;
m_peripheral->MSTCTL = MSTSTOP;
if (!waitForState(MasterStates::Idle)) return false;
So what should I set after sending the address of register i want to read ?
Thanks