/* * @Author : stark1898y 1658608470@qq.com * @Date : 2024-09-04 17:32:45 * @LastEditors : stark1898y 1658608470@qq.com * @LastEditTime : 2024-09-08 11:38:37 * @FilePath : \JT-DT-YD4N02A_RTT_MRS\bsp\inc\bsp_hr.h * @Description : * * Copyright (c) 2024 by yzy, All Rights Reserved. */ #ifndef __BSP_HISTORY_READING_H__ #define __BSP_HISTORY_READING_H__ #include "board.h" #include "rtdef.h" #define HR_THREAD_STACK_SIZE (2048) #define HR_THREAD_PRIORITY (7) #define HR_THREAD_TIMESLICE (15) #define HR_UART USART2 #define HR_BAUDRATE (4800) #define HR_TX_GPIO_PIN GPIO_Pin_2 #define HR_TX_GPIO_PORT GPIOA #define HR_RX_GPIO_PIN GPIO_Pin_3 #define HR_RX_GPIO_PORT GPIOA #define FRAME_HEADER (0xAA) #define FRAME_TAIL (0x55) #define HOST_FRAME_MIN_LEN (6U) // #define HR_ALARM_MAX_NUM (200) // #define HR_ALARM_RCY_MAX_NUM (200) // #define HR_FAULT_MAX_NUM (100) // #define HR_FAULT_RCY_MAX_NUM (100) // #define HR_POWER_FAILURE_MAX_NUM (50) // #define HR_POWER_ON_MAX_NUM (50) // #define HR_SENSOR_FAILURE_MAX_NUM (1) 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, kGetCurrentTimeSecond, // include second kSetCurrentTime, kSetFactoryTime, kSetExpirationTime, kSetAlarmValue, kOutSysStatus, // 0x0E kGetAlarmValue, kGetMqVoltage, kSetSysStatus, kGetSysStatus, kEraseRecords, kGetFactoryTime, kGetExpirationTime, // kGetEsig, kReboot, } TeFrameC2; typedef struct __attribute__((packed)) { 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; typedef struct __attribute__((packed)) { rt_uint8_t c1; TeFrameC2 c2; rt_uint8_t len; rt_uint8_t data[]; } TsFrameData; typedef struct __attribute__((packed)) { rt_uint8_t len; rt_uint8_t buf[256]; } TsRawFrameData; extern struct rt_semaphore hr_rx_sem; int BSP_HR_Init(void); TsFrameData* HR_GetFrameData(const rt_uint8_t *p_src, const rt_uint8_t src_len); // FlagStatus HR_ProcessData(const TsFrameData *pHostFrameData); // uint8_t HR_ProcessData(const TsFrameData *pHostFrameData); rt_uint8_t HR_ProcessData(const TsFrameData *pHostFrameData); rt_uint8_t HR_GenerateRawFrame(TsRawFrameData* pRawData , rt_uint8_t c1,TeFrameC2 c2, const rt_uint8_t* p_src, rt_uint8_t src_len); #endif //!__BSP_HISTORY_READING_H__