基于stm32的人体体温传感器Max30205的应用源程序 C语言

目前现有的max30205的驱动代码大多是基于Android单片机的,之前用了一个模块,看了一下数据手册,通信用的是IIC通信,读写数据地址都按照数据手册中来就行,和我用过的其他IIC通信的传感器相比,这个传感器的温度数据寄存器是十六位的,而我们一般用的读取代码历程都是一个字节,然后地址位依向后加一,这个模块在读完高八位时需要主机发送一个应答信号,然后继续读取低八位下面附有时序图和源代码:

30205.c:

#include "30205.h"
#include "delay.h"
//float temperature=0;
void max_init (void)
{
     IIC_Init();
   I2CwriteByte(MAX30205_ADDRESS, MAX30205_CONFIGURATION, 0x00);
     //I2CwriteByte(MAX30205_ADDRESS, MAX30205_THYST ,        0x00);
  // I2CwriteByte(MAX30205_ADDRESS, MAX30205_TOS, 0x00);
}
//写入指定地址一个字节数据
void I2CwriteByte(u8 address,u8 subAddress,u8 data)  //
{
     //IIC_Start();                                       //产生开始信号
       I2Cwriteaddr(address|IIC_WRITE,subAddress);  //对器件地址写入命令信号 然后寄存器地址
       IIC_Send_Byte(data);                               //对数据进行写进去
       IIC_Wait_Ack();                                    //等待回应
       IIC_Stop();                             //产生停止信号
}
//I2C读一个字节操作
u8 I2CreadByte(u8 address,u8 subAddress)
{   
       u8 data;
    // IIC_Start();                           //开始
       I2Cwriteaddr(address|IIC_WRITE, subAddress); //对器件地址发送写入命令 写入寄存器地址
     IIC_Start();                                           //开始
       IIC_Send_Byte(address|IIC_READ);                //发送读取命令
     
       IIC_Wait_Ack();                                    //等待回应
       data=IIC_Read_Byte(0);
       IIC_Stop();                             //产生停止信号
       return data;      
}

void I2CreadBytes(u8 address,u8 subAddress,u8*dest,u8 count)
{
    int i;
      for(i=0;i<count;i++)
        {
            dest[ i]=I2CreadByte(address,subAddress);
            subAddress+=1;
        }

}


void I2Cwriteaddr(u8 address,u8 subAddress)//写地址和寄存器操作
{
     IIC_Start();                         //产生开始条件
       IIC_Send_Byte(address);              //写入器件地址
       IIC_Wait_Ack();                      //等待回应
       IIC_Send_Byte(subAddress);           //写入寄存器地址
       IIC_Wait_Ack();                       //等待回应
       //IIC_Stop();                             //产生停止信号
}
int16_t Read_max16(u8 address,u8 subAddress)
{
            int16_t data;
            u8 instant;
        // IIC_Start();                           //开始
            I2Cwriteaddr(address|IIC_WRITE, subAddress); //对器件地址发送写入命令 写入寄存器地址
            IIC_Start();                                           //开始
            IIC_Send_Byte(address|IIC_READ);                //发送读取命令
         
            IIC_Wait_Ack();                                    //等待回应
            data=IIC_Read_Byte(1);//主机发送应答信号
            //IIC_Wait_Ack();
            instant = IIC_Read_Byte(0);//主机发送非应答信号
            IIC_Stop();                             //产生停止信号
            data = (data<<8)|instant;
            return data;   
}   

double GetTemperature(void)
    {
        double temperature= 0.0;
        int16_t temp;
        temp = Read_max16(MAX30205_ADDRESS,MAX30205_TEMPERATURE);
        temperature = temp*0.00390625;
        return  temperature;
    }

30205.h

#ifndef __30205_H
#define __30205_H
#include "sys.h"
#include "IIC.h"
#define MAX30205_ADDRESS  0X90    //8bit address converted to 7bit
//一些寄存器地址
#define MAX30205_TEMPERATURE 0X00
#define MAX30205_CONFIGURATION 0X01
#define MAX30205_THYST         0X02
#define MAX30205_TOS           0X03
#define IIC_WRITE 0   //数据方向 写入
#define IIC_READ   1   //数据方向 读取
//extern float temperature;
void shutdown(void);
void max_init (void);
void I2CwriteByte(u8 address,u8 subAddress,u8 data);
void I2Cwriteaddr(u8 address,u8 subAddress);
u8 I2CreadByte(u8 address,u8 subAddress);
void I2CreadBytes(u8 address,u8 subAddress,u8*dest,u8 count);
int16_t Read_max16(u8 address,u8 subAddress);
double GetTemperature(void);
#endif

IIC用的是模拟IIC,用的是原子哥的IIC底层
下面是完整工程代码附件:

暂无优惠

已有0人支付

