test
Dependencies: mbed-STM32F103C8T6 mbed-rtos mbed-dev
main.cpp
- Committer:
- hankzhang
- Date:
- 2020-04-18
- Revision:
- 3:30d61fa10b98
- Parent:
- 2:f48b0967b6cc
- Child:
- 4:864bb8bde75c
File content as of revision 3:30d61fa10b98:
#include "mbed.h" #include "stm32f103c8t6.h" #include "string.h" #include "main.h" 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[64]; int i = 0; ATCmdParser *_parser; void led2_thread() { while (true) { debug_uart.write("led2+++", 6); thread_sleep_for(4000); } } void debug_uart_recv() { //rxBuf[i++] = debug_uart.getc(); debug_uart.read(rxBuf, 5); } 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); //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); } }