资源简介
此代码是STM32F2 系类为MCU.里面包含MCP2515 CAN通信 收发程序,同时包含是SPI 初始化程序源码,这个程序源码可以直接移植使用.
代码片段和文件信息
#include “can_mcp2515.h“
#include “delay.h“
/* CAN 波特率选择 */
static u16 s_Baud = 125;
// static u16 s_Baud = 250;
/* static u16 s_Baud = 500; */
/* MCP2515 外部晶振为 8M */
static u32 s_Osc = 8000;
/* mcp2515 控制指令 */
typedef enum
{
RESET_CMD = 0xc0
READ_CMD = 0x03
READ_RX_CMD = 0x90
WRITE_CMD = 0x02
LOAD_TX_CMD = 0x40
RTS_CMD = 0x80
RTS_BUFF0_CMD = 0x81
RTS_BUFF1_CMD = 0x82
RTS_BUFF2_CMD = 0x84
READ_STATUS_CMD = 0xA0
RX_STATUS_CMD = 0xB0
BIT_MODIFY_CMD = 0x05
}_Cmd;
/* mcp2515 寄存器地址 */
typedef enum
{
REG_RXF0SIDH = 0x00
REG_RXF0SIDL = 0x01
REG_RXF0EID8 = 0x02
REG_RXF0EID0 = 0x03
REG_RXF1SIDH = 0x04
REG_RXF1SIDL = 0x05
REG_RXF1EID8 = 0x06
REG_RXF1EID0 = 0x07
REG_RXF2SIDH = 0x08
REG_RXF2SIDL = 0x09
REG_RXF2EID8 = 0x0a
REG_RXF2EID0 = 0x0b
REG_BFPCTRL = 0x0c
REG_TXRTSCTRL = 0x0d
REG_CANSTAT = 0x0e
REG_CANCTRL = 0x0f
REG_RXF3SIDH = 0x10
REG_RXF3SIDL = 0x11
REG_RXF3EID8 = 0x12
REG_RXF3EID0 = 0x13
REG_RXF4SIDH = 0x14
REG_RXF4SIDL = 0x15
REG_RXF4EID8 = 0x16
REG_RXF4EID0 = 0x17
REG_RXF5SIDH = 0x18
REG_RXF5SIDL = 0x19
REG_RXF5EID8 = 0x1a
REG_RXF5EID0 = 0x1b
REG_TEC = 0x1c
REG_REC = 0x1d
REG_RXM0SIDH = 0x20
REG_RXM0SIDL = 0x21
REG_RXM0EID8 = 0x22
REG_RXM0EID0 = 0x23
REG_RXM1SIDH = 0x24
REG_RXM1SIDL = 0x25
REG_RXM1EID8 = 0x26
REG_RXM1EID0 = 0x27
REG_CNF3 = 0x28
REG_CNF2 = 0x29
REG_CNF1 = 0x2a
REG_CANINTE = 0x2b
REG_CANINTF = 0x2c
REG_EFLG = 0x2d
REG_TXB0CTRL = 0x30
REG_TXB0SIDH = 0x31
REG_TXB0SIDL = 0x32
REG_TXB0EID8 = 0x33
REG_TXB0EID0 = 0x34
REG_TXB0DLC = 0x35
REG_TXB0D0 = 0x36
REG_TXB0D1 = 0x37
REG_TXB0D2 = 0x38
REG_TXB0D3 = 0x39
REG_TXB0D4 = 0x3a
REG_TXB0D5 = 0x3b
REG_TXB0D6 = 0x3c
REG_TXB0D7 = 0x3d
REG_TXB1CTRL = 0x40
REG_TXB1SIDH = 0x41
REG_TXB1SIDL = 0x42
REG_TXB1EID8 = 0x43
REG_TXB1EID0 = 0x44
REG_TXB1DLC = 0x45
REG_TXB1D0 = 0x46
REG_TXB1D1 = 0x47
REG_TXB1D2 = 0x48
REG_TXB1D3 = 0x49
REG_TXB1D4 = 0x4a
REG_TXB1D5 = 0x4b
REG_TXB1D6 = 0x4c
REG_TXB1D7 = 0x4d
REG_TXB2CTRL = 0x50
REG_TXB2SIDH = 0x51
REG_TXB2SIDL = 0x52
REG_TXB2EID8 = 0x53
REG_TXB2EID0 = 0x54
REG_TXB2DLC = 0x55
REG_TXB2D0 = 0x56
REG_TXB2D1 = 0x57
REG_TXB2D2 = 0x58
REG_TXB2D3 = 0x59
REG_TXB2D4 = 0x5a
REG_TXB2D5 = 0x5b
REG_TXB2D6 = 0x5c
REG_TXB2D7 = 0x5d
REG_RXB0CTRL = 0x60
REG_RXB0SIDH = 0x61
REG_RXB0SIDL = 0x62
REG_RXB0EID8 = 0x63
REG_RXB0EID0 = 0x64
REG_RXB0DLC = 0x65
REG_RXB0D0 = 0x66
REG_RXB0D1 = 0x67
REG_RXB0D2 = 0x68
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 19339 2017-08-26 16:47 CAN_MCP2515.c
文件 666 2017-08-28 08:49 CAN_MCP2515.h
相关资源
- Spin-1目标的广义parton分布的多项式和
- 介子和S波氘核的四极矩以及对spin-1系
- 基于STM32F4x9的LCD显示
- 基于SPCE061A和PTR8000的模拟SPI总线通信
- VS1053B编解码器的VDR分布式声音采集卡
- stm32的DAC播放音乐文件
- 用8位spi实现16位spi
- linux SPI设备注册和驱动小结
- 用Verilog语言写的CPLD和MCU通讯的SPI接口
- STM32+TMC5160代码电路图.rar
- 基于STM32的深海钻机甲板控制系统
- stm32f103.SchDoc
- STM32F103 USART+DMA
- DMA+stm32 407.zip
- 4_USART串口通信(空闲中断+DMA.zip
- stm32f105-usart-DMA收发demo
- STM32F042F6P6 Uart12DMA;发送中断接收
- 基于STM32的嵌入式双目图像采集系统设
- 基于STM32F103C8单片机的晶联讯电子JL
- 基于STM32的温湿度检测系统实现
- stm32F4+w5300
- 14284969_《STM32单片机应用与全案例实践
-
ST-li
nk-V2的SWD仿真使用方法.docx - 安富莱STM32开发板资料
- Spirent iTest用户手册详细介绍iTest的各
- 精确结果为3d N $$ \\ mathcal {N} $$ = 2 S
- STM32F103实现OV7670摄像头显示
- STM32F207学习板例程
- 从Poincaré代数的闭合中得
- STM32F103VCT6TR - High-density performance lin
评论
共有 条评论