TI中文支持网
TI专业的中文技术问题搜集分享网站

CC2530: 使用IAR8.10编译ZStack2问题

Part Number:CC2530Other Parts Discussed in Thread:Z-STACK

我在构建工程时出现如下错误

Error[e27]: Entry "Control" in module AddressMenu ( D:\ZM\BSZigbee\Gateway\Projects\zstack\Samples\SampleApp\CC2530DB\CoordinatorEB-Pro\Obj\AddressMenu.r51 ) redefined in module OSAL_SampleApp ( D:\ZM\BSZigbee\Gateway\Projects\zstack\Samples\SampleApp\CC2530DB\CoordinatorEB-Pro\Obj\OSAL_SampleApp.r51 )Error while running Linker

但是我在这两份代码文件中都没有找到任何名为Control的定义,请问如何解决?

Nick Sun:

您好,

感谢您的对TI产品的关注!为更加有效地解决您的问题,我需要多一些时间查看这个问题,稍后会为您解答。

,

CXY CSSD:

好的,您需要我的代码文件吗?

,

Nick Sun:

您好,

您可以发过来。我这边还有几个问题:您使用哪个 Z-Stack 版本?您是否使用版本说明中描述的匹配 IAR 版本?

,

YiKai Chen:

請問你使用的Z-Stack版本?有使用release note裡面提到對應的IAR版本嗎?

,

CXY CSSD:

使用ZStack2.3.0-1.4.0,IAR版本为8.10

,

YiKai Chen:

ZStack2.3.0-1.4.0應該不是用使用ZStack2.3.0-1.4.0,你要不要看一下ZStack2.3.0-1.4.0安裝目錄下的release note看看IAR該用什麼版本;另外ZStack2.3.0-1.4.0太舊了,建議你換用最新的Z-Stack 3.0.2

,

CXY CSSD:

原始协议栈内自带的SmapleApp可以编译,但是加入我的代码后不能编译了

,

Nick Sun:

您好,

TI 将无法支持此已弃用的 Z-Stack 软件。 请按照 YiKai 关于 IAR 版本的说明进行操作,然后确认默认项目可以正确构建。 接下来,确定导致问题的特定应用程序代码,并相应地进行修改以避免问题。

,

CXY CSSD:

定位到了出错代码,但是代码中并没有定义任何名为Control的,可能是编译时生成的导致链接错误

,

YiKai Chen:

這個應該就是IAR版本的問題,如果沒記錯的話你至少要用7.50的版本

,

CXY CSSD:

但是我使用的是8.10?

,

YiKai Chen:

所以你至少要用7.50的版本

,

CXY CSSD:

这个是8.10下的报错(报错内容如题),8.10应该高于7.5吧?

