泰凌微8258 SPI使用遇到的坑

本文介绍了在使用泰凌微8258 SPI时遇到的两个主要问题:1. 低功耗问题,解决方法是使用后务必反初始化并设置为输入悬空以减少漏电;2. SPI读取问题,由于多个SPI器件共用总线,需要控制CS引脚。原始SDK代码中存在数据丢失问题,通过增加是否为第一次读写的标志解决了该问题。
摘要由CSDN通过智能技术生成

1.低功耗问题
使用结束后,必须将spi反初始化,设置为输入悬空,不然会有大概500uA的漏电。
2.SPI读取的问题
在实际使用中,SPI总线可能不止挂载一个SPI器件,所以要控制不同的SPI的CS引脚,这就需要对SDK的源码进行修改,以下是SDK的源码;

/**
 * @brief      This function serves to read a bulk of data from the SPI slave
 *             device specified by the CS pin
 * @param[in]  Cmd - pointer to the command bytes needed written into the
 *             slave device first before the reading operation of actual data
 * @param[in]  CmdLen - length in byte of the command bytes
 * @param[out] Data - pointer to the buffer that will cache the reading out data
 * @param[in]  DataLen - length in byte of the data need to read
 * @param[in]  CSPin - the CS pin specifing the slave device
 * @return     none
 */
void spi_read(unsigned char *Cmd, int CmdLen, unsigned char *Data, int DataLen, GPIO_PinTypeDef CSPin)
{
    int i = 0;
    unsigned char te
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值