81 lines
1.8 KiB
C
81 lines
1.8 KiB
C
/***
|
||
* @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.
|
||
*/
|
||
#ifndef __BSP_HISTORY_H__
|
||
#define __BSP_HISTORY_H__
|
||
|
||
#include "rtthread.h"
|
||
#include "rtdef.h"
|
||
|
||
#define HR_THREAD_STACK_SIZE (1024)
|
||
#define HR_THREAD_PRIORITY (10)
|
||
#define HR_THREAD_TIMESLICE (5)
|
||
|
||
/*一组数据帧:帧头(1字节) + 控制码(2字节) + 帧长度(1字节) + 数据(n字节) + 校验码 + 帧尾(1字节)*/
|
||
/*帧头:0xAA*/
|
||
/*帧尾:0x55*/
|
||
/*控制码:帧类型*/
|
||
/*帧长度:数据域长度*/
|
||
/*数据域:数据*/
|
||
/*校验码:数据域的校验和*/
|
||
#define FRAME_HEADER (0xAA)
|
||
#define FRAME_TAIL (0x55)
|
||
#define HOST_FRAME_MIN_LEN (6U)
|
||
|
||
#define FRAME_DATA_LEN (7U)
|
||
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;
|
||
|
||
#pragma pack(1)
|
||
typedef struct
|
||
{
|
||
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;
|
||
#pragma pack()
|
||
|
||
#pragma pack(1)
|
||
typedef struct
|
||
{
|
||
rt_uint8_t c1;
|
||
TeFrameC2 c2;
|
||
rt_uint8_t len;
|
||
rt_uint8_t data[];
|
||
} TsFrameData;
|
||
#pragma pack()
|
||
|
||
#pragma pack(1)
|
||
typedef struct
|
||
{
|
||
rt_uint8_t len;
|
||
rt_uint8_t buf[256];
|
||
} TsRawFrameData;
|
||
#pragma pack()
|
||
|
||
// extern rt_sem_t hr_rx_completion;
|
||
extern struct rt_completion hr_rx_completion;
|
||
|
||
|
||
#endif // !__BSP_HISTORY_H__
|