/*! * \brief Kinetis Start * \return None * * This function calls all of the needed starup routines and then * branches to the main process. */ void start(void) { /* Disable the watchdog timer */ wdog_disable(); /* Copy any vector or data sections that need to be in RAM */ common_startup(); /* Perform processor initialization */ sysinit(); printf("\n\n"); /* Determine the last cause(s) of reset */ outSRS(); /* Determine specific Kinetis device and revision */ cpu_identify(); /* Jump to main process */ main(); /* No actions to perform after this so wait forever */ while(1); }
/*! * \brief Kinetis Start * \return None * * This function calls all of the needed starup routines and then * branches to the main process. */ void start(void) { //#ifdef DEBUG /* 关闭看门狗 */ wdog_disable(); //#endif /* 复制中断向量表、初始化数据、以__ramfunc声明的子函数复制到RAM区 */ common_startup(); /* CPU初始化,设置频率 */ sysinit(); #if (defined(DEBUG) && defined(DEBUG_PRINT)) printf("\n\n\t\t野火kinetis核心板测试程序\n"); printf("内核频率:%dMHz\t总线频率 :%dMHz\nflex频率:%dMHz \tflash频率:%dMHz\n\n",\ core_clk_mhz,core_clk_mhz/(mcg_div.bus_div+1),core_clk_mhz/(mcg_div.flex_div+1),core_clk_mhz/(mcg_div.flash_div+1)); /* Determine the last cause(s) of reset */ if (MC_SRSH & MC_SRSH_SW_MASK) printf("Software Reset\n"); if (MC_SRSH & MC_SRSH_LOCKUP_MASK) printf("Core Lockup Event Reset\n"); if (MC_SRSH & MC_SRSH_JTAG_MASK) printf("JTAG Reset\n"); if (MC_SRSL & MC_SRSL_POR_MASK) printf("Power-on Reset\n"); if (MC_SRSL & MC_SRSL_PIN_MASK) printf("External Pin Reset\n"); if (MC_SRSL & MC_SRSL_COP_MASK) printf("Watchdog(COP) Reset\n"); if (MC_SRSL & MC_SRSL_LOC_MASK) printf("Loss of Clock Reset\n"); if (MC_SRSL & MC_SRSL_LVD_MASK) printf("Low-voltage Detect Reset\n"); if (MC_SRSL & MC_SRSL_WAKEUP_MASK) printf("LLWU Reset\n"); /* 这两个数组的地址 在 链接器Linker文件,即ICF文件 定义 */ extern uint32 __VECTOR_TABLE[]; extern uint32 __VECTOR_RAM[]; /* 检测是否需要 复制中断向量表,即可以知道是ROM启动还是RAM启动*/ printf("\n野火Kinetis开发板启动方式:"); if (__VECTOR_RAM != __VECTOR_TABLE) printf("flash启动\n"); else printf("SRAM启动\n"); /* Determine specific Kinetis device and revision */ cpu_identify(); #endif //DUBUG && DEBUG_PRINT /* 跳进main函数 */ main(); /* 保证CPU不会停止执行 */ while(1); }
//-------------------------------------------------------------------------* //函数名: start * //功 能: 系统启动 * //参 数: 无 * //说 明: 无 * //-------------------------------------------------------------------------* void start(void) { //关闭看门狗 wdog_disable(); //复制中断向量表到RAM中 common_startup(); //系统设置 sysinit(); //进入主函数 main(); }
/*! * \brief Kinetis Start * \return None * * This function calls all of the needed starup routines and then * branches to the main process. */ void start(void) { /* Disable the watchdog timer */ wdog_disable(); /* Copy any vector or data sections that need to be in RAM */ common_startup(); /* Jump to main process */ main(); /* No actions to perform after this so wait forever */ while(1); }
/* * 描述: Kinetis启动代码 * 返回值: 无 * * This function calls all of the needed starup routines and then * branches to the main process. */ void start(void) { /* 禁用看门狗定时器 */ wdog_disable(); /* 复制需要用到的中断向量表和数据段到RAM中 */ common_startup(); /* 执行处理器初始化 */ sysinit(); #if(defined(DEBUG_PRINT)) if (MC_SRSH & MC_SRSH_SW_MASK) printf("Software Reset\r\n"); if (MC_SRSH & MC_SRSH_LOCKUP_MASK) printf("Core Lockup Event Reset\r\n"); if (MC_SRSH & MC_SRSH_JTAG_MASK) printf("JTAG Reset\r\n"); if (MC_SRSL & MC_SRSL_POR_MASK) printf("Power-on Reset\r\n"); if (MC_SRSL & MC_SRSL_PIN_MASK) printf("External Pin Reset\r\n"); if (MC_SRSL & MC_SRSL_COP_MASK) printf("Watchdog(COP) Reset\r\n"); if (MC_SRSL & MC_SRSL_LOC_MASK) printf("Loss of Clock Reset\r\n"); if (MC_SRSL & MC_SRSL_LVD_MASK) printf("Low-voltage Detect Reset\r\n"); if (MC_SRSL & MC_SRSL_WAKEUP_MASK) printf("LLWU Reset\r\n"); /* Determine specific Kinetis device and revision */ cpu_identify(); #endif /* 执行main主函数 */ main(); /* 无限等待 */ while(1); }
/*! * \brief Kinetis Start * \return None * * This function calls all of the needed starup routines and then * branches to the main process. */ void start(void) { /* Disable the watchdog timer */ wdog_disable(); /* Copy any vector or data sections that need to be in RAM */ common_startup(); /* Perform processor initialization */ sysinit(); printf("\n\n"); /* Determine the last cause(s) of reset */ if (MC_SRSH & MC_SRSH_SW_MASK) printf("Software Reset\n"); if (MC_SRSH & MC_SRSH_LOCKUP_MASK) printf("Core Lockup Event Reset\n"); if (MC_SRSH & MC_SRSH_JTAG_MASK) printf("JTAG Reset\n"); if (MC_SRSL & MC_SRSL_POR_MASK) printf("Power-on Reset\n"); if (MC_SRSL & MC_SRSL_PIN_MASK) printf("External Pin Reset\n"); if (MC_SRSL & MC_SRSL_COP_MASK) printf("Watchdog(COP) Reset\n"); if (MC_SRSL & MC_SRSL_LOC_MASK) printf("Loss of Clock Reset\n"); if (MC_SRSL & MC_SRSL_LVD_MASK) printf("Low-voltage Detect Reset\n"); if (MC_SRSL & MC_SRSL_WAKEUP_MASK) printf("LLWU Reset\n"); /* Determine specific Kinetis device and revision */ cpu_identify(); /* Jump to main process */ main(); /* No actions to perform after this so wait forever */ while(1); }
/*! * \brief Kinetis Start * \return None * * This function calls all of the needed starup routines and then * branches to the main process. */ void start(void) { /* Disable the watchdog timer but enable update */ WDOG_DisableWDOGEnableUpdate(); #ifndef __GNUC__ #ifndef KEIL /* Copy any vector or data sections that need to be in RAM */ common_startup(); #endif #endif /* Jump to main process */ main(); /* No actions to perform after this so wait forever */ while(1); }
/*! * \brief Kinetis Start * \return None * * This function calls all of the needed starup routines and then * branches to the main process. */ void start(void) { /* Disable the watchdog timer */ wdog_disable(); /* Copy any vector or data sections that need to be in RAM */ common_startup(); /* Perform processor initialization */ sysinit(); /* Determine the flash revision */ flash_identify(); /* Jump to main process */ main(); /* No actions to perform after this so wait forever */ while(1); }
int main(int argc, char *argv[]) { char basepath[FILENAME_MAX]; char path[FILENAME_MAX]; char *p; common_startup(); p = strrchr(argv[0], '/'); if (p == NULL) { p = argv[0]; } else { ++p; } snprintf(basepath, FILENAME_MAX, "%.*sdata/", (int) (p - argv[0]), argv[0]); /* Cleanup */ { #define RM(File) \ snprintf(path, FILENAME_MAX, "%s/%s", basepath, File); \ unlink(path); RM("test1_greylist.db"); RM("test1_whitelist.db"); RM("test2_greylist.db"); RM("test2_whitelist.db"); RM("test1_rate.db"); #undef RM } snprintf(path, FILENAME_MAX, "%s/test.conf", basepath); config_t *config = config_read(path); if (config == NULL) { return 1; } #define RUN(Name, Test, ...) \ printf("Running %s:\n", Name); \ printf("%s\n", run_##Test(config, basepath, ##__VA_ARGS__) ? "SUCCESS" \ : "FAILED"); /* Test stateless filters */ DIR *dir = opendir(basepath); if (dir == NULL) { UNIXERR("opendir"); return 1; } struct dirent *ent; while ((ent = readdir(dir)) != NULL) { if (strncmp("testcase_", ent->d_name, 9) == 0) { RUN(ent->d_name, testcase, ent->d_name); } } closedir(dir); /* Test greylist */ RUN("greylist", greylisttest); /* Test rate control */ RUN("rate", ratetest); #undef RUN return 0; }