/********************************************************************** INCLUDES*/
#include "SampleAppHw.h"#include "OSAL.h"
#include "OSAL_Nv.h"
#include "ZGlobals.h"
#include "AF.h"
#include "aps_groups.h"
#include "ZDApp.h"#include "OnBoard.h"/* HAL */
#include "hal_lcd.h"
#include "hal_led.h"
#include "hal_key.h"#ifndef SAMPLEAPP_H
#define SAMPLEAPP_H#ifdef __cplusplus
extern "C"
{
#endif/********************************************************************** INCLUDES*/
#include "ZComDef.h"/********************************************************************** CONSTANTS*/// These constants are only for example and should be changed to the
// device's needs
#define SAMPLEAPP_ENDPOINT20#define SAMPLEAPP_PROFID0x0F08
#define SAMPLEAPP_DEVICEID0x0001
#define SAMPLEAPP_DEVICE_VERSION0
#define SAMPLEAPP_FLAGS0#define SAMPLEAPP_MAX_CLUSTERS2
#define SAMPLEAPP_PERIODIC_CLUSTERID 1
#define SAMPLEAPP_FLASH_CLUSTERID2
#define SAMPLEAPP_COM_CLUSTERID3
#define SAMPLEAPP_P2P_CLUSTERID4#define DATA_PIN P0_4//定义P0.5口为继电器的控制端#define ZD_NV_START_ADDRESS 0x0402//定义掉电存储起始条目地址// Send Message Timeout
#define SAMPLEAPP_SEND_PERIODIC_MSG_TIMEOUT1000// Every 1 seconds// Application Events (OSAL) - These are bit weighted definitions.
#define SAMPLEAPP_SEND_PERIODIC_MSG_EVT0x0001// Group ID for Flash Command
#define SAMPLEAPP_FLASH_GROUP0x0001// Flash Command Duration - in milliseconds
#define SAMPLEAPP_FLASH_DURATION1000// This list should be filled with Application specific Cluster IDs.
const cId_t SampleApp_ClusterList[SAMPLEAPP_MAX_CLUSTERS] =
{SAMPLEAPP_PERIODIC_CLUSTERID,
};void SampleApp_MessageMSGCB( afIncomingMSGPacket_t *pckt );const SimpleDescriptionFormat_t SampleApp_SimpleDesc =
{SAMPLEAPP_ENDPOINT,//int Endpoint;SAMPLEAPP_PROFID,//uint16 AppProfId[2];SAMPLEAPP_DEVICEID,//uint16 AppDeviceId[2];SAMPLEAPP_DEVICE_VERSION,//intAppDevVer:4;SAMPLEAPP_FLAGS,//intAppFlags:4;SAMPLEAPP_MAX_CLUSTERS,//uint8AppNumInClusters;(cId_t *)SampleApp_ClusterList,//uint8 *pAppInClusterList;SAMPLEAPP_MAX_CLUSTERS,//uint8AppNumInClusters;(cId_t *)SampleApp_ClusterList//uint8 *pAppInClusterList;
};// This is the Endpoint/Interface description.It is defined here, but
// filled-in in SampleApp_Init().Another way to go would be to fill
// in the structure here and make it a "const" (in code space).The
// way it's defined in this sample app it is define in RAM.
endPointDesc_t SampleApp_epDesc;/********************************************************************** LOCAL VARIABLES*/
uint8 SampleApp_TaskID;// Task ID for internal task/event processing// This variable will be received when// SampleApp_Init() is called.
devStates_t SampleApp_NwkState;uint8 SampleApp_TransID;// This is the unique message ID (counter)afAddrType_t SampleApp_Periodic_DstAddr;
afAddrType_t SampleApp_Flash_DstAddr;aps_Group_t SampleApp_Group;uint8 SampleAppPeriodicCounter = 0;
uint8 SampleAppFlashCounter = 0;/********************************************************************** GLOBAL VARIABLES*/
uint8 LedState = 0;//LED状态uint8 FunState = 0;//风扇状态uint8 Control = 0;//开关控制,0为一起,1为灯,2为风扇uint16 ZD_NV_OFFSET = 0xFFF;//掉电存储条目偏移,初始化最大uint16 Local_Fun_Code = 0xFFFF;//本机功能代码,初始化最大uint16 Local_Address = 0xFFF;//本机地址码,初始化最大uint16 Gateway_Bus_Address = 0xFFF;//子网总线地址,初始化最大/********************************************************************** STRUCTS*///本机信息
struct EquPar
{uint16 FunCode;uint16 Address;
};//地址功能表信息
struct AddressInfo
{uint16 BusAddress;uint16 OffsetAddress;
};//数据包
struct Packet
{uint16 SourceAddress;uint16 TargetAddress;uint16 Type;uint16 Data;uint16 Verify;
};struct Parket* ParketTempBuf = NULL;extern void SampleApp_Init( uint8 task_id );void SampleApp_HandleKeys( uint8 shift, uint8 keys );/********************************************************************** FUNCTIONS*/void SampleApp_SendPeriodicMessage( void );extern UINT16 SampleApp_ProcessEvent( uint8 task_id, uint16 events );extern void ReceiveData(struct Packet Data);extern uint8 ZigbeeSend(uint16 Data, uint16 Address, uint16 Type);extern uint16 Get_BusAddress(void);extern void AddressTable_Init(void);extern uint8* ConversionToRF(struct Packet Data);extern void ConversionToData(uint8* Data);extern void AddDevice(uint16 Type);/*********************************************************************
*********************************************************************/#ifdef __cplusplus
}
#endif#endif /* SAMPLEAPP_H */
/********************************************************************** INCLUDES*/
#include "SampleApp.h"
#include "SampleAppHw.h"#include "OSAL.h"
#include "OSAL_Nv.h"
#include "ZGlobals.h"
#include "AF.h"
#include "aps_groups.h"
#include "ZDApp.h"#include "OnBoard.h"/* HAL */
#include "hal_lcd.h"
#include "hal_led.h"
#include "hal_key.h"/********************************************************************** PUBLIC FUNCTIONS*/void SampleApp_Init( uint8 task_id )
{SampleApp_TaskID = task_id;SampleApp_NwkState = DEV_INIT;SampleApp_TransID = 0;P0SEL &= ~0x10;//设置P0.4口为普通IOP0DIR |= 0x10;//设置P0.4口为输出AddressTable_Init();//执行地址功能表初始化// Device hardware initialization can be added here or in main() (Zmain.c).// If the hardware is application specific - add it here.// If the hardware is other parts of the device add it in main().#if defined ( BUILD_ALL_DEVICES )// The "Demo" target is setup to have BUILD_ALL_DEVICES and HOLD_AUTO_START// We are looking at a jumper (defined in SampleAppHw.c) to be jumpered// together - if they are - we will start up a coordinator. Otherwise,// the device will start as a router.if ( readCoordinatorJumper() )zgDeviceLogicalType = ZG_DEVICETYPE_COORDINATOR;elsezgDeviceLogicalType = ZG_DEVICETYPE_ROUTER;
#endif // BUILD_ALL_DEVICES#if defined ( HOLD_AUTO_START )// HOLD_AUTO_START is a compile option that will surpress ZDApp//from starting the device and wait for the application to//start the device.ZDOInitDevice(0);
#endif// Setup for the periodic message's destination address// Broadcast to everyoneSampleApp_Periodic_DstAddr.addrMode = (afAddrMode_t)AddrBroadcast;SampleApp_Periodic_DstAddr.endPoint = SAMPLEAPP_ENDPOINT;SampleApp_Periodic_DstAddr.addr.shortAddr = 0xFFFF;// Setup for the flash command's destination address - Group 1SampleApp_Flash_DstAddr.addrMode = (afAddrMode_t)afAddrGroup;SampleApp_Flash_DstAddr.endPoint = SAMPLEAPP_ENDPOINT;SampleApp_Flash_DstAddr.addr.shortAddr = SAMPLEAPP_FLASH_GROUP; //组号1// Fill out the endpoint description.SampleApp_epDesc.endPoint = SAMPLEAPP_ENDPOINT;SampleApp_epDesc.task_id = &SampleApp_TaskID;SampleApp_epDesc.simpleDesc= (SimpleDescriptionFormat_t *)&SampleApp_SimpleDesc;SampleApp_epDesc.latencyReq = noLatencyReqs;// Register the endpoint description with the AFafRegister( &SampleApp_epDesc );// Register for all key events - This app will handle all key eventsRegisterForKeys( SampleApp_TaskID );// By default, all devices start out in Group 1SampleApp_Group.ID = 0x0001;osal_memcpy( SampleApp_Group.name, "Group 1", 7 );aps_AddGroup( SAMPLEAPP_ENDPOINT, &SampleApp_Group );#if defined ( LCD_SUPPORTED )HalLcdWriteString( "SampleApp", HAL_LCD_LINE_1 );
#endif
}void SampleApp_HandleKeys( uint8 shift, uint8 keys )
{(void)shift;// Intentionally unreferenced parameterif ( keys & HAL_KEY_SW_6 ){SampleApp_SendPeriodicMessage();//发送数据}if ( keys & HAL_KEY_SW_1 ){/* The Flashr Command is sent to Group 1.* This key toggles this device in and out of group 1.* If this device doesn't belong to group 1, this application* will not receive the Flash command sent to group 1.*/aps_Group_t *grp;grp = aps_FindGroup( SAMPLEAPP_ENDPOINT, SAMPLEAPP_FLASH_GROUP );if ( grp ){// Remove from the groupaps_RemoveGroup( SAMPLEAPP_ENDPOINT, SAMPLEAPP_FLASH_GROUP );}else{// Add to the flash groupaps_AddGroup( SAMPLEAPP_ENDPOINT, &SampleApp_Group );}}
}/*********************************************************************
*********************************************************************/
/********************************************************************** INCLUDES*/
#include "SampleApp.h"
#include "OSAL.h"
#include "OSAL_Nv.h"
#include "ZGlobals.h"
#include "aps_groups.h"
#include "ZDApp.h"#include "OnBoard.h"uint16 Get_BusAddress(void){uint16 Results = 0xFFF;//总线地址,初始化为最大值return Results;
}void AddressTable_Init(void){struct EquPar LocalTempBuf1, InitTempBuf1;uint8 InitNVStatus1 = osal_nv_item_init(ZD_NV_START_ADDRESS, sizeof(LocalTempBuf1), NULL);//初始化本机信息条目if(InitNVStatus1 != NV_OPER_FAILED){//判断读取成功if(InitNVStatus1 == SUCCESS){//非首次组网osal_nv_read(ZD_NV_START_ADDRESS, 0, sizeof(LocalTempBuf1), &LocalTempBuf1);//读取本机信息条目Local_Fun_Code = LocalTempBuf1.FunCode;Local_Address = LocalTempBuf1.Address;}else if(InitNVStatus1 == NV_ITEM_UNINIT){//首次组网(本代码为网关)InitTempBuf1.FunCode = 0x0001;InitTempBuf1.Address = 0x000;osal_nv_write(ZD_NV_START_ADDRESS, 0, sizeof(InitTempBuf1), &InitTempBuf1);//网关信息写入,网关地址永为0x000,网关功能码为0x0001}}struct AddressInfo LocalTempBuf2, InitTempBuf2;uint8 InitNVStatus2 = osal_nv_item_init(ZD_NV_START_ADDRESS+1, sizeof(LocalTempBuf2), NULL);//初始化地址表头条目if(InitNVStatus2 != NV_OPER_FAILED){//判断读取成功if(InitNVStatus2 == SUCCESS){//非首次组网osal_nv_read(ZD_NV_START_ADDRESS+1, 0, sizeof(LocalTempBuf2), &LocalTempBuf2);//读取原地址表头Gateway_Bus_Address = LocalTempBuf2.BusAddress;ZD_NV_OFFSET = LocalTempBuf2.OffsetAddress;}else if(InitNVStatus2 == NV_ITEM_UNINIT){//首次组网(本代码为网关)InitTempBuf2.BusAddress = Get_BusAddress();InitTempBuf2.OffsetAddress = 2;ZD_NV_OFFSET = 2;osal_nv_write(ZD_NV_START_ADDRESS+1, 0, sizeof(InitTempBuf2), &InitTempBuf2);//获取子网地址信息,偏移地址为3,并向服务器索取总线地址}}return;
}void AddDevice(uint16 Type){struct EquPar DeviceTempBuf;uint8 InitNVStatus1 = osal_nv_item_init(ZD_NV_START_ADDRESS+ZD_NV_OFFSET, sizeof(DeviceTempBuf), NULL);//新增一条地址表if(InitNVStatus1 == NV_ITEM_UNINIT){DeviceTempBuf.FunCode = Type;DeviceTempBuf.Address = 0x000 + ZD_NV_OFFSET - 1;osal_nv_write(ZD_NV_START_ADDRESS+ZD_NV_OFFSET, 0, sizeof(DeviceTempBuf), &DeviceTempBuf);//ZigbeeSend();ZD_NV_OFFSET++;struct AddressInfo TempBuf;uint8 InitNVStatus2 = osal_nv_item_init(ZD_NV_START_ADDRESS+1, sizeof(TempBuf), NULL);if(InitNVStatus2 == SUCCESS){TempBuf.BusAddress = Gateway_Bus_Address;TempBuf.OffsetAddress = ZD_NV_OFFSET;osal_nv_write(ZD_NV_START_ADDRESS+1, 0, sizeof(TempBuf), &TempBuf);}}return;
}
/**************************************************************************************************Filename:OSAL_SampleApp.cRevised:$Date: 2008-02-07 12:10:00 -0800 (Thu, 07 Feb 2008) $Revision:$Revision: 16360 $Description:This file contains all the settings and other functionsthat the user should set and change.Copyright 2007 Texas Instruments Incorporated. All rights reserved.IMPORTANT: Your use of this Software is limited to those specific rightsgranted under the terms of a software license agreement between the userwho downloaded the software, his/her employer (which must be your employer)and Texas Instruments Incorporated (the "License").You may not use thisSoftware unless you agree to abide by the terms of the License. The Licenselimits your use, and you acknowledge, that the Software may not be modified,copied or distributed unless embedded on a Texas Instruments microcontrolleror used solely and exclusively in conjunction with a Texas Instruments radiofrequency transceiver, which is integrated into your product.Other than forthe foregoing purpose, you may not use, reproduce, copy, prepare derivativeworks of, modify, distribute, perform, display or sell this Software and/orits documentation for any purpose.YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION AREPROVIDED 揂S IS?WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALLTEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHERLEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSESINCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVEOR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENTOF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.Should you have any questions regarding your right to use this Software,contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************//********************************************************************** INCLUDES*/#include "ZComDef.h"
#include "hal_drivers.h"
#include "OSAL.h"
#include "OSAL_Tasks.h"#if defined ( MT_TASK )#include "MT.h"#include "MT_TASK.h"
#endif#include "nwk.h"
#include "APS.h"
#include "ZDApp.h"
#if defined ( ZIGBEE_FREQ_AGILITY ) || defined ( ZIGBEE_PANID_CONFLICT )#include "ZDNwkMgr.h"
#endif
#if defined ( ZIGBEE_FRAGMENTATION )#include "aps_frag.h"
#endif#include "SampleApp.h"/********************************************************************** 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,
#endifAPS_event_loop,
#if defined ( ZIGBEE_FRAGMENTATION )APSF_ProcessEvent,
#endifZDApp_event_loop,
#if defined ( ZIGBEE_FREQ_AGILITY ) || defined ( ZIGBEE_PANID_CONFLICT )ZDNwkMgr_event_loop,
#endifSampleApp_ProcessEvent
};const uint8 tasksCnt = sizeof( tasksArr ) / sizeof( tasksArr[0] );
uint16 *tasksEvents;/********************************************************************** FUNCTIONS*********************************************************************//********************************************************************** @fnosalInitTasks** @briefThis function invokes the initialization function for each task.** @paramvoid** @returnnone*/
void osalInitTasks( void )
{uint8 taskID = 0;tasksEvents = (uint16 *)osal_mem_alloc( sizeof( uint16 ) * tasksCnt);osal_memset( tasksEvents, 0, (sizeof( uint16 ) * tasksCnt));macTaskInit( taskID++ );nwk_init( taskID++ );Hal_Init( taskID++ );
#if defined( MT_TASK )MT_TaskInit( taskID++ );
#endifAPS_Init( taskID++ );
#if defined ( ZIGBEE_FRAGMENTATION )APSF_Init( taskID++ );
#endifZDApp_Init( taskID++ );
#if defined ( ZIGBEE_FREQ_AGILITY ) || defined ( ZIGBEE_PANID_CONFLICT )ZDNwkMgr_Init( taskID++ );
#endifSampleApp_Init( taskID );
}/*********************************************************************
*********************************************************************/

