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
|
|
|
|
|
2024-03-24 02:35:21 +01:00
|
|
|
// Function to initialize I2C
|
2024-03-24 04:07:20 +01:00
|
|
|
void I2C_init(uint32_t SCL_CLOCK);
|
2024-03-24 02:35:21 +01:00
|
|
|
|
|
|
|
// Function to send start condition
|
2024-03-24 00:00:32 +01:00
|
|
|
uint8_t I2C_start(uint8_t addr);
|
2024-03-24 02:35:21 +01:00
|
|
|
|
|
|
|
// Function to send stop condition
|
2024-03-23 21:18:52 +01:00
|
|
|
void I2C_stop();
|
2024-03-24 02:35:21 +01:00
|
|
|
|
|
|
|
// Write a byte to I2C bus
|
2024-03-24 00:00:32 +01:00
|
|
|
uint8_t I2C_write(uint8_t data);
|
2024-03-24 02:35:21 +01:00
|
|
|
|
|
|
|
// Read a byte from I2C bus
|
2024-03-23 21:18:52 +01:00
|
|
|
uint8_t I2C_read(uint8_t ack);
|