2 Commits

3 changed files with 30 additions and 23 deletions

View File

@ -4,7 +4,7 @@
#==============================================================================#
LOCAL_DIR := $(strip $(shell pwd))
SDK_TOP := $(LOCAL_DIR)
CMAKE_DIR := $(LOCAL_DIR)/.cmake
CMAKE_DIR := $(LOCAL_DIR)/output/.cmake
OUTPUT_DIR ?= $(LOCAL_DIR)/output
INSTALL_DIR ?= $(LOCAL_DIR)/__install
@ -39,7 +39,8 @@ check_env:
mkdir -p $(CMAKE_DIR); \
cmake -G "Unix Makefiles" \
-S $(LOCAL_DIR) -B $(CMAKE_DIR) \
-DCMAKE_TOOLCHAIN_FILE:PATH=$(SDK_TOP)/scripts/cmake/toolchain.cmake; \
-DCMAKE_TOOLCHAIN_FILE:PATH=$(SDK_TOP)/scripts/cmake/toolchain.cmake \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1;\
fi;
clean: check_env $(CLEAN_ALL)

View File

@ -147,26 +147,6 @@ void start_task(void *p_arg)
app_init();
#endif
#if defined (CONFIG_GY3513)
#if 0
printf("reading input from file... ");
fflush(stdout);
filename = "Test.txt";
LWIP_ASSERT("invalid filename", filename != NULL);
f = fopen(filename, "rb");
LWIP_ASSERT("open failed", f != NULL);
len = fread(pktbuf, 1, sizeof(pktbuf), f);
len = fwrite(pktbuf, 1, sizeof(pktbuf), f);
fclose(f);
printf("testing file: \"%s\"...\r\n", filename);
#else
fprintf(stdout, "What is your name?\r\n");
fscanf(stdin, "%s", read_buf);
fprintf(stdout, "\nHello, %s\r\n", read_buf);
#endif
#endif // CONFIG_GY3513
sys_task_delete(NULL);
}

View File

@ -37,6 +37,7 @@ OF SUCH DAMAGE.
#include "app_cfg.h"
#include "bsp_inc.h"
#include "gd32w51x_usart.h"
#include "platform_def.h"
#include "uart.h"
#include "malloc.h"
#include "wifi_netlink.h"
@ -90,6 +91,31 @@ int _write(int fd, char *str, int len)
return i;
}
int _read(int handle, char *buffer, int size)
{
uint8_t ch = 0U;
int actualSize = 0;
/* This function only reads from "standard in", for all other file handles it returns failure. */
if (handle != 0) {
return -1;
}
/* Receive data. */
for (; size > 0; size--) {
while(RESET == usart_flag_get(LOG_UART, USART_FLAG_RBNE));
*buffer++ = (char)usart_data_receive(LOG_UART);
actualSize++;
if ((ch == 0U) || (ch == (uint8_t)'\n') || (ch == (uint8_t)'\r')) {
break;
}
}
return (actualSize > 0) ? actualSize : -1;
}
#endif
/*!
@ -134,7 +160,7 @@ void usart_config(uint32_t usart_periph)
usart_baudrate_set(usart_periph, 115200);
usart_receive_config(usart_periph, USART_RECEIVE_ENABLE);
usart_transmit_config(usart_periph, USART_TRANSMIT_ENABLE);
//usart_interrupt_enable(usart_periph, USART_INT_RBNE);
usart_interrupt_enable(usart_periph, USART_INT_RBNE);
usart_enable(usart_periph);
}