From 711f15677d6ec3196f588360782642ea9c0c3b7d Mon Sep 17 00:00:00 2001 From: gaoyang3513 Date: Fri, 2 Aug 2024 16:19:58 +0800 Subject: [PATCH] =?UTF-8?q?[Mod]=20=E6=94=AF=E6=8C=81=E5=8F=91=E9=80=81pin?= =?UTF-8?q?g=E5=91=BD=E4=BB=A4=E6=8E=A7=E5=88=B6=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Uart_PingPong/ebyte/ebyte_callback.c | 5 +- .../CMT2310/0_Project/Uart_PingPong/main.c | 46 ++++++++++--------- .../E48xMx/ebyte_e48x.c | 13 +++--- MBL/source_ns/mbl_ns.c | 1 + 4 files changed, 35 insertions(+), 30 deletions(-) diff --git a/MBL/source_ns/drivers/CMT2310/0_Project/Uart_PingPong/ebyte/ebyte_callback.c b/MBL/source_ns/drivers/CMT2310/0_Project/Uart_PingPong/ebyte/ebyte_callback.c index ba203b2..ea03e06 100755 --- a/MBL/source_ns/drivers/CMT2310/0_Project/Uart_PingPong/ebyte/ebyte_callback.c +++ b/MBL/source_ns/drivers/CMT2310/0_Project/Uart_PingPong/ebyte/ebyte_callback.c @@ -32,10 +32,10 @@ extern uint8_t BufferPong[5]; extern uint8_t Callback_isPingCheckReady; extern uint8_t PC_isConnected; extern uint8_t PcEchoBuffer[20]; +extern uint8_t is_jump_main; + /*==================================================================*/ - - /* ! * @brief 发送完成回调接口 由客户实现自己的发送完成逻辑 * @@ -113,6 +113,7 @@ void Ebyte_Port_ReceiveCallback( uint16_t state, uint8_t *buffer, uint8_t lengt Ebyte_BSP_LedControl( BSP_LED_1, ON ); if( ! PC_isConnected ) { + is_jump_main = 1; snprintf(rx_data, sizeof(rx_data), "%s", buffer); EBYTE_LOG("\r\n Receive Data: %s", rx_data); } diff --git a/MBL/source_ns/drivers/CMT2310/0_Project/Uart_PingPong/main.c b/MBL/source_ns/drivers/CMT2310/0_Project/Uart_PingPong/main.c index 2b791e0..b029b39 100755 --- a/MBL/source_ns/drivers/CMT2310/0_Project/Uart_PingPong/main.c +++ b/MBL/source_ns/drivers/CMT2310/0_Project/Uart_PingPong/main.c @@ -49,6 +49,8 @@ uint8_t Callback_isPingCheckReady = 0; /* 自检模式 标识 */ uint8_t PC_isConnected = 0; +uint8_t is_jump_main = 0; + static BSP_BTN_EVENT_t BTN_Event; /* ! @@ -56,32 +58,34 @@ static BSP_BTN_EVENT_t BTN_Event; */ int ebyte_main( void ) { - /* 板载硬件资源 初始化 */ - Ebyte_BSP_Init(); - /* (可选) 串口中断接收FIFO 可根据需要自行处理 */ - Ebyte_FIFO_Init( &hfifo, EBYTE_FIFO_SIZE ); - /* EBYTE 无线模块初始化 */ - Ebyte_RF.Init(); - /* 启用无线模块接收 */ - Ebyte_RF.EnterReceiveMode( 0 ); - /* MCU 开全局中断 */ - Ebyte_BSP_GlobalIntEnable(); + /* 板载硬件资源 初始化 */ + Ebyte_BSP_Init(); + /* (可选) 串口中断接收FIFO 可根据需要自行处理 */ + Ebyte_FIFO_Init( &hfifo, EBYTE_FIFO_SIZE ); + /* EBYTE 无线模块初始化 */ + Ebyte_RF.Init(); + /* 启用无线模块接收 */ + Ebyte_RF.EnterReceiveMode( 0 ); + /* MCU 开全局中断 */ + Ebyte_BSP_GlobalIntEnable(); - EBYTE_LOG( "Start PingPong.....\r\n" ); - EBYTE_LOG( "Please push button1 or button2.....\r\n" ); + EBYTE_LOG( "Start PingPong.....\r\n" ); + EBYTE_LOG( "Please push button1 or button2.....\r\n" ); - while( 1 ) { - /* 按键事件响应 */ - Task_Button(); + while( !is_jump_main ) { + /* 按键事件响应 */ + Task_Button(); - /* 任务:检测串口数据并无线发送 客户请按需自定义 */ - Task_Transmit(); + /* 任务:检测串口数据并无线发送 客户请按需自定义 */ + Task_Transmit(); - /* 任务:EBYTE驱动库必须的周期执行任务 客户无需修改 */ - Ebyte_RF.StartPollTask(); + /* 任务:EBYTE驱动库必须的周期执行任务 客户无需修改 */ + Ebyte_RF.StartPollTask(); - delay_1ms(100); - } + delay_1ms(100); + } + + Ebyte_BSP_GlobalIntDisable(); } /* ! diff --git a/MBL/source_ns/drivers/CMT2310/3_Ebyte_WirelessModule_Drivers/E48xMx/ebyte_e48x.c b/MBL/source_ns/drivers/CMT2310/3_Ebyte_WirelessModule_Drivers/E48xMx/ebyte_e48x.c index 12a806d..8d88642 100755 --- a/MBL/source_ns/drivers/CMT2310/3_Ebyte_WirelessModule_Drivers/E48xMx/ebyte_e48x.c +++ b/MBL/source_ns/drivers/CMT2310/3_Ebyte_WirelessModule_Drivers/E48xMx/ebyte_e48x.c @@ -69,15 +69,14 @@ void Ebyte_E48x_SetSleep( uint8_t cmd ) return; } - void Ebyte_E48x_IntOrPollTask( void ) { - radio_rece_data_flag = gpio_input_bit_get( BSP_GPIO_PORT_E48_GP4 , BSP_GPIO_PIN_E48_GP4); - /* 有接收数据 */ - if( radio_rece_data_flag != RESET ) { - vRadioGetPacket(rf_rxbuffer, &rf_rxsize); - Ebyte_Port_ReceiveCallback(0x0002,rf_rxbuffer,rf_rxsize); - } + radio_rece_data_flag = gpio_input_bit_get( BSP_GPIO_PORT_E48_GP4 , BSP_GPIO_PIN_E48_GP4); + /* 有接收数据 */ + if( radio_rece_data_flag != RESET ) { + vRadioGetPacket(rf_rxbuffer, &rf_rxsize); + Ebyte_Port_ReceiveCallback(0x0002,rf_rxbuffer,rf_rxsize); + } } diff --git a/MBL/source_ns/mbl_ns.c b/MBL/source_ns/mbl_ns.c index b379264..1c152b6 100644 --- a/MBL/source_ns/mbl_ns.c +++ b/MBL/source_ns/mbl_ns.c @@ -75,6 +75,7 @@ static void jump_to_main_image(uint32_t msp, uint32_t reset) img_reset = (img_fptr_t)reset; + __disable_irq(); #if defined(__ARM_ARCH_8M_MAIN__) || defined(__ARM_ARCH_8M_BASE__) /* Restore the Main Stack Pointer Limit register's reset value * before passing execution to runtime firmware to make the