AVR-Playground/i2c.h

20 lines
380 B
C
Raw Normal View History

2024-03-23 21:18:52 +01:00
#pragma once
2024-03-24 00:00:32 +01:00
#include <stdint.h>
2024-03-23 21:18:52 +01:00
2024-03-24 01:23:44 +01:00
#define TW_WRITE 0
#define TW_READ 1
// Function to initialize I2C
2024-03-24 04:07:20 +01:00
void I2C_init(uint32_t SCL_CLOCK);
// Function to send start condition
2024-03-24 00:00:32 +01:00
uint8_t I2C_start(uint8_t addr);
// Function to send stop condition
2024-03-23 21:18:52 +01:00
void I2C_stop();
// Write a byte to I2C bus
2024-03-24 00:00:32 +01:00
uint8_t I2C_write(uint8_t data);
// Read a byte from I2C bus
2024-03-23 21:18:52 +01:00
uint8_t I2C_read(uint8_t ack);