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.

CC2640R2F SPI接收不slave的数据

Other Parts Discussed in Thread: CC2640R2F

我使用了CC2640R2F的硬件SPI对 9PIN的 OLED进行通信,这款OLED内含了GT20L16S1Y字库芯片和SSD1309。在发送数据给SSD1309能正常的显示BMP图片,

但是在显示中文的时候RX一直没有数据,在逻辑分析仪上已经显示成功切换片选切发送了数据,但是就是没有数据的返回。已知字库芯片上的最高支持的时钟频率为30MHZ,主机设置的params.bitRate     = 300000。能分析分析到底是哪里出现问题了吗?

void OLED_WR_Byte(u8 dat,u8 cmd)
{
    bool data_status = false;
    if(CSNpin != OLED_CSN_STATUS)
    {
        //更换片选
        SPI_control(handle, ***, &csnPin0);
        CSNpin = OLED_CSN_STATUS;
    }
    transmitBuffer[0] = dat;
    transaction.count = 1;
    transaction.txBuf = transmitBuffer;
    transaction.rxBuf = NULL;
    transaction.arg = NULL;
    if(cmd)
        OLED_DC_Set();
    else
    {
        OLED_DC_Clr();
    }


    // Open the SPI and perform the transfer
    // handle = SPI_open(Board_SPI, &params);
    data_status = SPI_transfer(handle, &transaction);

    if(data_status == false)
    {
        Log_error0("Error SPI_send!");
    }
   /* if(data_status == true && cmd == OLED_DATA)
    {
       // Log_info1("oled send msg: %u ",transmitBuffer[0]);
    }*/
    //拉高DC
    OLED_DC_Set();

}

//发送一个字节到GT20L16S1Y
void Send_Command_to_ROM(u8 dat)
{
    int ret;
    if(CSNpin != ROM_CSN_STATUS)
    {
        //更换片选
        ret = SPI_control(handle, ***, &csnPin1);
        CSNpin = ROM_CSN_STATUS;
    }

    transmitBuffer[0] = dat;
    transaction.count = 1;
    transaction.txBuf = transmitBuffer;
    transaction.rxBuf = NULL;
    transaction.arg = NULL;

    // Open the SPI and perform the transfer
    // handle = SPI_open(Board_SPI, &params);
     SPI_transfer(handle, &transaction);

    if(CSNpin == ROM_CSN_STATUS)
    {
        Log_info1("rom send msg: %u ",transmitBuffer[0]);
    }

}
//从GT20L16S1Y获得一个字节
u8 Get_data_from_ROM(void)
{
    int ret=0;
    bool data_status = false;
    u8 read=0;
    if(CSNpin != ROM_CSN_STATUS)
    {
        ret = SPI_control(handle, ***, &csnPin1);
        if(ret != SPI_STATUS_SUCCESS)
        {
            Log_error0("Error Get_data_from_ROM");
        }
        CSNpin = ROM_CSN_STATUS;
    }

    transaction.count = 1;
    transaction.txBuf = NULL;
    transaction.rxBuf = receiveBuffer;
    data_status = SPI_transfer(handle, &transaction);
    if(data_status == false)
    {
        Log_error0("Error SPI_send!");
    }else
        Log_info1("ROM_read_data %U",receiveBuffer[0]);

    read = receiveBuffer[0];


    return read;
}

最后是SPI的初始化:

    SPI_init();
    SPI_Params_init(&params);
    params.bitRate     = 300000;
    params.frameFormat = SPI_POL0_PHA0;
    params.mode        = SPI_MASTER;
    params.dataSize    = 8;
    handle = SPI_open(Board_SPI0, &params);
    if(handle == NULL)
    {
        Log_error0("Error SPI_open!");
    }