资源简介
stm32f407的CAN的通信功能的实现
代码片段和文件信息
/**
******************************************************************************
* @file can.c
* @brief This file provides code for the configuration
* of the CAN instances.
******************************************************************************
* @attention
*
* © Copyright (c) 2021 STMicroelectronics.
* All rights reserved.
*
* This software component is licensed by ST under BSD 3-Clause license
* the “License“; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include “can.h“
#include
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
CAN_HandleTypeDef hcan1;
CAN_HandleTypeDef hcan2;
CAN_TxHeaderTypeDef TxMessage; //发送缓冲区
CAN_RxHeaderTypeDef RxMessage; //接收缓冲区
HAL_StatusTypeDef HAL_Status;
uint8_t RxData[8];
uint8_t TxData[8]={0x010x020x030x040x050x060x070x08};
/* CAN1 init function */
void MX_CAN1_Init(void)
{
hcan1.Instance = CAN1;
hcan1.Init.Prescaler = 14;
hcan1.Init.Mode = CAN_MODE_NORMAL;
hcan1.Init.SyncJumpWidth = CAN_SJW_1TQ;
hcan1.Init.TimeSeg1 = CAN_BS1_4TQ;
hcan1.Init.TimeSeg2 = CAN_BS2_1TQ;
hcan1.Init.TimeTriggeredMode = DISABLE;
hcan1.Init.AutoBusOff = DISABLE;
hcan1.Init.AutoWakeUp = DISABLE;
hcan1.Init.AutoRetransmission = ENABLE;
hcan1.Init.ReceiveFifoLocked = DISABLE;
hcan1.Init.TransmitFifoPriority = DISABLE;
if (HAL_CAN_Init(&hcan1) != HAL_OK)
{
Error_Handler();
}
}
/* CAN2 init function */
void MX_CAN2_Init(void)
{
hcan2.Instance = CAN2;
hcan2.Init.Prescaler = 14;
hcan2.Init.Mode = CAN_MODE_NORMAL;
hcan2.Init.SyncJumpWidth = CAN_SJW_1TQ;
hcan2.Init.TimeSeg1 = CAN_BS1_4TQ;
hcan2.Init.TimeSeg2 = CAN_BS2_1TQ;
hcan2.Init.TimeTriggeredMode = DISABLE;
hcan2.Init.AutoBusOff = DISABLE;
hcan2.Init.AutoWakeUp = DISABLE;
hcan2.Init.AutoRetransmission = ENABLE;
hcan2.Init.ReceiveFifoLocked = DISABLE;
hcan2.Init.TransmitFifoPriority = DISABLE;
if (HAL_CAN_Init(&hcan2) != HAL_OK)
{
Error_Handler();
}
}
static uint32_t HAL_RCC_CAN1_CLK_ENABLED=0;
void HAL_CAN_MspInit(CAN_HandleTypeDef* canHandle)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(canHandle->Instance==CAN1)
{
/* USER CODE BEGIN CAN1_MspInit 0 */
/* USER CODE END CAN1_MspInit 0 */
/* CAN1 clock enable */
HAL_RCC_CAN1_CLK_ENABLED++;
if(HAL_RCC_CAN1_CLK_ENABLED==1){
__HAL_RCC_CAN1_CLK_ENABLE();
}
__HAL_RCC_GPIOA_CLK_ENABLE();
/**CAN1 GPIO Configuration
PA11 ------> CAN1_RX
PA12 ------> CAN1_TX
*/
GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12;
GPIO_InitSt
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 8023 2021-01-01 00:06 STM32F407_CubeMX_DEMO\.mxproject
文件 1607 2021-01-03 13:28 STM32F407_CubeMX_DEMO\Core\Inc\can.h
文件 1433 2021-01-01 00:06 STM32F407_CubeMX_DEMO\Core\Inc\gpio.h
文件 2181 2021-01-01 00:06 STM32F407_CubeMX_DEMO\Core\Inc\main.h
文件 20047 2021-01-01 00:06 STM32F407_CubeMX_DEMO\Core\Inc\stm32f4xx_hal_conf.h
文件 2232 2021-01-01 00:06 STM32F407_CubeMX_DEMO\Core\Inc\stm32f4xx_it.h
文件 1465 2021-01-01 00:06 STM32F407_CubeMX_DEMO\Core\Inc\tim.h
文件 1552 2021-01-03 15:29 STM32F407_CubeMX_DEMO\Core\Inc\usart.h
文件 9904 2021-01-10 11:22 STM32F407_CubeMX_DEMO\Core\Src\can.c
文件 2825 2021-01-01 00:06 STM32F407_CubeMX_DEMO\Core\Src\gpio.c
文件 5836 2021-01-03 16:47 STM32F407_CubeMX_DEMO\Core\Src\main.c
文件 2409 2021-01-01 00:06 STM32F407_CubeMX_DEMO\Core\Src\stm32f4xx_hal_msp.c
文件 6900 2021-01-01 00:06 STM32F407_CubeMX_DEMO\Core\Src\stm32f4xx_it.c
文件 26457 2020-12-14 17:06 STM32F407_CubeMX_DEMO\Core\Src\system_stm32f4xx.c
文件 2873 2021-01-01 00:06 STM32F407_CubeMX_DEMO\Core\Src\tim.c
文件 4991 2021-01-03 16:39 STM32F407_CubeMX_DEMO\Core\Src\usart.c
文件 1349439 2020-12-14 17:06 STM32F407_CubeMX_DEMO\Drivers\CMSIS\Device\ST\STM32F4xx\Include\stm32f407xx.h
文件 9485 2020-12-14 17:06 STM32F407_CubeMX_DEMO\Drivers\CMSIS\Device\ST\STM32F4xx\Include\stm32f4xx.h
文件 3796 2020-12-14 17:06 STM32F407_CubeMX_DEMO\Drivers\CMSIS\Device\ST\STM32F4xx\Include\system_stm32f4xx.h
文件 28208 2020-12-14 17:06 STM32F407_CubeMX_DEMO\Drivers\CMSIS\Include\cmsis_armcc.h
文件 56497 2020-12-14 17:06 STM32F407_CubeMX_DEMO\Drivers\CMSIS\Include\cmsis_armclang.h
文件 9014 2020-12-14 17:06 STM32F407_CubeMX_DEMO\Drivers\CMSIS\Include\cmsis_compiler.h
文件 62344 2020-12-14 17:06 STM32F407_CubeMX_DEMO\Drivers\CMSIS\Include\cmsis_gcc.h
文件 28414 2020-12-14 17:06 STM32F407_CubeMX_DEMO\Drivers\CMSIS\Include\cmsis_iccarm.h
文件 1716 2020-12-14 17:06 STM32F407_CubeMX_DEMO\Drivers\CMSIS\Include\cmsis_version.h
文件 97995 2020-12-14 17:06 STM32F407_CubeMX_DEMO\Drivers\CMSIS\Include\core_armv8mbl.h
文件 168914 2020-12-14 17:06 STM32F407_CubeMX_DEMO\Drivers\CMSIS\Include\core_armv8mml.h
文件 42208 2020-12-14 17:06 STM32F407_CubeMX_DEMO\Drivers\CMSIS\Include\core_cm0.h
文件 50464 2020-12-14 17:06 STM32F407_CubeMX_DEMO\Drivers\CMSIS\Include\core_cm0plus.h
文件 43456 2020-12-14 17:06 STM32F407_CubeMX_DEMO\Drivers\CMSIS\Include\core_cm1.h
............此处省略188个文件信息
相关资源
- 基于STM32F103C8T6主控板使用BH1750检测光
- stm32 BootLoader程序(main.c)
- STM32修炼的最好书
- STM32 BLDC 无刷电机
- stm32 实现Fatfs对U盘文件操作(main.c)
- stm32f103 USB键盘
- OBD_CAN读取代码(stm32f103)
-
STM32-ba
se64加密源代码 - stm32 MQTT
- stm32f103 can驱动
- STM32三菱PLC源码原理图
- 基于STM32智能家居的无线网关设计与实
- 基于stm32的交通信号灯代码
- DHT11驱动程序基于STM32
- 基于STEM32的倒车记录仪智能报警系统
- STM32_GY25Z计步器
- C语言实现的红外发送STM32F10x单片机应
- stm32L系列F系列 加密库Cryptographic lib
- 心率传感器算法-stm32-实测可用
- 工程使用的STM32版FX2N源码和原理图
- 基于stm32f1的频率计
- stm32F103zet6开串口通信2 C语言
- ADC电压采集程序
- STM32 电子密码锁设计,LCD12864显示C语
- 利用OV7725照相机与STM32F1识别车牌
- 基于STM32的小车红外黑线寻迹代码
- stm32图像采集+QT上位机源码
- STM32,5110液晶显示声纳探鱼器200KHz,
- stm32iap+bootloader+app+mfc上位机
- BMP180气压计STM32例程+51例程+数据手册
评论
共有 条评论