]>
Commit | Line | Data |
---|---|---|
327f7a02 WD |
1 | CONTENT: |
2 | ||
3 | i2c.h | |
4 | i2c1.c | |
5 | i2c2.s | |
6 | ||
7 | WHAT ARE THESE FILES: | |
8 | ||
9 | These files contain MPC8240 (Kahlua) I2C | |
10 | driver routines. The driver routines are not | |
11 | written for any specific operating system. | |
12 | They serves the purpose of code sample, and | |
13 | jump-start for using the MPC8240 I2C unit. | |
14 | ||
15 | For the reason of correctness of C language | |
16 | syntax, these files are compiled by Metaware | |
17 | C compiler and assembler. | |
18 | ||
19 | ENDIAN NOTATION: | |
20 | ||
21 | The algorithm is designed for big-endian mode, | |
22 | software is responsible for byte swapping. | |
23 | ||
24 | USAGE: | |
25 | ||
26 | 1. The host system that is running on MPC8240 | |
27 | shall link the files listed here. The memory | |
28 | location of driver routines shall take into | |
29 | account of that driver routines need to run | |
30 | in supervisor mode and they process I2C | |
31 | interrupt. | |
32 | ||
33 | 2. The host system is responsible for configuring | |
34 | the MPC8240 including Embedded Utilities Memory | |
35 | Block. All I2C driver functions require the | |
36 | content of Embedded Utilities Memory Block | |
37 | Base Address Register, EUMBBAR, as the first | |
38 | parameter. | |
39 | ||
40 | 3. Before I2C unit of MPC8240 can be used, | |
41 | initialize I2C unit by calling I2C_Init | |
42 | with the corresponding parameters. | |
43 | ||
44 | Note that the I2CFDR register shall be written | |
45 | once during the initialization. If it is written | |
46 | in the midst of transers, or after I2C STOPs or | |
47 | REPEAT STATRs, depending on the data written, | |
48 | a long reset time may be encountered. | |
49 | ||
50 | 4. After I2C unit has been successfully initialized, | |
51 | use the Application level API to send data or | |
52 | receive data upon the desired mode, Master or | |
53 | Slave. | |
54 | ||
55 | 5. If the host system is also using the EPIC unit | |
56 | on MPC8240, the system can register the | |
57 | I2C_ISR with the EPIC including other | |
58 | desired resources. | |
59 | ||
60 | If the host system does not using the EPIC unit | |
61 | on MPC8240, I2C_Timer_Event function can | |
62 | be called for each desired time interval. | |
63 | ||
64 | In both cases, the host system is free to provide | |
65 | its own timer event handler and interrupt service | |
66 | routine. | |
67 | ||
68 | 6. The I2C driver routines contains a set | |
69 | of utilities, Set and Get, for host system | |
70 | to query and modify the desired I2C registers. | |
71 | ||
72 | 7. It is the host system's responsibility of | |
73 | queueing the I2C I/O request. The host | |
74 | system shall check the I2C_ISR return code | |
75 | for I2C I/O status. If I2C_ISR returns | |
76 | I2CBUFFEMPTY or I2CBUFFFULL, it means | |
77 | I2C unit has completed a I/O request | |
78 | stated by the Application API. | |
79 | ||
80 | 8. If the host system has more than one master | |
81 | mode I2C unit I/O requests but doesn't want | |
82 | to be intervented by being addressed as slave, | |
83 | the host system can use the master mode | |
84 | Application API with stop_flag set to 0 in | |
85 | conjunction with is_cnt flag set to 1. | |
86 | The first API call sets both stop_flag and | |
87 | is_cnt to 0, indicating a START condition | |
88 | shall be generated but when the end of | |
89 | transaction is reached, do not generate a | |
90 | STOP condition. Once the host system is | |
91 | informed that the transaction has been | |
92 | completed, the next Application API call | |
93 | shall set is_cnt flag to 1, indicating a | |
94 | repeated START condition shall be generated. | |
95 | The last Application API call shall set | |
96 | stop_flag | |
97 | to 1. | |
98 | ||
99 | 9. The I2C_Timer_Event function containes | |
100 | a user defined function pointer. It | |
101 | serves the purpose of providing the | |
102 | host system a way to use its own event | |
103 | handler instead of the I2C_ISR provided | |
104 | here. |