Digi XBee(R) ANSI C Host Library
gpm.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2013 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  */
22 #include "xbee/platform.h"
23 #include "xbee/device.h"
24 #include "wpan/aps.h"
25 
26 #define DIGI_CLUST_MEMORY_ACCESS 0x23
27 
28 typedef XBEE_PACKED(xbee_gpm_request_header_t, {
29  uint8_t cmd_id;
30  uint8_t options;
31  uint16_t block_num_be;
32  uint16_t start_index_be;
33  uint16_t byte_count_be;
36 
37 typedef XBEE_PACKED(xbee_gpm_response_header_t, {
38  uint8_t cmd_id;
39  uint8_t status;
40  uint16_t block_num_be;
41  uint16_t start_index_be;
42  uint16_t byte_count_be;
44 
45 typedef XBEE_PACKED(xbee_gpm_frame_t, {
46  union {
49  } header;
50  uint8_t data[1];
52 
56 #define XBEE_GPM_OVERHEAD (sizeof (xbee_gpm_request_header_t))
57 
58 enum xbee_gpm_cmd {
59  XBEE_GPM_CMD_PLATFORM_INFO_REQ = 0x00,
60  XBEE_GPM_CMD_ERASE_REQ = 0x01,
61  XBEE_GPM_CMD_WRITE_REQ = 0x02,
62  XBEE_GPM_CMD_ERASE_THEN_WRITE_REQ = 0x03,
63  XBEE_GPM_CMD_READ_REQ = 0x04,
64  XBEE_GPM_CMD_FIRMWARE_VERIFY_REQ = 0x05,
65  XBEE_GPM_CMD_FIRMWARE_INSTALL_REQ = 0x06,
66 
67  XBEE_GPM_CMD_PLATFORM_INFO_RESP = 0x80,
68  XBEE_GPM_CMD_ERASE_RESP = 0x81,
69  XBEE_GPM_CMD_WRITE_RESP = 0x82,
70  XBEE_GPM_CMD_ERASE_THEN_WRITE_RESP = 0x83,
71  XBEE_GPM_CMD_READ_RESP = 0x84,
72  XBEE_GPM_CMD_FIRMWARE_VERIFY_RESP = 0x85,
73  XBEE_GPM_CMD_FIRMWARE_INSTALL_RESP = 0x86,
74 };
75 
76 typedef struct xbee_gpm_flash_info_t {
77  uint16_t block_count;
78  uint16_t block_size;
80 
81 enum xbee_gpm_status {
82  XBEE_GPM_STATUS_ERROR_FLAG = (1<<0)
83 };
84 
85 int xbee_gpm_envelope_create( wpan_envelope_t *envelope, wpan_dev_t *dev,
86  const addr64 FAR *ieee);
87 
88 int xbee_gpm_envelope_local( wpan_envelope_t *envelope, wpan_dev_t *dev);
89 
90 int xbee_gpm_request_send( const wpan_envelope_t *envelope,
91  const void *request, uint16_t request_length);
92 
93 int xbee_gpm_get_flash_info( const wpan_envelope_t *envelope);
94 
95 int xbee_gpm_erase_block( const wpan_envelope_t *envelope,
96  uint16_t block_num, uint16_t block_size);
97 
98 // Maximum number of bytes allowed per write (based on device's ATNP and size
99 // of GPM header).
100 uint16_t xbee_gpm_max_write( const wpan_dev_t *dev);
101 
102 // Command to erase entire flash is to see block num and block size to 0.
103 #define xbee_gpm_erase_flash( env) xbee_gpm_erase_block( env, 0, 0)
104 
105 int xbee_gpm_write( const wpan_envelope_t *envelope, uint16_t block_num,
106  uint16_t byte_offset, uint16_t byte_count, const void FAR *data);
107 
108 int xbee_gpm_erase_then_write( const wpan_envelope_t *envelope,
109  uint16_t block_num, uint16_t byte_offset, uint16_t byte_count,
110  const void FAR *data);
111 
112 int xbee_gpm_read( const wpan_envelope_t *envelope, uint16_t block_num,
113  uint16_t byte_offset, uint16_t byte_count);
114 
115 // TODO: possibly move the firmware commands to a gpm_firmware layer, in case
116 // a device just wants GPM access and doesn't need the extra functionality of
117 // doing firmware updates. Base the API for gpm_firmware on the existing
118 // xbee_firmware API, with callbacks to read the firmware image.
119 
120 int xbee_gpm_firmware_verify( const wpan_envelope_t *envelope);
121 
122 int xbee_gpm_firmware_install( const wpan_envelope_t *envelope);
123 
#define FAR
On platforms with "far" pointers, define to the proper keyword; empty definition if not required...
Definition: platform.h:396
Common header for Hardware Abstraction Layer.
< one of GPM_CMD_*, same as cmd_id in request indication whether command was successful block number ...
Definition: gpm.h:43
unsigned short uint16_t
16-bit unsigned integer
Definition: platform_config.h:41
unsigned char uint8_t
8-bit unsigned integer
Definition: platform_config.h:39
Definition: gpm.h:76
Cluster/Endpoint layer for WPAN networks (ZigBee and DigiMesh).
Typedef used to hold a 64-bit IEEE address, represented as 8 bytes, 4 16-bit values or 2 32-bit value...
Definition: types.h:34
< one of GPM_CMD_* varies by command block number addressed in the GPM byte index within the addresse...
Definition: gpm.h:35
< variable-length data field
Definition: gpm.h:51
The "envelope" is used to gather all necessary information about a given frame on the network...
Definition: aps.h:40
Structure used by the WPAN/ZigBee layers.
Definition: aps.h:390