From ae079c1fc5d990ba55714d4b3a51b19f96edaec4 Mon Sep 17 00:00:00 2001 From: WXK <287788329@qq.com> Date: 星期四, 24 四月 2025 16:01:43 +0800 Subject: [PATCH] 改为中断来低电平触发发送当前扫描数据,3s内扫描不到的会退出,串口来55 AA 75 70 64 61 74 65,进入升级模式 --- 01_SDK/modules/hal/panchip/panplat/pan1070/bsp/device/Source/retarget.c | 61 ++++++++++++++---------------- 1 files changed, 29 insertions(+), 32 deletions(-) diff --git a/01_SDK/modules/hal/panchip/panplat/pan1070/bsp/device/Source/retarget.c b/01_SDK/modules/hal/panchip/panplat/pan1070/bsp/device/Source/retarget.c index 51ec47f..c2db794 100644 --- a/01_SDK/modules/hal/panchip/panplat/pan1070/bsp/device/Source/retarget.c +++ b/01_SDK/modules/hal/panchip/panplat/pan1070/bsp/device/Source/retarget.c @@ -10,8 +10,12 @@ *****************************************************************************/ #include <stdio.h> #include "PanSeries.h" +#if CONFIG_RTT_LOG_ENABLE +#include "SEGGER_RTT.h" +#endif -#define UART0_ENABLE (1) +/* Suppress the build warning #111-D: statement is unreachable */ +#pragma diag_suppress 111 #if defined ( __CC_ARM ) #if (__ARMCC_VERSION < 400000) @@ -28,14 +32,6 @@ #else #define DEBUG_PORT UART0 #endif - -/* Un-comment this line to disable all printf and getchar. getchar() will always return 0x00*/ -//#define DISABLE_UART - -/*---------------------------------------------------------------------------------------------------------*/ -/* Global variables */ -/*---------------------------------------------------------------------------------------------------------*/ - //#if !(defined(__ICCARM__) && (__VER__ >= 6010000)) //struct __FILE { int handle; /* Add whatever you need here */ }; @@ -60,15 +56,21 @@ void Hard_Fault_Handler(uint32_t stack[]) { +#if CONFIG_IO_TIMING_TRACK + PAN_IO_TIMING_TRACK_LEVEL(CONFIG_TRACK_PIN_HARDFAULT_IRQ, 1); +#endif + printf("In Hard Fault Handler\r\n"); stackDump(stack); - //Chip Reset - //SYS_UnlockReg(); - //SYS->IPRSTC1 |= SYS_IPRSTC1_CHIP_RST_Msk; + while(1){}; - while(1); + // Although program won't run into here, we write a statement + // just for symmetry. +#if CONFIG_IO_TIMING_TRACK + PAN_IO_TIMING_TRACK_LEVEL(CONFIG_TRACK_PIN_HARDFAULT_IRQ, 0); +#endif } @@ -334,14 +336,8 @@ void SendChar_ToUART(int ch) { -#ifndef DISABLE_UART - -#if (UART0_ENABLE) - while(UART_IsTxFifoFull(DEBUG_PORT)); - DEBUG_PORT->RBR_THR_DLL = ch; -#endif //UART0_ENABLE - -#endif //DISABLE_UART + while(UART_IsTxFifoFull(DEBUG_PORT)); + DEBUG_PORT->RBR_THR_DLL = ch; } @@ -374,7 +370,13 @@ g_buf_len = 0; } } -#else +#endif + +#if CONFIG_RTT_LOG_ENABLE + SEGGER_RTT_PutCharSkipNoLock(0, ch); +#endif + +#if CONFIG_UART_LOG_ENABLE SendChar_ToUART(ch); #endif } @@ -409,7 +411,8 @@ } #endif #endif -#ifndef DISABLE_UART + +#if CONFIG_UART_LOG_ENABLE while (1) { if((DEBUG_PORT->USR & UART_USR_RFNE_Msk)) @@ -417,8 +420,10 @@ return (DEBUG_PORT->RBR_THR_DLL); } } +#elif CONFIG_RTT_LOG_ENABLE + return SEGGER_RTT_WaitKey(); #else - return(0); + return 0; #endif } @@ -432,11 +437,7 @@ */ int kbhit(void) { -#ifndef DISABLE_UART return (DEBUG_PORT->USR & UART_USR_RFNE_Msk); -#else - return(0); -#endif } /** @@ -448,11 +449,7 @@ */ int IsDebugFifoEmpty(void) { -#ifndef DISABLE_UART return (DEBUG_PORT->USR & UART_USR_TFE_Msk) ? 1 : 0; -#else - return(1); -#endif } /*---------------------------------------------------------------------------------------------------------*/ -- Gitblit v1.9.3