zxc807492312
zxc807492312
This guy hasn't written anything yet

注册于 2 years ago

回答
0
文章
0
关注者
0

就是要再开一个线程专门用于rt_device_read,然后发送出去吗?

whj467467222 发表于 2019-3-14 16:24
这个应该是HAL库版本的问题,去年更新HAL更新一次,就是修改了CAN结构体


谢谢,应该是这个问题,我从别的地方找了F4的hal是可以用的

Summer_gift 发表于 2019-3-14 07:37
嗯嗯 正在加油开发


我看了一下git里的文件,这个驱动是不是只支持f1。不如里面的这个机构体的几种类型的名字,基本都是F1的叫法,F4里面不一样。(我也不确定是不是我这边文件的问题)
struct stm32_drv_can
{
CAN_HandleTypeDef CanHandle;
CAN_TxHeaderTypeDef TxMessage;
CAN_RxHeaderTypeDef RxMessage;
CAN_RxHeaderTypeDef Rx1Message;
CAN_FilterTypeDef FilterConfig;
};


比如CanTxMsgTypeDef这个定义
stm32f1xx_hal_can.h里面是这样的
typedef struct
{
uint32_t StdId; /*!< Specifies the standard identifier.
This parameter must be a number between Min_Data = 0 and Max_Data = 0x7FF */

uint32_t ExtId; /*!< Specifies the extended identifier.
This parameter must be a number between Min_Data = 0 and Max_Data = 0x1FFFFFFF */

uint32_t IDE; /*!< Specifies the type of identifier for the message that will be transmitted.
This parameter can be a value of @ref CAN_Identifier_Type */

uint32_t RTR; /*!< Specifies the type of frame for the message that will be transmitted.
This parameter can be a value of @ref CAN_remote_transmission_request */

uint32_t DLC; /*!< Specifies the length of the frame that will be transmitted.
This parameter must be a number between Min_Data = 0 and Max_Data = 8 */

uint8_t Data[8]; /*!< Contains the data to be transmitted.
This parameter must be a number between Min_Data = 0 and Max_Data = 0xFF */

}CanTxMsgTypeDef;


而f4下面类似的定义是这样的,名字不一样
typedef struct
{
uint32_t StdId; /*!< Specifies the standard identifier.
This parameter must be a number between Min_Data = 0 and Max_Data = 0x7FF. */

uint32_t ExtId; /*!< Specifies the extended identifier.
This parameter must be a number between Min_Data = 0 and Max_Data = 0x1FFFFFFF. */

uint32_t IDE; /*!< Specifies the type of identifier for the message that will be transmitted.
This parameter can be a value of @ref CAN_identifier_type */

uint32_t RTR; /*!< Specifies the type of frame for the message that will be transmitted.
This parameter can be a value of @ref CAN_remote_transmission_request */

uint32_t DLC; /*!< Specifies the length of the frame that will be transmitted.
This parameter must be a number between Min_Data = 0 and Max_Data = 8. */

FunctionalState TransmitGlobalTime; /*!< Specifies whether the timestamp counter value captured on start
of frame transmission, is sent in DATA6 and DATA7 replacing pData[6] and pData[7].
@note: Time Triggered Communication Mode must be enabled.
@note: DLC must be programmed as 8 bytes, in order these 2 bytes are sent.
This parameter can be set to ENABLE or DISABLE. */

} CAN_TxHeaderTypeDef;



这样导致编译时候有大量的报错

Summer_gift 发表于 2019-3-13 17:58
新的 BSP 框架已经有人提交 can 驱动了,正在 review,可能经过一些修改就可以用了。 ...


指日可待了吗?感谢开发者的努力,希望有详细例程。主要是之前几个的有点乱,加上水平有限,导致用不起来

请问你的问题解决了吗,我也是使用427,CAN还跑不起来,是否可以参考一下你的代码

yqiu 发表于 2018-12-14 17:30
建议使用 https://github.com/RT-Thread/rt-thread/tree/master/bsp/stm32 这个 BSP,后续所有 stm32 BSP ...


非常感谢,用这里面的模板配出来能用了。但奇怪的是在rtt里引脚排序有问题。直接pa1,2,3对应1,2,3。pb1,2,3对应16,17,18…按顺序排了

回到
顶部

发布
问题

投诉
建议