# Archive e:\Users\huo\Downloads\stm32体温Max30205程序.zip
清除临时文件.bat
CORE
CORE\core_cm3.c
CORE\core_cm3.h
CORE\startup_stm32f10x_md.s
HARDWARE
HARDWARE\IIC
HARDWARE\IIC\IIC.c
HARDWARE\IIC\IIC.h
HARDWARE\IIC\sht31.c
HARDWARE\IIC\sht31.h
HARDWARE\led
HARDWARE\led\led.c
HARDWARE\led\led.h
HARDWARE\max30205
HARDWARE\max30205\30205.c
HARDWARE\max30205\30205.h
HARDWARE\oled
HARDWARE\oled\oled.c
HARDWARE\oled\oled.h
HARDWARE\timer
HARDWARE\timer\timer.c
HARDWARE\timer\timer.h
OBJ
OBJ\Bliz.hex
STM32F10x_FWLib
STM32F10x_FWLib\inc
STM32F10x_FWLib\inc\misc.h
STM32F10x_FWLib\inc\stm32f10x_adc.h
STM32F10x_FWLib\inc\stm32f10x_bkp.h
STM32F10x_FWLib\inc\stm32f10x_can.h
STM32F10x_FWLib\inc\stm32f10x_cec.h
STM32F10x_FWLib\inc\stm32f10x_crc.h
STM32F10x_FWLib\inc\stm32f10x_dac.h
STM32F10x_FWLib\inc\stm32f10x_dbgmcu.h
STM32F10x_FWLib\inc\stm32f10x_dma.h
STM32F10x_FWLib\inc\stm32f10x_exti.h
STM32F10x_FWLib\inc\stm32f10x_flash.h
STM32F10x_FWLib\inc\stm32f10x_fsmc.h
STM32F10x_FWLib\inc\stm32f10x_gpio.h
STM32F10x_FWLib\inc\stm32f10x_i2c.h
STM32F10x_FWLib\inc\stm32f10x_iwdg.h
STM32F10x_FWLib\inc\stm32f10x_pwr.h
STM32F10x_FWLib\inc\stm32f10x_rcc.h
STM32F10x_FWLib\inc\stm32f10x_rtc.h
STM32F10x_FWLib\inc\stm32f10x_sdio.h
STM32F10x_FWLib\inc\stm32f10x_spi.h
STM32F10x_FWLib\inc\stm32f10x_tim.h
STM32F10x_FWLib\inc\stm32f10x_usart.h
STM32F10x_FWLib\inc\stm32f10x_wwdg.h
STM32F10x_FWLib\src
STM32F10x_FWLib\src\misc.c
STM32F10x_FWLib\src\stm32f10x_adc.c
STM32F10x_FWLib\src\stm32f10x_bkp.c
STM32F10x_FWLib\src\stm32f10x_can.c
STM32F10x_FWLib\src\stm32f10x_cec.c
STM32F10x_FWLib\src\stm32f10x_crc.c
STM32F10x_FWLib\src\stm32f10x_dac.c
STM32F10x_FWLib\src\stm32f10x_dbgmcu.c
STM32F10x_FWLib\src\stm32f10x_dma.c
STM32F10x_FWLib\src\stm32f10x_exti.c
STM32F10x_FWLib\src\stm32f10x_flash.c
STM32F10x_FWLib\src\stm32f10x_fsmc.c
STM32F10x_FWLib\src\stm32f10x_gpio.c
STM32F10x_FWLib\src\stm32f10x_i2c.c
STM32F10x_FWLib\src\stm32f10x_iwdg.c
STM32F10x_FWLib\src\stm32f10x_pwr.c
STM32F10x_FWLib\src\stm32f10x_rcc.c
STM32F10x_FWLib\src\stm32f10x_rtc.c
STM32F10x_FWLib\src\stm32f10x_sdio.c
STM32F10x_FWLib\src\stm32f10x_spi.c
STM32F10x_FWLib\src\stm32f10x_tim.c
STM32F10x_FWLib\src\stm32f10x_usart.c
STM32F10x_FWLib\src\stm32f10x_wwdg.c
SYSTEM
SYSTEM\delay
SYSTEM\delay\delay.c
SYSTEM\delay\delay.h
SYSTEM\sys
SYSTEM\sys\sys.c
SYSTEM\sys\sys.h
SYSTEM\usart
SYSTEM\usart\usart.c
SYSTEM\usart\usart.h
USER
USER\JLinkSettings.ini
USER\main.c
USER\Mini_balance_car.uvgui._xiaolong
USER\Mini_balance_car.uvgui._xiaolong_PC
USER\Mini_balance_car.uvguix.Administrator
USER\Mini_balance_car.uvopt
USER\Mini_balance_car.uvoptx
USER\Mini_balance_car.uvproj.saved_uv4
USER\Mini_balance_car.uvprojx
USER\stm32f10x.h
USER\stm32f10x_conf.h
USER\stm32f10x_it.c
USER\stm32f10x_it.h
USER\system_stm32f10x.c
USER\system_stm32f10x.h

1,本站所有资源来源于用户上传和网络搜集,如有侵权请邮件联系站长删除。
2,分享目的仅供大家个人的学习用途,请不要用于商业用途。
3,如果你也有好的源码或者教程,可以投稿到本站,采纳后有积分奖励。
4,本站提供的各类资源均不保证其可用性及完整性,也没有任何技术服务。
5,如有链接无法下载、失效、过期,请联系管理员处理。
6,本站资源部分需要积分只是赞助,仅用于本站服务器和日常运营所需,不提供任何技术支持。
快捷联系方式 Email:admin@lzbk.com QQ:361113272
蓝知博库 » 基于stm32的人体体温传感器Max30205的应用源程序 C语言

提供最优质的资源集合

立即查看 了解详情