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