2024-09-20 11:14:25 +08:00
|
|
|
|
/***
|
|
|
|
|
* @Author: mbw
|
|
|
|
|
* @Date: 2024-08-23 10:14:23
|
|
|
|
|
* @LastEditors: mbw && 1600520629@qq.com
|
|
|
|
|
* @LastEditTime: 2024-09-20 10:42:54
|
|
|
|
|
* @FilePath: \USART1_Interrupt - RT-Thread\bsp\inc\bsp_history.h
|
|
|
|
|
* @Description:
|
|
|
|
|
* @
|
|
|
|
|
* @Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
|
2024-08-31 10:27:58 +08:00
|
|
|
|
*/
|
|
|
|
|
#ifndef __BSP_HISTORY_H__
|
|
|
|
|
#define __BSP_HISTORY_H__
|
2024-08-23 11:16:27 +08:00
|
|
|
|
|
2024-08-31 10:27:58 +08:00
|
|
|
|
#include "rtthread.h"
|
|
|
|
|
#include "rtdef.h"
|
2024-08-23 11:16:27 +08:00
|
|
|
|
|
2024-09-20 11:14:25 +08:00
|
|
|
|
#define HR_THREAD_STACK_SIZE (1024)
|
2024-09-02 16:09:03 +08:00
|
|
|
|
#define HR_THREAD_PRIORITY (10)
|
|
|
|
|
#define HR_THREAD_TIMESLICE (5)
|
2024-08-23 11:16:27 +08:00
|
|
|
|
|
2024-08-31 10:27:58 +08:00
|
|
|
|
/*一组数据帧:帧头(1字节) + 控制码(2字节) + 帧长度(1字节) + 数据(n字节) + 校验码 + 帧尾(1字节)*/
|
|
|
|
|
/*帧头:0xAA*/
|
|
|
|
|
/*帧尾:0x55*/
|
|
|
|
|
/*控制码:帧类型*/
|
|
|
|
|
/*帧长度:数据域长度*/
|
|
|
|
|
/*数据域:数据*/
|
|
|
|
|
/*校验码:数据域的校验和*/
|
|
|
|
|
#define FRAME_HEADER (0xAA)
|
|
|
|
|
#define FRAME_TAIL (0x55)
|
|
|
|
|
#define HOST_FRAME_MIN_LEN (6U)
|
2024-08-23 11:16:27 +08:00
|
|
|
|
|
2024-09-02 15:12:26 +08:00
|
|
|
|
#define FRAME_DATA_LEN (7U)
|
2024-08-31 10:27:58 +08:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
kNumOfRecords = 0U,
|
|
|
|
|
kAlarmRecord, // at least 200
|
|
|
|
|
kAlarmRcyRecord, // at least 200
|
|
|
|
|
kFaultRecord, // at least 100
|
|
|
|
|
kFaultRcyRecord, // at least 100
|
|
|
|
|
kPowerFailureRecord, // at least 50
|
|
|
|
|
kPowerOnRecord, // at least 50
|
|
|
|
|
kSensorFailureRecord, // at least 1
|
|
|
|
|
kGetCurrentTime,
|
|
|
|
|
} TeFrameC2;
|
2024-08-23 11:16:27 +08:00
|
|
|
|
|
2024-09-02 15:12:26 +08:00
|
|
|
|
#pragma pack(1)
|
|
|
|
|
typedef struct
|
2024-08-31 10:27:58 +08:00
|
|
|
|
{
|
|
|
|
|
rt_uint8_t year_h;
|
|
|
|
|
rt_uint8_t year_l;
|
|
|
|
|
rt_uint8_t month;
|
|
|
|
|
rt_uint8_t day;
|
|
|
|
|
rt_uint8_t hour;
|
|
|
|
|
rt_uint8_t minute;
|
|
|
|
|
} TsRecordsTime;
|
2024-09-02 15:12:26 +08:00
|
|
|
|
#pragma pack()
|
2024-08-23 11:16:27 +08:00
|
|
|
|
|
2024-09-02 15:12:26 +08:00
|
|
|
|
#pragma pack(1)
|
2024-09-02 16:09:03 +08:00
|
|
|
|
typedef struct
|
2024-08-31 10:27:58 +08:00
|
|
|
|
{
|
|
|
|
|
rt_uint8_t c1;
|
|
|
|
|
TeFrameC2 c2;
|
|
|
|
|
rt_uint8_t len;
|
|
|
|
|
rt_uint8_t data[];
|
|
|
|
|
} TsFrameData;
|
2024-09-02 15:12:26 +08:00
|
|
|
|
#pragma pack()
|
2024-08-23 11:16:27 +08:00
|
|
|
|
|
2024-09-02 15:12:26 +08:00
|
|
|
|
#pragma pack(1)
|
|
|
|
|
typedef struct
|
2024-08-31 10:27:58 +08:00
|
|
|
|
{
|
|
|
|
|
rt_uint8_t len;
|
|
|
|
|
rt_uint8_t buf[256];
|
|
|
|
|
} TsRawFrameData;
|
2024-09-02 15:12:26 +08:00
|
|
|
|
#pragma pack()
|
2024-08-23 11:16:27 +08:00
|
|
|
|
|
2024-09-19 17:13:58 +08:00
|
|
|
|
// extern rt_sem_t hr_rx_completion;
|
|
|
|
|
extern struct rt_completion hr_rx_completion;
|
2024-08-23 11:16:27 +08:00
|
|
|
|
|
|
|
|
|
|
2024-08-31 10:27:58 +08:00
|
|
|
|
#endif // !__BSP_HISTORY_H__
|