forked from glidernet/diy-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
i2c.h
22 lines (15 loc) · 819 Bytes
/
i2c.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef __I2C_H__
#define __I2C_H__
#include "stm32f10x_i2c.h"
void I2C_Configuration(I2C_TypeDef* I2Cx, uint32_t ClockSpeed=100000);
void I2C_Restart(I2C_TypeDef* I2Cx, uint32_t ClockSpeed=100000);
void I2C_Reset(I2C_TypeDef* I2Cx);
uint8_t I2C_Write(I2C_TypeDef *I2Cx, uint8_t Addr, uint8_t Reg, const uint8_t *Data, uint8_t Len);
uint8_t I2C_Read (I2C_TypeDef *I2Cx, uint8_t Addr, uint8_t Reg, uint8_t *Data, uint8_t Len);
template <class Type>
inline uint8_t I2C_Write(I2C_TypeDef *I2Cx, uint8_t Addr, uint8_t Reg, Type &Object)
{ return I2C_Write(I2Cx, Addr, Reg, (uint8_t *)&Object, sizeof(Type)); }
template <class Type>
inline uint8_t I2C_Read(I2C_TypeDef *I2Cx, uint8_t Addr, uint8_t Reg, Type &Object)
{ return I2C_Read(I2Cx, Addr, Reg, (uint8_t *)&Object, sizeof(Type)); }
#endif // __I2C_H__