TI中文支持网
TI专业的中文技术问题搜集分享网站

CC2640R2F SPI传输模式

最近在按照官方的SPI历程跟OLED通信,发现有几个参数不是很明白:

typedef struct {
    SPI_TransferMode transferMode;       /*!< Blocking or Callback mode */
    uint32_t         transferTimeout;    /*!< Transfer timeout in system
                                              ticks */
    SPI_CallbackFxn  transferCallbackFxn;/*!< Callback function pointer */
    SPI_Mode         mode;               /*!< Master or Slave mode */
    /*! @brief SPI bit rate in Hz
     *
     *  Maximum bit rates supported by hardware:
     *  Device Family | Slave Max (MHz)    | Master Max (MHz) |
     *  ————- | —————— | —————- |
     *  MSP432P4      | 16 MHz             | 24 MHz           |
     *  MSP432E4      | 10 MHz             | 60 MHz           |
     *  CC13XX/CC26XX | 4  MHz             | 12 MHz           |
     *  CC32XX        | 20 MHz             | 20 MHz           |
     *
     *  Please note that depending on the specific use case, the driver may not
     *  support the hardware's maximum bit rate.
     */
    uint32_t         bitRate;
    uint32_t         dataSize;           /*!< SPI data frame size in bits */
    SPI_FrameFormat  frameFormat;        /*!< SPI frame format */
    void            *custom;             /*!< Custom argument used by driver
                                              implementation */
} SPI_Params;
在Params中:transferMode中包含了阻塞模式和回调模式,这两个模式有什么区别?阻塞模式会在我发送完数据以后阻塞我的主进程代码的运行吗?回调模式又是如何来理解呢?

还有bitRate我可以理解为传输速度吗?传输速度对从机设备有要求吗?这个传输速度在SPI的时序图上该如何来理解呢?

Kevin Qiu1:

阻塞:系统进程将会停止在任务处,直到任务执行完成,系统才会继续执行下去

回调:系统不会在任务处停止,直到任务触发,才会跳转到任务执行

bitRate是传输速度,如果是从机发送数据的话和从机的时钟频率有关,时序图中一次发送8bit,bitrate越大,发送相同大小数据的时间越短

Viki Shi:

1、In blocking mode, a task's code execution is blocked until a SPI transaction has completed or a timeout has occurred. This ensures that only one SPI transfer operates at a given time. Other tasks requesting SPI transfers while a transfer is currently taking place will receive a FALSE return value. If a timeout occurs the transfer is canceled, the task is unblocked & will receive a FALSE return value. The transaction count field will have the amount of frames which were transferred successfully before the timeout. In blocking mode, transfers cannot be performed in software or hardware ISR context.

In callback mode, a SPI transaction functions asynchronously, which means that it does not block code execution. After a SPI transaction has been completed, the SPI driver calls a user-provided hook function. Callback mode is supported in the execution context of tasks and hardware interrupt routines.

2、比特率是指每秒传送的比特数。比特率越高,每秒传送数据就越多。需要双方都速率一致

user6359397:

回复 Kevin Qiu1:

我看到官方的例程代码中没有单独控制片选引脚的代码,因为我的SPI从机设备只有一个,我需要额外配置IO口来控制片选引脚吗?还是说例程中的函数已经包含了控制片选引脚了

user6359397:

回复 Viki Shi:

我看到官方的例程代码中没有单独控制片选引脚的代码,因为我的SPI从机设备只有一个,我需要额外配置IO口来控制片选引脚吗?还是说例程中的函数已经包含了控制片选引脚了

Viki Shi:

回复 user6359397:

片选分为硬件片选和软件片选,硬件片选时应用程序不用对此进行任何操作,自动完成片选;软件片选需要应用程序去配置片选信号。CC2640R2F默认硬件片选

user6359397:

回复 Viki Shi:

硬件片选是将我们的设备OLED连接到开发版上固定的 ***?然后我只需要按照例程直接发送据接受数据即可,不需要对片选引脚进行操作。软件片选是自己自定义CS引脚,需要自己使能IO口来控制数据收发,可以这样理解吗?

user6359397:

回复 Viki Shi:

硬件片选是将我们的设备OLED连接到开发版上设定的片选引脚?然后我只需要按照例程直接发送据接受数据即可,不需要对片选引脚进行操作。软件片选是自己自定义CS引脚,需要自己使能IO口来控制数据收发,可以这样理解吗?

user6359397:

回复 Viki Shi:

十分感谢你

user6359397:

回复 Viki Shi:

我发现了硬件片选的片选引脚数据自动拉高似乎阻止了我的数据返回,我如何改为软件片选呢?

赞(0)
未经允许不得转载:TI中文支持网 » CC2640R2F SPI传输模式
分享到: 更多 (0)