105 lines
2.7 KiB
C
105 lines
2.7 KiB
C
|
|
/* USER CODE BEGIN Header */
|
|||
|
|
/**
|
|||
|
|
******************************************************************************
|
|||
|
|
* @file : o2_sensor.h
|
|||
|
|
* @brief : <EFBFBD><EFBFBD>Ũ<EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD>
|
|||
|
|
* @version : 1.0
|
|||
|
|
* @changelog : version 1.0 <EFBFBD><EFBFBD>ʼ<EFBFBD>汾 2025.11.13
|
|||
|
|
******************************************************************************
|
|||
|
|
* @attention
|
|||
|
|
*
|
|||
|
|
* Copyright (c) 2025 Yuwell Software Danyang.Jiangsu.China
|
|||
|
|
* THIS SOFTWARE is licensed under the Mulan PSL v1.
|
|||
|
|
* can use this software according to the terms and conditions of the Mulan PSL v1.
|
|||
|
|
* You may obtain a copy of Mulan PSL v1 at:
|
|||
|
|
* http://license.coscl.org.cn/MulanPSL
|
|||
|
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
|||
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
|||
|
|
* PURPOSE.
|
|||
|
|
* See the Mulan PSL v1 for more details.
|
|||
|
|
*
|
|||
|
|
******************************************************************************
|
|||
|
|
*/
|
|||
|
|
/* USER CODE END Header */
|
|||
|
|
|
|||
|
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
|||
|
|
#ifndef __O2_SENSOR_H
|
|||
|
|
#define __O2_SENSOR_H
|
|||
|
|
|
|||
|
|
#ifdef __cplusplus
|
|||
|
|
extern "C" {
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#include <stdint.h>
|
|||
|
|
#include "fm33lg0xx_fl.h"
|
|||
|
|
#include "fm33lg0xx_queue.h"
|
|||
|
|
#include "fm33lg0xx_event.h"
|
|||
|
|
|
|||
|
|
|
|||
|
|
/* <20><>Ӳ<EFBFBD><D3B2>ʹ<EFBFBD>ý<EFBFBD><C3BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
|
#define O2_SENSOR_USED_UART_NUM UART5
|
|||
|
|
|
|||
|
|
|
|||
|
|
#define CHECK_TRANS_DONE while(FL_UART_IsActiveFlag_TXShiftBuffEmpty(O2_SENSOR_USED_UART_NUM) != FL_SET){};
|
|||
|
|
#define OXG_UART_TRANS_BYTE(x) FL_UART_WriteTXBuff(O2_SENSOR_USED_UART_NUM, x);CHECK_TRANS_DONE;
|
|||
|
|
|
|||
|
|
|
|||
|
|
// ״̬<D7B4><CCAC><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD>壨<EFBFBD>ڲ<EFBFBD>ʹ<EFBFBD>ã<EFBFBD>
|
|||
|
|
typedef enum
|
|||
|
|
{
|
|||
|
|
O2_STATE_WAIT_HEADER1, // <20>ȴ<EFBFBD>֡ͷ<D6A1><CDB7>1<EFBFBD>ֽڣ<D6BD>0x16
|
|||
|
|
O2_STATE_WAIT_HEADER2, // <20>ȴ<EFBFBD>֡ͷ<D6A1><CDB7>2<EFBFBD>ֽڣ<D6BD>0x09
|
|||
|
|
O2_STATE_WAIT_HEADER3, // <20>ȴ<EFBFBD>֡ͷ<D6A1><CDB7>3<EFBFBD>ֽڣ<D6BD>0x01
|
|||
|
|
O2_STATE_RECV_DATA, // <20><><EFBFBD>պ<EFBFBD><D5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
|||
|
|
O2_STATE_CHECK_FRAME // У<><D0A3>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
} RecvState;
|
|||
|
|
|
|||
|
|
|
|||
|
|
// <20>ȶ<EFBFBD><C8B6><EFBFBD>Э<EFBFBD><D0AD><EFBFBD><EFBFBD><EFBFBD>漰<EFBFBD><E6BCB0>ö<EFBFBD><C3B6>/<2F><><EFBFBD><EFBFBD>
|
|||
|
|
typedef enum
|
|||
|
|
{
|
|||
|
|
O2_FRAME_IDLE = 0, // <20><><EFBFBD><EFBFBD>״̬
|
|||
|
|
O2_FRAME_RECEIVING, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
O2_FRAME_COMPLETE, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3>ɽ<EFBFBD><C9BD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
O2_FRAME_ERROR // ֡<><D6A1><EFBFBD><EFBFBD>
|
|||
|
|
} O2FrameState;
|
|||
|
|
|
|||
|
|
|
|||
|
|
typedef struct
|
|||
|
|
{
|
|||
|
|
struct{
|
|||
|
|
|
|||
|
|
uint8_t DF[8];
|
|||
|
|
uint8_t CheckSum;
|
|||
|
|
|
|||
|
|
}O2_raw_data;
|
|||
|
|
|
|||
|
|
uint16_t o2_concentration; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵֵ<CAB5><D6B5><EFBFBD><EFBFBD>10
|
|||
|
|
uint16_t o2_flow; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵֵ<CAB5><D6B5><EFBFBD><EFBFBD>10 <20><>λL/min
|
|||
|
|
uint16_t o2_temperature;
|
|||
|
|
|
|||
|
|
RecvState receive_state;
|
|||
|
|
O2FrameState frame_state;
|
|||
|
|
|
|||
|
|
uint32_t fault_count;
|
|||
|
|
|
|||
|
|
}O2SensorData;
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/************************** <20><><EFBFBD><EFBFBD><E2B5BC><EFBFBD><EFBFBD>API<50><49><EFBFBD><EFBFBD> *************************/
|
|||
|
|
void oxg_sensor_init(void);
|
|||
|
|
void oxg_sensor_task(void);
|
|||
|
|
void UART5_IRQHandler(void);
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#ifdef __cplusplus
|
|||
|
|
}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#endif /* __O2_SENSOR_H */
|
|||
|
|
|
|||
|
|
/************************ (C) COPYRIGHT Yuwell *****END OF FILE****/
|