《示功仪嵌入式软件讲解》由会员分享,可在线阅读,更多相关《示功仪嵌入式软件讲解(60页珍藏版)》请在金锄头文库上搜索。
1、60示功仪嵌入式软件V1.0#include usi.h#include frw.hstatic void *frw_core_config_pthread_routine(void *arg)frw_core_config_pthread_t *pthread = (frw_core_config_pthread_t *)arg;frw_lib_pthread_init_t init = pthread-init;frw_lib_pthread_block_t block = pthread-block;frw_lib_pthread_deal_t deal = pthread-deal;u
2、si_uint8_t argsFRW_LIB_PTHREAD_OWNED_SIZE;usi_status_t ret;if (init) if (init(args) != USI_SUCCESS) return NULL;if (!block | !deal) return NULL;while(1) ret = block(args);if (deal(ret, args) != USI_SUCCESS) continue;return NULL;frw_core_config_pthread_t frw_core_config_pthreads = timer, FRW_LIB_PTHR
3、EAD_PRIORITY_HIGHEST, 0, frw_core_timer_thread_init, frw_core_timer_thread_block, frw_core_timer_thread_deal, USI_TRUE , , 0, 0, NULL, NULL, NULL, USI_FALSE ;usi_status_t _init frw_core_config_pthread(void)usi_uint32_t desc, i = 0;while (frw_core_config_pthreadsi.init) if (FRW_PTHREAD_NR_MAX = i) re
4、turn USI_ERROR;if (USI_FALSE = frw_core_config_pthreadsi.used) i+;continue;desc = frw_lib_pthread_create(frw_core_config_pthreadsi.priority,frw_core_config_pthreadsi.stack,frw_core_config_pthread_routine,&frw_core_config_pthreadsi);if (FRW_LIB_PTHREAD_DESC_INVALID = desc) return USI_ERROR;i+;return
5、USI_SUCCESS;frw_core_config_sch_t frw_core_config_schs = main, FRW_SCH_MAIN, FRW_CORE_SCH_PRIORITY_M, 0, frw_core_sch_main, USI_TRUE , , 0, 0, 0, NULL, USI_FALSE ;usi_status_t _init frw_core_config_sch(void)usi_uint32_t i = 0;while (frw_core_config_schsi.start) if (FRW_SCH_NR_MAX = i) return USI_ERR
6、OR;if (USI_FALSE = frw_core_config_schsi.used) i+;continue;if (frw_core_sch_create(frw_core_config_schsi.name,frw_core_config_schsi.sch,frw_core_config_schsi.priority,frw_core_config_schsi.stack,frw_core_config_schsi.start) != USI_SUCCESS) return USI_ERROR;i+;return USI_SUCCESS;frw_core_config_proc_
7、t frw_core_config_procs = frw_ctrl_proc, FRW_PROC_CTRL, FRW_SCH_MAIN, FRW_SCH_PROC_T0, FRW_TIME_FOREVER, FRW_TIME_03_SEC, frw_ctrl_proc , frw_test0_proc, FRW_PROC_GEN(1, 0), FRW_SCH_MAIN, FRW_SCH_PROC_T3, FRW_TIME_FOREVER, FRW_TIME_03_SEC, frw_test0_proc , frw_test1_proc, FRW_PROC_GEN(2, 0), FRW_SCH
8、_MAIN, FRW_SCH_PROC_T2, FRW_TIME_FOREVER, FRW_TIME_03_SEC, frw_test1_proc , frw_test2_proc, FRW_PROC_GEN(3, 0), FRW_SCH_MAIN, FRW_SCH_PROC_T1, FRW_TIME_FOREVER, FRW_TIME_03_SEC, frw_test2_proc , , 0, 0, 0, 0, 0, NULL ;usi_status_t _init frw_core_config_proc(void)usi_uint32_t i = 0;while (frw_core_co
9、nfig_procsi.start) if (FRW_PROC_CLS_NR_MAX * FRW_PROC_INST_NR_MAX) 16) & 0xffff);usi_uint16_t inst = (usi_uint16_t)(proc & 0xffff);usi_assert(!inst);return cls * FRW_PROC_INST_NR_MAX + inst;frw_core_proc_list_t *frw_core_proc_get_list(usi_uint32_t *nr)frw_core_sch_pcb_t *pcb;usi_uint32_t type, desc,
10、 i = 0;for (type = 0; type = FRW_SCH_PROC_T3; type+) for (desc = 0; desc ithresh) continue;if (type = pcb-type) frw_core_proc_listsi.proc = pcb-proc;frw_core_proc_listsi.ithresh = pcb-ithresh;frw_core_proc_listsi.rthresh = pcb-rthresh;i+;*nr = i;return frw_core_proc_lists;frw_core_sch_pcb_t *frw_cor
11、e_proc_alloc_pcb(usi_uint32_t proc)usi_uint32_t desc; desc = frw_core_proc_calc_desc(proc);if (FRW_PROC_CLS_NR_MAX * FRW_PROC_INST_NR_MAX) = desc) frw_dbg_output(FRW_SYSTEM_LO, FRW_MODULE_LO, FRW_DBG_LEVEL_WARN, frw_core_proc_alloc_pcb(): invalid proc(%d).n, proc);return NULL;if (USI_TRUE = frw_core_proc_descsdesc.used) frw_dbg_output(FRW_SYSTEM_LO, FRW_MODULE_LO, FRW_DBG_LEVEL_WARN, frw_core_proc_alloc_pcb(): proc(%d) in use.