[Mod] 暂存,LED、fscan非中断

This commit is contained in:
2023-06-18 15:59:15 +00:00
parent f4ac7db357
commit f453b08452
3 changed files with 42 additions and 7 deletions

View File

@ -589,7 +589,7 @@
<Group> <Group>
<GroupName>Bsp</GroupName> <GroupName>Bsp</GroupName>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>

View File

@ -46,6 +46,8 @@ OF SUCH DAMAGE.
#include "main.h" #include "main.h"
#include "wifi_version.h" #include "wifi_version.h"
#include "nspe_region.h" #include "nspe_region.h"
#include <stdint.h>
#include <stdio.h>
#ifdef CONFIG_FATFS_SUPPORT #ifdef CONFIG_FATFS_SUPPORT
#include "fatfs.h" #include "fatfs.h"
#endif #endif
@ -91,13 +93,12 @@ static int32_t led_init(void)
void led_task(void *p_arg) void led_task(void *p_arg)
{ {
uint32_t count = 0;
while (1) { while (1) {
gd_eval_led_toggle(LED1); gd_eval_led_toggle(((int32_t)(count % 12) - 6) < 0 ? count % 3 : (2 - count % 3));
sys_ms_sleep(200);
gd_eval_led_toggle(LED2);
sys_ms_sleep(200);
gd_eval_led_toggle(LED3);
sys_ms_sleep(200); sys_ms_sleep(200);
count++;
} }
sys_task_delete(NULL); sys_task_delete(NULL);
@ -124,6 +125,11 @@ __WEAK void app_init(void)
void start_task(void *p_arg) void start_task(void *p_arg)
{ {
(void)p_arg; (void)p_arg;
#if defined (CONFIG_GY3513)
size_t len;
uint8_t read_buf[2000];
const char *filename;
#endif // CONFIG_GY3513
sys_reset_flag_check(); sys_reset_flag_check();
sys_os_misc_init(); sys_os_misc_init();
@ -134,12 +140,33 @@ void start_task(void *p_arg)
rcu_periph_clock_enable(RCU_CRC); rcu_periph_clock_enable(RCU_CRC);
fatfs_mk_mount(); fatfs_mk_mount();
#endif #endif
#ifdef CONFIG_CONSOLE_ENABLE #ifdef CONFIG_CONSOLE_ENABLE
console_init(); console_init();
#else #else
app_init(); app_init();
#endif #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); sys_task_delete(NULL);
} }

View File

@ -36,6 +36,7 @@ OF SUCH DAMAGE.
#include <ctype.h> #include <ctype.h>
#include "app_cfg.h" #include "app_cfg.h"
#include "bsp_inc.h" #include "bsp_inc.h"
#include "gd32w51x_usart.h"
#include "uart.h" #include "uart.h"
#include "malloc.h" #include "malloc.h"
#include "wifi_netlink.h" #include "wifi_netlink.h"
@ -46,6 +47,7 @@ char uart_buf[UART_BUFFER_SIZE];
int index = 0; int index = 0;
#if defined(__ARMCC_VERSION) #if defined(__ARMCC_VERSION)
//#if 1
/* retarget the C library printf function to the USART */ /* retarget the C library printf function to the USART */
int fputc(int ch, FILE *f) int fputc(int ch, FILE *f)
{ {
@ -54,6 +56,12 @@ int fputc(int ch, FILE *f)
return ch; return ch;
} }
int fgetc(FILE *f)
{
while(RESET == usart_flag_get(LOG_UART, USART_FLAG_RBNE));
return usart_data_receive(LOG_UART);
}
#elif defined(__ICCARM__) #elif defined(__ICCARM__)
int putchar(int ch) int putchar(int ch)
{ {
@ -126,7 +134,7 @@ void usart_config(uint32_t usart_periph)
usart_baudrate_set(usart_periph, 115200); usart_baudrate_set(usart_periph, 115200);
usart_receive_config(usart_periph, USART_RECEIVE_ENABLE); usart_receive_config(usart_periph, USART_RECEIVE_ENABLE);
usart_transmit_config(usart_periph, USART_TRANSMIT_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); usart_enable(usart_periph);
} }