source: rtems/c/src/lib/libcpu/m68k/mcf5206/include/mcfmbus.h @ 57e9580f

4.104.114.84.95
Last change on this file since 57e9580f was 57e9580f, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 4, 2003 at 6:53:02 PM

2003-09-04 Joel Sherrill <joel@…>

  • clock/ckinit.c, console/mcfuart.c, include/mcf5206e.h, include/mcfmbus.h, include/mcfuart.h, mbus/mcfmbus.c, timer/timer.c, timer/timerisr.S: URL for license changed.
  • Property mode set to 100644
File size: 3.9 KB
Line 
1/* MCF5206e MBUS module (I2C bus) driver header file
2 *
3 * Copyright (C) 2000 OKTET Ltd., St.-Petersburg, Russia
4 * Author: Victor V. Vengerov <vvv@oktet.ru>
5 *
6 * The license and distribution terms for this file may be
7 * found in the file LICENSE in this distribution or at
8 *
9 * http://www.rtems.com/license/LICENSE.
10 *
11 * @(#) $Id$
12 */
13
14#ifndef __MCFBSP_MCFMBUS_H__
15#define __MCFBSP_MCFMBUS_H__
16
17#include "mcf5206e.h"
18#include "i2c.h"
19
20/* States of I2C machine */
21typedef enum mcfmbus_i2c_state {
22    STATE_IDLE,
23    STATE_ADDR_7,
24    STATE_ADDR_1_W,
25    STATE_ADDR_1_R,
26    STATE_SENDING,
27    STATE_RECEIVING
28} mcfmbus_i2c_state;
29
30typedef struct mcfmbus {
31    rtems_unsigned32       base; /* ColdFire internal peripherial base
32                                    address */
33    enum mcfmbus_i2c_state state;/* State of I2C machine */
34    i2c_message           *msg;  /* Pointer to the first message in transfer */
35    int                    nmsg; /* Number of messages in transfer */
36    i2c_message           *cmsg; /* Current message */
37    int                    byte; /* Byte number in current message */
38    rtems_isr_entry        oldisr; /* Old interrupt handler */
39    rtems_id               sema; /* MBUS semaphore */
40    i2c_transfer_done      done; /* Transfer done function */
41    rtems_unsigned32       done_arg; /* Done function argument */
42} mcfmbus;
43
44/* mcfmbus_initialize --
45 *     Initialize ColdFire MBUS I2C bus controller.
46 *
47 * PARAMETERS:
48 *     i2c_bus - pointer to the bus descriptor structure
49 *     base    - ColdFire internal peripherial base address
50 *
51 * RETURNS:
52 *     RTEMS_SUCCESSFUL, or RTEMS error code when initialization failed.
53 */
54rtems_status_code
55mcfmbus_initialize(mcfmbus *i2c_bus, rtems_unsigned32 base);
56
57/* mcfmbus_select_clock_divider --
58 *     Select divider for system clock which is used for I2C bus clock
59 *     generation. Not each divider can be selected for I2C bus; this
60 *     function select nearest larger or equal divider, or maximum
61 *     possible divider, if passed value greater.
62 *
63 * PARAMETERS:
64 *     i2c_bus - pointer to the bus descriptor structure
65 *     divider - system frequency divider for I2C serial clock.
66 *
67 * RETURNS:
68 *     RTEMS_SUCCESSFUL, if operation performed successfully, or
69 *     RTEMS error code when failed.
70 */
71rtems_status_code
72mcfmbus_select_clock_divider(mcfmbus *i2c_bus, int divider);
73
74/* mcfmbus_i2c_transfer --
75 *     Initiate multiple-messages transfer over I2C bus via ColdFire MBUS
76 *     controller.
77 *
78 * PARAMETERS:
79 *     bus - pointer to MBUS controller descriptor
80 *     nmsg - number of messages
81 *     msg - pointer to messages array
82 *     done - function which is called when transfer is finished
83 *     done_arg - arbitrary argument passed to done funciton
84 *
85 * RETURNS:
86 *     RTEMS_SUCCESSFUL if transfer initiated successfully, or error
87 *     code when failed.
88 */
89rtems_status_code
90mcfmbus_i2c_transfer(mcfmbus *bus, int nmsg, i2c_message *msg,
91                     i2c_transfer_done done, rtems_unsigned32 done_arg);
92
93/* mcfmbus_i2c_done --
94 *     Close ColdFire MBUS I2C bus controller and release all resources.
95 *
96 * PARAMETERS:
97 *     bus - pointer to MBUS controller descriptor
98 *
99 * RETURNS:
100 *     RTEMS_SUCCESSFUL, if transfer initiated successfully, or error
101 *     code when failed.
102 */
103rtems_status_code
104mcfmbus_i2c_done(mcfmbus *i2c_bus);
105
106/* mcfmbus_i2c_interrupt_handler --
107 *     ColdFire MBUS I2C bus controller interrupt handler. This function
108 *     called from real interrupt handler, and pointer to MBUS descriptor
109 *     structure passed to this function.
110 *
111 * PARAMETERS:
112 *     bus - pointert to the bus descriptor structure
113 *
114 * RETURNS:
115 *     none
116 */
117void mcfmbus_i2c_interrupt_handler(mcfmbus *bus);
118
119/* mcfmbus_poll --
120 *     MBUS module poll routine; used to poll events when I2C driver
121 *     operates in poll-driven mode.
122 *
123 * PARAMETERS:
124 *     none
125 *
126 * RETURNS:
127 *     none
128 */
129void mcfmbus_poll(mcfmbus *bus);
130
131#endif /* __MCFBSP_MCFMBUS_H__ */
Note: See TracBrowser for help on using the repository browser.