other/i2c_stts75_sensor: Cosmetics.
This commit is contained in:
parent
53a0c44bfd
commit
8a77630997
@ -79,16 +79,16 @@ void i2c_setup(void)
|
||||
i2c_set_fast_mode(I2C2);
|
||||
|
||||
/*
|
||||
* fclock for I2C is 36MHz APB2 -> cycle time 28ns, low time at 400KHz
|
||||
* fclock for I2C is 36MHz APB2 -> cycle time 28ns, low time at 400kHz
|
||||
* incl trise -> Thigh = 1600ns; CCR = tlow/tcycle = 0x1C,9;
|
||||
* datasheet suggests 0x1e.
|
||||
* Datasheet suggests 0x1e.
|
||||
*/
|
||||
i2c_set_ccr(I2C2, 0x1e);
|
||||
|
||||
/*
|
||||
* fclock for I2C is 36MHz -> cycle time 28ns, rise time for
|
||||
* 400KHz => 300ns and 100KHz => 1000ns; 300ns/28ns = 10;
|
||||
* incremented by 1 -> 11.
|
||||
* 400kHz => 300ns and 100kHz => 1000ns; 300ns/28ns = 10;
|
||||
* Incremented by 1 -> 11.
|
||||
*/
|
||||
i2c_set_trise(I2C2, 0x0b);
|
||||
|
||||
|
@ -43,7 +43,8 @@ void stts75_write_config(u32 i2c, u8 sensor)
|
||||
/* Sending the data. */
|
||||
i2c_send_data(i2c, 0x1); /* stts75 config register */
|
||||
while (!(I2C_SR1(i2c) & I2C_SR1_BTF)); /* Await ByteTransferedFlag. */
|
||||
i2c_send_data(i2c, 0x4); /* pol reverse - LED glows if temp is below Tos/Thyst */
|
||||
/* Polarity reverse - LED glows if temp is below Tos/Thyst. */
|
||||
i2c_send_data(i2c, 0x4);
|
||||
while (!(I2C_SR1(i2c) & (I2C_SR1_BTF | I2C_SR1_TxE)));
|
||||
|
||||
/* Send STOP condition. */
|
||||
@ -76,7 +77,8 @@ void stts75_write_temp_os(u32 i2c, u8 sensor, u16 temp_os)
|
||||
i2c_send_data(i2c, (u8)(temp_os >> 8)); /* MSB */
|
||||
while (!(I2C_SR1(i2c) & I2C_SR1_BTF));
|
||||
i2c_send_data(i2c, (u8)(temp_os & 0xff00)); /* LSB */
|
||||
while (!(I2C_SR1(i2c) & (I2C_SR1_BTF | I2C_SR1_TxE))); /* After the last byte we have to wait for TxE too. */
|
||||
/* After the last byte we have to wait for TxE too. */
|
||||
while (!(I2C_SR1(i2c) & (I2C_SR1_BTF | I2C_SR1_TxE)));
|
||||
|
||||
/* Send STOP condition. */
|
||||
i2c_send_stop(i2c);
|
||||
@ -108,7 +110,8 @@ void stts75_write_temp_hyst(u32 i2c, u8 sensor, u16 temp_hyst)
|
||||
i2c_send_data(i2c, (u8)(temp_hyst >> 8)); /* MSB */
|
||||
while (!(I2C_SR1(i2c) & I2C_SR1_BTF));
|
||||
i2c_send_data(i2c, (u8)(temp_hyst & 0xff00)); /* LSB */
|
||||
while (!(I2C_SR1(i2c) & (I2C_SR1_BTF | I2C_SR1_TxE))); /* After the last byte we have to wait for TxE too. */
|
||||
/* After the last byte we have to wait for TxE too. */
|
||||
while (!(I2C_SR1(i2c) & (I2C_SR1_BTF | I2C_SR1_TxE)));
|
||||
|
||||
/* Send STOP condition. */
|
||||
i2c_send_stop(i2c);
|
||||
|
Loading…
x
Reference in New Issue
Block a user