From ecc03bab6ac470c91af02303f484fc1a07048d75 Mon Sep 17 00:00:00 2001 From: "luohui2320@gmail.com" Date: Wed, 13 Jun 2012 17:00:09 +0000 Subject: [PATCH] update AT91SAM9260 i2c driver git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2160 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- bsp/at91sam9260/application.c | 10 +--------- bsp/at91sam9260/at91_i2c_gpio.c | 15 +++++---------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/bsp/at91sam9260/application.c b/bsp/at91sam9260/application.c index 9edb781408..b440c16ac1 100755 --- a/bsp/at91sam9260/application.c +++ b/bsp/at91sam9260/application.c @@ -18,6 +18,7 @@ /*@{*/ #include +#include #ifdef RT_USING_DFS /* dfs init */ @@ -57,14 +58,6 @@ #include #endif -#ifdef RT_USING_I2C -#include - -static struct rt_i2c_hardware_info hw_info[] = { - { RT_I2C_HARDWARE_INFO("pcf8563", 0, 0xA2 >> 1, 0), }, -}; -#endif - void rt_init_thread_entry(void* parameter) { /* Filesystem Initialization */ @@ -145,7 +138,6 @@ void rt_init_thread_entry(void* parameter) #ifdef RT_USING_I2C { rt_i2c_core_init(); - rt_i2c_hw_info_register(hw_info, 1); at91_i2c_init(); } #endif diff --git a/bsp/at91sam9260/at91_i2c_gpio.c b/bsp/at91sam9260/at91_i2c_gpio.c index 2aebe1b839..bbee2033aa 100644 --- a/bsp/at91sam9260/at91_i2c_gpio.c +++ b/bsp/at91sam9260/at91_i2c_gpio.c @@ -12,10 +12,8 @@ * 2012-04-25 weety first version */ -#include +#include #include -#include -#include #include @@ -98,25 +96,22 @@ static const struct rt_i2c_bit_ops bit_ops = { rt_err_t at91_i2c_init(void) { - struct rt_i2c_bus *bus; + struct rt_i2c_bus_device *bus; - bus = rt_malloc(sizeof(struct rt_i2c_bus)); + bus = rt_malloc(sizeof(struct rt_i2c_bus_device)); if (bus == RT_NULL) { rt_kprintf("rt_malloc failed\n"); return -RT_ENOMEM; } - rt_memset((void *)bus, 0, sizeof(struct rt_i2c_bus)); - bus->id = 0; - - rt_snprintf(bus->name, sizeof(bus->name), "i2c-gpio%d", bus->id); + rt_memset((void *)bus, 0, sizeof(struct rt_i2c_bus_device)); bus->priv = (void *)&bit_ops; at91_i2c_gpio_init(); - rt_i2c_bit_add_bus(bus); + rt_i2c_bit_add_bus(bus, "i2c0"); return RT_EOK; }