-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathi2c.h
More file actions
27 lines (22 loc) · 721 Bytes
/
i2c.h
File metadata and controls
27 lines (22 loc) · 721 Bytes
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
#ifndef _I2C_H_
#define _I2C_H_
#include <stdint.h>
/*###############Constants##########################*/
#define F_CPU 8000000UL // Frequency of the microcontroller
#define ACK 0
#define NACK 1
// I2C interface ports
#define SDA 4
#define SCL 5
#define I2C_PORT PORTC
#define I2C_PIN PINC
#define I2C_DDR DDRC
// Delay
#define i2c_delay _delay_us(5);
/*################Functions#####################*/
void i2c_init(); // Initialization ports
void i2c_start(); // Start signal
void i2c_stop(); // Stop signal
uint8_t i2c_write_byte(uint8_t); // Byte transfering
uint8_t i2c_read_byte(uint8_t); // Byte recieving (1-receiving the last byte)
#endif