1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup lpc24xx_libi2c |
---|
5 | * |
---|
6 | * @brief LibI2C bus driver for the I2C modules. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (c) 2009-2011 embedded brains GmbH. All rights reserved. |
---|
11 | * |
---|
12 | * embedded brains GmbH |
---|
13 | * Obere Lagerstr. 30 |
---|
14 | * 82178 Puchheim |
---|
15 | * Germany |
---|
16 | * <rtems@embedded-brains.de> |
---|
17 | * |
---|
18 | * The license and distribution terms for this file may be |
---|
19 | * found in the file LICENSE in this distribution or at |
---|
20 | * http://www.rtems.com/license/LICENSE. |
---|
21 | */ |
---|
22 | |
---|
23 | #include <bspopts.h> |
---|
24 | #include <bsp/i2c.h> |
---|
25 | #include <bsp/irq.h> |
---|
26 | |
---|
27 | #ifdef LPC24XX_CONFIG_I2C_0 |
---|
28 | static const lpc24xx_pin_range lpc24xx_i2c_pins_0 [] = { |
---|
29 | LPC24XX_PIN_I2C_0_SDA, |
---|
30 | LPC24XX_PIN_I2C_0_SCL, |
---|
31 | LPC24XX_PIN_TERMINAL |
---|
32 | }; |
---|
33 | |
---|
34 | static lpc24xx_i2c_bus_entry lpc24xx_i2c_entry_0 = { |
---|
35 | .bus = { |
---|
36 | .ops = &lpc24xx_i2c_ops, |
---|
37 | .size = sizeof(lpc24xx_i2c_bus_entry) |
---|
38 | }, |
---|
39 | .regs = (volatile lpc24xx_i2c *) I2C0_BASE_ADDR, |
---|
40 | .index = 0, |
---|
41 | .pins = &lpc24xx_i2c_pins_0 [0], |
---|
42 | .vector = LPC24XX_IRQ_I2C_0 |
---|
43 | }; |
---|
44 | |
---|
45 | rtems_libi2c_bus_t * const lpc24xx_i2c_0 = |
---|
46 | &lpc24xx_i2c_entry_0.bus; |
---|
47 | #endif |
---|
48 | |
---|
49 | #ifdef LPC24XX_CONFIG_I2C_1 |
---|
50 | static const lpc24xx_pin_range lpc24xx_i2c_pins_1 [] = { |
---|
51 | LPC24XX_PIN_I2C_1_SDA_P0_19, |
---|
52 | LPC24XX_PIN_I2C_1_SCL_P0_20, |
---|
53 | LPC24XX_PIN_TERMINAL |
---|
54 | }; |
---|
55 | |
---|
56 | static lpc24xx_i2c_bus_entry lpc24xx_i2c_entry_1 = { |
---|
57 | .bus = { |
---|
58 | .ops = &lpc24xx_i2c_ops, |
---|
59 | .size = sizeof(lpc24xx_i2c_bus_entry) |
---|
60 | }, |
---|
61 | .regs = (volatile lpc24xx_i2c *) I2C1_BASE_ADDR, |
---|
62 | .index = 1, |
---|
63 | .pins = &lpc24xx_i2c_pins_1 [0], |
---|
64 | .vector = LPC24XX_IRQ_I2C_1 |
---|
65 | }; |
---|
66 | |
---|
67 | rtems_libi2c_bus_t * const lpc24xx_i2c_1 = |
---|
68 | &lpc24xx_i2c_entry_1.bus; |
---|
69 | #endif |
---|
70 | |
---|
71 | #ifdef LPC24XX_CONFIG_I2C_2 |
---|
72 | static const lpc24xx_pin_range lpc24xx_i2c_pins_2 [] = { |
---|
73 | LPC24XX_PIN_I2C_2_SDA_P0_10, |
---|
74 | LPC24XX_PIN_I2C_2_SCL_P0_11, |
---|
75 | LPC24XX_PIN_TERMINAL |
---|
76 | }; |
---|
77 | |
---|
78 | static lpc24xx_i2c_bus_entry lpc24xx_i2c_entry_2 = { |
---|
79 | .bus = { |
---|
80 | .ops = &lpc24xx_i2c_ops, |
---|
81 | .size = sizeof(lpc24xx_i2c_bus_entry) |
---|
82 | }, |
---|
83 | .regs = (volatile lpc24xx_i2c *) I2C2_BASE_ADDR, |
---|
84 | .index = 2, |
---|
85 | .pins = &lpc24xx_i2c_pins_2 [0], |
---|
86 | .vector = LPC24XX_IRQ_I2C_2 |
---|
87 | }; |
---|
88 | |
---|
89 | rtems_libi2c_bus_t * const lpc24xx_i2c_2 = |
---|
90 | &lpc24xx_i2c_entry_2.bus; |
---|
91 | #endif |
---|