Rev 464 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 464 | Rev 470 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #ifndef __I2C0_H |
1 | #ifndef __I2C0_H |
2 | #define __I2C0_H |
2 | #define __I2C0_H |
Line 3... | Line 3... | ||
3 | 3 | ||
4 | #include "i2c.h" |
- | |
5 | extern volatile u32 I2C0_Timeout; |
- | |
Line -... | Line 4... | ||
- | 4 | #include "i2c1.h" |
|
6 | 5 | ||
7 | 6 | extern volatile u32 I2C0_Timeout; |
|
8 | // current I2C state |
7 | // current I2C state |
9 | extern volatile u8 I2C0_State; |
8 | extern volatile u8 I2C0_State; |
Line 10... | Line 9... | ||
10 | // the last I2C error |
9 | // the last I2C error |
Line 11... | Line 10... | ||
11 | extern volatile u8 I2C0_Error; |
10 | extern volatile u8 I2C0_Error; |
12 | 11 | ||
13 | #define I2C0_TIMEOUT 500 // 500 ms |
12 | #define I2C0_TIMEOUT 500 // 500 ms |
14 | 13 | ||
15 | // define the size of the rx/tx buffer |
14 | // define the size of the rx/tx buffer |
16 | #define I2C0_Buffer_LEN 100 |
15 | #define I2C0_BUFFER_LEN 100 |
Line 17... | Line 16... | ||
17 | // transfer buffer should be filled after a successful |
16 | // transfer buffer should be filled after a successful |
Line 18... | Line 17... | ||
18 | // I2C_LockBuffer(...) and before a start of transmission |
17 | // I2C_LockBuffer(...) and before a start of transmission |
Line 19... | Line -... | ||
19 | // initiated by I2C_Transmission(...). |
- | |
20 | extern volatile u8 I2C0_Buffer[]; |
- | |
21 | - | ||
22 | void I2C0_Init(void); |
18 | // initiated by I2C_Transmission(...). |
23 | 19 | extern volatile u8 I2C0_Buffer[]; |
|
24 | void I2C0_Deinit(void); |
20 | |
25 | 21 | void I2C0_Init(void); |
|
26 | // the pointer to the rxbuffer handler function |
22 | |
27 | // called by the IRQ routine after all bytes are recieved from slave |
23 | void I2C0_Deinit(void); |
28 | 24 | ||
29 | // Initiate i2c transmission |
25 | // Initiate i2c transmission |
30 | // A transmission sends first TxBytes from I2C_Buffer0 to slave |
26 | // A transmission sends first TxBytes from I2C0_Buffer to slave |
31 | // and then RxBytes are read from slave to I2C_Buffer0 |
27 | // and then RxBytes are read from slave to I2C0_Buffer |
32 | // replacing the byte that have been sent. |
28 | // replacing the byte that have been sent. |
33 | // Then the RxHandler function is called to handle the result. |
29 | // Then the RxHandler function is called to handle the result. |
34 | // This function returns imediatly after a start condition. |
30 | // This function returns imediatly after a start condition. |
35 | // returns 1 if a transmission has been started, otherwise 0 |
31 | // returns 1 if a transmission has been started, otherwise 0 |