,

YiKai Chen:

8.10是高于7.5、所以不能編譯成功

,

CXY CSSD:

但是协议栈的原版SmapleApp使用IAR7.5打不开

,

YiKai Chen:

你有查看ZStack2.3.0-1.4.0安裝目錄下的release note看看IAR該用什麼版本嗎?

,

CXY CSSD:

显示8.10,并且8.10确实可以编译协议栈原始的SmapleApp

,

YiKai Chen:

CXY CSSD 说:并且8.10确实可以编译协议栈原始的SmapleApp

如果是這樣的話你的問題是?

,

CXY CSSD:

问题报错在原文中已给出,报错代码在之前的回复中写到了

,

CXY CSSD:

使用ZStack2.3.0-1.4.0,IAR版本为8.10,和文档中是完全匹配的

代码如下:

/**************************************************************************************************Filename:OSAL_SampleApp.cRevised:$Date: 2008-02-07 12:10:00 -0800 (Thu, 07 Feb 2008) $Revision:$Revision: 16360 $Description:This file contains all the settings and other functionsthat the user should set and change.Copyright 2007 Texas Instruments Incorporated. All rights reserved.IMPORTANT: Your use of this Software is limited to those specific rightsgranted under the terms of a software license agreement between the userwho downloaded the software, his/her employer (which must be your employer)and Texas Instruments Incorporated (the "License").You may not use thisSoftware unless you agree to abide by the terms of the License. The Licenselimits your use, and you acknowledge, that the Software may not be modified,copied or distributed unless embedded on a Texas Instruments microcontrolleror used solely and exclusively in conjunction with a Texas Instruments radiofrequency transceiver, which is integrated into your product.Other than forthe foregoing purpose, you may not use, reproduce, copy, prepare derivativeworks of, modify, distribute, perform, display or sell this Software and/orits documentation for any purpose.YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION AREPROVIDED 揂S IS?WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALLTEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHERLEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSESINCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVEOR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENTOF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.Should you have any questions regarding your right to use this Software,contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************//********************************************************************** INCLUDES*/#include "ZComDef.h"
#include "hal_drivers.h"
#include "OSAL.h"
#include "OSAL_Tasks.h"#if defined ( MT_TASK )#include "MT.h"#include "MT_TASK.h"
#endif#include "nwk.h"
#include "APS.h"
#include "ZDApp.h"
#if defined ( ZIGBEE_FREQ_AGILITY ) || defined ( ZIGBEE_PANID_CONFLICT )#include "ZDNwkMgr.h"
#endif
#if defined ( ZIGBEE_FRAGMENTATION )#include "aps_frag.h"
#endif#include "SampleApp.h"/********************************************************************** 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,
#endifAPS_event_loop,
#if defined ( ZIGBEE_FRAGMENTATION )APSF_ProcessEvent,
#endifZDApp_event_loop,
#if defined ( ZIGBEE_FREQ_AGILITY ) || defined ( ZIGBEE_PANID_CONFLICT )ZDNwkMgr_event_loop,
#endifSampleApp_ProcessEvent
};const uint8 tasksCnt = sizeof( tasksArr ) / sizeof( tasksArr[0] );
uint16 *tasksEvents;/********************************************************************** FUNCTIONS*********************************************************************//********************************************************************** @fnosalInitTasks** @briefThis function invokes the initialization function for each task.** @paramvoid** @returnnone*/
void osalInitTasks( void )
{uint8 taskID = 0;tasksEvents = (uint16 *)osal_mem_alloc( sizeof( uint16 ) * tasksCnt);osal_memset( tasksEvents, 0, (sizeof( uint16 ) * tasksCnt));macTaskInit( taskID++ );nwk_init( taskID++ );Hal_Init( taskID++ );
#if defined( MT_TASK )MT_TaskInit( taskID++ );
#endifAPS_Init( taskID++ );
#if defined ( ZIGBEE_FRAGMENTATION )APSF_Init( taskID++ );
#endifZDApp_Init( taskID++ );
#if defined ( ZIGBEE_FREQ_AGILITY ) || defined ( ZIGBEE_PANID_CONFLICT )ZDNwkMgr_Init( taskID++ );
#endifSampleApp_Init( taskID );
}/*********************************************************************
*********************************************************************/

