Digi XBee(R) ANSI C Host Library
io.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 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 
22 #ifndef XBEE_IO_H
23 #define XBEE_IO_H
24 
25 #include "xbee/platform.h"
26 #include "xbee/device.h"
27 #include "xbee/atcmd.h"
28 #include "wpan/types.h"
29 
31 
32 /***
33  @brief This structure stores broken-out I/O state for an XBee's configurable
34  I/Os.
35 
36 */
37 typedef struct xbee_io_t {
39  clc;
50 
53  uint16_t adc_sample[8];
71 } xbee_io_t;
72 
76 #define XBEE_IO_AD0 0x0001
78 #define XBEE_IO_DIO0 0x0001
80 #define XBEE_IO_AD1 0x0002
82 #define XBEE_IO_DIO1 0x0002
84 #define XBEE_IO_AD2 0x0004
86 #define XBEE_IO_DIO2 0x0004
88 #define XBEE_IO_AD3 0x0008
90 #define XBEE_IO_DIO3 0x0008
92 #define XBEE_IO_DIO4 0x0010
94 #define XBEE_IO_DIO5 0x0020
96 #define XBEE_IO_DIO6 0x0040
98 #define XBEE_IO_DIO7 0x0080
100 #define XBEE_IO_GPIO7 0x0080
101 #define XBEE_IO_VCC_SENSE 0x80
103 #define XBEE_IO_DIO10 0x0400
105 #define XBEE_IO_DIO11 0x0800
107 #define XBEE_IO_DIO12 0x1000
109 
111 
112 typedef XBEE_PACKED(xbee_frame_io_response_t, {
113  uint8_t frame_type;
114  addr64 ieee_address_be;
115  uint16_t network_address_be;
116  uint8_t options;
117  uint8_t num_samples;
118  uint16_t data[1];
121 
138 
140 
142  XBEE_IO_TYPE_PULLUP = 0x20,
145  XBEE_IO_TYPE_PULLDOWN = 0x40,
148  XBEE_IO_FORCE = 0x80,
151 
154 
155  XBEE_IO_TYPE_DIGITAL_INPUT_PULLUP =
157 };
158 
159 
166 
167  XBEE_IO_FORCE_LOW = XBEE_IO_SET_LOW|XBEE_IO_FORCE,
168  XBEE_IO_FORCE_HIGH = XBEE_IO_SET_HIGH|XBEE_IO_FORCE,
169 };
170 
171 
172 int xbee_io_response_parse( xbee_io_t FAR *parsed, const void FAR *source);
173 void xbee_io_response_dump( const xbee_io_t FAR *io);
174 
176 #define XBEE_IO_ANALOG_INVALID INT16_C(-32768)
177 
179 #define XBEE_IO_MIN_SAMPLE_PERIOD 50
180 
181 int xbee_io_get_digital_input( const xbee_io_t FAR *io, uint_fast8_t index);
182 int xbee_io_get_digital_output( const xbee_io_t FAR *io, uint_fast8_t index);
183 int16_t xbee_io_get_analog_input( const xbee_io_t FAR *io, uint_fast8_t index);
184 extern const FAR xbee_at_cmd_t xbee_io_cmd_by_index[];
186  uint_fast8_t index, enum xbee_io_digital_output_state state,
187  const wpan_address_t FAR *address);
188 int xbee_io_configure( xbee_dev_t *xbee, xbee_io_t FAR *io,
189  uint_fast8_t index, enum xbee_io_type type,
190  const wpan_address_t FAR *address);
193  const wpan_address_t FAR *address);
194 int xbee_io_query( xbee_dev_t *xbee, xbee_io_t FAR *io,
195  const wpan_address_t FAR *address);
197 
199 
200 // If compiling in Dynamic C, automatically #use the appropriate C file.
201 #ifdef __DC__
202  #use "xbee_io.c"
203 #endif
204 
205 #endif
206 
uint16_t adc_sample[8]
Analog samples (raw count 0..1023) Entries 0..3 correspond to AD0..3, Entries 4..6 not currently used...
Definition: io.h:54
uint16_t din_state
Sampled state of digital inputs.
Definition: io.h:45
< XBEE_FRAME_IO_RESPONSE (0x92) ATSH and ATSL of sender ATMY value of sender
Definition: io.h:120
WPAN datatypes and support functions, valid for ZigBee and DigiMesh.
#define FAR
On platforms with "far" pointers, define to the proper keyword; empty definition if not required...
Definition: platform.h:396
uint16_t din_enabled
Which pins have digital input sampling enabled.
Definition: io.h:41
Disabled.
Definition: io.h:129
Datatype used for passing and storing XBee AT Commands.
Definition: atcmd.h:54
#define XBEE_BEGIN_DECLS
Macro defined to.
Definition: platform.h:41
void xbee_io_response_dump(const xbee_io_t FAR *io)
Debugging function used to dump an xbee_io_t structure to stdout.
Definition: xbee_io.c:149
Common header for Hardware Abstraction Layer.
uint8_t pwm_timeout
ATPT value.
Definition: io.h:69
uint16_t sample_rate
Shadow value of ATIR.
Definition: io.h:60
OR in to the above to specify automatic sampling when edge detected (ATIC command).
Definition: io.h:141
uint16_t change_mask
Shadow value of ATIC.
Definition: io.h:61
Analog input.
Definition: io.h:132
uint16_t pwm0_level
Output PWM level (ATM0)
Definition: io.h:67
int xbee_io_query_status(xbee_io_t FAR *io)
Check the status of querying an XBee device, as initiated by xbee_io_query().
Definition: xbee_io.c:776
unsigned short uint16_t
16-bit unsigned integer
Definition: platform_config.h:41
Digital output low.
Definition: io.h:134
RS485 transmit enable (act low)
Definition: io.h:136
Digital input.
Definition: io.h:133
int xbee_io_set_options(xbee_dev_t *xbee, xbee_io_t FAR *io, uint16_t sample_rate, uint16_t change_mask, const wpan_address_t FAR *address)
Configure XBee automatic I/O sampling options.
Definition: xbee_io.c:535
uint16_t pullup_enable
Raw ATPR command value.
Definition: io.h:65
unsigned char uint8_t
8-bit unsigned integer
Definition: platform_config.h:39
Digital output high.
Definition: io.h:135
uint16_t dout_state
Shadow state of digital outputs.
Definition: io.h:46
Single structure to hold an 802.15.4 device&#39;s 64-bit IEEE/MAC address and 16-bit network address...
Definition: types.h:98
int xbee_io_configure(xbee_dev_t *xbee, xbee_io_t FAR *io, uint_fast8_t index, enum xbee_io_type type, const wpan_address_t FAR *address)
Configure XBee digital and analog I/Os.
Definition: xbee_io.c:425
Context data passed to command list processor.
Definition: atcmd.h:448
OR in to the above to specify pull-down resistor active (reserved for future hardware).
Definition: io.h:147
Definition: io.h:37
High (Vcc)
Definition: io.h:165
int xbee_io_get_digital_input(const xbee_io_t FAR *io, uint_fast8_t index)
Return state of a digital input.
Definition: xbee_io.c:200
int xbee_io_set_digital_output(xbee_dev_t *xbee, xbee_io_t FAR *io, uint_fast8_t index, enum xbee_io_digital_output_state state, const wpan_address_t FAR *address)
Set state of a digital output.
Definition: xbee_io.c:335
int xbee_io_get_digital_output(const xbee_io_t FAR *io, uint_fast8_t index)
Return state of a digital output.
Definition: xbee_io.c:229
OR in to the above to force transmit to the device (else only transmits if changed from last known st...
Definition: io.h:150
int xbee_io_response_parse(xbee_io_t FAR *parsed, const void FAR *source)
Parse an I/O response and store it in an xbee_io_t structure.
Definition: xbee_io.c:60
uint16_t pulldown_state
Shadow state of pull-down resistors 0:no pull-down; 1:pull-down applied.
Definition: io.h:49
Special function e.g.
Definition: io.h:130
Sending AT command requests and processing the responses.
uint16_t pwm1_level
Output PWM level (ATM1)
Definition: io.h:68
short int16_t
16-bit signed integer
Definition: platform_config.h:40
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
Definition: device.h:361
xbee_io_type
Configuration type for XBee built-in I/Os.
Definition: io.h:128
uint16_t pullup_state
Shadow state of pull-up resistors 0:no pull-up; 1:pull-up applied.
Definition: io.h:47
RS485 transmit enable (act high)
Definition: io.h:137
uint16_t pullup_direction
Raw ATPD command value.
Definition: io.h:66
Low (0V)
Definition: io.h:164
#define XBEE_END_DECLS
Macro defined to.
Definition: platform.h:42
uint16_t dout_enabled
Which pins have digital output enabled.
Definition: io.h:43
uint8_t config[16]
First 16 configuration states (from ATD0 etc.
Definition: io.h:62
Mask for above settings.
Definition: io.h:139
OR in to the above to specify pull-up resistor active (ATPR command).
Definition: io.h:144
xbee_io_digital_output_state
Digital output state for XBee built-in I/Os configured as outputs.
Definition: io.h:163
uint8_t analog_enabled
Which analog inputs are enabled See XBEE_IO_AD0 etc.
Definition: io.h:52
uint8_t tx_samples
ATIT value.
Definition: io.h:70
int16_t xbee_io_get_analog_input(const xbee_io_t FAR *io, uint_fast8_t index)
Return reading of an analog input.
Definition: xbee_io.c:262
xbee_command_list_context_t clc
Command list context used for querying configuration.
Definition: io.h:39