ReSpeaker DSP V02
Dependencies: mbed MbedJSONValue
Diff: main.cpp
- Revision:
- 2:59c1a24aed7c
- Parent:
- 1:574b54755983
- Child:
- 3:48258b86e182
--- a/main.cpp Sun Feb 11 15:13:52 2018 +0000 +++ b/main.cpp Mon Feb 19 10:52:46 2018 +0000 @@ -3,8 +3,10 @@ // Arkadiraf@gmail.com - 11/02/2018 // //////////////////////////////////////// /* + Json Format: json:{"name":"dsp","filter":"none","mode":"off"}\r\n +*/ -*/ + /* Board : Nucleo STM32F446RE @@ -76,6 +78,9 @@ // uart Serial pc(USBTX, USBRX); +// uart switch_dsp +Serial switch_dsp(PC_10, PC_11); + // digital DigitalIn user_button(PC_13); DigitalIn sw_trigger(PA_10); @@ -166,8 +171,16 @@ initDSP(); pc.baud(57600); + switch_dsp.baud(57600); + + + // pc is used for debbuging, in application mode the commands are from the switch_dsp. // attach serial event interrupt pc.attach(&rxCallback, Serial::RxIrq); + + // attach serial event interrupt + switch_dsp.attach(&rxCallback, Serial::RxIrq); + #ifdef DEBUG_MOD1 pc.printf("ReSpeaker Test \r\n"); #endif @@ -206,17 +219,22 @@ Dac_Reg += __HAL_DHR12R1_ALIGNEMENT(DAC_ALIGN_12B_R); // intialize filter function pointer - FilterFunction = no_filter; + FilterFunction = no_filter;//highpath_filter;//no_filter; } // Serial Event function void rxCallback(void) { - while (pc.readable()) { + while ((pc.readable()) || (switch_dsp.readable())) { // read icoming + uint8_t in_byte=0; //led = !led; - uint8_t in_byte = pc.getc(); + if (pc.readable()) { + in_byte = pc.getc(); + } else if (switch_dsp.readable()) { + in_byte = switch_dsp.getc(); + } #ifdef DEBUG_MOD1 pc.putc(in_byte); #endif @@ -365,6 +383,7 @@ #ifdef DEBUG_MOD10 // send parsed values pc.printf("filter: %s , mode: %s\r\n", filterType.c_str(),modeType.c_str()); + switch_dsp.printf("filter: %s , mode: %s\r\n", filterType.c_str(),modeType.c_str()); #endif // selected operation mode if ( filterType == "none" ) { @@ -372,7 +391,7 @@ } else if( filterType == "hpf" ) { FilterFunction = highpath_filter; } else { - pc.printf("fundefined filter %s \r\n", filterType.c_str()); + switch_dsp.printf("undefined filter %s \r\n", filterType.c_str()); FilterFunction = no_filter; } @@ -380,7 +399,7 @@ if ( modeType == "off" ) { } else if( modeType == "on" ) { } else { - pc.printf("fundefined filter %s \r\n", modeType.c_str()); + switch_dsp.printf("undefined filter %s \r\n", modeType.c_str()); } }// end dspPacket \ No newline at end of file