设为首页收藏本站

米尔科技论坛

 找回密码
 注册账号

QQ登录

只需一步,快速开始

查看: 4997|回复: 0

[SAM9G45] MYS-SAM9G45配置SPI1

[复制链接]

25

主题

34

帖子

280

积分

中级会员

Rank: 3Rank: 3

积分
280
Willian.Mo 发表于 2015-8-18 16:26:46 | 显示全部楼层 |阅读模式
介绍:
        MYS-SAM9G45开发板SPI1管脚为PB14(SPI1_MISO),PB15(SPI1_MOSI),PB16(SPI1_SPCK),PB17(SPI1_NPCS0)引出到J4扩展板上。内核没有对SPI1进行配置,所以需要对内核做一些改动。下面介绍配置SPI1步骤:

步骤:

1.内核配置push buttons时占用了SPI1管脚,首先应先去掉这部分配置。修改arch/arm/mach-at91/board-sam9m10g45ek.c文件,找到ek_buttons相关代码,修改后如下:
#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
static struct gpio_keys_button ek_buttons[] = {
        {        /* BP1, "leftclic" */
                .code                = BTN_LEFT,
                .gpio                = AT91_PIN_PB6,
                .active_low        = 1,
                .desc                = "left_click",
                .wakeup                = 1,
        },
        {        /* BP2, "rightclic" */
                .code                = BTN_RIGHT,
                .gpio                = AT91_PIN_PB7,
                .active_low        = 1,
                .desc                = "right_click",
                .wakeup                = 1,
        },
                /* BP3, "joystick" */
        /*{
                .code                = KEY_LEFT,
                .gpio                = AT91_PIN_PB14,
                .active_low        = 1,
                .desc                = "Joystick Left",
        },
        {
                .code                = KEY_RIGHT,
                .gpio                = AT91_PIN_PB15,
                .active_low        = 1,
                .desc                = "Joystick Right",
        },
        {
                .code                = KEY_UP,
                .gpio                = AT91_PIN_PB16,
                .active_low        = 1,
                .desc                = "Joystick Up",
        },
        {
                .code                = KEY_DOWN,
                .gpio                = AT91_PIN_PB17,
                .active_low        = 1,
                .desc                = "Joystick Down",
        },
        {
                .code                = KEY_ENTER,
                .gpio                = AT91_PIN_PB18,
                .active_low        = 1,
                .desc                = "Joystick Press",
        },*/
};

2.在arch/arm/mach-at91/board-sam9m10g45ek.c中找到结构体数组ek_spi_devices[],在数组中添加SPI1配置如下:
/*
 * SPI devices.
 */
static struct spi_board_info ek_spi_devices[] = {
        {        /* DataFlash chip */
                .modalias        = "mtd_dataflash",
                .chip_select        = 0,
                .max_speed_hz        = 15 * 1000 * 1000,
                .bus_num        = 0,
        },
        
        {        /* spidev1.0*/
                        .modalias        = "spidev",
                        .chip_select        = 0,
                        .max_speed_hz        = 15 * 1000 * 1000,
                        .bus_num        = 1,
        },
};

3.配置内核,导出spidev节点:
进入mys-sam9g45-linux-2.6.30目录,依次执行如下命令:
(1)配置.config
$ make ARCH=arm MYS-SAM9G45_4.3lcd_defconfig
(2)添加spidev设备支持,选上User mode SPI device driver support 
$ make ARCH=arm menuconfig
Device Drivers  ---> 
         SPI support  ---> 
                <*>   User mode SPI device driver support 
(3)编译内核
$ make ARCH=arm uImage CROSS_COMPILE=/usr/local/arm-2007q1/bin/arm-none-linux-gnueabi-

4.重新烧写系统就可以在/dev下看到SPI1的设备节点。






回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号

本版积分规则

Archiver|手机版|小黑屋|米尔科技论坛   

GMT+8, 2019-10-21 14:16 , Processed in 0.387275 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表