100 lines
2.2 KiB
C
100 lines
2.2 KiB
C
|
|
#ifndef _UART_SET_H
|
|||
|
|
#define _UART_SET_H
|
|||
|
|
#include "STC8xxxx.h"
|
|||
|
|
#define USART_CMD_QUEST 0x20
|
|||
|
|
#define USART_CMD_SET_BRIGHTNESS 0x21
|
|||
|
|
#define USART_CMD_SET_MODE 0x22
|
|||
|
|
#define USART_CMD_ALL_BRIGHTNESS 0x23
|
|||
|
|
#define USART_CMD_SWITCH_STATUS 0x24
|
|||
|
|
#define USART_CMD_DEBUG_SET 0x25 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD>㹻<EFBFBD>Ҳ<EFBFBD><D2B2>ÿ<EFBFBD><C3BF>ƣ<EFBFBD>Ĭ<EFBFBD><C4AC>Ϊ<EFBFBD><CEAA>
|
|||
|
|
#define Usart_CMD_Version 0x26
|
|||
|
|
|
|||
|
|
#define USART_TEST_MODE 0xE0
|
|||
|
|
#define USART_TEST_DATA 0xE1
|
|||
|
|
|
|||
|
|
#define USART_CMD_QUEST_A 0x30
|
|||
|
|
#define USART_CMD_SET_BRIGHTNESS_A 0x31
|
|||
|
|
#define USART_CMD_SET_MODE_A 0x32
|
|||
|
|
#define USART_CMD_ALL_BRIGHTNESS_A 0x33
|
|||
|
|
#define USART_CMD_SWITCH_STATUS_A 0x34
|
|||
|
|
#define USART_CMD_DEBUG_SET_A 0x35
|
|||
|
|
#define Usart_CMD_Version_A 0x36
|
|||
|
|
|
|||
|
|
#define USART_TEST_MODE_A 0xF0
|
|||
|
|
#define USART_TEST_DATA_A 0xF1
|
|||
|
|
|
|||
|
|
#define ADDR_RX 0x01 //C12_CH12<31>ĵ<EFBFBD>ַ
|
|||
|
|
#define DEV_TYPE 0x03
|
|||
|
|
|
|||
|
|
#define Version_High 0x13 //<2F><><EFBFBD><EFBFBD><EFBFBD>汾
|
|||
|
|
#define Version_Low 0x00
|
|||
|
|
|
|||
|
|
typedef enum
|
|||
|
|
{
|
|||
|
|
UART_FMT_ADDR_TX = 0x00,
|
|||
|
|
UART_FMT_TYPE,
|
|||
|
|
UART_FMT_DEV_TYPE,
|
|||
|
|
UART_FMT_ADDR_RX,
|
|||
|
|
UART_FMT_LEN,
|
|||
|
|
UART_FMT_CKS,
|
|||
|
|
UART_FMT_CMD,
|
|||
|
|
} UART_FMT_e;
|
|||
|
|
|
|||
|
|
typedef struct Usart
|
|||
|
|
{
|
|||
|
|
u8 lastsn;
|
|||
|
|
u8 Sn;
|
|||
|
|
u8 ok_flag;
|
|||
|
|
u8 recv_buffer[32];
|
|||
|
|
}xdata G_Usart;
|
|||
|
|
|
|||
|
|
typedef struct answer
|
|||
|
|
{
|
|||
|
|
u8 short_answer[7];
|
|||
|
|
u8 long_answer[20];
|
|||
|
|
u8 long_answer_flag;
|
|||
|
|
u8 short_answer_flag;
|
|||
|
|
u8 version_answer_flag;
|
|||
|
|
u8 version_answer[9];
|
|||
|
|
}xdata G_answer;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ݵĽṹ<C4BD><E1B9B9>
|
|||
|
|
/*
|
|||
|
|
* <EFBFBD>ĸ<EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ܱ<EFBFBD>־λ
|
|||
|
|
* flag1ָ<EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD>0x21
|
|||
|
|
* flag2ָ<EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD>0x22
|
|||
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⣬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
*/
|
|||
|
|
typedef struct
|
|||
|
|
{
|
|||
|
|
u16 flag1[12];
|
|||
|
|
u16 flag2[12];
|
|||
|
|
|
|||
|
|
//0x21
|
|||
|
|
u16 gradual_time[12];
|
|||
|
|
u16 B_Ch[12];
|
|||
|
|
|
|||
|
|
//0x22
|
|||
|
|
u16 mode[12];
|
|||
|
|
u16 forward[12];
|
|||
|
|
u16 pwm_step[12];
|
|||
|
|
|
|||
|
|
//0x23
|
|||
|
|
u16 global_brightness;
|
|||
|
|
u16 B_max;
|
|||
|
|
u16 B_min;
|
|||
|
|
// u16 changeflag;
|
|||
|
|
|
|||
|
|
//0x24
|
|||
|
|
u16 key_status[12];
|
|||
|
|
}xdata S_recv;
|
|||
|
|
|
|||
|
|
extern S_recv s_recv;
|
|||
|
|
extern G_answer g_answer;
|
|||
|
|
extern G_Usart g_Usart;
|
|||
|
|
void Usart_Deal_Data(void);
|
|||
|
|
void Usart_judge_Data(void);
|
|||
|
|
void Usart_answer(void);
|
|||
|
|
u8 sumfunc(u8* answer,u8 len);
|
|||
|
|
extern u8 debug;
|
|||
|
|
#endif
|