diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2011-05-19 12:30:00 +0000 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2011-05-19 12:30:00 +0000 |
commit | d74ed4ad4bde98dda6b685515b2523539e04ea1f (patch) | |
tree | 263bf95d00057efd30a7e0eec10f6125d74c2c63 /c/src/lib/libbsp/arm/lpc24xx/i2c | |
parent | 2011-05-19 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff) | |
download | rtems-d74ed4ad4bde98dda6b685515b2523539e04ea1f.tar.bz2 |
2011-05-19 Sebastian Huber <sebastian.huber@embedded-brains.de>
* i2c/i2c-config.c: New file.
* include/lcd.h: Removed EMC definitions.
* misc/dma.c: Fixed initialization.
* include/i2c.h, include/io.h, include/lpc-ethernet-config.h,
include/lpc24xx.h, console/console-config.c, i2c/i2c.c, misc/io.c,
misc/lcd.c, startup/bspstart.c, startup/bspstarthooks.c: New pin
configuration API.
* Makefile.am, preinstall.am: Update.
Diffstat (limited to 'c/src/lib/libbsp/arm/lpc24xx/i2c')
-rw-r--r-- | c/src/lib/libbsp/arm/lpc24xx/i2c/i2c-config.c | 91 | ||||
-rw-r--r-- | c/src/lib/libbsp/arm/lpc24xx/i2c/i2c.c | 84 |
2 files changed, 102 insertions, 73 deletions
diff --git a/c/src/lib/libbsp/arm/lpc24xx/i2c/i2c-config.c b/c/src/lib/libbsp/arm/lpc24xx/i2c/i2c-config.c new file mode 100644 index 0000000000..22b3f79be0 --- /dev/null +++ b/c/src/lib/libbsp/arm/lpc24xx/i2c/i2c-config.c @@ -0,0 +1,91 @@ +/** + * @file + * + * @ingroup lpc24xx_libi2c + * + * @brief LibI2C bus driver for the I2C modules. + */ + +/* + * Copyright (c) 2009-2011 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#include <bspopts.h> +#include <bsp/i2c.h> +#include <bsp/irq.h> + +#ifdef LPC24XX_CONFIG_I2C_0 + static const lpc24xx_pin_range lpc24xx_i2c_pins_0 [] = { + LPC24XX_PIN_I2C_0_SDA, + LPC24XX_PIN_I2C_0_SCL, + LPC24XX_PIN_TERMINAL + }; + + static lpc24xx_i2c_bus_entry lpc24xx_i2c_entry_0 = { + .bus = { + .ops = &lpc24xx_i2c_ops, + .size = sizeof(lpc24xx_i2c_bus_entry) + }, + .regs = (volatile lpc24xx_i2c *) I2C0_BASE_ADDR, + .index = 0, + .pins = &lpc24xx_i2c_pins_0 [0], + .vector = LPC24XX_IRQ_I2C_0 + }; + + rtems_libi2c_bus_t * const lpc24xx_i2c_0 = + &lpc24xx_i2c_entry_0.bus; +#endif + +#ifdef LPC24XX_CONFIG_I2C_1 + static const lpc24xx_pin_range lpc24xx_i2c_pins_1 [] = { + LPC24XX_PIN_I2C_1_SDA_P0_19, + LPC24XX_PIN_I2C_1_SCL_P0_20, + LPC24XX_PIN_TERMINAL + }; + + static lpc24xx_i2c_bus_entry lpc24xx_i2c_entry_1 = { + .bus = { + .ops = &lpc24xx_i2c_ops, + .size = sizeof(lpc24xx_i2c_bus_entry) + }, + .regs = (volatile lpc24xx_i2c *) I2C1_BASE_ADDR, + .index = 1, + .pins = &lpc24xx_i2c_pins_1 [0], + .vector = LPC24XX_IRQ_I2C_1 + }; + + rtems_libi2c_bus_t * const lpc24xx_i2c_1 = + &lpc24xx_i2c_entry_1.bus; +#endif + +#ifdef LPC24XX_CONFIG_I2C_2 + static const lpc24xx_pin_range lpc24xx_i2c_pins_2 [] = { + LPC24XX_PIN_I2C_2_SDA_P0_10, + LPC24XX_PIN_I2C_2_SCL_P0_11, + LPC24XX_PIN_TERMINAL + }; + + static lpc24xx_i2c_bus_entry lpc24xx_i2c_entry_2 = { + .bus = { + .ops = &lpc24xx_i2c_ops, + .size = sizeof(lpc24xx_i2c_bus_entry) + }, + .regs = (volatile lpc24xx_i2c *) I2C2_BASE_ADDR, + .index = 2, + .pins = &lpc24xx_i2c_pins_2 [0], + .vector = LPC24XX_IRQ_I2C_2 + }; + + rtems_libi2c_bus_t * const lpc24xx_i2c_2 = + &lpc24xx_i2c_entry_2.bus; +#endif diff --git a/c/src/lib/libbsp/arm/lpc24xx/i2c/i2c.c b/c/src/lib/libbsp/arm/lpc24xx/i2c/i2c.c index dc4ba13c1d..862c8ab475 100644 --- a/c/src/lib/libbsp/arm/lpc24xx/i2c/i2c.c +++ b/c/src/lib/libbsp/arm/lpc24xx/i2c/i2c.c @@ -7,43 +7,29 @@ */ /* - * Copyright (c) 2009 - * embedded brains GmbH - * Obere Lagerstr. 30 - * D-82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * Copyright (c) 2009-2011 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://www.rtems.com/license/LICENSE. */ -#include <rtems.h> - #include <bsp.h> #include <bsp/i2c.h> -#include <bsp/io.h> #include <bsp/irq.h> #include <bsp/irq-generic.h> -#include <bsp/lpc24xx.h> #include <bsp/system-clocks.h> #define RTEMS_STATUS_CHECKS_USE_PRINTK #include <rtems/status-checks.h> -typedef struct { - rtems_libi2c_bus_t bus; - volatile lpc24xx_i2c *regs; - unsigned index; - unsigned config; - rtems_vector_number vector; - rtems_id state_update; - uint8_t * volatile data; - uint8_t * volatile end; -} lpc24xx_i2c_bus_entry; - static void lpc24xx_i2c_handler(void *arg) { lpc24xx_i2c_bus_entry *e = arg; @@ -131,9 +117,9 @@ static rtems_status_code lpc24xx_i2c_init(rtems_libi2c_bus_t *bus) sc = lpc24xx_module_enable(LPC24XX_MODULE_I2C_0 + e->index, LPC24XX_MODULE_CCLK_8); RTEMS_CHECK_SC(sc, "enable module"); - /* IO configuration */ - sc = lpc24xx_io_config(LPC24XX_MODULE_I2C_0 + e->index, e->config); - RTEMS_CHECK_SC(sc, "IO configuration"); + /* Pin configuration */ + sc = lpc24xx_pin_config(e->pins, LPC24XX_PIN_SET_FUNCTION); + RTEMS_CHECK_SC(sc, "pin configuration"); /* Clock high and low duty cycles */ regs->sclh = cycles; @@ -327,7 +313,7 @@ static int lpc24xx_i2c_ioctl(rtems_libi2c_bus_t *bus, int cmd, void *arg) return rv; } -static const rtems_libi2c_bus_ops_t lpc24xx_i2c_ops = { +const rtems_libi2c_bus_ops_t lpc24xx_i2c_ops = { .init = lpc24xx_i2c_init, .send_start = lpc24xx_i2c_send_start, .send_stop = lpc24xx_i2c_send_stop, @@ -336,51 +322,3 @@ static const rtems_libi2c_bus_ops_t lpc24xx_i2c_ops = { .write_bytes = lpc24xx_i2c_write, .ioctl = lpc24xx_i2c_ioctl }; - -#ifdef LPC24XX_CONFIG_I2C_0 - static lpc24xx_i2c_bus_entry lpc24xx_i2c_entry_0 = { - .bus = { - .ops = &lpc24xx_i2c_ops, - .size = sizeof(lpc24xx_i2c_bus_entry) - }, - .regs = (volatile lpc24xx_i2c *) I2C0_BASE_ADDR, - .index = 0, - .config = LPC24XX_CONFIG_I2C_0, - .vector = LPC24XX_IRQ_I2C_0 - }; - - rtems_libi2c_bus_t * const lpc24xx_i2c_0 = - (rtems_libi2c_bus_t *) &lpc24xx_i2c_entry_0; -#endif - -#ifdef LPC24XX_CONFIG_I2C_1 - static lpc24xx_i2c_bus_entry lpc24xx_i2c_entry_1 = { - .bus = { - .ops = &lpc24xx_i2c_ops, - .size = sizeof(lpc24xx_i2c_bus_entry) - }, - .regs = (volatile lpc24xx_i2c *) I2C1_BASE_ADDR, - .index = 1, - .config = LPC24XX_CONFIG_I2C_1, - .vector = LPC24XX_IRQ_I2C_1 - }; - - rtems_libi2c_bus_t * const lpc24xx_i2c_1 = - (rtems_libi2c_bus_t *) &lpc24xx_i2c_entry_1; -#endif - -#ifdef LPC24XX_CONFIG_I2C_2 - static lpc24xx_i2c_bus_entry lpc24xx_i2c_entry_2 = { - .bus = { - .ops = &lpc24xx_i2c_ops, - .size = sizeof(lpc24xx_i2c_bus_entry) - }, - .regs = (volatile lpc24xx_i2c *) I2C2_BASE_ADDR, - .index = 2, - .config = LPC24XX_CONFIG_I2C_2, - .vector = LPC24XX_IRQ_I2C_2 - }; - - rtems_libi2c_bus_t * const lpc24xx_i2c_2 = - (rtems_libi2c_bus_t *) &lpc24xx_i2c_entry_2; -#endif |