/********************************************************************** INCLUDES*/
#include "SampleApp.h"
#include "OSAL.h"
#include "OSAL_Nv.h"
#include "ZGlobals.h"
#include "aps_groups.h"
#include "ZDApp.h"#include "OnBoard.h"uint16 Get_BusAddress(void){uint16 Results = 0xFFF;//总线地址,初始化为最大值return Results;
}void AddressTable_Init(void){struct EquPar LocalTempBuf1, InitTempBuf1;uint8 InitNVStatus1 = osal_nv_item_init(ZD_NV_START_ADDRESS, sizeof(LocalTempBuf1), NULL);//初始化本机信息条目if(InitNVStatus1 != NV_OPER_FAILED){//判断读取成功if(InitNVStatus1 == SUCCESS){//非首次组网osal_nv_read(ZD_NV_START_ADDRESS, 0, sizeof(LocalTempBuf1), &LocalTempBuf1);//读取本机信息条目Local_Fun_Code = LocalTempBuf1.FunCode;Local_Address = LocalTempBuf1.Address;}else if(InitNVStatus1 == NV_ITEM_UNINIT){//首次组网(本代码为网关)InitTempBuf1.FunCode = 0x0001;InitTempBuf1.Address = 0x000;osal_nv_write(ZD_NV_START_ADDRESS, 0, sizeof(InitTempBuf1), &InitTempBuf1);//网关信息写入,网关地址永为0x000,网关功能码为0x0001}}struct AddressInfo LocalTempBuf2, InitTempBuf2;uint8 InitNVStatus2 = osal_nv_item_init(ZD_NV_START_ADDRESS+1, sizeof(LocalTempBuf2), NULL);//初始化地址表头条目if(InitNVStatus2 != NV_OPER_FAILED){//判断读取成功if(InitNVStatus2 == SUCCESS){//非首次组网osal_nv_read(ZD_NV_START_ADDRESS+1, 0, sizeof(LocalTempBuf2), &LocalTempBuf2);//读取原地址表头Gateway_Bus_Address = LocalTempBuf2.BusAddress;ZD_NV_OFFSET = LocalTempBuf2.OffsetAddress;}else if(InitNVStatus2 == NV_ITEM_UNINIT){//首次组网(本代码为网关)InitTempBuf2.BusAddress = Get_BusAddress();InitTempBuf2.OffsetAddress = 2;ZD_NV_OFFSET = 2;osal_nv_write(ZD_NV_START_ADDRESS+1, 0, sizeof(InitTempBuf2), &InitTempBuf2);//获取子网地址信息,偏移地址为3,并向服务器索取总线地址}}return;
}void AddDevice(uint16 Type){struct EquPar DeviceTempBuf;uint8 InitNVStatus1 = osal_nv_item_init(ZD_NV_START_ADDRESS+ZD_NV_OFFSET, sizeof(DeviceTempBuf), NULL);//新增一条地址表if(InitNVStatus1 == NV_ITEM_UNINIT){DeviceTempBuf.FunCode = Type;DeviceTempBuf.Address = 0x000 + ZD_NV_OFFSET - 1;osal_nv_write(ZD_NV_START_ADDRESS+ZD_NV_OFFSET, 0, sizeof(DeviceTempBuf), &DeviceTempBuf);//ZigbeeSend();ZD_NV_OFFSET++;struct AddressInfo TempBuf;uint8 InitNVStatus2 = osal_nv_item_init(ZD_NV_START_ADDRESS+1, sizeof(TempBuf), NULL);if(InitNVStatus2 == SUCCESS){TempBuf.BusAddress = Gateway_Bus_Address;TempBuf.OffsetAddress = ZD_NV_OFFSET;osal_nv_write(ZD_NV_START_ADDRESS+1, 0, sizeof(TempBuf), &TempBuf);}}return;
}

