[Mod] 支持CMT2310 接收
1. 关联gd32w51x中断处理; 1.1. 支持基于SysTick的延时; 1.2. 支持基于Timer2中断的数据接收; 2. 解决程序过大问题,链接中移除printf的浮点支持; 3. 支持CMT2310初始化并进入接收模式; 3.1. 支持HAL层替换打印EBYTE_LOG;
This commit is contained in:
@ -42,6 +42,11 @@
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define __SYSTEM_CLOCK_180M_PLLP_40M_HXTAL (uint32_t)(180000000)
|
||||
|
||||
uint32_t SystemCoreClock = __SYSTEM_CLOCK_180M_PLLP_40M_HXTAL;
|
||||
|
||||
/*!
|
||||
\brief configure the system clock to HXTAL
|
||||
\param[in] none
|
||||
|
||||
@ -34,6 +34,8 @@ OF SUCH DAMAGE.
|
||||
|
||||
#include "gd32w51x_it.h"
|
||||
#include "rom_export.h"
|
||||
#include <systick.h>
|
||||
#include <irq_handle.h>
|
||||
|
||||
/*!
|
||||
\brief this function handles NMI exception
|
||||
@ -127,3 +129,25 @@ void UsageFault_Handler(void)
|
||||
while(1){
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief this function handles SysTick exception
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void SysTick_Handler(void)
|
||||
{
|
||||
delay_decrement();
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief This function handles TIMER2 interrupt request.
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void TIMER2_IRQHandler(void)
|
||||
{
|
||||
__TIMER2_IRQHandler();
|
||||
}
|
||||
|
||||
94
MBL/platform/gdm32/systick.c
Normal file
94
MBL/platform/gdm32/systick.c
Normal file
@ -0,0 +1,94 @@
|
||||
/*!
|
||||
\file systick.c
|
||||
\brief the systick configuration file
|
||||
|
||||
\version 2021-10-30, V1.0.0, firmware for GD32W51x
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (c) 2021, GigaDevice Semiconductor Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "gd32w51x.h"
|
||||
#include "systick.h"
|
||||
|
||||
volatile static uint32_t delay;
|
||||
|
||||
/*!
|
||||
\brief configure systick
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void systick_config(void)
|
||||
{
|
||||
/* setup systick timer for 1MHz interrupts */
|
||||
if (SysTick_Config(SystemCoreClock / 1000000U)) {
|
||||
/* capture error */
|
||||
while(1);
|
||||
}
|
||||
|
||||
/* configure the systick handler priority */
|
||||
NVIC_SetPriority(SysTick_IRQn, 0x00U);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief delay a time in milliseconds
|
||||
\param[in] count: count in milliseconds
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void delay_1us(uint32_t count)
|
||||
{
|
||||
delay = count;
|
||||
|
||||
while(0U != delay);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief delay a time in milliseconds
|
||||
\param[in] count: count in milliseconds
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void delay_1ms(uint32_t count)
|
||||
{
|
||||
delay = count * 1000;
|
||||
|
||||
while(0U != delay);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief delay decrement
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void delay_decrement(void)
|
||||
{
|
||||
if (0U != delay)
|
||||
delay--;
|
||||
}
|
||||
49
MBL/platform/gdm32/systick.h
Normal file
49
MBL/platform/gdm32/systick.h
Normal file
@ -0,0 +1,49 @@
|
||||
/*!
|
||||
\file systick.h
|
||||
\brief the header file of systick
|
||||
|
||||
\version 2021-10-30, V1.0.0, firmware for GD32W51x
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (c) 2021, GigaDevice Semiconductor Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SYSTICK_H
|
||||
#define SYSTICK_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* configure systick */
|
||||
void systick_config(void);
|
||||
/* delay a time in milliseconds */
|
||||
void delay_1us(uint32_t count);
|
||||
/* delay a time in milliseconds */
|
||||
void delay_1ms(uint32_t count);
|
||||
/* delay decrement */
|
||||
void delay_decrement(void);
|
||||
|
||||
#endif /* SYSTICK_H */
|
||||
@ -57,16 +57,21 @@ target_sources(${TARGET_EXE}
|
||||
${PROJECT_SOURCE_DIR}/NSPE/Firmware/GD32W51x_standard_peripheral/Source/gd32w51x_qspi.c
|
||||
${PROJECT_SOURCE_DIR}/NSPE/Firmware/GD32W51x_standard_peripheral/Source/gd32w51x_rcu.c
|
||||
${PROJECT_SOURCE_DIR}/NSPE/Firmware/GD32W51x_standard_peripheral/Source/gd32w51x_usart.c
|
||||
${PROJECT_SOURCE_DIR}/NSPE/Firmware/GD32W51x_standard_peripheral/Source/gd32w51x_spi.c
|
||||
${PROJECT_SOURCE_DIR}/NSPE/Firmware/GD32W51x_standard_peripheral/Source/gd32w51x_timer.c
|
||||
)
|
||||
|
||||
target_sources(${TARGET_EXE}
|
||||
PRIVATE
|
||||
../platform/gdm32/cmsis_core/mbl_system_gdm32.c
|
||||
../platform/gdm32/gcc/mbl_startup_gdm32.s
|
||||
../platform/gdm32/gd32w51x_it.c
|
||||
../platform/gdm32/systick.c
|
||||
)
|
||||
|
||||
target_include_directories(${TARGET_EXE}
|
||||
PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/MBL/platform/gdm32/
|
||||
${PROJECT_SOURCE_DIR}/NSPE/Firmware/GD32W51x_standard_peripheral/Include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/CMT2310/0_Project/Uart_PingPong/
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/CMT2310/0_Project/Uart_PingPong/ebyte/
|
||||
@ -87,6 +92,10 @@ target_link_options(${TARGET_EXE}
|
||||
-Wl,-Map=${TAGET_PROJECT_DIR}/GCC/output/bin/${TARGET_EXE}.map
|
||||
)
|
||||
|
||||
get_target_property(LINK_FLAGS ${TARGET_EXE} LINK_OPTIONS)
|
||||
string(REGEX REPLACE "(.*)-u._printf_float(.*)" "\\1\\2" LINK_FLAGS "${LINK_FLAGS}")
|
||||
set_target_properties(${TARGET_EXE} PROPERTIES LINK_OPTIONS "${LINK_FLAGS}")
|
||||
|
||||
if(CMAKE_HOST_UNIX)
|
||||
add_custom_command(TARGET ${TARGET_EXE} POST_BUILD
|
||||
COMMAND ${TAGET_PROJECT_DIR}/mbl_afterbuild.sh ${TAGET_PROJECT_DIR}/GCC/output/bin ${TARGET_EXE} GCC \"\"
|
||||
|
||||
@ -134,7 +134,7 @@ void Ebyte_Port_ReceiveCallback( uint16_t state, uint8_t *buffer, uint8_t lengt
|
||||
if( ! PC_isConnected )
|
||||
{
|
||||
|
||||
DEBUGPRINT("\r\n Receive Data:");
|
||||
EBYTE_LOG("\r\n Receive Data:");
|
||||
Ebyte_BSP_UartTransmit ( buffer, length );
|
||||
}
|
||||
|
||||
|
||||
@ -23,6 +23,8 @@
|
||||
|
||||
/*= !!!<21><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>Ӳ<EFBFBD><D3B2>ƽ̨ͷ<CCA8>ļ<EFBFBD> =======================================*/
|
||||
#include "board.h" //E15-EVB02 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#include "drivers/CMT2310/3_Ebyte_WirelessModule_Drivers/E48xMx/radio_hal.h"
|
||||
#include "systick.h"
|
||||
/*==================================================================*/
|
||||
|
||||
/* !
|
||||
@ -77,7 +79,7 @@ void Ebyte_Port_SpiCsIoControl( uint8e_t cmd )
|
||||
void Ebyte_Port_DelayMs( uint16e_t time )
|
||||
{
|
||||
/* !<21><><EFBFBD><EFBFBD><EFBFBD>ṩ: <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> */
|
||||
sys_ms_sleep(time);
|
||||
delay_1ms(time);
|
||||
}
|
||||
|
||||
|
||||
@ -90,7 +92,5 @@ void Ebyte_Port_DelayMs( uint16e_t time )
|
||||
void Ebyte_Port_DelayUs( uint16e_t time )
|
||||
{
|
||||
/* !<21><><EFBFBD><EFBFBD><EFBFBD>ṩ: <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> */
|
||||
sys_us_delay(time);
|
||||
delay_1us(time);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#ifndef __EBYTE_E48_H__
|
||||
#define __EBYTE_E48_H__
|
||||
|
||||
#include <board.h>
|
||||
|
||||
int ebyte_main( void );
|
||||
|
||||
#endif /* __EBYTE_E48_H__ */
|
||||
|
||||
@ -67,8 +67,8 @@ int ebyte_main( void )
|
||||
/* MCU <20><>ȫ<EFBFBD><C8AB><EFBFBD>ж<EFBFBD> */
|
||||
Ebyte_BSP_GlobalIntEnable();
|
||||
|
||||
DEBUGPRINT( "Start PingPong.....\r\n" );
|
||||
DEBUGPRINT( "Please push button1 or button2.....\r\n" );
|
||||
EBYTE_LOG( "Start PingPong.....\r\n" );
|
||||
EBYTE_LOG( "Please push button1 or button2.....\r\n" );
|
||||
|
||||
while( 1 ) {
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>Ӧ */
|
||||
@ -80,7 +80,7 @@ int ebyte_main( void )
|
||||
/* <20><><EFBFBD><EFBFBD>:EBYTE<54><45><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
Ebyte_RF.StartPollTask();
|
||||
|
||||
sys_ms_sleep(100);
|
||||
delay_1ms(100);
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ void Task_Transmit( void )
|
||||
{
|
||||
pongLength = 5;
|
||||
}else{
|
||||
DEBUGPRINT( "\r\n Echo : pong \r\n" );
|
||||
EBYTE_LOG( "\r\n Echo : pong \r\n" );
|
||||
pongLength = 4;
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@ void Task_Button( void )
|
||||
pingLength = 5;
|
||||
}else
|
||||
{
|
||||
DEBUGPRINT( "\r\n Send Command : ping \r\n" );
|
||||
EBYTE_LOG( "\r\n Send Command : ping \r\n" );
|
||||
pingLength = 4;
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ void Task_Button( void )
|
||||
pingLength = 5;
|
||||
}else
|
||||
{
|
||||
DEBUGPRINT( "\r\n Send Command : ping \r\n" );
|
||||
EBYTE_LOG( "\r\n Send Command : ping \r\n" );
|
||||
pingLength = 4;
|
||||
}
|
||||
|
||||
|
||||
@ -235,10 +235,10 @@ void Ebyte_BSP_Init( void )
|
||||
Ebyte_BSP_SPI_Init();
|
||||
|
||||
/* <20><>ʱ<EFBFBD><CAB1> <20><>ʼ<EFBFBD><CABC> */
|
||||
Ebyte_BSP_TIMER_Init();
|
||||
// Ebyte_BSP_TIMER_Init();
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD> <20><>ʼ<EFBFBD><CABC> */
|
||||
Ebyte_BTN_FIFO_Init( &BSP_BTN_FIFO );
|
||||
// Ebyte_BTN_FIFO_Init( &BSP_BTN_FIFO );
|
||||
}
|
||||
|
||||
/* !
|
||||
|
||||
@ -22,9 +22,8 @@
|
||||
#define __EBYTE_BOARD_H__
|
||||
|
||||
#include <stdint.h>
|
||||
//#include "stm8l15x_conf.h"
|
||||
#include "gd32w51x.h"
|
||||
#include "debug_print.h"
|
||||
#include <gd32w51x.h>
|
||||
#include <systick.h>
|
||||
#include "board_mini_printf.h"
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LED */
|
||||
|
||||
@ -3,4 +3,6 @@
|
||||
|
||||
void mprintf(char * Data, ...);
|
||||
|
||||
#define EBYTE_LOG printf
|
||||
|
||||
#endif // !__BOARD_PRINTF_H__
|
||||
|
||||
@ -37,17 +37,17 @@ void Ebyte_E48x_Init( void )
|
||||
/* Step2 */
|
||||
g_chip_id = lRadioChipVersion();
|
||||
if(0x00231000 != (g_chip_id & 0x00FFFF00)) {
|
||||
DEBUGPRINT("[%s|%u] Error, dismatch Chip-ID[%#x](!=0x231000).\r\n", __FUNCTION__, __LINE__, g_chip_id);
|
||||
EBYTE_LOG("[%s|%u] Error, dismatch Chip-ID[%#x](!=0x231000).\r\n", __FUNCTION__, __LINE__, g_chip_id);
|
||||
return;
|
||||
}
|
||||
DEBUGPRINT("[%s|%u] Info, Link Device:E48-XXXM20S.\r\n", __FUNCTION__, __LINE__);
|
||||
EBYTE_LOG("[%s|%u] Info, Link Device:E48-XXXM20S.\r\n", __FUNCTION__, __LINE__);
|
||||
|
||||
/* Step3 */
|
||||
if (bRadioGetState() == CMT2310A_STATE_IS_READY) {
|
||||
DEBUGPRINT("[%s|%u] Infor, CMT2310 already in State[READY], so skip initialization.\r\n", __FUNCTION__, __LINE__);
|
||||
EBYTE_LOG("[%s|%u] Infor, CMT2310 already in State[READY], so skip initialization.\r\n", __FUNCTION__, __LINE__);
|
||||
return;
|
||||
}
|
||||
DEBUGPRINT("[%s|%u] Info, goto initialize E48-XXXM20S.\r\n", __FUNCTION__, __LINE__);
|
||||
EBYTE_LOG("[%s|%u] Info, goto initialize E48-XXXM20S.\r\n", __FUNCTION__, __LINE__);
|
||||
|
||||
/* Step4 */
|
||||
vRadioInit();
|
||||
|
||||
@ -63,6 +63,7 @@ const uint8_t cmt2310a_power[55][7] = {
|
||||
{0x21,0x16,0x00,0x47,0x00,0x00,0x01 }, /* cmt2310a_params20-N8.h */
|
||||
{0x1D,0x16,0x00,0x47,0x00,0x00,0x01 } /* cmt2310a_params20-N9.h */
|
||||
};
|
||||
|
||||
/******************************
|
||||
**Name: vRadioInit
|
||||
**Func: Radio config spi & reset
|
||||
@ -399,16 +400,16 @@ void vRadioCheckLink(void)
|
||||
g_chip_id = lRadioChipVersion();
|
||||
if(0x00231000==(g_chip_id&0x00FFFF00)) break;
|
||||
|
||||
DEBUGPRINT( "Link Error.....\r\n" );
|
||||
EBYTE_LOG( "Link Error.....\r\n" );
|
||||
delay1ms(500);
|
||||
i++;
|
||||
if(i >= 20) while(1);
|
||||
}
|
||||
DEBUGPRINT( "Link Device:E48-XXXM20S....\r\n" );
|
||||
EBYTE_LOG( "Link Device:E48-XXXM20S....\r\n" );
|
||||
}
|
||||
|
||||
void vRadioSetFreqChannel(uint8_t channel)
|
||||
{
|
||||
bRadioGoStandby();
|
||||
bRadioWriteReg( CMT2310A_CTL_REG_03, channel);
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,10 +39,13 @@ OF SUCH DAMAGE.
|
||||
#include "mbl_sys.h"
|
||||
#include "mbl_uart.h"
|
||||
#include "mbl_flash.h"
|
||||
#include "ebyte_e48.h"
|
||||
#include "rom_region.h"
|
||||
|
||||
typedef void (*img_fptr_t) (void);
|
||||
int32_t mbl_err_process = ERR_PROCESS_ENDLESS_LOOP;
|
||||
int32_t mbl_trace_level = MBL_WARN;
|
||||
struct rom_api_s_t *p_rom_api_s = (struct rom_api_s_t *)ROM_API_ARRAY_BASE;
|
||||
|
||||
#if defined(__ARM_ARCH_8M_MAIN__) || defined(__ARM_ARCH_8M_BASE__)
|
||||
/* Macros to pick linker symbols */
|
||||
@ -95,12 +98,13 @@ static void jump_to_main_image(uint32_t msp, uint32_t reset)
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
int ret;
|
||||
struct image_header hdr;
|
||||
uint32_t boot_idx = 0, image_offset = 0, version;
|
||||
uint32_t arm_vector[2];
|
||||
int ret;
|
||||
#if defined(__ARM_ARCH_8M_MAIN__) || defined(__ARM_ARCH_8M_BASE__)
|
||||
uint32_t msp_stack_bottom = 0;
|
||||
|
||||
#if defined (__ICCARM__)
|
||||
msp_stack_bottom = (uint32_t)®ION_NAME(CSTACK, $$Base);
|
||||
#else
|
||||
@ -119,6 +123,12 @@ int main(void)
|
||||
/* Initialize flash for reading system info */
|
||||
flash_init();
|
||||
|
||||
/* Init Systick */
|
||||
systick_config();
|
||||
|
||||
/* Init Systick */
|
||||
ebyte_main();
|
||||
|
||||
/* Initialize system status if empty or validate system status */
|
||||
ret = sys_status_check();
|
||||
if (ret < 0) {
|
||||
|
||||
Reference in New Issue
Block a user