gcc/Makefile
ÎļþÒÑɾ³ý keil/EventRecorderStub.scvd
ÎļþÒÑɾ³ý keil/JLinkLog.txt
ÎļþÒÑɾ³ý keil/JLinkSettings.ini
@@ -1,39 +1,3 @@ [BREAKPOINTS] ForceImpTypeAny = 0 ShowInfoWin = 1 EnableFlashBP = 2 BPDuringExecution = 0 [CFI] CFISize = 0x00 CFIAddr = 0x00 [CPU] MonModeVTableAddr = 0xFFFFFFFF MonModeDebug = 0 MaxNumAPs = 0 LowPowerHandlingMode = 0 OverrideMemMap = 0 AllowSimulation = 1 ScriptFile="" [FLASH] CacheExcludeSize = 0x00 CacheExcludeAddr = 0x00 MinNumBytesFlashDL = 0 SkipProgOnCRCMatch = 1 VerifyDownload = 1 AllowCaching = 1 EnableFlashDL = 2 Override = 0 Device="MK8000" [GENERAL] WorkRAMSize = 0x00 WorkRAMAddr = 0x00 RAMUsageLimit = 0x00 [SWO] SWOLogFile="" [MEM] RdOverrideOrMask = 0x00 RdOverrideAndMask = 0xFFFFFFFF RdOverrideAddr = 0xFFFFFFFF WrOverrideOrMask = 0x00 WrOverrideAndMask = 0xFFFFFFFF WrOverrideAddr = 0xFFFFFFFF [FLASH] Override = 1 Device="Cortex-M0" keil/Listings/uwb_simple_example.map
ÎļþÒÑɾ³ý keil/Objects/ExtDll.iex
ÎļþÒÑɾ³ý keil/Objects/uwb_simple_example.build_log.htm
ÎļþÒÑɾ³ý keil/Objects/uwb_simple_example.hex
ÎļþÒÑɾ³ý keil/Objects/uwb_simple_example.htm
ÎļþÒÑɾ³ý keil/Objects/uwb_simple_example.lnp
ÎļþÒÑɾ³ý keil/Objects/uwb_simple_example_MK8000 Release.dep
ÎļþÒÑɾ³ý keil/dw_app.c
ÎļþÒÑɾ³ý keil/dw_app.h
ÎļþÒÑɾ³ý keil/include/components/app/src/ranging_fira_task.c
@@ -114,7 +114,7 @@ if (ind->slot_idx == 0) { ranging_env.range_data.sequence_num = (ranging_env.phy_sts_index - fira_key.phyStsIdxInit) / ranging_env.slots_per_block; uint8_t work_mode_idx = uwb_app_config.session_param.ranging_round_usage < 5 ? uwb_app_config.session_param.ranging_round_usage : 0; uint8_t work_mode_idx = uwb_app_config.session_param.ranging_round_usage < 5 ? uwb_app_config.session_param.ranging_round_usage : 0;//工使¨¡å¼è®°å½ #if MCTT_TEST_EN LOG_INFO(TRACE_NO_OPTION, "%s Init-seq:%u\r\n", work_mode_table[work_mode_idx], ranging_env.range_data.sequence_num + 1); #else keil/include/components/app/src/uci_tl_task.c
@@ -93,7 +93,7 @@ { p->msg_length = len; memcpy(p->msg, buf, len); WsfQueueEnq(&uci_tl_dev->tl_up_queue, p); WsfQueueEnq(&uci_tl_dev->tl_up_queue, p);//å°rxä¸è¡ç¼ååºçæ¶æ¯æ¾å ¥txä¸è¡ç¼ååº } else { @@ -221,7 +221,7 @@ { if (uci_tl_dev->uci_tl_up_req != NULL) { uci_tl_dev->uci_tl_up_req(); uci_tl_dev->uci_tl_up_req();//éå¿ç¢ç¶æä½æ¯ç¼ååºè¿æ²¡åå®å°±éç¥ä¸å±ç»§ç»åæ°æ® } } } keil/include/components/uci/src/uci_uart_driver.c
@@ -156,7 +156,7 @@ { memcpy(p->msg, recv_buff, frame_len); p->msg_length = frame_len; WsfQueueEnq(&g_uci_tl_dev.tl_down_queue, p); WsfQueueEnq(&g_uci_tl_dev.tl_down_queue, p);//æ¾å ¥å¾ å¤çä¿¡æ¯å¨ä¸å±ä¿¡æ¯ç¼ååºå°¾é¨ } else { keil/include/main/main.c
@@ -40,255 +40,103 @@ #include "mk_trace.h" #include "mk_wdt.h" #include "mk_calib.h" #include "mk_reset.h" #include "mk_gpio.h" #include "mk_misc.h" #include "mk_flash.h" #include "libc_rom.h" #include <serial_at_cmd_app.h> #include <global_param.h> #include "board.h" #include "wsf_nvm.h" #include "mk_power.h" #include "mk_sleep_timer.h" #include "Usart.h" #include "mk_adc.h" extern int TagRange(void); extern void parameter_init(void); uint8_t trx_buf[10] = {0}; #define TEST_UART_POLL_MODE 0 #define TEST_UART_INTERUPT_MODE 1 #define TEST_UART_DMA_MODE 2 #define TEST_UART_MODE TEST_UART_DMA_MODE #include "mk_power.h" #include "mk_uwb.h" #include "mk_calib.h" #include "mk_uart.h" #include "mk_spi.h" #include "mk_flash.h" #define NUM_SAMPLES 1 #define SLEEP_START_TIME 1 #define FREQ_LOST_TIME 5 #define NOTAG_FREQ 1 #define BATTERY_GET_TIME 3600 uint8_t enable_sleep_count,sleep_flag; uint32_t battery_get_count; //#define DEBUG_MODE uint32_t reboot_num; struct UART_CFG_T test_uart_cfg = { .parity = UART_PARITY_NONE, .stop = UART_STOP_BITS_1, .data = UART_DATA_BITS_8, .flow = UART_FLOW_CONTROL_NONE, .rx_level = UART_RXFIFO_CHAR_1, .tx_level = UART_TXFIFO_EMPTY, .baud = BAUD_115200, #if (TEST_UART_MODE == TEST_UART_POLL_MODE) .dma_en = false, .int_rx = false, .int_tx = false, #elif (TEST_UART_MODE == TEST_UART_INTERUPT_MODE) .dma_en = false, .int_rx = true, .int_tx = true, #elif (TEST_UART_MODE == TEST_UART_DMA_MODE) .dma_en = true, .int_rx = false, .int_tx = false, #include "board.h" #include "pal_sys.h" #include "wsf_os.h" #include "wsf_timer.h" #include "wsf_buf.h" #include "wsf_nvm.h" #include "app.h" #include "ranging_fira.h" #include "uwb_api.h" #include "lib_ranging.h" #include "uci_tl_task.h" #include "libc_rom.h" #ifdef UWB_UCI_TEST_EN #include "uwb_test.h" #endif }; static void app_wdt_callback(void *dev, uint32_t status) { ASSERT(status, "WDT TIMEOUTï¼ç¨åºå¤ä½"); //LOG_INFO(TRACE_MODULE_APP, "ç¨åºå¡æ»ï¼çé¨çå¤ä½"); } static uint32_t sample[NUM_SAMPLES] = {0}; static struct ADC_CFG_T usr_adc_cfg = { .mode = ADC_MODE_CONTINUE, /* Selected single conversion mode */ .clk_sel = ADC_CLK_HIGH, /* Selected 62.4M high speed clock */ .vref_sel = ADC_SEL_VREF_INT, /* Using internal reference voltage (1.2V)*/ .rate = 500000, /* ADC works at high frequency system clock, the maximum sampling rate is 2M */ .channel_p = ADC_IN_EXTPIN0, /* ADC positive channel --> GPIO0 */ .channel_n = ADC_IN_VREF, /* ADC negative channel --> Vref */ .int_en = false, .dma_en = false, /* DMA support only in continue mode */ .acc_num = 0, .high_pulse_time = 4, .settle_time = 1, }; struct WDT_CFG_T app_wdt_cfg = { .timeout = 32768 * 30, .rst_en = true, .int_en = true, .callback = app_wdt_callback, }; uint8_t state5v = 1; uint8_t bat_percent=0,g_start_send_flag=1; int16_t fVoltage_mv; uint8_t bat_percent; extern uint32_t dev_id; extern uint8_t group_id; extern float freqlost_count; uint8_t tag_frequency; void UartDeinit(void); void UartInit(void); void Program_Init(void); void IdleTask(void); void boot_deinit(void); void Get_batterty_Voltage(void); void Calculate_battery_percent(void); static void uart_receive_callback(void *dev, uint32_t err_code) { uart_receive(UART_ID0,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart_receive_callback); } void UartInit(void) #ifdef CELL_PHONE_EN #include "mk_efuse.h" #define EFUSE_FLASH_EN_ADDR (0x67) #define EFUSE_FLASH_EN_BIT (0x80) bool check_flash_bit_of_efuse(void); bool program_efuse(void); bool check_flash_bit_of_efuse(void) { board_pins_config(); uart_open(UART_ID1, &test_uart_cfg); board_debug_console_open(TRACE_PORT_UART0); uart_receive(UART_ID1,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart_receive_callback); uint8_t val; val = efuse_read_byte(EFUSE_FLASH_EN_ADDR); return ((val & EFUSE_FLASH_EN_BIT) ? true : false); } void UartDeinit(void) bool program_efuse(void) { uart_close(UART_ID0); uart_close(UART_ID1); efuse_program_byte(EFUSE_FLASH_EN_ADDR, EFUSE_FLASH_EN_BIT); if (check_flash_bit_of_efuse()) { LOG_INFO(TRACE_MODULE_APP, "Program eFuse INT_FLASH bit successfully.\r\n"); return true; } else { LOG_INFO(TRACE_MODULE_APP, "Program eFuse INT_FLASH bit failed.\r\n"); return false; } return true; } void Get_batterty_Voltage(void) { battery_monitor_open(); fVoltage_mv=battery_monitor_get(); battery_monitor_close(); Calculate_battery_percent(); } void Calculate_battery_percent(void) { if(fVoltage_mv < 3000) { bat_percent = 0; } else if(fVoltage_mv > 3500) { bat_percent = 100; } else { bat_percent = ((fVoltage_mv - 3000) /8); } //LOG_INFO(TRACE_MODULE_APP, "The voltage is %d ,percent is %%%d \r\n",fVoltage_mv,bat_percent); } #endif //***************************************************************************** // // WSF buffer pools. // //***************************************************************************** #define WSF_BUF_POOLS 5 void Fira_Ranging_Task(void); // Default pool descriptor. static wsfBufPoolDesc_t poolDescriptors[WSF_BUF_POOLS] = { {32, 26}, {64, 24}, {128, 4}, {256 + 32, 4}, {1024 + 32, 2}, }; static void sleep_timer_callback(void *dev, uint32_t time) { //sleep_timer_start(__MS_TO_32K_CNT(1000)); static uint8_t lost_jumpcount=0; reboot_num++; if(reboot_num>=3600) NVIC_SystemReset(); //软å¤ä½åå°bootloader enable_sleep_count++; if(enable_sleep_count==SLEEP_START_TIME){ enable_sleep_count=0; sleep_flag=1; } if(battery_get_count++>=BATTERY_GET_TIME) { Get_batterty_Voltage(); battery_get_count=0; } // if(freqlost_count++>FREQ_LOST_TIME) // { // tag_frequency = NOTAG_FREQ; // if(lost_jumpcount++>=4) //æ æµè·æ åµä¸ï¼æ¯5ç§å䏿¬¡ï¼ // { // lost_jumpcount = 0; // g_start_send_flag=1; // } // }else{ // g_start_send_flag=1; // } g_start_send_flag=1; } static void adc_callback(void *data, uint32_t number) { uint32_t *result = (uint32_t *)data; for (uint16_t i = 0; i < number; i++) { // LOG_INFO(TRACE_MODULE_APP, "The voltage measured %d mv\r\n", // ADC_INTERNAL_VREF_MV + adc_code_to_mv((int16_t)*result, ADC_INTERNAL_VREF_MV)); fVoltage_mv=ADC_INTERNAL_VREF_MV + adc_code_to_mv((int16_t)*result, ADC_INTERNAL_VREF_MV); fVoltage_mv=fVoltage_mv*2; if(fVoltage_mv < 3300) { bat_percent = 0; } else if(fVoltage_mv > 4100) { bat_percent = 100; } else { bat_percent = ((fVoltage_mv - 3300) /8); } } //LOG_INFO(TRACE_MODULE_APP, "The voltage is %%%d \r\n",bat_percent); // LOG_INFO(TRACE_MODULE_APP, "Wake up by sleep timer %d\r\n", time); } static void voltage_input_handler(enum IO_PIN_T pin) static void board_init(void) { //LOG_INFO(TRACE_MODULE_APP, "䏿å¤é\r\n"); } void Program_Init(void) { Usart1ParseDataCallback = UsartParseDataHandler; parameter_init();//g_com_map表åå§å group_id=g_com_map[GROUP_ID]; memcpy(&dev_id ,&g_com_map[DEV_ID],2); tag_frequency=1000/g_com_map[COM_INTERVAL]; g_com_map[VERSION] = (1<<8)|11; LOG_INFO(TRACE_MODULE_APP,"设å¤ID: %x .\r\n",dev_id); LOG_INFO(TRACE_MODULE_APP,"åºä»¶çæ¬:UWB-å å¸çº¿ä¿¡æ V%d.%d. \r\n",g_com_map[VERSION]>>8,g_com_map[VERSION]&0xff); } void IdleTask(void) { UART0_CheckReceive(); if(gpio_pin_get_val(INPUT_5V_Pin)) { //UART_CheckSend(); // bat_percent=Get_Battary(); if(state5v==0) { state5v=1; } }else{ if(state5v==1) { state5v=0; //UartDeinit(); } } } void boot_deinit(void) { //å°bootä¸ä¸²å£è¿åæ®égpio // UART0 TX/RX io_pin_mux_set(IO_PIN_5, IO_FUNC0); io_pin_mux_set(IO_PIN_6, IO_FUNC0); // UART1 RX/TX io_pin_mux_set(IO_PIN_10, IO_FUNC0); io_pin_mux_set(IO_PIN_9, IO_FUNC0); uart_close(UART_ID1);//è§£ç»åæ¥ä¸²å£1 uart_close(UART_ID0);//è§£ç»åæ¥ä¸²å£0 } int main(void) { board_clock_run(); boot_deinit(); board_pins_config(); board_debug_console_open(TRACE_PORT_UART0); // Reset reason reset_cause_get(); reset_cause_clear(); // Load calibration parameters from NVM uint32_t internal_flash = (REG_READ(0x40000018) >> 17) & 0x1; uint32_t external_flash = (REG_READ(0x40010030) >> 28) & 0x3; // Clock configuration board_clock_run(); // Pin configuration board_pins_config(); // Trace configuration board_debug_console_open(TRACE_PORT_UART1); // Reset reason reset_cause_get(); reset_cause_clear(); #ifndef CELL_PHONE_EN // Load calibration parameters from NVM if (internal_flash || external_flash == 1) { WsfNvmInit(); @@ -299,73 +147,159 @@ { board_calibration_params_default(); } #else if (internal_flash) { program_efuse(); } board_calibration_params_default(); #endif // Chip calibration calib_chip(); gpio_open(); #ifdef CELL_PHONE_EN // Configure IO_04 for RF Switch gpio_pin_set_dir(IO_PIN_4, GPIO_DIR_OUT, 0); #else // led board_led_init(); // board_led_on(BOARD_LED_1); #endif board_configure(); } void app_process_handle(uint8_t msg_id, const void *param) { switch (msg_id) { case APP_TEST_TIMER1_MSG: { #if ANT_DELAY_CAL_EN // stop calibration uwbapi_session_stop(uwb_app_config.session_id); uwbapi_session_deinit(uwb_app_config.session_id); // restart UCI RX uci_tl_rx_restart(); #endif } break; default: break; } } wsfHandlerId_t handlerId; void Fira_Ranging_Task(void) { // // Create app task // handlerId = WsfOsSetNextHandler(app_handler); app_init(handlerId); // // Create ranging task or test task // handlerId = WsfOsSetNextHandler(ranging_handler); ranging_init(handlerId); #ifdef UWB_UCI_TEST_EN // Create test task handlerId = WsfOsSetNextHandler(uwb_test_handler); uwb_test_init(handlerId); #endif uwb_open(); // set advanced parameters struct PHY_ADV_CONFIG_T adv_config = { // RPM0: 40, RPM3: 60 .thres_fap_detect = 60, // RPM0: 4, RPM3: 8 .nth_scale_factor = 8, // RFrame SP0: 0/1, Others: 0/1/2/3 .ranging_performance_mode = 3, #if RX_ANT_PORTS_NUM == 4 .skip_weakest_port_en = 1, #else .skip_weakest_port_en = 0, #endif }; phy_adv_params_configure(&adv_config); // which RX ports will be used for AoA/PDoA phy_rx_ant_mode_set(RX_ANT_PORTS_COMBINATION); uwbs_init(); uwb_app_config.ranging_flow_mode = (uint8_t)(RANGING_FLOW_FIRA); uwb_app_config.filter_en = (uint8_t)(FILTER_EN); uwb_app_config.session_param.tx_power_level = board_param.tx_power_fcc[CALIB_CH(uwb_app_config.ppdu_params.ch_num)]; uwb_app_config.ppdu_params.rx_ant_id = (uint8_t)(RX_MAIN_ANT_PORT); } int main(void) { // Initialize MCU system board_init(); // Disable watchdog timer wdt_close(WDT_ID0); wdt_open(WDT_ID0,&app_wdt_cfg);//30sæå¤§ä¸éæ£æµåç //LOG_INFO(TRACE_MODULE_APP, "UWB qiang test example\r\n"); LOG_INFO(TRACE_MODULE_APP, "UCI FiRa example\r\n"); // open system timer //sys_timer_open(); gpio_open(); board_led_init(); //uart_open(UART_ID0, &test_uart_cfg); Program_Init(); //power_wakeup_enable((enum POWER_WAKEUP_SOURCE_T)POWER_WAKEUP_BY_GPIO_0, POWER_WAKEUP_LEVEL_LOW); uart_receive(UART_ID0,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart_receive_callback); // Initialize low power mode power_init(); Get_batterty_Voltage();//è·åå½åå é¨çµå //Calculate_battery_percent(); //adc_open(&usr_adc_cfg); //adc_get(&sample[0], NUM_SAMPLES, adc_callback);//adcéæ · // Enable sleep timer Tag_uwb_init(); sleep_timer_open(true, SLEEP_TIMER_MODE_RELOAD, sleep_timer_callback); //sleep_timer_start(__MS_TO_32K_CNT(g_com_map[COM_INTERVAL]));//æµè¯ sleep_timer_start(__MS_TO_32K_CNT(SLEEP_COUNT));//æµè¯ //board_5V_input_init(voltage_input_handler);//æä¿®æ¹3.3Vä¼ä¸ç´é«çµå¹³å¯¼è´æ æ³è¿å ¥ä¼ç #ifdef BOXING io_pin_mux_set(IO_PIN_5, IO_FUNC0);//波形æµè¯ gpio_pin_set_dir( IO_PIN_5, GPIO_DIR_OUT, 0); io_pull_set(IO_PIN_5 , IO_PULL_DOWN, IO_PULL_UP_LEVEL4); #endif //Serial0_PutString("è¿å ¥appæµè¯\r\n"); while (1) { wdt_ping(WDT_ID0);//åç if(g_start_send_flag) { //LOG_INFO(TRACE_MODULE_APP, "æµè·ing"); g_start_send_flag = 0; gpio_pin_set(LED_PIN);//亮 TagRange(); gpio_pin_clr(LED_PIN);//ç IdleTask(); }else{ IdleTask(); } LoraUp_Poll(); #ifndef DEBUG_MODE if(sleep_flag){//å¼å§ä¸æ®µæ¶é´æ ä¼ç trace_flush(); uint32_t lock = int_lock(); //LOG_INFO(TRACE_MODULE_APP, "è¿å ¥ä½åè"); //å¤éæºè®¾ç½®MK8000ä¿®æ¹ //board_5V_input_init(voltage_input_handler); //sleep_timer_start(g_com_map[COM_INTERVAL]); power_enter_power_down_mode(0); uart_receive(UART_ID0,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart_receive_callback); //LOG_INFO(TRACE_MODULE_APP, "è¿å ¥ä½åè"); int_unlock(lock); } #endif // Platform init for WSF PalSysInit(); // Initialize os // // Set up timers for the WSF scheduler. // WsfOsInit(); WsfTimerInit(); sys_tick_callback_set(WsfTimerUpdateTicks); // // Initialize a buffer pool for WSF dynamic memory needs. // uint32_t wsfBufMemLen = WsfBufInit(WSF_BUF_POOLS, poolDescriptors); if (wsfBufMemLen > FREE_MEM_SIZE) { LOG_INFO(TRACE_MODULE_APP, "Memory pool is not enough %d\r\n", wsfBufMemLen - FREE_MEM_SIZE); } // // Create UCI transmission layer task // handlerId = WsfOsSetNextHandler(uci_tl_handler); uci_tl_init(handlerId); // Initialize low power mode power_init(); #if LOW_POWER_EN power_mode_request(POWER_UNIT_USER, POWER_MODE_POWER_DOWN); uwb_app_config.low_power_en = 1; #else power_mode_request(POWER_UNIT_USER, POWER_MODE_SLEEP); uwb_app_config.low_power_en = 0; #endif // Enable sleep timer sleep_timer_open(true, SLEEP_TIMER_MODE_ONESHOT, sleep_timer_callback); while (1) { wsfOsDispatcher(); power_manage(); } } void app_restore_from_power_down(void) { } keil/simple_ss_twr_dw_resp.c
ÎļþÒÑɾ³ý keil/uci_fira.uvmpw
ÎļþÃû´Ó keil/uwb_simple_example.uvmpw ÐÞ¸Ä @@ -1,16 +1,9 @@ <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <?xml version="1.0" encoding="UTF-8"?> <ProjectWorkspace xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_mpw.xsd"> <SchemaVersion>1.0</SchemaVersion> <Header>### uVision Project, (C) Keil Software</Header> <WorkspaceName>WorkSpace</WorkspaceName> <project> <PathAndName>.\uwb_simple_example.uvprojx</PathAndName> <NodeIsActive>1</NodeIsActive> <NodeIsExpanded>1</NodeIsExpanded> <PathAndName>uci_fira.uvprojx</PathAndName> </project> </ProjectWorkspace> </ProjectWorkspace> keil/uci_fira.uvprojx
ÎļþÃû´Ó keil/uwb_simple_example.uvprojx ÐÞ¸Ä @@ -49,10 +49,10 @@ <InvalidFlash>1</InvalidFlash> </TargetStatus> <OutputDirectory>.\Objects\</OutputDirectory> <OutputName>uwb_simple_example</OutputName> <OutputName>uci_fira</OutputName> <CreateExecutable>1</CreateExecutable> <CreateLib>0</CreateLib> <CreateHexFile>1</CreateHexFile> <CreateHexFile>0</CreateHexFile> <DebugInformation>1</DebugInformation> <BrowseInformation>1</BrowseInformation> <ListingPath>.\Listings\</ListingPath> @@ -313,7 +313,7 @@ </ArmAdsMisc> <Cads> <interw>1</interw> <Optim>4</Optim> <Optim>3</Optim> <oTime>0</oTime> <SplitLS>0</SplitLS> <OneElfS>1</OneElfS> @@ -336,10 +336,10 @@ <v6WtE>0</v6WtE> <v6Rtti>0</v6Rtti> <VariousControls> <MiscControls>-Wno-declaration-after-statement -Wno-double-promotion -Wno-extra-semi-stmt -Wno-gnu-zero-variadic-macro-arguments -Wno-padded -Wno-unused-parameter</MiscControls> <Define>UWB_EN</Define> <MiscControls>-Wno-cast-qual -Wno-declaration-after-statement -Wno-double-promotion -Wno-extra-semi-stmt -Wno-gnu-zero-variadic-macro-arguments -Wno-padded -Wno-unused-parameter</MiscControls> <Define>FIRA_RANGING_EN UWB_EN UWB_UCI_TEST_EN WSF_EN</Define> <Undefine></Undefine> <IncludePath>..;.\include\board;.\include\components\algo\inc;.\include\components\crc;.\include\components\libc;.\include\components\wsf\include;.\include\components\wsf\include\platform;.\include\devices\MK800X\Include;.\include\drivers;.\include\CMSIS\Include</IncludePath> <IncludePath>..;..\..\..;.\include\CMSIS\Include;.\include\components\algo\inc;.\include\components\app\inc;.\include\components\crc;.\include\components\libc;.\include\components\se\inc;.\include\components\uci\inc;.\include\components\uwb\inc;.\include\components\wsf\include;.\include\components\wsf\include\platform;.\include\devices\MK800X\Include;.\include\drivers;.\include\board</IncludePath> </VariousControls> </Cads> <Aads> @@ -370,12 +370,12 @@ <TextAddressRange></TextAddressRange> <DataAddressRange></DataAddressRange> <pXoBase></pXoBase> <ScatterFile>.\include\devices\MK800X\Source\ARM\MK800X_ac6_copy.sct</ScatterFile> <ScatterFile>.\include\devices\MK800X\Source\ARM\MK800X_ac6.sct</ScatterFile> <IncludeLibs></IncludeLibs> <IncludeLibsPath></IncludeLibsPath> <Misc></Misc> <LinkerInputFile></LinkerInputFile> <DisabledWarnings></DisabledWarnings> <DisabledWarnings>6314</DisabledWarnings> </LDads> </TargetArmAds> </TargetOption> @@ -394,9 +394,64 @@ <FilePath>.\include\components\algo\lib\lib_aoa.lib</FilePath> </File> <File> <FileName>lib_kf.lib</FileName> <FileType>4</FileType> <FilePath>.\include\components\algo\lib\lib_kf.lib</FilePath> </File> <File> <FileName>lib_pdoa.lib</FileName> <FileType>4</FileType> <FilePath>.\include\components\algo\lib\lib_pdoa.lib</FilePath> </File> <File> <FileName>lib_ranging.lib</FileName> <FileType>4</FileType> <FilePath>.\include\components\algo\lib\lib_ranging.lib</FilePath> </File> <File> <FileName>MK8000_kf_top.c</FileName> <FileType>1</FileType> <FilePath>.\include\components\algo\src\kf\MK8000_kf_top.c</FilePath> </File> </Files> </Group> <Group> <GroupName>App</GroupName> <Files> <File> <FileName>app.c</FileName> <FileType>1</FileType> <FilePath>.\include\components\app\src\app.c</FilePath> </File> <File> <FileName>app_task.c</FileName> <FileType>1</FileType> <FilePath>.\include\components\app\src\app_task.c</FilePath> </File> <File> <FileName>ranging_fira.c</FileName> <FileType>1</FileType> <FilePath>.\include\components\app\src\ranging_fira.c</FilePath> </File> <File> <FileName>ranging_fira_task.c</FileName> <FileType>1</FileType> <FilePath>.\include\components\app\src\ranging_fira_task.c</FilePath> </File> <File> <FileName>uci_tl_task.c</FileName> <FileType>1</FileType> <FilePath>.\include\components\app\src\uci_tl_task.c</FilePath> </File> <File> <FileName>uwb_test.c</FileName> <FileType>1</FileType> <FilePath>.\include\components\app\src\uwb_test.c</FilePath> </File> <File> <FileName>uwb_test_task.c</FileName> <FileType>1</FileType> <FilePath>.\include\components\app\src\uwb_test_task.c</FilePath> </File> </Files> </Group> @@ -459,6 +514,11 @@ <FilePath>.\include\drivers\mk_dual_timer.c</FilePath> </File> <File> <FileName>mk_efuse.c</FileName> <FileType>1</FileType> <FilePath>.\include\drivers\mk_efuse.c</FilePath> </File> <File> <FileName>mk_flash.c</FileName> <FileType>1</FileType> <FilePath>.\include\drivers\mk_flash.c</FilePath> @@ -499,6 +559,16 @@ <FilePath>.\include\drivers\mk_sleep_timer.c</FilePath> </File> <File> <FileName>mk_spi.c</FileName> <FileType>1</FileType> <FilePath>.\include\drivers\mk_spi.c</FilePath> </File> <File> <FileName>mk_timer.c</FileName> <FileType>1</FileType> <FilePath>.\include\drivers\mk_timer.c</FilePath> </File> <File> <FileName>mk_trace.c</FileName> <FileType>1</FileType> <FilePath>.\include\drivers\mk_trace.c</FilePath> @@ -518,36 +588,6 @@ <FileType>1</FileType> <FilePath>.\include\drivers\mk_wdt.c</FilePath> </File> <File> <FileName>serial_at_cmd_app.c</FileName> <FileType>1</FileType> <FilePath>.\include\drivers\serial_at_cmd_app.c</FilePath> </File> <File> <FileName>global_param.c</FileName> <FileType>1</FileType> <FilePath>.\include\drivers\global_param.c</FilePath> </File> <File> <FileName>Usart.c</FileName> <FileType>1</FileType> <FilePath>.\include\drivers\Usart.c</FilePath> </File> <File> <FileName>Usart1.c</FileName> <FileType>1</FileType> <FilePath>.\include\drivers\Usart1.c</FilePath> </File> <File> <FileName>dw_app.c</FileName> <FileType>1</FileType> <FilePath>.\dw_app.c</FilePath> </File> <File> <FileName>dw_app.h</FileName> <FileType>5</FileType> <FilePath>.\dw_app.h</FilePath> </File> </Files> </Group> <Group> @@ -559,14 +599,14 @@ <FilePath>.\include\board\board.c</FilePath> </File> <File> <FileName>pin_config.c</FileName> <FileType>1</FileType> <FilePath>..\pin_config.c</FilePath> </File> <File> <FileName>main.c</FileName> <FileType>1</FileType> <FilePath>.\include\main\main.c</FilePath> </File> <File> <FileName>pin_config.c</FileName> <FileType>1</FileType> <FilePath>..\pin_config.c</FilePath> </File> </Files> </Group> @@ -646,12 +686,37 @@ </Files> </Group> <Group> <GroupName>Simple</GroupName> <GroupName>SE</GroupName> <Files> <File> <FileName>uwb_tag_.c</FileName> <FileName>phdriver.c</FileName> <FileType>1</FileType> <FilePath>.\uwb_tag_.c</FilePath> <FilePath>.\include\components\se\src\phdriver.c</FilePath> </File> <File> <FileName>se_api.c</FileName> <FileType>1</FileType> <FilePath>.\include\components\se\src\se_api.c</FilePath> </File> <File> <FileName>T1.c</FileName> <FileType>1</FileType> <FilePath>.\include\components\se\src\T1.c</FilePath> </File> <File> <FileName>t1_split.c</FileName> <FileType>1</FileType> <FilePath>.\include\components\se\src\t1_split.c</FilePath> </File> <File> <FileName>tm_main.c</FileName> <FileType>1</FileType> <FilePath>.\include\components\se\src\tm_main.c</FilePath> </File> <File> <FileName>uart_in_spi.c</FileName> <FileType>1</FileType> <FilePath>.\include\components\se\src\uart_in_spi.c</FilePath> </File> </Files> </Group> @@ -670,6 +735,31 @@ </File> </Files> </Group> <Group> <GroupName>UWB</GroupName> <Files> <File> <FileName>lib_fira.lib</FileName> <FileType>4</FileType> <FilePath>.\include\components\uwb\lib\lib_fira.lib</FilePath> </File> <File> <FileName>lib_uwbs.lib</FileName> <FileType>4</FileType> <FilePath>.\include\components\uwb\lib\lib_uwbs.lib</FilePath> </File> <File> <FileName>uci_spi_driver.c</FileName> <FileType>1</FileType> <FilePath>.\include\components\uci\src\uci_spi_driver.c</FilePath> </File> <File> <FileName>uci_uart_driver.c</FileName> <FileType>1</FileType> <FilePath>.\include\components\uci\src\uci_uart_driver.c</FilePath> </File> </Files> </Group> </Groups> </Target> </Targets> keil/uwb_simple_example.uvguix.xookk
ÎļþÒÑɾ³ý keil/uwb_simple_example.uvmpw.uvgui.xookk
ÎļþÒÑɾ³ý keil/uwb_simple_example.uvoptx
ÎļþÒÑɾ³ý keil/uwb_tag_.c
ÎļþÒÑɾ³ý pin_config.c
@@ -43,22 +43,49 @@ void board_pins_config(void) { #if UCI_INTF_PORT == 1 // SPI0 MOSI/MISO/CLK/CS io_pin_mux_set(IO_PIN_11, IO_FUNC2); io_pin_mux_set(IO_PIN_12, IO_FUNC2); io_pin_mux_set(IO_PIN_13, IO_FUNC2); io_pin_mux_set(IO_PIN_14, IO_FUNC2); // setting for idle and sleep mode io_pull_set(IO_PIN_11, IO_HIGH_Z, IO_PULL_UP_NONE); io_pull_set(IO_PIN_12, IO_HIGH_Z, IO_PULL_UP_NONE); io_pull_set(IO_PIN_13, IO_HIGH_Z, IO_PULL_UP_NONE); io_pull_set(IO_PIN_14, IO_PULL_UP, IO_PULL_UP_LEVEL2); #if UCI_CHECK_SE_EN // SPI1 MISO/MOSI/CLK/CS io_pin_mux_set(IO_PIN_5, IO_FUNC2); io_pin_mux_set(IO_PIN_6, IO_FUNC2); io_pin_mux_set(IO_PIN_7, IO_FUNC2); io_pin_mux_set(IO_PIN_8, IO_FUNC0); #endif #else // UART0 TX/RX io_pin_mux_set(IO_PIN_5, IO_FUNC4); io_pin_mux_set(IO_PIN_6, IO_FUNC4); io_pin_mux_set(IO_PIN_9, IO_FUNC6); io_pin_mux_set(IO_PIN_10, IO_FUNC6); // io_pull_set(IO_PIN_9 , IO_PULL_DOWN, IO_PULL_UP_LEVEL3); // io_pull_set(IO_PIN_10 , IO_PULL_DOWN, IO_PULL_UP_LEVEL3); //io_pin_mux_set(IO_PIN_6, IO_FUNC4); #endif // // UART1 RX/TX已修æ¹å¤ç¨å¼è为ADCçåºç©ºé´ // io_pin_mux_set(IO_PIN_10, IO_FUNC4); // io_pin_mux_set(IO_PIN_9, IO_FUNC4); // // // Single ADC, If IO0 is set to negative input, the positive input is Vref, and vice versa // io_pin_mux_set(IO_PIN_0, IO_FUNC1); // io_pull_set(IO_PIN_0, IO_HIGH_Z, IO_PULL_UP_NONE); #if TRACE_EN #if BOARD_TYPE == MK8000_EVK // UART1 RX/TX io_pin_mux_set(IO_PIN_0, IO_FUNC4); io_pin_mux_set(IO_PIN_1, IO_FUNC4); #elif BOARD_TYPE == MK8000_DK // UART1 TX/RX io_pin_mux_set(IO_PIN_9, IO_FUNC4); io_pin_mux_set(IO_PIN_10, IO_FUNC4); #endif #endif } user_config.h
@@ -40,6 +40,13 @@ #ifndef USER_CONFIG_H_ #define USER_CONFIG_H_ /* =========================================================================================================================== */ /* ================ Platform configuration ================ */ /* =========================================================================================================================== */ /** Platform */ // #define CELL_PHONE_EN // #define RPI4_EN /* =========================================================================================================================== */ /* ================ Silicon configuration ================ */ @@ -51,6 +58,117 @@ /* =========================================================================================================================== */ /* ================ Board configuration ================ */ /* =========================================================================================================================== */ /** UCI hardware port config: 0 - UART, 1 - SPI */ #define UCI_INTF_PORT (0) /** UCI UART handshake enable, handshake pins configured from board.h */ #define UCI_INTF_UART_HS_EN (0) /** UCI SPI half-duplex or full-duplex mode selection: 0 - half-duplex, 1 - full-duplex */ #define UCI_INTF_SPI_HD_FD (0) /** When the host platform is cell phone or Raspberry Pi, the SPI full-duplex handshake interface is enabled */ #if defined(CELL_PHONE_EN) || defined(RPI4_EN) /** By default, spi full-duplex is used to communicate with cell phone and Raspberry Pi */ #undef UCI_INTF_PORT #define UCI_INTF_PORT (1) #undef UCI_INTF_SPI_HD_FD #define UCI_INTF_SPI_HD_FD (1) #endif #if UCI_INTF_PORT == 1 #if UCI_INTF_SPI_HD_FD /** UCI SPI full-duplex handshake interface, handshake pins configured from board.h */ #define UCI_INTF_SPI_FD_HS (1) #else /** UCI SPI half-duplex handshake interface, handshake pins configured from board.h */ #define UCI_INTF_SPI_HD_HS (1) #endif /** UCI SPI bit rate */ #define UCI_INTF_SPI_SPEED 1000000 #else #if UCI_INTF_UART_HS_EN /** UCI UART interface with handshake */ #define UCI_INTF_UART_HS (1) /** The time for UART delay to send */ #define UCI_INTF_UART_HS_DELAYED_SEND_US (1000) #else /** UCI UART interface without handshake */ #define UCI_INTF_UART (1) #endif /** UART baudrate, @ref enum UART_BAUD_T */ #define UCI_INTF_UART_BAUD BAUD_921600 #endif /** Enable SE check over SPI */ #if defined(CELL_PHONE_EN) #define UCI_CHECK_SE_EN (1) #else #define UCI_CHECK_SE_EN (0) #endif /** UCI handshake timeout */ #define UCI_HS_TIMEOUT_MS (50U) /** Enable antenna delay calibration, golden reference need to set this macro */ #define ANT_DELAY_CAL_EN (1) /* =========================================================================================================================== */ /* ================ Driver configuration ================ */ /* =========================================================================================================================== */ // ACMP work mode #define ACMP_INT_MODE_EN (0) // ADC work mode #define ADC_INT_MODE_EN (0) #define ADC_DMA_MODE_EN (0) #define ADC_POLL_MODE_EN (1) // AES work mode #define AES_INT_MODE_EN (0) #define AES_DMA_MODE_EN (1) #define AES_POLL_MODE_EN (0) // Flash work mode #define FLASH_INT_MODE_EN (0) #define FLASH_DMA_MODE_EN (0) #if ANT_DELAY_CAL_EN #define FLASH_WRITE_EN (1) #else #define FLASH_WRITE_EN (0) #endif // I2C work mode #define I2C_INT_MODE_EN (0) #define I2C_POLL_MODE_EN (1) // LSP work mode #define LSP_INT_MODE_EN (0) // PWM work mode #define PWM_INT_MODE_EN (0) // RTC work mode #define RTC_FREE_COUNTER_EN (0) // SPI work mode #define SPI_INT_MODE_EN (0) #define SPI_DMA_MODE_EN (1) #define SPI_POLL_MODE_EN (1) // TRNG work mode #define TRNG_INT_MODE_EN (0) #define TRNG_POLL_MODE_EN (1) // UART work mode #define UART_INT_MODE_EN (0) #define UART_DMA_MODE_EN (1) #define UART_POLL_MODE_EN (0) // Dual Timer work mode #define TIMER0_INT_MODE_EN (1) #define TIMER1_INT_MODE_EN (1) // Timer work mode #define TIMER2_INT_MODE_EN (0) #define TIMER3_INT_MODE_EN (1) /* =========================================================================================================================== */ /* ================ Debug/TRACE configuration ================ */ @@ -68,17 +186,25 @@ #define TRACE_STD_LIB_EN (0) /** Configure trace level for modules: BOOT | TEST | UCI | UWB | APP | DRIVER | PHY | MAC */ #define TRACE_LVL_CONFIG_0 (0x44444004) //yuan #define TRACE_LVL_CONFIG_0 (0x44444444) #define TRACE_LVL_CONFIG_0 (0x44444444) /** Configure trace level for modules: CCC | FIRA | OS */ #define TRACE_LVL_CONFIG_1 (0x00000444) /** Configure trace buffer size (in bytes) */ #define TRACE_BUF_SIZE (1024) /* =========================================================================================================================== */ /* ================ Power configuration ================ */ /* =========================================================================================================================== */ /** Enable low power mode */ #ifndef LOW_POWER_EN #if (UCI_INTF_PORT || (UCI_INTF_PORT == 0 && UCI_INTF_UART_HS_EN) || ANT_DELAY_CAL_EN) #define LOW_POWER_EN (1) #else #define LOW_POWER_EN (0) #endif #endif /** Enable 32.768K crystal as low power mode clock source */ @@ -103,7 +229,7 @@ /** Enable UWB high performance mode, it will increase power consumption */ #ifndef HIGH_PERFORMANCE_MODE_EN #define HIGH_PERFORMANCE_MODE_EN (0) #define HIGH_PERFORMANCE_MODE_EN (1) #endif /* =========================================================================================================================== */ @@ -111,7 +237,11 @@ /* =========================================================================================================================== */ /** Configure system clock source @ref enum CLOCK_ATTACH_TYPE_T */ #if defined(CELL_PHONE_EN) #define SYS_CLK_SOURCE (CLOCK_62P4M_EXT38P4M_SINE_TO_SYS_CLK) #else #define SYS_CLK_SOURCE (CLOCK_62P4M_XTAL38P4M_TO_SYS_CLK) #endif /** AHBCLK = SYSCLK/(div) @ref enum CLOCK_BUS_DIVIDER_VAL_T */ #define AHB_DIV (CLOCK_DIVIDED_BY_1) @@ -120,12 +250,16 @@ #define APB_DIV (CLOCK_DIVIDED_BY_1) /** Configure 32K clock source @ref enum CLOCK_ATTACH_TYPE_T */ #if defined(CELL_PHONE_EN) #define CLK_32K_SOURCE (CLOCK_EXT32K_SQUARE_TO_32K_CLK) #else #if XTAL32K_EN #define CLK_32K_SOURCE (CLOCK_XTAL32K_TO_32K_CLK) #define LOW_POWER_CLOCK_PPM (50) #else #define CLK_32K_SOURCE (CLOCK_RCO32K_TO_32K_CLK) #define LOW_POWER_CLOCK_PPM (1000) #endif #endif /** Enable system tick timer (period = 10ms), needed by OS */ @@ -135,60 +269,64 @@ /* ================ UWB configuration ================ */ /* =========================================================================================================================== */ /** Enable Post-process filter */ #define FILTER_EN (0) /** Enable RSSI output */ #define RSSI_EN (1) /** Enable Channel status information output */ #define CSI_EN (0) /** Enable PDoA 3D */ #define PDOA_3D_EN (0) /** Enable AoA */ #define AOA_EN (1) /** Measure angle on 1 (responder side), 2 (initiator side), 3 (both sides), 0 (None) */ #define MEASURE_ANGLE_ON_ROLE (3) /** TX power level: 0 ~ 60 */ #define TX_POWER_LEVEL (55) #define TX_POWER_LEVEL (36) /** Antenna port number for AoA, 2~4 */ #define RX_AOA_ANT_PORTS_NUM (4) /** Antenna ports combination, @ref macro definition RX_xPORTS_ANT_xxx */ #define RX_ANT_PORTS_COMBINATION (RX_4PORTS_ANT_3_0_1_2) /** Antenna ports c ombination for AoA, @ref enum RX_ANTENNA_MODE_T */ #define RX_AOA_ANT_PORTS_COMBINATION (RX_4PORTS_ANT_3_0_1_2) /** Dynamic update RX main antenna, can be enabled only when 4 ports are in use */ #define DYNAMIC_UPDATE_MAIN_ANTENNA_EN (0) /** Antenna pattern: Linear or Square */ #define SQUARE_4ANTS (0) #if PDOA_3D_EN /// Antenna pattern #define ANT_PATTERN (ANT_PATTERN_SQUARE) /// Antenna layout, @ref enum ANT_LAYOUT_T #define ANT_LAYOUT (ANT_LAYOUT_HORIZONTAL) #else /// Antenna pattern #define ANT_PATTERN (ANT_PATTERN_LINEAR) #endif /** Enable load cap automatic tuning during ranging procedure */ #define XTAL_AUTO_TUNE_EN (1) /** Enable kalman filter as post process filter, FILTER_EN should be enabled meanwhile */ #define KF_EN (0) /** Velocity of propagation (%) */ #define VP_VAL (100) /** Maximum PHY payload length */ #define PHY_PAYLOAD_LEN_MAX (127) /* ========================================== Timing configuration ======================================== */ //#define BOXING //#define BOXING /// Period prefetch time for event program from wakeup - 400us+ #define UWB_PERIOD_PREFETCH_TIME (US_TO_PHY_TIMER_COUNT(400)) /// Event prefetch time for event program - 300us #define UWB_EVT_PREFETCH_TIME (US_TO_PHY_TIMER_COUNT(300)) /// RX window open in advance time - 10us #define UWB_RX_OPEN_IN_ADVANCE (US_TO_PHY_TIMER_COUNT(10)) /// RX window - 750us #define UWB_RX_WINDOW (US_TO_PHY_TIMER_COUNT(750)) #define LED_PIN IO_PIN_4 /* =========================================================================================================================== */ /* ================ Simple Selection ================ */ /* =========================================================================================================================== */ //#define MK_SIMPLE_TX //#define MK_SIMPLE_RX //#define MK_DS_TWR_INIT //#define MK_DS_TWR_RESP //#define MK_DS_TWR_INIT_STS //#define MK_DS_TWR_RESP_STS #define MK_SS_TWR_DW_INIT //#define MK_SS_TWR_DW_RESP #define INPUT_5V_Pin IO_PIN_11 #define RSSI_EN (0) /** channel number: 2, 5, 9 */ #define UWB_CH_NUM (5) /** Velocity of propagation (%) */ #define VP_VAL (100) #define RANGING_CORR (0) #define XTAL_AUTO_TUNE_EN (0) //#define STS_MODE //#define MK_MODE #define SLEEP_COUNT 1000 #define DW1000 /* =========================================================================================================================== */ /* ================ End ================ */ /* =========================================================================================================================== */