/********************************************************************** INCLUDES*/
#include "SampleApp.h"
#include "SampleAppHw.h"#include "OSAL.h"
#include "OSAL_Nv.h"
#include "ZGlobals.h"
#include "AF.h"
#include "aps_groups.h"
#include "ZDApp.h"#include "OnBoard.h"/* HAL */
#include "hal_lcd.h"
#include "hal_led.h"
#include "hal_key.h"/********************************************************************** PUBLIC FUNCTIONS*/void SampleApp_Init( uint8 task_id )
{SampleApp_TaskID = task_id;SampleApp_NwkState = DEV_INIT;SampleApp_TransID = 0;P0SEL &= ~0x10;//设置P0.4口为普通IOP0DIR |= 0x10;//设置P0.4口为输出AddressTable_Init();//执行地址功能表初始化// Device hardware initialization can be added here or in main() (Zmain.c).// If the hardware is application specific - add it here.// If the hardware is other parts of the device add it in main().#if defined ( BUILD_ALL_DEVICES )// The "Demo" target is setup to have BUILD_ALL_DEVICES and HOLD_AUTO_START// We are looking at a jumper (defined in SampleAppHw.c) to be jumpered// together - if they are - we will start up a coordinator. Otherwise,// the device will start as a router.if ( readCoordinatorJumper() )zgDeviceLogicalType = ZG_DEVICETYPE_COORDINATOR;elsezgDeviceLogicalType = ZG_DEVICETYPE_ROUTER;
#endif // BUILD_ALL_DEVICES#if defined ( HOLD_AUTO_START )// HOLD_AUTO_START is a compile option that will surpress ZDApp//from starting the device and wait for the application to//start the device.ZDOInitDevice(0);
#endif// Setup for the periodic message's destination address// Broadcast to everyoneSampleApp_Periodic_DstAddr.addrMode = (afAddrMode_t)AddrBroadcast;SampleApp_Periodic_DstAddr.endPoint = SAMPLEAPP_ENDPOINT;SampleApp_Periodic_DstAddr.addr.shortAddr = 0xFFFF;// Setup for the flash command's destination address - Group 1SampleApp_Flash_DstAddr.addrMode = (afAddrMode_t)afAddrGroup;SampleApp_Flash_DstAddr.endPoint = SAMPLEAPP_ENDPOINT;SampleApp_Flash_DstAddr.addr.shortAddr = SAMPLEAPP_FLASH_GROUP; //组号1// Fill out the endpoint description.SampleApp_epDesc.endPoint = SAMPLEAPP_ENDPOINT;SampleApp_epDesc.task_id = &SampleApp_TaskID;SampleApp_epDesc.simpleDesc= (SimpleDescriptionFormat_t *)&SampleApp_SimpleDesc;SampleApp_epDesc.latencyReq = noLatencyReqs;// Register the endpoint description with the AFafRegister( &SampleApp_epDesc );// Register for all key events - This app will handle all key eventsRegisterForKeys( SampleApp_TaskID );// By default, all devices start out in Group 1SampleApp_Group.ID = 0x0001;osal_memcpy( SampleApp_Group.name, "Group 1", 7 );aps_AddGroup( SAMPLEAPP_ENDPOINT, &SampleApp_Group );#if defined ( LCD_SUPPORTED )HalLcdWriteString( "SampleApp", HAL_LCD_LINE_1 );
#endif
}void SampleApp_HandleKeys( uint8 shift, uint8 keys )
{(void)shift;// Intentionally unreferenced parameterif ( keys & HAL_KEY_SW_6 ){SampleApp_SendPeriodicMessage();//发送数据}if ( keys & HAL_KEY_SW_1 ){/* The Flashr Command is sent to Group 1.* This key toggles this device in and out of group 1.* If this device doesn't belong to group 1, this application* will not receive the Flash command sent to group 1.*/aps_Group_t *grp;grp = aps_FindGroup( SAMPLEAPP_ENDPOINT, SAMPLEAPP_FLASH_GROUP );if ( grp ){// Remove from the groupaps_RemoveGroup( SAMPLEAPP_ENDPOINT, SAMPLEAPP_FLASH_GROUP );}else{// Add to the flash groupaps_AddGroup( SAMPLEAPP_ENDPOINT, &SampleApp_Group );}}
}/*********************************************************************
*********************************************************************/

