资源简介
项目中用到的程序,稳定可靠,由官方源码改写,模拟I2C,改好IO口直接就能驱动。初始化的时候调用 SHT3X_Init(0x44);(地址看自己硬件0x44或45)即可。官方源码的各种模式都保留了,省事的话直接用SHT3X_getHumidityTemperature函数就是最简单的获取温湿度到&temperature, &humidity。
代码片段和文件信息
//=============================================================================
// S E N S I R I O N AG Laubisruetistr. 50 CH-8712 Staefa Switzerland
//=============================================================================
// Project : SHT3x Sample Code (V1.1)
// File : sht3x.c (V1.1)
// Author : RFU
// Date : 6-Mai-2015
// Controller: STM32F100RB
// IDE : 礦ision V5.12.0.0
// Compiler : Armcc
// Brief : Sensor layer: Implementation of functions for sensor access.
//=============================================================================
//-- Includes -----------------------------------------------------------------
#include “sht3x.h“
#include “gpio.h“
extern float tem_temp_displayftem_humi_displayf;
//-- Defines ------------------------------------------------------------------
// Generator polynomial for CRC
//-- Defines ------------------------------------------------------------------
// Generator polynomial for CRC
#define POLYNOMIAL 0x131 // P(x) = x^8 + x^5 + x^4 + 1 = 100110001
//=============================================================================
// IO-Pins /* -- adapt the defines for your uC -- */
//-----------------------------------------------------------------------------
// Reset on port B bit 12
#define RESET_LOW() LED_GREEN_ON// set Reset to low
#define RESET_HIGH() LED_GREEN_OFF // set Reset to high
// Alert on port B bit 10
#define ALERT_READ // read Alert
//=============================================================================
//-- Global variables ---------------------------------------------------------
static u8t _i2cAddress; // I2C Address
//-- Static function prototypes -----------------------------------------------
static etError SHT3X_WriteAlertLimitData(ft humidity ft temperature);
static etError SHT3X_ReadAlertLimitData(ft* humidity ft* temperature);
static etError SHT3X_StartWriteAccess(void);
static etError SHT3X_StartReadAccess(void);
static void SHT3X_StopAccess(void);
static etError SHT3X_WriteCommand(etCommands command);
static etError SHT3X_Read2BytesAndCrc(u16t* data etI2cAck finaleAckNack
u8t timeout);
static etError SHT3X_Write2BytesAndCrc(u16t data);
static u8t SHT3X_CalcCrc(u8t data[] u8t nbrOfBytes);
static etError SHT3X_CheckCrc(u8t data[] u8t nbrOfBytes u8t checksum);
static ft SHT3X_CalcTemperature(u16t rawValue);
static ft SHT3X_CalcHumidity(u16t rawValue);
static u16t SHT3X_CalcRawTemperature(ft temperature);
static u16t SHT3X_CalcRawHumidity(ft humidity);
//=============================================================================
// IO-Pins /* -- adapt the defines for your uC -- */
//-----------------------------------------------------------------------------
// Reset on port B bit 12
//#define RESET_LOW() (GPIOB->BSRR = 0x10000000) // set Reset to
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 32725 2020-01-15 14:23 sht3x\sht3x.c
文件 16793 2020-01-15 14:24 sht3x\sht3x.h
目录 0 2020-01-15 14:29 sht3x\
相关资源
- DSP6713 I2C传输
- 基于STM32实现的模拟I2C
- Arduino LiquidCrystal_I2C库
- I2C slaver 从机 Verilog代码实现
- i2c_master verilog源码与testbench
- 模拟I2C读写24C256和24C02
- I2C Master
- I2C总线规范V2.1中文版
- atsha204 认证程序基于I2C通信
- 24C01C/24C02C/24LC01B中文资料 I2C串行EEP
- STM32F103+VL53L0源代码.zip
- 串口/I2C调试工具
- Intel SoC处理器的I2C总线IP核设计与应用
- dw_apb_i2c_db.pdf
- DesignWare DW_apb_i2c Databook
- SMBUS1.1 SMBUS110 中文注释版
- LSM6DSL I2C总线驱动
- cw2015_battery 电池检测芯片 I2C
- I2C读写AT24C02 基于STM32F103 cube
- arduion库文件LiquidCrystal_I2C.rar
- ST TOF测距传感器 适用于stm32f103系列,
- stm32 gpio模拟i2c_slave
- STM32和SHT3X 高精度温湿度传感器驱动
- 28335读写I2CEEPROM的例程
- STM32 I2C例程
- PMBUS规范总结.docx
- sony imx290 driver
- STM32F10x_模拟I2C读写EEPROM综合版切换
- SHT3X_C驱动
- STM32f103+SHT30代码.rar
评论
共有 条评论