CI130X SDK API手册  2.2.0
本手册用于描述CI130X SDK各个组件和驱动API
voice_module_uart_protocol.h
浏览该文件的文档.
1 
2 
3 #include <stdint.h>
4 #include <stdbool.h>
5 #include <string.h>
6 
7 
8 #include "ci130x_uart.h"
9 #include "command_info.h"
10 #include "sdk_default_config.h"
11 
12 
13 #ifndef _VOICE_MODULE_UART_PROTOCOL_
14 #define _VOICE_MODULE_UART_PROTOCOL_
15 
16 #if 1//(UART_PROTOCOL_VER == 2)
17 
18 #ifdef __cplusplus
19 extern "C"
20 {
21 #endif
22 
30 #define VMUP_PROTOCOL_VERSION 1
32 #define VMUP_PROTOCOL_SUBVERSION 0
34 #define VMUP_PROTOCOL_REVISION 0
36 
38 #define VMUP_MSG_DATA_MAX_SIZE (20)
39 
44 #pragma pack(1)
45 typedef struct
46 {
48  uint16_t header;
50  uint16_t data_length;
52  uint8_t msg_type;
54  uint8_t msg_cmd;
56  uint8_t msg_seq;
58  uint8_t msg_data[VMUP_MSG_DATA_MAX_SIZE];
59  /*uint16_t chksum; send add auto*/
60  /*uint8_t tail; send add auto*/
62 #pragma pack()
63 
64 /*header*/
66 #define VMUP_MSG_HEAD_LOW (0xA5)
67 #define VMUP_MSG_HEAD_HIGH (0xFC)
69 #define VMUP_MSG_HEAD ((VMUP_MSG_HEAD_HIGH<<8)|VMUP_MSG_HEAD_LOW)
71 
72 
73 /*tail*/
75 #define VMUP_MSG_TAIL (0xFB)
76 
77 
78 /*msg_type*/
80 #define VMUP_MSG_TYPE_CMD_UP (0xA0)
81 #define VMUP_MSG_TYPE_CMD_DOWN (0xA1)
83 #define VMUP_MSG_TYPE_ACK (0xA2)
85 #define VMUP_MSG_TYPE_NOTIFY (0xA3)
87 
88 
89 /*msg_cmd*/
91 #define VMUP_MSG_CMD_ASR_RESULT (0x91)
92 #define VMUP_MSG_CMD_PLAY_VOICE (0x92)
94 #define VMUP_MSG_CMD_GET_FLASHUID (0x93)
96 #define VMUP_MSG_CMD_GET_VERSION (0x94)
98 #define VMUP_MSG_CMD_RESET_MODULE (0x95)
100 #define VMUP_MSG_CMD_SET_CONFIG (0x96)
102 //#define VMUP_MSG_CMD_ENTER_OTA_MODE (0x97) //进入升级模式
104 #define VMUP_MSG_CMD_NOTIFY_STATUS (0x9A)
105 #define VMUP_MSG_CMD_ACK_COMMON (0xAA)
107 /* !!! if user want add please add form VMUP_MSG_CMD_USER_START*/
108 // #define VMUP_MSG_CMD_USER_START (0xB0)
109 
110 
111 /*msg_data msg_cmd:VMUP_MSG_CMD_PLAY_VOICE*/
113 #define VMUP_MSG_DATA_PLAY_START (0x80)
114 #define VMUP_MSG_DATA_PLAY_PAUSE (0x81)
116 #define VMUP_MSG_DATA_PLAY_RESUME (0x82)
118 #define VMUP_MSG_DATA_PLAY_STOP (0x83)
120 
122 #define VMUP_MSG_DATA_PLAY_BY_VOICEID (0x90)
123 #define VMUP_MSG_DATA_PLAY_BY_SEMANTIC_ID (0x91)
125 #define VMUP_MSG_DATA_PLAY_BY_CMD_ID (0x92)
127 
128 
129 /*msg_data msg_cmd:VMUP_MSG_CMD_GET_VERSION*/
131 #define VMUP_MSG_DATA_VER_PROTOCOL (0x80)
132 #define VMUP_MSG_DATA_VER_SDK (0x81)
134 #define VMUP_MSG_DATA_VER_ASR (0x82)
136 #define VMUP_MSG_DATA_VER_PREPROCESS (0x83)
138 #define VMUP_MSG_DATA_VER_PLAYER (0x84)
140 #define VMUP_MSG_DATA_VER_APP (0x8A)
142 
143 
144 /*msg_data msg_cmd:VMUP_MSG_CMD_NOTIFY_STATUS*/
146 #define VMUP_MSG_DATA_NOTIFY_POWERON (0xB0)
147 #define VMUP_MSG_DATA_NOTIFY_WAKEUPENTER (0xB1)
149 #define VMUP_MSG_DATA_NOTIFY_WAKEUPEXIT (0xB2)
151 #define VMUP_MSG_DATA_NOTIFY_PLAYSTART (0xB3)
153 #define VMUP_MSG_DATA_NOTIFY_PLAYEND (0xB4)
155 
156 
157 /*msg_data msg_cmd:VMUP_MSG_CMD_SET_CONFIG*/
159 #define VMUP_MSG_CMD_SET_VOLUME (0x80)
160 #define VMUP_MSG_CMD_SET_ENTERWAKEUP (0x81)
162 // #define VMUP_MSG_CMD_SET_PRT_MID_RST (0x82)
164 #define VMUP_MSG_CMD_SET_MUTE (0x83)
165 // #define VMUP_MSG_CMD_SET_NEEDACK (0x90)
166 // #define VMUP_MSG_CMD_SET_NEEDSTRING (0x91)
167 
168 
169 /*ACK error code*/
171 #define VMUP_MSG_ACK_ERR_NONE (0x0)
172 // #define VMUP_MSG_ACK_ERR_CHECKSUM (0xff)
174 #define VMUP_MSG_ACK_ERR_NOSUPPORT (0xfe)
175 
181 void vmup_receive_packet(uint8_t receive_char);
182 
187 void vmup_communicate_init(void);
188 
194 void vmup_send_notify(uint8_t notify_event);
195 
202 
209 // void userapp_send_com_test(void);
210 
217 void vmup_send_asr_result_cmd(cmd_handle_t cmd_handle, uint8_t asr_score);
218 
221 #ifdef __cplusplus
222 }
223 #endif
224 
225 #endif //#if (UART_PROTOCOL_VER == 2)
226 
227 #endif
228 
uint8_t msg_seq
协议序列号
Definition: voice_module_uart_protocol.h:56
2代串口协议结构体定义
Definition: voice_module_uart_protocol.h:45
uint16_t data_length
数据长度
Definition: voice_module_uart_protocol.h:50
#define VMUP_MSG_DATA_MAX_SIZE
协议数据最大长度,可配置
Definition: voice_module_uart_protocol.h:38
void vmup_send_asr_result_cmd(cmd_handle_t cmd_handle, uint8_t asr_score)
报告语音识别结果
Definition: voice_module_uart_protocol.c:448
uint16_t header
协议头
Definition: voice_module_uart_protocol.h:48
此模块用于查询和读取命令词信息(来源于命令词信息excel表格).
uint8_t msg_type
协议类型
Definition: voice_module_uart_protocol.h:52
UART驱动文件
void vmup_send_notify(uint8_t notify_event)
发送通知类协议
Definition: voice_module_uart_protocol.c:417
uint8_t msg_cmd
协议命令
Definition: voice_module_uart_protocol.h:54
void userapp_deal_cmd(sys_msg_com_data_t *msg)
根据协议命令控制不同的功能
Definition: voice_module_uart_protocol.c:656
void vmup_communicate_init(void)
2代串口协议初始化
Definition: voice_module_uart_protocol.c:402
void vmup_receive_packet(uint8_t receive_char)
串口RX中断接收协议,发送到消息处理任务
Definition: voice_module_uart_protocol.c:223
void * cmd_handle_t
定义命令词信息结构的句柄类型。
Definition: command_info_v2.h:54
sdk配置文件
void userapp_deal_com_msg(sys_msg_com_data_t *msg)
用户层解析RX接收到的协议,根据协议类型分开处理
Definition: voice_module_uart_protocol.c:810