i2c.h
819 Bytes
#ifndef I2C_H
#define I2C_H
#include "stm32f10x.h"
#include "stm32f10x_i2c.h"
#include "stm32f10x_gpio.h"
#include "sensors.h"
#include "libwismart.h"
#define I2C_TIMEOUT 100
#define DBG_I2C(fmt,...) printf("%c[1;35mi2c.c:%c[1;00m "fmt,0x1B,0x1B, ##__VA_ARGS__)
//#define DBG_I2C(fmt,...) printf("")
void I2C_init(void);
void I2C_start(I2C_TypeDef* I2Cx, uint8_t address, uint8_t direction);
void I2C_stop(I2C_TypeDef* I2Cx);
void I2C_write(I2C_TypeDef* I2Cx, uint8_t data);
uint8_t I2C_read_ack(I2C_TypeDef* I2Cx);
uint8_t I2C_read_nack(I2C_TypeDef* I2Cx);
void I2C_scan(I2C_TypeDef* I2Cx,uint8_t *addresses);
uint8_t I2C_check(I2C_TypeDef* I2Cx, uint8_t address);
void I2C_reset(I2C_TypeDef* I2Cx);
void I2C_restart(I2C_TypeDef* I2Cx, uint8_t address, uint8_t direction);
#endif