ISKBoard example project
Wenxue
2025-09-02 6e5f041f9aa1c91150988b47ea7de67b9e34b7db
Core/Src/board/sht20.c
@@ -11,7 +11,7 @@
 ***********************************************************************/
#include <stdio.h>
#include <string.h>
#include "i2c.h"
#include "i2c_bitbang.h"
#include "sht20.h"
#define CONFIG_DEBUG_SHT2X /* Enable SHT20 debug */
@@ -61,6 +61,8 @@
    float           temp, rh;
    int             rv;
    i2c_lock(SHT2X_CHIPADDR);
    if( sht2x_softreset() < 0 )
    {
        sht2x_print("SHT20 soft reset failed.\r\n");
@@ -94,6 +96,7 @@
        *humdity=rh;
OUT:
   i2c_free();
    return rv;
}
@@ -104,8 +107,8 @@
    sht2x_print("Start soft reset sht2x\r\n");
    rv=HAL_I2C_Master_Transmit(&hi2c1, SHT2X_CHIPADDR<<1, &command, 1, 0xFFFFFFFF);
    if( rv != HAL_OK )
    rv=i2c_write(&command, 1);
    if( rv )
    {
        sht2x_print("SHT2X send soft reset command 0x%0x failure: rv=0x%02x\r\n", command, rv);
        return -rv;
@@ -161,7 +164,7 @@
        return -2;
    }
    if( HAL_I2C_Master_Transmit(&hi2c1, SHT2X_CHIPADDR<<1, &command, 1, 0xFFFFFFFF) != HAL_OK )
    if( i2c_write(&command, 1) < 0 )
    {
        sht2x_print("SHT2X send measure command 0x%0x failure\r\n", command);
        return -3;
@@ -176,7 +179,7 @@
    {
        memset(buf, 0, 3);
        if( HAL_OK == HAL_I2C_Master_Receive(&hi2c1, SHT2X_CHIPADDR<<1|1, buf, 3, 0xFFFFFFFF) )
        if( !i2c_read(buf, 3) )
        {
            break;
        }