/********************************************************************** INCLUDES*/
#include "SampleAppHw.h"#include "OSAL.h"
#include "OSAL_Nv.h"
#include "ZGlobals.h"
#include "AF.h"
#include "aps_groups.h"
#include "ZDApp.h"#include "OnBoard.h"/* HAL */
#include "hal_lcd.h"
#include "hal_led.h"
#include "hal_key.h"#ifndef SAMPLEAPP_H
#define SAMPLEAPP_H#ifdef __cplusplus
extern "C"
{
#endif/********************************************************************** INCLUDES*/
#include "ZComDef.h"/********************************************************************** CONSTANTS*/// These constants are only for example and should be changed to the
// device's needs
#define SAMPLEAPP_ENDPOINT20#define SAMPLEAPP_PROFID0x0F08
#define SAMPLEAPP_DEVICEID0x0001
#define SAMPLEAPP_DEVICE_VERSION0
#define SAMPLEAPP_FLAGS0#define SAMPLEAPP_MAX_CLUSTERS2
#define SAMPLEAPP_PERIODIC_CLUSTERID 1
#define SAMPLEAPP_FLASH_CLUSTERID2
#define SAMPLEAPP_COM_CLUSTERID3
#define SAMPLEAPP_P2P_CLUSTERID4#define DATA_PIN P0_4//定义P0.5口为继电器的控制端#define ZD_NV_START_ADDRESS 0x0402//定义掉电存储起始条目地址// Send Message Timeout
#define SAMPLEAPP_SEND_PERIODIC_MSG_TIMEOUT1000// Every 1 seconds// Application Events (OSAL) - These are bit weighted definitions.
#define SAMPLEAPP_SEND_PERIODIC_MSG_EVT0x0001// Group ID for Flash Command
#define SAMPLEAPP_FLASH_GROUP0x0001// Flash Command Duration - in milliseconds
#define SAMPLEAPP_FLASH_DURATION1000// This list should be filled with Application specific Cluster IDs.
const cId_t SampleApp_ClusterList[SAMPLEAPP_MAX_CLUSTERS] =
{SAMPLEAPP_PERIODIC_CLUSTERID,
};void SampleApp_MessageMSGCB( afIncomingMSGPacket_t *pckt );const SimpleDescriptionFormat_t SampleApp_SimpleDesc =
{SAMPLEAPP_ENDPOINT,//int Endpoint;SAMPLEAPP_PROFID,//uint16 AppProfId[2];SAMPLEAPP_DEVICEID,//uint16 AppDeviceId[2];SAMPLEAPP_DEVICE_VERSION,//intAppDevVer:4;SAMPLEAPP_FLAGS,//intAppFlags:4;SAMPLEAPP_MAX_CLUSTERS,//uint8AppNumInClusters;(cId_t *)SampleApp_ClusterList,//uint8 *pAppInClusterList;SAMPLEAPP_MAX_CLUSTERS,//uint8AppNumInClusters;(cId_t *)SampleApp_ClusterList//uint8 *pAppInClusterList;
};// This is the Endpoint/Interface description.It is defined here, but
// filled-in in SampleApp_Init().Another way to go would be to fill
// in the structure here and make it a "const" (in code space).The
// way it's defined in this sample app it is define in RAM.
endPointDesc_t SampleApp_epDesc;/********************************************************************** LOCAL VARIABLES*/
uint8 SampleApp_TaskID;// Task ID for internal task/event processing// This variable will be received when// SampleApp_Init() is called.
devStates_t SampleApp_NwkState;uint8 SampleApp_TransID;// This is the unique message ID (counter)afAddrType_t SampleApp_Periodic_DstAddr;
afAddrType_t SampleApp_Flash_DstAddr;aps_Group_t SampleApp_Group;uint8 SampleAppPeriodicCounter = 0;
uint8 SampleAppFlashCounter = 0;/********************************************************************** GLOBAL VARIABLES*/
uint8 LedState = 0;//LED状态uint8 FunState = 0;//风扇状态uint8 Control = 0;//开关控制,0为一起,1为灯,2为风扇uint16 ZD_NV_OFFSET = 0xFFF;//掉电存储条目偏移,初始化最大uint16 Local_Fun_Code = 0xFFFF;//本机功能代码,初始化最大uint16 Local_Address = 0xFFF;//本机地址码,初始化最大uint16 Gateway_Bus_Address = 0xFFF;//子网总线地址,初始化最大/********************************************************************** STRUCTS*///本机信息
struct EquPar
{uint16 FunCode;uint16 Address;
};//地址功能表信息
struct AddressInfo
{uint16 BusAddress;uint16 OffsetAddress;
};//数据包
struct Packet
{uint16 SourceAddress;uint16 TargetAddress;uint16 Type;uint16 Data;uint16 Verify;
};struct Parket* ParketTempBuf = NULL;extern void SampleApp_Init( uint8 task_id );void SampleApp_HandleKeys( uint8 shift, uint8 keys );/********************************************************************** FUNCTIONS*/void SampleApp_SendPeriodicMessage( void );extern UINT16 SampleApp_ProcessEvent( uint8 task_id, uint16 events );extern void ReceiveData(struct Packet Data);extern uint8 ZigbeeSend(uint16 Data, uint16 Address, uint16 Type);extern uint16 Get_BusAddress(void);extern void AddressTable_Init(void);extern uint8* ConversionToRF(struct Packet Data);extern void ConversionToData(uint8* Data);extern void AddDevice(uint16 Type);/*********************************************************************
*********************************************************************/#ifdef __cplusplus
}
#endif#endif /* SAMPLEAPP_H */

