基于stm32f407下的W5500网卡驱动(上)

       前段时间布置的任务是弄w5500的驱动,w5500本身硬件就具有tcp/ip协议,这样就省去了再把tcp协议栈移植到Uclinux的麻烦,而且我的存储空间一直是不够用的,所以选择w5500作为一个网卡来使用是再合适不过。

       仔细看了一遍w5500的说明pdf,要使它能正常在Uclinux的环境下运行是要正确设置它的相关寄存器,而要设置它的寄存器,是要用spi接口与spi传输协议来设置,所以第一步的工作是要先添加Uclinux的spi驱动,庆幸的是spi驱动也已经由这个内核的开发小组所编写出来了,我们只要在内核设置里面勾选相关选项即可。

Device Drivers and enable SPI Support. Then from SPI Support enable STM32 SPI Controller and User mode spi device driver support


这里写图片描述

system Type->stm32 IO interfaces

>Enable STM32 spi1 port

<div>

这里写图片描述

       设置完成后,运行内核,出现如下图的提示,证明spidev驱动已经成功添加进内核了。


这里写图片描述

       在Documentation/spi/spidev_test.c中有spi驱动的测试代码如下:

/*
 * SPI testing utility (using spidev driver)
 *
 * Copyright (c) 2007  MontaVista Software, Inc.
 * Copyright (c) 2007  Anton Vorontsov <avorontsov@ru.mvista.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License.
 *
 * Cross-compile with cross-gcc -I/path/to/cross-kernel/include
 */

#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/types.h>
#include <linux/spi/spidev.h>

#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))

static void pabort(const 
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值