This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SSI通信接口的数据寄存器为什么不能直接赋值?

在学SSI的通信接口,试着通过寄存器直接控制,可是调试时发现,对SSI的数据寄存器直接赋值根本就不能赋值,换句话说赋值是无效的。这是什么情况?是我别的寄存器控制有问题,导致这个受干扰?还是什么别的情况?个人觉得应该是可以直接赋值的,求指导?

  • SSI的数据发送和接收通过操作FIFO来实现。

    具体函数为:

    void SSIDataPut(uint32_t ui32Base, uint32_t ui32Data)

    void SSIDataGet(uint32_t ui32Base, uint32_t *pui32Data)

  • 用寄存器直接操作怎么操作?

  • 看外设驱动库的源码嘛:

    void
    SSIDataGet(uint32_t ui32Base, uint32_t *pui32Data)
    {
    //
    // Check the arguments.
    //
    ASSERT(_SSIBaseValid(ui32Base));

    //
    // Wait until there is data to be read.
    //
    while(!(HWREG(ui32Base + SSI_O_SR) & SSI_SR_RNE))
    {
    }

    //
    // Read data from SSI.
    //
    *pui32Data = HWREG(ui32Base + SSI_O_DR);
    }

    void
    SSIDataPut(uint32_t ui32Base, uint32_t ui32Data)
    {
    //
    // Check the arguments.
    //
    ASSERT(_SSIBaseValid(ui32Base));
    ASSERT((ui32Data & (0xfffffffe << (HWREG(ui32Base + SSI_O_CR0) &
    SSI_CR0_DSS_M))) == 0);

    //
    // Wait until there is space.
    //
    while(!(HWREG(ui32Base + SSI_O_SR) & SSI_SR_TNF))
    {
    }

    //
    // Write the data to the SSI.
    //
    HWREG(ui32Base + SSI_O_DR) = ui32Data;
    }