,

YiKai Chen:

根據 release note https://www.ti2k.com/wp-content/uploads/ti2k/DeyiSupport_Zigbee_README CC2530 Full.txt 應該要用EW8051 version 7.51A

,

CXY CSSD:

我尝试了EW8051 version 7.51A,但是并不能正常编译SmapleApp?而使用EW8051 version8.10却是可以编译SmapleApp的?

,

YiKai Chen:

你該確認你的ZStack2.3.0-1.4.0是否是TI官方提供的

,

CXY CSSD:

是的,之前从Ti官网取得的,保存在公用的只读文件服务器上

,

YiKai Chen:

移除再重新安裝zstack2.3.0-1.4.0後再用EW8051 version 7.51A編譯看看

,

CXY CSSD:

效果相同

,

YiKai Chen:

CXY CSSD 说:并且8.10确实可以编译协议栈原始的SmapleApp

CXY CSSD 说:问题报错在原文中已给出,报错代码在之前的回复中写到了

你先前的描述說8.10确实可以编译协议栈原始的SmapleApp,後來又說报错代码在之前的回复中写到了,所以你是可以用8.10编译协议栈原始的SmapleApp,但是加上你自己的代码就會报错,是嗎?

,

CXY CSSD:

是的

,

CXY CSSD:

您还在关注此帖吗?

,

Nick Sun:

您好,

我们仍在持续关注此帖。

,

YiKai Chen:

既然是8.10编译协议栈原始的SmapleApp沒問題,但是加上你自己的代码就會报错,建議你可以逐行檢查是哪些程序碼造成编译报错

赞(0)
未经允许不得转载:TI中文支持网 » CC2530: 使用IAR8.10编译ZStack2问题
分享到: 更多 (0)

© 2024 TI中文支持网   网站地图 鲁ICP备2022002796号-1