source: rtems/c/src/lib/libbsp/powerpc/gen5200/i2c/mpc5200mbus.h @ d898f6e

Last change on this file since d898f6e was d898f6e, checked in by Sebastian Huber <sebastian.huber@…>, on Jan 19, 2018 at 2:28:33 PM

bsp/gen5200: Fix i2c.h and i2cdrv.h installation

Install these files only as <bsp/i2c.h> and <bsp/i2cdrv.h>.

Update #3254.

  • Property mode set to 100644
File size: 5.2 KB
Line 
1/*===============================================================*\
2| Project: RTEMS generic MPC5200 BSP                              |
3+-----------------------------------------------------------------+
4|                    Copyright (c) 2005                           |
5|                    Embedded Brains GmbH                         |
6|                    Obere Lagerstr. 30                           |
7|                    D-82178 Puchheim                             |
8|                    Germany                                      |
9|                    rtems@embedded-brains.de                     |
10+-----------------------------------------------------------------+
11| The license and distribution terms for this file may be         |
12| found in the file LICENSE in this distribution or at            |
13|                                                                 |
14| http://www.rtems.org/license/LICENSE.                           |
15|                                                                 |
16+-----------------------------------------------------------------+
17| MBUS module (I2C bus) definitions                               |
18+-----------------------------------------------------------------+
19| This file has been adapted from an existing source code file,   |
20| see the original file header below for reference                |
21\*===============================================================*/
22/*
23 * MCF5206e MBUS module (I2C bus) driver header file
24 *
25 * Copyright (C) 2000 OKTET Ltd., St.-Petersburg, Russia
26 * Author: Victor V. Vengerov <vvv@oktet.ru>
27 *
28 * The license and distribution terms for this file may be
29 * found in the file LICENSE in this distribution or at
30 *
31 * http://www.rtems.org/license/LICENSE.
32 */
33
34#ifndef __MPC5200BSP_MPC5200MBUS_H__
35#define __MPC5200BSP_MPC5200MBUS_H__
36
37#include <bsp/mpc5200.h>
38#include <bsp/i2c.h>
39
40
41/* States of I2C machine */
42typedef enum mpc5200mbus_i2c_state {
43    STATE_UNINITIALIZED,
44    STATE_IDLE,
45    STATE_ADDR_7,
46    STATE_ADDR_1_W,
47    STATE_ADDR_1_R,
48    STATE_SENDING,
49    STATE_RECEIVING
50} mpc5200mbus_i2c_state;
51
52typedef struct mpc5200_mbus {
53    enum mpc5200mbus_i2c_state state;/* State of I2C machine */
54    i2c_message           *msg;  /* Pointer to the first message in transfer */
55    int                    nmsg; /* Number of messages in transfer */
56    i2c_message           *cmsg; /* Current message */
57    int                    byte; /* Byte number in current message */
58    rtems_id               sema; /* MBUS semaphore */
59    i2c_transfer_done      done; /* Transfer done function */
60    void *         done_arg_ptr; /* Done function argument pointer */
61  int              bus_idx;  /* bus index: 0 or 1 */
62} mpc5200mbus;
63
64/* mpc5200mbus_initialize --
65 *     Initialize ColdFire MBUS I2C bus controller.
66 *
67 * PARAMETERS:
68 *     i2c_bus - pointer to the bus descriptor structure
69 *
70 * RETURNS:
71 *     RTEMS_SUCCESSFUL, or RTEMS error code when initialization failed.
72 */
73rtems_status_code
74mpc5200mbus_initialize(mpc5200mbus *i2c_bus);
75
76/* mpc5200mbus_select_clock_divider --
77 *     Select divider for system clock which is used for I2C bus clock
78 *     generation. Not each divider can be selected for I2C bus; this
79 *     function select nearest larger or equal divider, or maximum
80 *     possible divider, if passed value greater.
81 *
82 * PARAMETERS:
83 *     i2c_bus - pointer to the bus descriptor structure
84 *     divider - system frequency divider for I2C serial clock.
85 *
86 * RETURNS:
87 *     RTEMS_SUCCESSFUL, if operation performed successfully, or
88 *     RTEMS error code when failed.
89 */
90rtems_status_code
91mpc5200mbus_select_clock_divider(mpc5200mbus *i2c_bus, int divider);
92
93/* mpc5200mbus_i2c_transfer --
94 *     Initiate multiple-messages transfer over I2C bus via ColdFire MBUS
95 *     controller.
96 *
97 * PARAMETERS:
98 *     bus - pointer to MBUS controller descriptor
99 *     nmsg - number of messages
100 *     msg - pointer to messages array
101 *     done - function which is called when transfer is finished
102 *     done_arg_ptr - arbitrary argument ptr passed to done funciton
103 *
104 * RETURNS:
105 *     RTEMS_SUCCESSFUL if transfer initiated successfully, or error
106 *     code when failed.
107 */
108rtems_status_code
109mpc5200mbus_i2c_transfer(mpc5200mbus *bus, int nmsg, i2c_message *msg,
110                     i2c_transfer_done done, void * done_arg_ptr);
111
112/* mpc5200mbus_i2c_done --
113 *     Close ColdFire MBUS I2C bus controller and release all resources.
114 *
115 * PARAMETERS:
116 *     bus - pointer to MBUS controller descriptor
117 *
118 * RETURNS:
119 *     RTEMS_SUCCESSFUL, if transfer initiated successfully, or error
120 *     code when failed.
121 */
122rtems_status_code
123mpc5200mbus_i2c_done(mpc5200mbus *i2c_bus);
124
125/* mpc5200mbus_i2c_interrupt_handler --
126 *     ColdFire MBUS I2C bus controller interrupt handler. This function
127 *     called from real interrupt handler, and pointer to MBUS descriptor
128 *     structure passed to this function.
129 *
130 * PARAMETERS:
131 *     bus - pointert to the bus descriptor structure
132 *
133 * RETURNS:
134 *     none
135 */
136void mpc5200mbus_i2c_interrupt_handler(mpc5200mbus *bus);
137
138/* mpc5200mbus_poll --
139 *     MBUS module poll routine; used to poll events when I2C driver
140 *     operates in poll-driven mode.
141 *
142 * PARAMETERS:
143 *     none
144 *
145 * RETURNS:
146 *     none
147 */
148void mpc5200mbus_poll(mpc5200mbus *bus);
149
150#endif /* __MPC5200BSP_MPC5200MBUS_H__ */
Note: See TracBrowser for help on using the repository browser.