forked from SZV10X_Software/SZV103_FM33A0xxEV_SiZhu

wujiazhi
2024-06-07 d0cca79a4aa7efce979c6aed275fe1bb75af4cc4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifndef _UPPER_COMPUTER_H_
#define _UPPER_COMPUTER_H_
 
#include "define_all.h"
#include "sundry.h"
 
#define UC_RANDOM_CREATED (rand() % 100) << 8 | (rand() % 100) // Ëæ»úÂë¹¹Ôì
 
// #define UC_TABLE_ID_LENGTH    SIZEOF_OF(UC_PROTOCOL_HEAD_T,table_id)    //ЭÒéÊý¾Ý±íID³¤¶È
 
#define UC_PROTOCOL_HEAD_LENGTH (sizeof(struct uc_protocol_head) - sizeof(struct uc_log_time_data_field)) /*sizeof(UC_PROTOCOL_HEAD_T)*/ // Ð­ÒéÍ·³¤¶È
 
#define UC_PROTOCOL_VER 0x0001 // Ð­Òé°æ±¾
 
#define UC_PASSWORD UC_PROTOCOL_VER // µÇ¼ÃÜÂë
 
// Upper_Computer
#define UC_RECV_LEN_MAX 1024 // ÉÏλ»ú½ÓÊÕ×î´ó³¤¶È
 
// ÉÏλ»úÃüÁî
#define UC_CMD_LOGIN 0x11
#define UC_CMD_EXIT 0x12
#define UC_CMD_WRITE 0x42
#define UC_CMD_READ 0x52
#define UC_CMD_GET_LOG_RECENT 0x82 // °´×î½ü£¨ÔÝÎÞ£©
#define UC_CMD_GET_LOG_TIME 0x83   // °´Ê±¼ä
#define UC_CMD_IAP 0x99            // IAPÔÚÏßÉý¼¶
 
typedef enum
{
  UC_UNKNOWN = 0U,
  UC_OK,            // ³É¹¦
  UC_PLANT_NUM_ERR, // ³§¼Ò´úÂë´íÎó
  UC_PASSWORD_ERR   // ÃÜÂë´íÎó
} UC_LOGIN_STATUS;
 
typedef enum
{
  UC_GENERAL = 0U,           // Í¨ÓÃ
  UC_IDEA_CREATED = 0x1234U, // Ë¼Öþ
  UC_ENN = 0x2345U,          // Ð°Â
  UC_GOLD_CARD = 0x3456U     // ½ð¿¨
} UC_PLANT_NUM;
 
#pragma pack(1)
 
typedef union
{
  uint8_t uc_recv_buf[UC_RECV_LEN_MAX];
  struct uc_protocol_head // ¹Ì¶¨µÄЭÒéÍ·
  {
    uint8_t frame_start_code;
    uint8_t uc_type;              // ÉÏλ»úÀàÐÍ
    uint8_t uc_admin;             // ÉÏλ»úȨÏÞ
    uint16_t plant_number;        // ³§¼Ò±àºÅ BCD
    uint16_t protocol_ver;        // Ð­Òé°æ±¾ BCD
    uint16_t random_number;       // Ëæ»úÂë
    uint8_t cmd_code;             // ¿ØÖÆÂë
    uint16_t data_field_length;   // Êý¾ÝÓò³¤¶È
    struct uc_log_time_data_field // ¹Ì¶¨µÄÈÕÖ¾Êý¾ÝÓò
    {
      uint16_t log_table_id;
      uint8_t log_start_time_bcd[6];
      uint8_t log_end_time_bcd[6];
      uint16_t log_num_limit;    // ÈÕÖ¾ÌõÊýÏÞÖÆ£¨ÎÞÓã©
      uint8_t log_continue_flag; // Ðø´«±ê־룬0´ú±íÊ״ζÁÈ¡
    } uc_log_time_data_field_s;
  } uc_protocol_head_s;
} UC_RECV_DATA_UNION_T;
 
typedef struct
{
  /*ÕâÑùÅÅÐòÊÇΪÁË×Ö½Ú¶ÔÆë£¬buffÊý¾ÝÒª4µÄ±¶ÊýÅäºÏ__attribute__ ((aligned (4)))ʹÓÃ*/
  UC_RECV_DATA_UNION_T uc_recv_buf_union;
  uint16_t uc_recv_length;
  FlagStatus uc_recv_flag;
} UC_RECV_PARA_T;
 
// typedef struct{
//    uint8_t frame_start_code;
//    uint8_t uc_type; //ÉÏλ»úÀàÐÍ
//    uint8_t uc_admin;//ÉÏλ»úȨÏÞ
//    uint16_t plant_number;//³§¼Ò±àºÅ BCD
//    uint16_t protocol_ver;//ЭÒé°æ±¾ BCD
//    uint16_t random_number;//Ëæ»úÂë
//    uint8_t cmd_code;//¿ØÖÆÂë
//    uint16_t data_field_length;//Êý¾ÝÓò³¤¶È
// }UC_PROTOCOL_HEAD_T;
 
#pragma pack()
 
extern __IO uint8_t uc_return_flag_g;
 
extern UC_RECV_PARA_T uc_recv_para_g;
// extern UC_RECV_DATA_UNION_T uc_recv_buf_union_g;
// extern UC_PROTOCOL_HEAD_T uc_protocol_head_g;
 
void Upper_ComputerCommProcess(UC_RECV_PARA_T *uc_rec_para_p);
 
/*ÓÉÓÚÄ£¿é»¯±à³Ì£¬ÎÒÃÇÏÞ¶¨APIÍ·ÎļþÖ»Äܱ»Ö÷Îļþinclude£¨°üº¬£©£¬
ËùÒÔµ±APIÎļþºÍÖ÷ÎļþÓÐÄÚÈÝÐèÒª»¥Ïàµ÷ÓÃʱ£¬Ðè°ÑAPIµÄÍ·Îļþ·ÅÔÚ×îºó£¬ÒÔÃâ³ö´í*/
#include "upper_computer_rw_api.h"
#include "upper_computer_read_log_api.h"
#include "upper_computer_iap_api.h"
#endif