Digi XBee(R) ANSI C Host Library
firmware.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2012 Digi International Inc.,
3  * All rights not expressly granted are reserved.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
7  * You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
10  * =======================================================================
11  */
12 
26 #ifndef __XBEE_FIRMWARE
27 #define __XBEE_FIRMWARE
28 
29 #include "xbee/xmodem.h"
30 
32 
33 // Datatypes should be defined in this file as well, possibly with a
34 // "function help" documentation block to document complex structures.
35 
36 typedef struct xbee_fw_oem_state_t {
37  uint32_t firmware_length;
38  uint32_t block_offset;
39  uint32_t cur_offset;
40  uint16_t block_length;
42 
43 typedef struct xbee_fw_source_t
44 {
45  xbee_dev_t *xbee;
46  int state;
47  int next_state;
48  int tries;
49  char bootloader_cmd; // cmd to initiate XMODEM
50  uint32_t timer;
51  union {
52  xbee_xmodem_state_t xbxm; // sub-status of xmodem transfer
53  xbee_fw_oem_state_t oem; // sub-status of oem transfer
54  } u;
55  char buffer[128+5]; // buffer for xmodem packet, must persist
56  // for duration of update
57  int (*seek)( void FAR *context, uint32_t offset);
58  int (*read)( void FAR *context, void FAR *buffer, int16_t bytes);
59  void FAR *context; // spot to hold user data
61 
62 #define XBEE_FW_LOAD_TIMEOUT 5000
63 
64 int xbee_fw_install_init( xbee_dev_t *xbee, const wpan_address_t FAR *target,
65  xbee_fw_source_t *source);
66 
68 unsigned int xbee_fw_install_ebl_state( xbee_fw_source_t *source);
69 char FAR *xbee_fw_status_ebl( xbee_fw_source_t *source, char FAR *buffer);
70 
73 #define xbee_fw_install_hcs08_state( source) xbee_fw_install_ebl_state( source)
74 #define xbee_fw_status_hcs08( source, buff) xbee_fw_status_ebl( source, buff)
76 
77 char FAR *xbee_fw_status_ebl( xbee_fw_source_t *source, char FAR *buffer);
78 
80 char FAR *xbee_fw_status_oem( xbee_fw_source_t *source, char FAR *buffer);
81 
82 
83 
84 // Helper function for installing firmware from a .OEM or .EBL file in memory.
85 typedef struct {
86  xbee_fw_source_t source;
87  uint32_t length;
88  const char FAR *address;
89  uint32_t offset;
91 
93  const char FAR *address);
94 
96 
97 // If compiling in Dynamic C, automatically #use the appropriate C file.
98 #ifdef __DC__
99  #use "xbee_firmware.c"
100 #endif
101 
102 #endif
103 
unsigned long uint32_t
32-bit unsigned integer
Definition: platform_config.h:43
Structure used to track the state of an Xmodem send.
Definition: xmodem.h:114
#define FAR
On platforms with "far" pointers, define to the proper keyword; empty definition if not required...
Definition: platform.h:396
char FAR * xbee_fw_status_ebl(xbee_fw_source_t *source, char FAR *buffer)
Update \a buffer with the current install status of \a source.
Definition: xbee_firmware.c:461
#define XBEE_BEGIN_DECLS
Macro defined to.
Definition: platform.h:41
unsigned int xbee_fw_install_ebl_state(xbee_fw_source_t *source)
Returns a unique value indicating the state of the .EBL/.GBL install process.
Definition: xbee_firmware.c:179
Definition: firmware.h:43
Makes use of xbee/serial.h API for sending and receiving serial data.
char FAR * xbee_fw_status_oem(xbee_fw_source_t *source, char FAR *buffer)
Update buffer with the current install status of source.
Definition: xbee_firmware.c:1193
int xbee_fw_buffer_init(xbee_fw_buffer_t *fw, uint32_t length, const char FAR *address)
Helper function for setting up an xbee_fw_buffer_t for use with a source firmware image held entirely...
Definition: xbee_firmware.c:1370
unsigned short uint16_t
16-bit unsigned integer
Definition: platform_config.h:41
Definition: firmware.h:36
Single structure to hold an 802.15.4 device's 64-bit IEEE/MAC address and 16-bit network address...
Definition: types.h:98
int xbee_fw_install_init(xbee_dev_t *xbee, const wpan_address_t FAR *target, xbee_fw_source_t *source)
Prepare to install new firmware on an attached XBee module.
Definition: xbee_firmware.c:133
Definition: firmware.h:85
int xbee_fw_install_hcs08_tick(xbee_fw_source_t *source)
Drive the firmware update process for the HCS08 application on Programmable XBee modules.
Definition: xbee_firmware.c:203
int xbee_fw_install_ebl_tick(xbee_fw_source_t *source)
Drive the firmware update process for boards that use .EBL/.GBL files to store their firmware...
Definition: xbee_firmware.c:249
short int16_t
16-bit signed integer
Definition: platform_config.h:40
Definition: device.h:361
#define XBEE_END_DECLS
Macro defined to.
Definition: platform.h:42
int xbee_fw_install_oem_tick(xbee_fw_source_t *source)
Install the firmware image stored in source.
Definition: xbee_firmware.c:773