source: rtems/c/src/lib/libbsp/arm/atsam/i2c/atsam_i2c_init.c @ 0c1413c

5
Last change on this file since 0c1413c was 0c1413c, checked in by Alexander Krutwig <alexander.krutwig@…>, on 06/14/16 at 15:10:05

bsp/atsam: Add I2C driver

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[0c1413c]1/*
2 * Copyright (c) 2016 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <info@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#include <bsp/atsam-i2c.h>
16#include <bsp/i2c.h>
17
18/** TWI0 data pin */
19#define PIN_TWI_TWD0 {PIO_PA3A_TWD0, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
20/** TWI0 clock pin */
21#define PIN_TWI_TWCK0 {PIO_PA4A_TWCK0, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
22
23/** TWI1 data pin */
24#define PIN_TWI_TWD1 {PIO_PB4A_TWD1, PIOB, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT}
25/** TWI1 clock pin */
26#define PIN_TWI_TWCK1 {PIO_PB5A_TWCK1, PIOB, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT}
27
28/** TWI2 data pin */
29#define PIN_TWI_TWD2 {PIO_PD27C_TWD2, PIOD, ID_PIOD, PIO_PERIPH_C, PIO_DEFAULT}
30/** TWI2 clock pin */
31#define PIN_TWI_TWCK2 {PIO_PD28C_TWCK2, PIOD, ID_PIOD, PIO_PERIPH_C, PIO_DEFAULT}
32
33int atsam_register_i2c_0(void)
34{
35        static const Pin pins[] = {PIN_TWI_TWD0, PIN_TWI_TWCK0};
36
37        return i2c_bus_register_atsam(
38            ATSAM_I2C_0_BUS_PATH,
39            TWIHS0,
40            ID_TWIHS0,
41            pins);
42}
43
44int atsam_register_i2c_1(void)
45{
46        static const Pin pins[] = {PIN_TWI_TWD1, PIN_TWI_TWCK1};
47
48        return i2c_bus_register_atsam(
49            ATSAM_I2C_1_BUS_PATH,
50            TWIHS1,
51            ID_TWIHS1,
52            pins);
53}
54
55int atsam_register_i2c_2(void)
56{
57        static const Pin pins[] = {PIN_TWI_TWD2, PIN_TWI_TWCK2};
58
59        return i2c_bus_register_atsam(
60            ATSAM_I2C_2_BUS_PATH,
61            TWIHS2,
62            ID_TWIHS2,
63            pins);
64}
Note: See TracBrowser for help on using the repository browser.