CI130X serial port protocol V2¶
1. Overview¶
This document is our standard voice module serial port protocol design specification, which is convenient for rapid code development and review, and maintenance personnel understand the code framework.
1.1. Functions¶
- Complete transmission package, including: head and tail, length, check, message type, and message serial number;
- Support variable length commands for easy expansion;
- Message type (command, notification, reply);
- Command message, configurable, reply to ACK. The notification message has no ACK;
- The message format will be the same as that of the bootloader upgrade, which is distinguished from the bootloader protocol through the header;
- Add a unified semantic ID of 6 bytes. The tool needs to generate the corresponding header file to facilitate the use of the platform to make firmware. For more semantic ID descriptions, please refer to ☞CI130X Semantic ID Document Description;
- The default baud rate is 9600. The default serial port uses UART1 (the fastest serial port is 1M);
- Supported commands: query the protocol version number, query the system version number, set the volume (the volume rating is defined in user_config. h), play the local broadcast, reset the command, obtain UNIQUEID, and the command word is as compatible as possible with the standard board protocol on CI1006.
1.2. Performance¶
- The receiving is processed in interrupt mode and the output is processed in polling mode, so the standard board is not suitable for large data transmission;
- In terms of code implementation, copy is used to reduce unnecessary malloc/free, so this protocol is not suitable for long commands with too much data.
2. Introduction to the Agreement¶
2.1. Overview of Serial Port Command Format¶
Note: non single byte data in the protocol, low byte first, high byte last.
2.2. Command Details¶
2.2.1. Error reply¶
Note: Use this reply when sending an error
ACK:
2.2.2. Speech recognition results¶
Note: After entering the wake-up state, the voice module will send the message (including wake-up words) after recognizing the result.
CMD:
The format of the ACK package is as follows, but the function and retransmission mechanism are not implemented yet.
2.2.3. Play local broadcast¶
Note: It is used to play the broadcast saved in the firmware of the voice module.
CMD:
ACK :
2.2.4. Obtain UNIQUEID¶
Note: It is used to query the unique ID of flash. Note that this function requires the support of flash devices.
CMD:
ACK:
2.2.5. Get version number¶
Note: Used to query the SDK version number used by the firmware in the voice module.
CMD:
ACK:
2.2.6. Reset module¶
Description: Used to reset the voice module.
CMD:
ACK:
2.2.7. Setting function¶
Note: It is used to set some function options of the module and the serial port protocol.
CMD:
ACK:
2.2.8. Status notification¶
Note: It is used to send notification of voice module status change.
CMD:
2.2.9. Enter OTA mode¶
Note: It is used to set the voice module to enter the OTA mode.
CMD:
ACK:
3. Serial port protocol configuration¶
Specific configuration of serial communication:
It is recommended that developers configure the following under their own project path, and do not modify the sdk_ default_ config. H file. The following is sample_ Take the light project as an example to modify the serial port communication configuration. Open SDK projects sample_ light\user_ config.h.
#define MSG_ COM_ USE_ UART_ EN 1
#define UART_ PROTOCOL_ NUMBER (HAL_UART1_BASE)
#define UART_ PROTOCOL_ BAUDRATE (UART_BaudRate9600)
4. Serial port protocol instructions¶
CI130X serial port protocol V2 has the following characteristics:
- Complete transmission package, including header and footer, length, verification, message type, and message serial number.
- Support variable length commands for easy expansion.
- Message type (command, notification, reply).
- Command message, configurable, reply to ACK. The notification message has no ACK.
- The message format will be the same as that of the bootloader upgrade, which is distinguished from the bootloader protocol through the header.
- The default baud rate is 9600. The default serial port uses UART1 (the fastest serial port is 1M).
- Supported commands: query the protocol version number, query the system version number, set the volume (the volume rating is defined in user_config. h), play the local broadcast, reset commands, etc. The specific protocol format is shown in the following figure:
Example 1:
-
A5 FC 07 00 A0 91 18 01 55 E0 01 00 00 1B 9B 02 FB is resolved as follows:,
-
A5 FC:head
- 07 00: Valid data is 7byte
- A0: This is the command word information
- 91: The command number is 0x91 (this data content is command word data)
- 18: Package serial number, the 0x08th outgoing data of this serial port, and the value is continuously accumulated
- 01 55 E0 01 00 00: unique data of the current command word
- 1B: Command word threshold
- 9B 02: Cumulative Sum
- FB: End data
Example 2:
-
A5 FC 02 00 A3 9A 17 00 B1 05 02 FB is resolved as follows:
-
A5 FC :head
- 02 00: Valid data 2byte
- A3: currently notification data
- 9A: The command number is 0X9A (the data content is the voice module content change this time)
- 17: The serial port sends data for the 0x07th time, and the value is continuously accumulated
- 00 B1: Valid data. (This data indicates entering the wake-up state)
- 05 02: Cumulative Sum
- FB: End data
Reference figure of serial port protocol data:
In practical application, users can easily connect the electronic control board of the device with the CI130X chip (module) by using the serial port protocol. The module delivered by our company can be designated to burn the corresponding serial port protocol firmware. When users develop and upgrade traditional equipment to voice equipment, they can only add the code for the main control chip of the electronic control board to process the serial port protocol, instead of developing the code for the CI130X chip or module end, It reduces the learning time of voice chip development and improves the efficiency of program development.
Taking the clothes pole as an example, when the user connects the serial port of the electric control board with the serial port of the CI130X chip on the circuit, and the CI130X chip with serial port protocol firmware is burned to receive the corresponding voice command, the communication serial port of the CI130X chip will send the protocol data as shown in the following figure. If the user sends out the command word of “打开吹风”, the CI130X chip performs voice recognition. After recognition, it will send out the serial port protocol data as shown in the third line of the figure below. After receiving the data through the serial port, the main control chip of the electric control board of the clothes dryer processes the recognition and finds that it is the protocol sent out by the command word of “打开吹风”, which can control the motor and other equipment to perform the action of opening blowing.
matters needing attention:
-
Modify UART_ PROTOCOL_ When NUMBER, please confirm whether the serial port has been occupied by other peripherals or codes. The SDK uses UART0 as the log by default (for more logs, please refer to ☞SDK Quick Start Document CI130X_ Quit_ Start document) output port;
-
Other default parameters of serial communication: data bit: 8 bits, stop bit: 1 bit, no odd and even parity check. The serial port of the main control chip of the electric control board shall also be configured according to this parameter. If you need to modify, please modify UART in the corresponding UART initialization interface (UARTInterruptConfig, UARTPollingConfig, UARTDMAConfig)_ For the calling parameters of the LCRConfig function, refer to ☞General Asynchronous Transceiver Document.