stm32 CAN总线例子

stm32 CAN总线例子


2024年4月12日发(作者:)

stm32 CAN总线例子

利用stm32实现了1个简单的CAN功能,使用了队列缓存

can.c 文件

#include "includes.h"

#define GPIO_CAN GPIOB

#define RCC_APB2Periph_GPIO_CAN RCC_APB2Periph_GPIOB

#define GPIO_Pin_RX GPIO_Pin_8

#define GPIO_Pin_TX GPIO_Pin_9

#define GPIO_Remap_CAN GPIO_Remap1_CAN1

#define MAX_MAIL_NUM 3

static u8 CAN_msg_num[MAX_MAIL_NUM]; // 发送邮箱标记

//

/**

* @brief Configures the CAN, transmit and receive by polling

* @param None

* @retval : PASSED if the reception is well done, FAILED in other case

*/

void CAN_config_init(void)

{

CAN_InitTypeDef CAN_InitStructure;

CAN_FilterInitTypeDef CAN_FilterInitStructure;

/* CAN register init */

CAN_DeInit(CAN1);

CAN_StructInit(&CAN_InitStructure);

/* CAN cell init */ // 36M 250k速率

CAN__TTCM=DISABLE;


发布者:admin,转转请注明出处:http://www.yc00.com/web/1712852505a2134747.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信