OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 2778|回复: 1

在库函数中can.c程序中是如何将结构体与寄存器联系在一起的??

[复制链接]

2

主题

2

帖子

0

精华

新手入门

积分
19
金钱
19
注册时间
2018-5-4
在线时间
2 小时
发表于 2018-5-18 21:24:37 | 显示全部楼层 |阅读模式
1金钱
stm32f10x_can.c里面定义了一个结构体  
typedef struct
{
  uint32_t StdId;  /*!< Specifies the standard identifier.
                        This parameter can be a value between 0 to 0x7FF. */

  uint32_t ExtId;  /*!< Specifies the extended identifier.
                        This parameter can be a value between 0 to 0x1FFFFFFF. */

  uint8_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 */

  uint8_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 */

  uint8_t DLC;     /*!< Specifies the length of the frame that will be
                        transmitted. This parameter can be a value between
                        0 to 8 */

  uint8_t Data[8]; /*!< Contains the data to be transmitted. It ranges from 0
                        to 0xFF. */
} CanTxMsg;



然后调用这个结构体的成员变量进行赋值

        TxMessage.StdId=0x12;  
        TxMessage.ExtId=0x12;
        TxMessage.IDE=CAN_Id_Standard;
        TxMessage.RTR=CAN_RTR_Data;  
        TxMessage.DLC=len;   



这里面好像没有设置寄存器内容吧   
所以他们是如何将寄存器和结构体联系在一起的呢??

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

31

主题

1955

帖子

3

精华

论坛元老

Rank: 8Rank: 8

积分
4524
金钱
4524
注册时间
2018-5-11
在线时间
947 小时
发表于 2018-5-18 21:30:28 | 显示全部楼层
本帖最后由 warship 于 2018-5-18 23:28 编辑

你看到的这个结构只是报文的帧格式,
这里确实没有涉及到寄存器.寄存器在另外的地方,
一般在初始化的时候,
在CAN_InitStructure结构体中实现对相关寄存器的操作.

我的开源链接 https://github.com/ShuifaHe/STM32.git  请关注,点赞支持哦。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-7-17 08:53

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表