Subversion Repositories NaviCtrl

Rev

Rev 470 | Go to most recent revision | Details | Last modification | View Log | RSS feed

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