-
Notifications
You must be signed in to change notification settings - Fork 1
/
i2c_bitbang.h
39 lines (29 loc) · 897 Bytes
/
i2c_bitbang.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* File: i2c_bitbang.h
* Author: Steffi
*
* Created on 23. April 2016, 09:50
*/
#ifndef I2C_BITBANG_H
#define I2C_BITBANG_H
#ifdef __cplusplus
extern "C" {
#endif
#include "DevelOS.h"
#define I2C_Buffer 64
#pragma udata I2C_Data
extern struct I2C_BUS {
unsigned char Buffer[I2C_Buffer]; // have a few bytes as buffer
unsigned char BufPos; // as a counter
unsigned long Delay; // for the timing of the bus
} i2c_bus;
#pragma udata
unsigned char I2C_ByteIn(char ack); // Read a byte from the bus, maybe ack it, return the byte
unsigned char I2C_ByteOut(char byte); // Write a byte to the bus, return the ack
void I2C_Start(void); // do the start condition
void I2C_Stop(void); // do the stop condition
#define I2C_Delay_100khz 5000
#ifdef __cplusplus
}
#endif
#endif /* I2C_BITBANG_H */