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