1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,我正在使用HTS221湿度和温度传感器以及STM32F205。它们通过SPI总线连接,但我无法使STM32F205的SPI通信正常工作。任何人都可以推荐一些已知可以为这种设备组合工作的示例代码吗?
谢谢, 道格伯瑞尔 #hts221 以上来自于谷歌翻译 以下为原文 hi, I'm using the HTS221 humidity and temperature sensor along with the STM32F205. They are connected over the SPI bus but I am unable to get the STM32F205's SPI communications working correctly. Can anyone recommend some known to work sample code for this combination of devices? Thanks, Doug Burrell #hts221 |
|
相关推荐
1个回答
|
|
嗨,
遵循STM32L1xx系列的SPI层实现示例。 首先,您必须从ST网站下载HTS221驱动程序: https://my.st.com/content/my_st_com/en/products/embedded-software/mems-and-sensors-software/drivers-for-mems/stsw-mems035.html# 1.在HTS221_Driver.h中,您必须重新映射以下用于I2C的函数 #define HTS221_ReadReg(RegAddr,NumByteToRead,Data)HAL_ReadReg(HTS221_I2C_ADDRESS,RegAddr,NumByteToRead,Data) #define HTS221_WriteReg(RegAddr,NumByteToWrite,Data)HAL_WriteReg(HTS221_I2C_ADDRESS,RegAddr,NumByteToWrite,Data) 有以下几点 #define HTS221_ReadReg(RegAddr,NumByteToRead,Data)HAL_ReadReg_SPI(RegAddr,NumByteToRead,Data) #define HTS221_WriteReg(RegAddr,NumByteToWrite,Data)HAL_WriteReg_SPI(RegAddr,NumByteToWrite,Data) 2.用户必须正确地重新定义自己的HAL_ReadReg_SPI和HAL_WriteReg_SPI函数。 此实现链接到使用的硬件和使用的库。 附加了一个文件.txt,其中包含一个基于STM32L1xx_Spi标准库的SPI函数示例。 您必须获得此示例并将其调整为STM32F205库。 3.用户必须根据所使用的hw正确初始化GPIO->配置3线SPI串行数据输入/输出(SDI / SDO),CLK和CHIP选择 4.用户必须根据使用的hw正确初始化SPI接口 - >在.txt文件中,您可以找到一个示例:请参阅HAL_Init_SPI()函数 总结步骤如下: 1.初始化GPIO(基于hw) 2.初始化SPI(基于hw) 3.重新映射HTS221_Driver.h中的函数,包括文件自己的HAL_Implementation.h文件。 4.在OWN HAL_Implementation.c中,用户必须编写HAL_ReadReg_SPI和HAL_WriteReg_SPI的源代码(沿.txt文件中报告的示例行) 问候 安东内拉 以上来自于谷歌翻译 以下为原文 Hi, follows an SPI layer implementation example for STM32L1xx family. First of all you have to download the HTS221 drivers from ST website: https://my.st.com/content/my_st_com/en/products/embedded-software/mems-and-sensors-software/drivers-for-mems/stsw-mems035.html# 1. In HTS221_Driver.h you have to remap the following functions used for I2C #define HTS221_ReadReg(RegAddr, NumByteToRead, Data) HAL_ReadReg(HTS221_I2C_ADDRESS, RegAddr, NumByteToRead, Data) #define HTS221_WriteReg(RegAddr, NumByteToWrite, Data) HAL_WriteReg(HTS221_I2C_ADDRESS, RegAddr, NumByteToWrite, Data) With the following #define HTS221_ReadReg(RegAddr, NumByteToRead, Data) HAL_ReadReg_SPI (RegAddr, NumByteToRead, Data) #define HTS221_WriteReg(RegAddr, NumByteToWrite, Data) HAL_WriteReg_SPI( RegAddr, NumByteToWrite, Data) 2. The user must properly redefine the own HAL_ReadReg_SPI and HAL_WriteReg_SPI functions . This implementation is linked to the hardware used and to the library used. Attached a file .txt including an example for SPI functions based on STM32L1xx_Spi standard library. You have to get this example and adapt it for STM32F205 library. 3. The user must properly initialize GPIO according the hw used-> configure 3-wire SPI serial data input /output (SDI/SDO),CLK and CHIP Select 4. The user must properly initialize the SPI interface according the hw used -> In .txt file you can find an example: see HAL_Init_SPI() function Summarizing the steps are listed below: 1. Initialize GPIO (hw based) 2. Initialize SPI (hw based) 3. Remap functions in HTS221_Driver.h , including file own HAL_Implementation.h file. 4. In OWN HAL_Implementation.c ,the user must write the source code for HAL_ReadReg_SPI and HAL_WriteReg_SPI (Along the lines of the example reported in .txt file) Regards Antonella |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2725 浏览 1 评论
3237 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1807 浏览 1 评论
3646 浏览 6 评论
6034 浏览 21 评论
1337浏览 4评论
197浏览 3评论
对H747I-DISCO写程序时将CN2的st-link复用为usart1,再次烧录时无法检测到stlink怎么解决?
350浏览 2评论
STM32G474RE芯片只是串口发个数据就发烫严重是怎么回事?
442浏览 2评论
STM32处理增量式编码器Z信号如何判断中断是正转的还是反向转的?
273浏览 2评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 21:34 , Processed in 0.964047 second(s), Total 46, Slave 40 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号