資源簡介
SHT11 溫濕度傳感器 STM32驅(qū)動 SHT11 溫濕度傳感器 STM32驅(qū)動

代碼片段和文件信息
////////////////////////////////////////////////////////////////////////////////////////
//Code?for?reading?the?SHT11?temeprature?and?humidity?sensor?with?an?STM?ARM?CORTEX-M3?MCU?
////////////////////////////////////////////////////////////////////////////////////////
/*
The?function?read_temperature_and_humidity()?reads?the?temperature?and?humidity?and?stores?the?data?in?XX.XX?format
*/
////////////////////////////////////////////////////////////////////////////////////////
char?temperature[15];
char?humidity[15];
void?mikrosekund(int?cas);
#ifndef?SHT1X_H
#define?SHT1X_H
/*
***********************************************************************************************
* PORT?DEFINITION
***********************************************************************************************
*/
//used?pins:
//PA0?-DATA
//PA1?-SCK
#define?DATA_WR GPIOA?GPIO_Pin_0
#define DATA_RD??? GPIO_ReadInputDataBit(GPIOAGPIO_Pin_0)
#define SCK??? GPIOA?GPIO_Pin_1 ?
void?datain(void)
{?GPIO_InitTypeDef?GPIO_InitStructure;
??GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_0;
??GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_IN_FLOATING;
??GPIO_InitStructure.GPIO_Speed?=?GPIO_Speed_50MHz;
??GPIO_Init(GPIOA?&GPIO_InitStructure);
}
void?dataout(void)
{?GPIO_InitTypeDef?GPIO_InitStructure;
?GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_0;
?GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_Out_PP;
?GPIO_InitStructure.GPIO_Speed?=?GPIO_Speed_2MHz;
?GPIO_Init(GPIOA?&GPIO_InitStructure);
}
void?sckout(void)
{GPIO_InitTypeDef?GPIO_InitStructure;
?GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_1;
?GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_Out_PP;
?GPIO_InitStructure.GPIO_Speed?=?GPIO_Speed_2MHz;
?GPIO_Init(GPIOA?&GPIO_InitStructure);
}
/*
***********************************************************************************************
* GLOBAL?CONSTANTS
***********************************************************************************************
*/
enum?{TEMPHUMI};
/*
***********************************************************************************************
* FUNCTION?PROTOTYPES
***********************************************************************************************
*/
char?s_softreset(void);
char?s_measure(unsigned?char?*p_value?unsigned?char?*p_checksum?unsigned?char?mode);
//char?s_write_statusreg(unsigned?char?*p_value);
//char?s_read_statusreg(unsigned?char?*p_value?unsigned?char?*p_checksum);
/*
***********************************************************************************************
* FUNCTION?PROTOTYPES
* ?HARDWARE?SPECIFIC
***********************************************************************************************
*/
void?s_transstart(void);
void?s_connectionreset(void);
char?s_read_byte(unsigned?char?ack);
char?s_write_byte(unsigned?char?value);
#endif
/*
*******************************************
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????13764??2010-11-18?20:29??sht11.c
-----------?---------??----------?-----??----
????????????????13764????????????????????1
- 上一篇:影子工廠實習(xí)報告 完成版
- 下一篇:DeviceNet協(xié)議 代碼
評論
共有 條評論