想建立自己项目的话,可以查阅文档中的Create New Application For CC2530DB来查看。根据官方文档,需要串口数据的话就用SerialApp Project ...\Projects\zstack\Utilities.,一切都从新开始的话可以用GenericApp project ...\Projects\zstack\Samples.
/********************************************************************* * @fn main * @brief First function called after startup. * @return don't care */ intmain( void ) { //关闭所有中断 osal_int_disable( INTS_ALL );
//初始化板子相关硬件(LED等) HAL_BOARD_INIT();
//检查电源电压以确保运行 zmain_vdd_check();
//初始化板载 I/O InitBoard( OB_COLD );
//初始化Hal层驱动 HalDriverInit();
//初始化NV系统 osal_nv_init( NULL );
//初始化Mac层 ZMacInit();
//确定扩展地址 zmain_ext_addr();
#if defined ZCL_KEY_ESTABLISH //初始化Certicom证书信息 zmain_cert_init(); #endif
//初始化基础NV事务 zgInit();
#ifndef NONWK // Since the AF isn't a task, call it's initialization routine afInit();//初始化AF例程 #endif
//初始化操作系统 osal_init_system();
//允许中断 osal_int_enable( INTS_ALL );
// Final board initialization InitBoard( OB_READY );
// Display information about this device zmain_dev_info();
/* Display the device info on the LCD */ #ifdef LCD_SUPPORTED zmain_lcd_init(); //初始化LCD #endif
#ifdef WDT_IN_PM1 /* If WDT is used, this is a good place to enable it. */ WatchDogEnable( WDTIMX ); #endif
/********************************************************************* * @fn osal_start_system * * @brief * * This function is the main loop function of the task system (if * ZBIT and UBIT are not defined). This Function doesn't return. * * @param void * * @return none */ voidosal_start_system( void ) { #if !defined ( ZBIT ) && !defined ( UBIT ) for(;;) // Forever Loop #endif { osal_run_system(); // } }
HAL_ENTER_CRITICAL_SECTION(intState); //进入临界区 tasksEvents[idx] |= events; // 返回未处理的事件 HAL_EXIT_CRITICAL_SECTION(intState); //推出临界区 } #if defined( POWER_SAVING ) else// Complete pass through all task events with no activity? { osal_pwrmgr_powerconserve(); // Put the processor/system into sleep } #endif
/* Yield in case cooperative scheduling is being used. */ #if defined (configUSE_PREEMPTION) && (configUSE_PREEMPTION == 0) { osal_task_yield(); } #endif }
/********************************************************************* * @fn osal_init_system * * @brief * * This function initializes the "task" system by creating the * tasks defined in the task table (OSAL_Tasks.h). * * @param void * * @return SUCCESS */ uint8 osal_init_system( void ) { // Initialize the Memory Allocation System osal_mem_init();
// Initialize the message queue osal_qHead = NULL;
// Initialize the timers osalTimerInit();
// Initialize the Power Management System osal_pwrmgr_init();
// Initialize the system tasks. osalInitTasks();
// Setup efficient search for the first free block of heap. osal_mem_kick();
/********************************************************************* * GLOBAL VARIABLES */
// The order in this table must be identical to the task initialization calls below in osalInitTask. const pTaskEventHandlerFn tasksArr[] = { macEventLoop, nwk_event_loop, Hal_ProcessEvent, #if defined( MT_TASK ) MT_ProcessEvent, #endif APS_event_loop, #if defined ( ZIGBEE_FRAGMENTATION ) APSF_ProcessEvent, #endif ZDApp_event_loop, #if defined ( ZIGBEE_FREQ_AGILITY ) || defined ( ZIGBEE_PANID_CONFLICT ) ZDNwkMgr_event_loop, #endif Smart_home_ProcessEvent };