⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modemfwload.c

📁 Dynamic C 程式語言源碼 嵌入式控制系統 Xbee蜂群網路~
💻 C
字号:
/*******************************************************************

	ModemFWLoad.c
	Digi International, Copyright (C) 2007-2008.  All rights reserved.

	This program is used to update the firmware on XBee modules.

	Description:
	============
	This program shows how to use the xbeeFWLoad() function to upload a
	particular firmware library to an XBee module.

	NOTE: You must compile this sample to flash, except on serial boot flash
   boards.  For example, the RCM4510W and BL4S230 must be compiled to flash
   and the BL4S1xx series may be compiled to either RAM or flash.

	Instructions:
	=============
	1. Set the XBEE_ROLE macro to NODE_TYPE_COORD, NODE_TYPE_ROUTER or
		NODE_TYPE_ENDDEV, and the XBEE_PROTOCOL macro to XBEE_PROTOCOL_ZB
		or ZBEE_PROTOCOL_ZNET to select a firmware to install on the XBee module.

	2. If necessary, modify the #use statement to point to correct firmware
		library (the defaults are for the firmware that was tested with this
		version of Dynamic C).

	3. If you want to see more details of what is happening while the code
		runs define the following
		- XBOOT_VERBOSE (recommended)
		- XBEE_VERBOSE
		- XMODEM_VERBOSE

	4. Compile and run the program.

	NOTE: It is HIGHLY RECOMMENDED that you compile and run another program
		after successfully loading new firmware to prevent this program
		from reloading (or partially reloading!) the modem firmware.

*****************************************************************************/

// Set XBEE_ROLE to NODE_TYPE_COORD, NODE_TYPE_ROUTER or NODE_TYPE_ENDDEV to
// select your XBee module's node type.
#define XBEE_ROLE			NODE_TYPE_ROUTER

// Choose ZNet 2.5 (XBEE_PROTOCOL_ZNET) or ZigBee firmware (XBEE_PROTOCOL_ZB)
#define XBEE_PROTOCOL	XBEE_PROTOCOL_ZB

// Ignore the current XBEE_ID macro on the target, since we are updating it
#define XB_IGNORE_XBEE_ID

// define the _VERBOSE macros for additional debugging information during
// the update process
#define XBOOT_VERBOSE
//#define XMODEM_VERBOSE
//#define XBEE_VERBOSE

#use "xbee_api.lib"
#use "xbee_boot.lib"

#if (XBEE_PROTOCOL == XBEE_PROTOCOL_ZNET)
	#if ! RCM4500W_SERIES || BLXS200_SERIES
		#fatal "ZNet 2.5 firmware is only supported on RCM4510W core modules."
	#endif
	#if XBEE_IS_COORD
	   // Firmware for ZNet 2.5 Coordinator
	   #use "XB24-B_ZigBee_1147.lib"
	#elif XBEE_IS_ROUTER || XBEE_IS_ENDDEV
	   // Firmware for ZNet 2.5 Router and End Device
	   #use "XB24-B_ZigBee_1347.lib"
	#else
		#fatal "XBEE_ROLE must be NODE_TYPE_COORD, NODE_TYPE_ROUTER or " \
			"NODE_TYPE_ENDDEV"
	#endif
#elif (XBEE_PROTOCOL == XBEE_PROTOCOL_ZB)
	#if XBEE_IS_COORD
	   // Firmware for ZB Coordinator
	   #use "XB24-ZB_2141.lib"
	#elif XBEE_IS_ROUTER
	   // Firmware for ZB Router
	   #use "XB24-ZB_2341.lib"
	#elif XBEE_IS_ENDDEV
	   // Firmware for ZB End Device
	   #use "XB24-ZB_2941.lib"
	#else
		#fatal "XBEE_ROLE must be NODE_TYPE_COORD, NODE_TYPE_ROUTER or " \
			"NODE_TYPE_ENDDEV"
	#endif
#else
	#fatal "Must define XBEE_PROTOCOL to XBEE_PROTOCOL_ZNET or " \
		"XBEE_PROTOCOL_ZB"
#endif

// xbee_api.lib requires an endpoint table definition, even if it's empty
ENDPOINT_TABLE_BEGIN
ENDPOINT_TABLE_END

void main (void)
{
	int ret_code;
	unsigned long reg;
	char ieee[8];

	ret_code = xbeeFWLoad();

	if (!ret_code)
	{
		// Update successful, display IEEE address for reference (useful for
		// identifying or labeling board).
	   printf( "Reading IEEE address... ");

	   if ( (ret_code = xb_get_register( xb_SH, &reg)) )
	   {
			printf( "Error %d reading SH\n", ret_code);
	   }
	   else
	   {
	      *(unsigned long *) &ieee[0] = ntohl( reg);
	      if ( (ret_code = xb_get_register( xb_SL, &reg)) )
	      {
	         printf( "Error %d reading SL\n", ret_code);
	      }
	      else
	      {
	         *(unsigned long *) &ieee[4] = ntohl( reg);
	         printf( "%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n", ieee[0],
	         	ieee[1], ieee[2], ieee[3], ieee[4], ieee[5], ieee[6], ieee[7]);
	      }
	   }
	}

   printf( "\nProgram will now go into an infinite loop.  Please run a\n");
   printf( "new program before disconnecting the programming cable.\n");

	while(1);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -