MCP251X can驱动移植

本篇记录移植spi 接口的 mcp2515 can 芯片驱动的过程,mcp2515 芯片通过spi接口连接NUC980 的spi1接口,中断引脚接PA0中断。 此驱动移植过程主要分为如下几步。

第一步: 配置 linux 内核支持mcp2515的驱动,配置内容:
can 功能配置

[*] Networking support  ---> 
	<*>   CAN bus subsystem support  --->
		<*>   Raw CAN Protocol (raw access with CAN-ID filtering)
		<*>   Broadcast Manager CAN Protocol (with content filtering)
		CAN Device Drivers  --->
			<*> Platform CAN drivers with Netlink support
			[*]   CAN bit-timing calculation
			CAN SPI interfaces  --->
				<*> Microchip MCP251x and MCP25625 SPI CAN controllers			

spi 接口配置

Device Drivers  --->
	[*] SPI support  --->
		<*>   Nuvoton NUC980 Series SPI Port 0
			SPI0 IO port selection (Port D)  --->
			SPI0 TX/RX by PDMA or not (Use PDMA)  --->			

spi1 的 portD 口、分别对于 PD8/SS0, PD9/MOSI, PD10/MISO,PD11/CLK,中断引脚接PA0 。

第二步: 此样例平台未采用设备树方式,所有在 linux/arch/arm/mach-nuc980/dev.c 文件中,添加 设备节点内容。

+ #include <linux/can/platform/mcp251x.h>

+ static struct mcp251x_platform_data mcp251x_info = {
+ 	.oscillator_frequency = 8000000,
+ };

#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_SPI_SPIDEV)
static struct spi_board_info nuc980_spi0_board_info[] __initdata = {

+	{
+		.modalias = "mcp2515",
+		.max_speed_hz = 2*1000*1000,		//  mcp2515 时钟 2MHz
+		.irq = IRQ_EXT0_A0,				//	中断编号 PA0 引脚
+		.bus_num = 1,					//  spi 1
+		.chip_select = 0,				//  use SS0
+		.mode = SPI_MODE_0,
+		.platform_data = &mcp251x_info,
+	},
};
#endif

第三步: 编译内核烧写至开发板中、确认配置can 网卡

系统引导过程中,mcp251x的过程
在这里插入图片描述
查看can网卡内容如下
在这里插入图片描述

下一篇博客会记录测试 can 通讯实验过程。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值