diff --git a/prj/TCPClient/Startup/startup_ch32v30x_D8.S b/prj/TCPClient/Startup/startup_ch32v30x_D8.S index f3ec0ab..3371f55 100644 --- a/prj/TCPClient/Startup/startup_ch32v30x_D8.S +++ b/prj/TCPClient/Startup/startup_ch32v30x_D8.S @@ -336,10 +336,10 @@ handle_reset: li t0, 0x1f csrw 0xbc0, t0 /* Enable interrupt nesting and hardware stack */ - li t0, 0x0b + li t0, 0x1f csrw 0x804, t0 /* Enable floating point and global interrupt, configure privileged mode */ - li t0, 0x6088 + li t0, 0x7800 csrw mstatus, t0 /* Configure the interrupt vector table recognition mode and entry address mode */ la t0, _vector_base diff --git a/prj/TCPClient/Startup/startup_ch32v30x_D8C.S b/prj/TCPClient/Startup/startup_ch32v30x_D8C.S index 17c4f8e..d9adeb3 100644 --- a/prj/TCPClient/Startup/startup_ch32v30x_D8C.S +++ b/prj/TCPClient/Startup/startup_ch32v30x_D8C.S @@ -356,10 +356,10 @@ handle_reset: li t0, 0x1f csrw 0xbc0, t0 /* Enable interrupt nesting and hardware stack */ - li t0, 0x0b + li t0, 0x1f csrw 0x804, t0 -/* Enable floating point and global interrupt, configure privileged mode */ - li t0, 0x6088 +/* Enable global interrupt, configure privileged mode */ + li t0, 0x7800 csrw mstatus, t0 /* Configure the interrupt vector table recognition mode and entry address mode */ la t0, _vector_base diff --git a/prj/TCPClient/User/main.c b/prj/TCPClient/User/main.c index c8ee851..3c9819a 100644 --- a/prj/TCPClient/User/main.c +++ b/prj/TCPClient/User/main.c @@ -8,7 +8,6 @@ #include "FreeRTOS.h" #include "task.h" -#include "timers.h" #define MAX_TCP_PAYLOAD_SIZE 10240 uint8_t g_TxNetBuffer_A_Mem[MAX_TCP_PAYLOAD_SIZE]; @@ -40,13 +39,8 @@ void OnConfigUpdate(const ConfigCommon_t *common, const Config2D_t *cfg2d, const #define NG_GPIO_CLK RCC_APB2Periph_GPIOA #define NG_PULSE_MS 200 /* default NG pulse width */ -static TimerHandle_t g_ng_timer; - -static void ng_timer_callback(TimerHandle_t xTimer) -{ - (void)xTimer; - GPIO_ResetBits(NG_GPIO_PORT, NG_GPIO_PIN); -} +static volatile uint32_t g_ng_off_time = 0; +extern volatile uint32_t sys_tick_ms; static void NG_GPIO_Init(void) { @@ -57,9 +51,6 @@ static void NG_GPIO_Init(void) gpio.GPIO_Speed = GPIO_Speed_2MHz; GPIO_Init(NG_GPIO_PORT, &gpio); GPIO_ResetBits(NG_GPIO_PORT, NG_GPIO_PIN); - - g_ng_timer = xTimerCreate("ng", pdMS_TO_TICKS(NG_PULSE_MS), - pdFALSE, NULL, ng_timer_callback); } void OnDetectionResult(uint32_t frameNumber, uint8_t resultStatus) @@ -68,8 +59,7 @@ void OnDetectionResult(uint32_t frameNumber, uint8_t resultStatus) /* resultStatus: 0 = NG, 1 = OK */ if (resultStatus == 0) { GPIO_SetBits(NG_GPIO_PORT, NG_GPIO_PIN); - if (g_ng_timer) - xTimerStart(g_ng_timer, 0); + g_ng_off_time = sys_tick_ms + NG_PULSE_MS; } } @@ -222,6 +212,12 @@ static void task_business_entry(void *pvParameters) while (1) { + /* NG pulse off check */ + if (g_ng_off_time && sys_tick_ms >= g_ng_off_time) { + GPIO_ResetBits(NG_GPIO_PORT, NG_GPIO_PIN); + g_ng_off_time = 0; + } + DVP_Task(); if (Frame_Ready_Flag)