前段时间布置的任务是弄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