5.1 Introduction to the TWEN-ASR-One Serial Port
About the serial port here I will not repeat, I believe that made embedded friends often used.
The author here briefly introduces the TWen-ASR-One serial port.
Twen-asr-one Development board has two serial ports: serial port 0 and serial port 1. The pins of serial port 0 are fixed to P1_7 and P2_0, while serial port 1 can be set to P0_5 and P0_6. P2_1, P2_2; P3_0, P3_1. As shown below:
5.2 TWEN-ASr-One Serial Port Printing Example
Twen-asr-one uses serial port 0 as the debugging download port, and the author still uses serial port 0 to print output. The serial port has the following setting blocks.
Serial communication is mainly serial port Settings, receiving data and sending data, or relatively simple.
Here is a direct example, in which the serial port outputs the corresponding string according to different commands.
The graphic code is as follows:
The character code is as follows:
#include "asr.h"
#include "setup.h"
#include "myLib/asr_event.h"
uint32_t snid;
/ / {ID: 250, keyword: "command word," ASR: "the largest volume," ASRTO: "the volume adjustment to the largest}"
/ / {ID: 251, keyword: "command word," ASR: "middle level", ASRTO: "the volume adjustment to moderate}"
/ / {ID: 252, keyword: "command word," ASR: "minimum volume," ASRTO: "the volume adjustment to minimum}"
void ASR_CODE(a)
{
//{ID:29,keyword:"唤醒词",ASR:"智能管家",ASRTO:"我在"}
if(snid == 29){
Serial.println("1");
}
//{ID:30,keyword:" keyword ",ASR:" fan on ",ASRTO:" fan on "}
if(snid == 30){
Serial.println("2");
}
//{ID:31,keyword:" fan is off ",ASRTO:" fan is off "}
if(snid == 31){
Serial.println("3");
}
//{ID:32,keyword:"命令词",ASR:"最大风速",ASRTO:"已执行"}
if(snid == 32){
Serial.println("4");
}
//{ID:33,keyword:"命令词",ASR:"中等风速",ASRTO:"已执行"}
if(snid == 33){
Serial.println("5");
}
//{ID:34,keyword:"命令词",ASR:"最小风速",ASRTO:"已执行"}
if(snid == 34){
Serial.println("6");
}
//{ID:35,keyword:",ASR:",ASRTO:" executed "}
if(snid == 35){
Serial.println("Seven");
}
//{ID:36,keyword:" fan stop ",ASRTO:" executed "}
if(snid == 36){
Serial.println("8"); }}void setup(a)
{
// As a voice recognition sensor, output identification ID through the serial port for other master to judge
//Serial is the USB download port, Serial1 is P30(RX), P31(TX)
/ / {speak: small butterfly - and fresh girl, vol. 10, speed: 10, platform: haohaodada}
//{playid:10001,voice: Welcome to smart butler, wake me up with smart butler. }
//{playid:10002,voice: I quit, wake me up with smart butler}
Serial.begin(9600);
Serial.setTimeout(10);
}
Copy the code
Compile and download.
The final effect is as follows:
Me: Smart butler
Twen-asr-one: I am on. Twen-asr-one: The fan is on. Twen-asr-one: the fan is on
Open the serial debugging assistant, you can see the corresponding character output.