Rev 470 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
464 | ingob | 1 | #ifndef __I2C0_H |
2 | #define __I2C0_H |
||
3 | |||
470 | killagreg | 4 | #include "i2c1.h" |
5 | |||
464 | ingob | 6 | extern volatile u32 I2C0_Timeout; |
7 | // current I2C state |
||
8 | extern volatile u8 I2C0_State; |
||
9 | // the last I2C error |
||
10 | extern volatile u8 I2C0_Error; |
||
11 | |||
12 | #define I2C0_TIMEOUT 500 // 500 ms |
||
13 | |||
14 | // define the size of the rx/tx buffer |
||
470 | killagreg | 15 | #define I2C0_BUFFER_LEN 100 |
464 | ingob | 16 | // transfer buffer should be filled after a successful |
17 | // I2C_LockBuffer(...) and before a start of transmission |
||
18 | // initiated by I2C_Transmission(...). |
||
19 | extern volatile u8 I2C0_Buffer[]; |
||
20 | |||
21 | void I2C0_Init(void); |
||
22 | |||
23 | void I2C0_Deinit(void); |
||
24 | |||
25 | // Initiate i2c transmission |
||
470 | killagreg | 26 | // A transmission sends first TxBytes from I2C0_Buffer to slave |
27 | // and then RxBytes are read from slave to I2C0_Buffer |
||
464 | ingob | 28 | // replacing the byte that have been sent. |
29 | // Then the RxHandler function is called to handle the result. |
||
30 | // This function returns imediatly after a start condition. |
||
31 | // returns 1 if a transmission has been started, otherwise 0 |
||
32 | u8 I2C0_Transmission(u8 SlaveAddr, u8 TxBytes, I2C_pRxHandler_t pRxHandler, u8 RxBytes); |
||
470 | killagreg | 33 | // try to allocate the I2C0_Buffer within the timeout limit |
464 | ingob | 34 | // returns 1 on success |
35 | u8 I2C0_LockBuffer(u32 timeout); |
||
36 | // wait until transmission progess is finished or timeout |
||
37 | // returns 1 if no timeout occurs |
||
38 | u8 I2C0_WaitForEndOfTransmission(u32 timeout); |
||
39 | |||
40 | #endif // I2C_H |
||
41 |