share it to hank
Dependencies: mbed-STM32F103C8T6_new
main_ori.cpp
- Committer:
- bbw
- Date:
- 2020-05-15
- Revision:
- 8:611fef4d4b5d
- Parent:
- 4:864bb8bde75c
File content as of revision 8:611fef4d4b5d:
#include "mbed.h" #include "stm32f103c8t6.h" #include "string.h" #include "main.h" #if 0 DigitalOut led1(PC_13); //Serial pc(PB_10,PB_11); UARTSerial *_serial; UARTSerial debug_uart(PB_10, PB_11, 115200); UARTSerial wifi_uart(PA_2, PA_3, 115200); char rxBuf[32]; char wifi_rxBuf[32]; int i = 0; ATCmdParser *_parser; void led1_thread() { int length; while (true) { wifi_uart.write("get_down\r", 9); if(wifi_uart.readable()) { length = wifi_uart.read(wifi_rxBuf, sizeof(wifi_rxBuf)); debug_uart.write(wifi_rxBuf, length); } thread_sleep_for(400); } } void led0_thread() { int length; while (1) { if(debug_uart.readable()) { length = debug_uart.read(rxBuf, sizeof(rxBuf)); debug_uart.write(rxBuf, length); wifi_uart.write(rxBuf, length); debug_uart.write("111\r",4); } if(wifi_uart.readable()) { length = wifi_uart.read(rxBuf, sizeof(rxBuf)); debug_uart.write(rxBuf, length); debug_uart.write("222\r",4); } wait(0.5); } } int main() { int length; led1 = 1; wait(2); //debug_uart.printf("hello world\r\n"); debug_uart.write("hello world",11); WIFI_PWREN = 1; #if 0 while(1){ if(debug_uart.readable()) { length = debug_uart.read(rxBuf, sizeof(rxBuf)); debug_uart.write(rxBuf, length); debug_uart.write("test",4); } wait(0.5); } //wifi_debug(); _serial = new UARTSerial(PA_2, PA_3, 115200); _parser = new ATCmdParser(_serial); _parser->debug_on( 1 ); _parser->set_delimiter("\r\n"); debug_uart.printf("\nATCmdParser: Retrieving model"); _parser->send("model\\r"); _parser->recv("%s", model); debug_uart.printf("model:%s", model); #endif Thread thread0(osPriorityNormal, 512, nullptr, nullptr); Thread thread1(osPriorityNormal, 512, nullptr, nullptr); //Thread thread2(osPriorityNormal, 512, nullptr, nullptr); thread0.start(led0_thread); thread1.start(led1_thread); //wifi_serial.printf("model\r\n"); //thread1.start(led1_thread); //thread2.start(led2_thread); while(1) { debug_uart.write("--main--\r\n",10); wait(3); } } #endif