2025-01-25 14:11:51 +08:00
|
|
|
|
/***
|
2024-12-30 11:50:48 +08:00
|
|
|
|
* @Author: mbw
|
2025-01-25 14:11:51 +08:00
|
|
|
|
* @Date: 2025-01-24 08:40:39
|
2024-12-30 11:50:48 +08:00
|
|
|
|
* @LastEditors: mbw && 1600520629@qq.com
|
2025-01-25 15:09:53 +08:00
|
|
|
|
* @LastEditTime: 2025-01-25 14:49:06
|
2025-01-25 14:11:51 +08:00
|
|
|
|
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\inc\bsp_h308.h
|
|
|
|
|
* @Description:
|
2024-12-30 11:50:48 +08:00
|
|
|
|
* @
|
2025-01-25 14:11:51 +08:00
|
|
|
|
* @Copyright (c) 2025 by ${git_name_email}, All Rights Reserved.
|
2024-12-30 11:50:48 +08:00
|
|
|
|
*/
|
|
|
|
|
#ifndef __BSP_H308_H__
|
|
|
|
|
#define __BSP_H308_H__
|
|
|
|
|
|
|
|
|
|
#include "board.h"
|
|
|
|
|
#include "rtdef.h"
|
|
|
|
|
#include "drv_gpio.h"
|
|
|
|
|
|
|
|
|
|
#define TSET_BSP_H308
|
|
|
|
|
|
2025-01-17 10:52:36 +08:00
|
|
|
|
#define H308_SAMPLING_TIMS (8U)
|
2024-12-30 11:50:48 +08:00
|
|
|
|
/*浓度异常采样周期*/
|
|
|
|
|
#define H308_SAMPLING_ABNORMAL (60U)
|
|
|
|
|
#define H308_PWR_PIN GET_PIN(B, 9)
|
|
|
|
|
#define H308_RST_PIN GET_PIN(C, 12)
|
|
|
|
|
|
|
|
|
|
#define H308_PWR_ON rt_pin_write(H308_PWR_PIN, PIN_HIGH)
|
|
|
|
|
#define H308_PWR_OFF rt_pin_write(H308_PWR_PIN, PIN_LOW)
|
|
|
|
|
|
|
|
|
|
#define H308_RST_ON rt_pin_write(H308_RST_PIN, PIN_LOW)
|
|
|
|
|
#define H308_RST_OFF rt_pin_write(H308_RST_PIN, PIN_HIGH)
|
|
|
|
|
|
|
|
|
|
#define H308_THREAD_STACK_SIZE (2048)
|
2025-01-23 16:29:51 +08:00
|
|
|
|
#define H308_THREAD_PRIORITY (7)
|
2024-12-30 11:50:48 +08:00
|
|
|
|
#define H308_THREAD_TIMESLICE (5)
|
|
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
// kH308Normal = 0, // 传感器工作正常
|
|
|
|
|
kH308TempCtrlErr, // 温控异常
|
|
|
|
|
kH308EnvTempErr, // 环境温度异常
|
|
|
|
|
kH308LaserWeak, // 激光信号弱
|
|
|
|
|
kH308LaserStrong, // 激光信号强
|
|
|
|
|
kH308LaserErr, // 激光信号异常
|
|
|
|
|
kH308LaserWeakErr, // 激光信号弱+激光信号异常
|
|
|
|
|
kH308LaserStrongErr, // 激光信号强+激光信号异常
|
|
|
|
|
} TeH308FaultCode;
|
|
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
kH308Normal = 0,
|
|
|
|
|
kH308Alarm = 1,
|
|
|
|
|
kH308Fault,
|
|
|
|
|
kH308EndOfLife,
|
|
|
|
|
kH308Abnormal,
|
|
|
|
|
} TeH308Status;
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
char vol[16]; // 浓度
|
|
|
|
|
char temp[16]; // 温度
|
|
|
|
|
char laser_temp[16]; // 激光器温度
|
|
|
|
|
char signal_strength[16]; // 信号强度
|
|
|
|
|
char gain[16]; // 放大系数
|
|
|
|
|
char fault_code[4]; // 传感器状态
|
|
|
|
|
char checksum[4]; // 校验
|
|
|
|
|
} TsH308StrData;
|
|
|
|
|
|
|
|
|
|
typedef struct __attribute__((packed))
|
|
|
|
|
{
|
|
|
|
|
float lel; // 浓度
|
|
|
|
|
float temp; // 温度
|
|
|
|
|
float laser_temp; // 激光器温度
|
|
|
|
|
float signal_strength; // 信号强度
|
|
|
|
|
float gain; // 放大系数
|
|
|
|
|
rt_uint8_t fault_code; // 故障码
|
|
|
|
|
rt_uint8_t checksum; // 校验
|
|
|
|
|
} TsH308Data;
|
|
|
|
|
|
2025-01-25 15:09:53 +08:00
|
|
|
|
typedef struct
|
2024-12-30 11:50:48 +08:00
|
|
|
|
{
|
2025-01-25 14:11:51 +08:00
|
|
|
|
uint8_t end_of_life; // 寿命到期
|
|
|
|
|
uint8_t last_life; // 上次状态
|
|
|
|
|
uint8_t to_be_calib; // 待标定
|
|
|
|
|
uint8_t alarm_value; // 报警器阈值 LEL
|
|
|
|
|
uint8_t detection_flag; // 实时检测的标志
|
|
|
|
|
uint32_t expiration_seconds; // 传感器到期时间,s
|
2024-12-30 11:50:48 +08:00
|
|
|
|
TeH308Status status_buffer[H308_SAMPLING_TIMS]; // 采样缓存数组
|
2025-01-25 14:11:51 +08:00
|
|
|
|
TeH308FaultCode fault_code; // 故障码
|
|
|
|
|
TsH308Data Data;
|
2024-12-30 11:50:48 +08:00
|
|
|
|
} TsH308;
|
|
|
|
|
|
|
|
|
|
extern TsH308 H308;
|
|
|
|
|
int BSP_H308_Init(void);
|
|
|
|
|
void H308_ShowData(TsH308Data data);
|
|
|
|
|
uint8_t IS_H308_EndOfLife(void);
|
|
|
|
|
#endif // !__BSP_H308_H__
|