XBee Firmware Library  1.6.0
Modules | Files | Functions
Hardware Abstraction Layer (HAL)

Modules

 DOS16/OpenWatcom
 
 Freescale/Codewarrior (Programmable XBee)
 
 Rabbit/Dynamic C
 
 Win32/cygwin/gcc
 

Files

file  platform.h
 

Functions

void hex_dump (const void FAR *address, uint16_t length, uint16_t flags)
 
int hexstrtobyte (const char FAR *p)
 Converts two hex characters (0-9A-Fa-f) to a byte. More...
 
int memcheck (const void FAR *src, int c, size_t length)
 Test whether a block of memory is set to a single byte value. More...
 
uint32_t() xbee_millisecond_timer (void)
 Platform-specific function to return the number of elapsed milliseconds. More...
 
int xbee_readline (char *buffer, int length)
 This function is a non-blocking version of gets(), used to read a line of input from the user. More...
 
XBEE_BEGIN_DECLS uint32_t() xbee_seconds_timer (void)
 Platform-specific function to return the number of elapsed seconds. More...
 
typedef struct xbee_serial_t xbee_serial_t
 

platform_stdint

Types typically defined in <stdint.h>, define manually if stdint.h is not available on this platform.

typedef signed char int8_t
 A signed char variable 8 bits. More...
 
typedef unsigned char uint8_t
 A unsigned char variable 8 bits. More...
 
typedef int int16_t
 A signed integer variable 16 bits. More...
 
typedef unsigned int uint16_t
 An unsigned integer variable 16 bits. More...
 
typedef long int32_t
 A signed long variable 32 bits. More...
 
typedef unsigned long uint32_t
 An unsigned long variable 32 bit. More...
 

Detailed Description

Typedef Documentation

A signed integer variable 16 bits.

16-bit signed integer

A signed long variable 32 bits.

32-bit signed integer

A signed char variable 8 bits.

8-bit signed integer

An unsigned integer variable 16 bits.

16-bit unsigned integer

An unsigned long variable 32 bit.

32-bit unsigned integer

_xbee_device_debug uint8_t

A unsigned char variable 8 bits.

8-bit unsigned integer

Must be a structure with uint32_t member baudrate and any additional members required by the functions in xbee/serial.h.

Function Documentation

void hex_dump ( const void FAR *  address,
uint16_t  length,
uint16_t  flags 
)

Helper function for printing a hex dump of memory to stdout. A reference implementation is provided in as util/hexdump.c. Dumps data in hex/printable format, 16 bytes to a line, to stdout.

Parameters
[in]addressAddress of data to dump.
[in]lengthNumber of bytes to dump.
[in]flagsOne of
  • #HEX_DUMP_FLAG_NONE
  • #HEX_DUMP_FLAG_OFFSET
  • #HEX_DUMP_FLAG_ADDRESS
  • #HEX_DUMP_FLAG_TAB
int hexstrtobyte ( const char FAR *  p)

Converts two hex characters (0-9A-Fa-f) to a byte.

Parameters
[in]pString of hex characters to convert.
Return values
-1Error (invalid character or string less than 2 bytes).
0-255The byte represented by the first two characters of p.
Examples
  • hexstrtobyte("FF") returns 255
  • hexstrtobyte("0") returns -1 (error because < 2 characters)
  • hexstrtobyte("ABCDEF") returns 0xAB (ignores additional chars)
int memcheck ( const void FAR *  src,
int  c,
size_t  length 
)

Test whether a block of memory is set to a single byte value.

Parameters
[in]srcstarting address
[in]cvalue to compare each byte to
[in]lengthnumber of bytes to compare
Return values
0length bytes from src are set to c
<0length bytes from src would sort before length bytes of c
>0length bytes from src would sort before length bytes of c
See also
memcmp, memset
uint32_t() xbee_millisecond_timer ( void  )

Platform-specific function to return the number of elapsed milliseconds.

OK for this counter to rollover. Used for timing and should have a resolution of at least 60ms.

  • Rabbit has 1ms resolution.
  • HCS08 has 4ms resolution.
  • DOS has 18 ticks/second (55.55ms resolution)

(Function name wrapped in parentheses so platforms can use a macro function of the same name.)

Returns
Number of elapsed milliseconds.
See also
XBEE_MS_TIMER_RESOLUTION
int xbee_readline ( char *  buffer,
int  length 
)

This function is a non-blocking version of gets(), used to read a line of input from the user.

It waits for a string from stdin terminated by a return. It should be called repeatedly, until it returns a value other than -EAGAIN. The input string, stored in buffer is null-terminated without the return.

The user should make sure only one process calls this function at a time.

Parameters
[in,out]bufferbuffer to store input from user
[in]lengthsize of buffer
Return values
>=0User ended the input with a newline, return value is number of bytes written.
-EAGAINUser has not completed a line.
-EINVALNULL buffer or length is less than 1.
XBEE_BEGIN_DECLS uint32_t() xbee_seconds_timer ( void  )

Platform-specific function to return the number of elapsed seconds.

On some platforms, this is the equivalent of an "uptime".

On other platforms, it may reflect the value of the RTC, which might not be synchronized with a time server and might include leap seconds.

Regardless, it should consistently report elapsed time and not jump on clock synchronization.

In addition to determining timeouts, the ZCL Time Cluster makes use of it to report current time.

(Function name wrapped in parentheses so platforms can use a macro function of the same name.)

Returns
Number of elapsed seconds.