Compare commits
No commits in common. "48f16565402797740c06035ea15c2aaacebb9bb0" and "de32bd245c7b2d3911e7a0bbb4ebcb9c16539abd" have entirely different histories.
48f1656540
...
de32bd245c
@ -86,7 +86,7 @@ void i2c_scan(I2C_TypeDef* I2Cx, void (*onPingFound)(u8 address)) {
|
|||||||
//! I2C SEND FUNCTION
|
//! I2C SEND FUNCTION
|
||||||
//! ####################################
|
//! ####################################
|
||||||
|
|
||||||
u8 i2c_sendBytes_noStop(I2C_TypeDef* I2Cx, u8 i2cAddress, const u8* buffer, u8 len) {
|
u8 i2c_sendBytes_noStop(I2C_TypeDef* I2Cx, u8 i2cAddress, u8* buffer, u8 len) {
|
||||||
u8 err = i2c_start(I2Cx, i2cAddress, 0); // Write mode
|
u8 err = i2c_start(I2Cx, i2cAddress, 0); // Write mode
|
||||||
if (err) return err;
|
if (err) return err;
|
||||||
u32 timeout;
|
u32 timeout;
|
||||||
@ -107,7 +107,7 @@ u8 i2c_sendBytes_noStop(I2C_TypeDef* I2Cx, u8 i2cAddress, const u8* buffer, u8 l
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 i2c_sendBytes(I2C_TypeDef* I2Cx, u8 i2cAddress, const u8* buffer, u8 len) {
|
u8 i2c_sendBytes(I2C_TypeDef* I2Cx, u8 i2cAddress, u8* buffer, u8 len) {
|
||||||
u8 err = i2c_sendBytes_noStop(I2Cx, i2cAddress, buffer, len);
|
u8 err = i2c_sendBytes_noStop(I2Cx, i2cAddress, buffer, len);
|
||||||
//# Generate STOP condition
|
//# Generate STOP condition
|
||||||
I2Cx->CTLR1 |= I2C_CTLR1_STOP;
|
I2Cx->CTLR1 |= I2C_CTLR1_STOP;
|
||||||
|
|||||||
@ -17,14 +17,16 @@
|
|||||||
void i2c_init(I2C_TypeDef* I2Cx, u32 PCLK, u32 i2cSpeed_Hz);
|
void i2c_init(I2C_TypeDef* I2Cx, u32 PCLK, u32 i2cSpeed_Hz);
|
||||||
u8 i2c_start(I2C_TypeDef* I2Cx, u8 i2cAddress, u8 isRead);
|
u8 i2c_start(I2C_TypeDef* I2Cx, u8 i2cAddress, u8 isRead);
|
||||||
void i2c_stop(I2C_TypeDef* I2Cx);
|
void i2c_stop(I2C_TypeDef* I2Cx);
|
||||||
|
u8 i2c_write(I2C_TypeDef* I2Cx, u8 i2cAddress, u8 reg, u8 data);
|
||||||
|
u8 i2c_read(I2C_TypeDef* I2Cx, u8 i2cAddress, u8 reg, u8* buffer, u8 len);
|
||||||
void i2c_scan(I2C_TypeDef* I2Cx, void (*onPingFound)(u8 address));
|
void i2c_scan(I2C_TypeDef* I2Cx, void (*onPingFound)(u8 address));
|
||||||
|
|
||||||
//! ####################################
|
//! ####################################
|
||||||
//! I2C SEND FUNCTION
|
//! I2C SEND FUNCTION
|
||||||
//! ####################################
|
//! ####################################
|
||||||
|
|
||||||
u8 i2c_sendBytes_noStop(I2C_TypeDef* I2Cx, u8 i2cAddress, const u8* buffer, u8 len);
|
u8 i2c_sendBytes_noStop(I2C_TypeDef* I2Cx, u8 i2cAddress, u8* buffer, u8 len);
|
||||||
u8 i2c_sendBytes(I2C_TypeDef* I2Cx, u8 i2cAddress, const u8* buffer, u8 len);
|
u8 i2c_sendBytes(I2C_TypeDef* I2Cx, u8 i2cAddress, u8* buffer, u8 len);
|
||||||
u8 i2c_sendByte(I2C_TypeDef* I2Cx, u8 i2cAddress, u8 data);
|
u8 i2c_sendByte(I2C_TypeDef* I2Cx, u8 i2cAddress, u8 data);
|
||||||
|
|
||||||
//! ####################################
|
//! ####################################
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user