update AT91SAM9260 i2c driver

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2160 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
luohui2320@gmail.com 2012-06-13 17:00:09 +00:00
parent 85169d7fe8
commit ecc03bab6a
2 changed files with 6 additions and 19 deletions

View File

@ -18,6 +18,7 @@
/*@{*/ /*@{*/
#include <rtthread.h> #include <rtthread.h>
#include <rtdevice.h>
#ifdef RT_USING_DFS #ifdef RT_USING_DFS
/* dfs init */ /* dfs init */
@ -57,14 +58,6 @@
#include <dfs_romfs.h> #include <dfs_romfs.h>
#endif #endif
#ifdef RT_USING_I2C
#include <i2c.h>
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) void rt_init_thread_entry(void* parameter)
{ {
/* Filesystem Initialization */ /* Filesystem Initialization */
@ -145,7 +138,6 @@ void rt_init_thread_entry(void* parameter)
#ifdef RT_USING_I2C #ifdef RT_USING_I2C
{ {
rt_i2c_core_init(); rt_i2c_core_init();
rt_i2c_hw_info_register(hw_info, 1);
at91_i2c_init(); at91_i2c_init();
} }
#endif #endif

View File

@ -12,10 +12,8 @@
* 2012-04-25 weety first version * 2012-04-25 weety first version
*/ */
#include <rtthread.h> #include <rtdevice.h>
#include <rthw.h> #include <rthw.h>
#include <i2c.h>
#include <i2c-bit-ops.h>
#include <at91sam926x.h> #include <at91sam926x.h>
@ -98,25 +96,22 @@ static const struct rt_i2c_bit_ops bit_ops = {
rt_err_t at91_i2c_init(void) 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) if (bus == RT_NULL)
{ {
rt_kprintf("rt_malloc failed\n"); rt_kprintf("rt_malloc failed\n");
return -RT_ENOMEM; return -RT_ENOMEM;
} }
rt_memset((void *)bus, 0, sizeof(struct rt_i2c_bus)); rt_memset((void *)bus, 0, sizeof(struct rt_i2c_bus_device));
bus->id = 0;
rt_snprintf(bus->name, sizeof(bus->name), "i2c-gpio%d", bus->id);
bus->priv = (void *)&bit_ops; bus->priv = (void *)&bit_ops;
at91_i2c_gpio_init(); at91_i2c_gpio_init();
rt_i2c_bit_add_bus(bus); rt_i2c_bit_add_bus(bus, "i2c0");
return RT_EOK; return RT_EOK;
} }