Dallas Semiconductor DS80C400 C Libraries Home Page

Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

rom400_util.h File Reference


Detailed Description

Utility functions in the DS80C400 ROM.

This library contains CRC, pseudo-RNG and utility memory functions.

For detailed information on the DS80C400 please see the High-Speed Microcontroller User's Guide: DS80C400 Supplement.

Warning:
Some functions in this library are NOT multi-process safe--that is, if you call the same method from two different processes at the same time, the parameters to the function may be destroyed, yielding unpredictable results. Consult each individual funtion's documentation for details on which functions are multi-process safe.

Go to the source code of this file.

Defines

#define ROM400_UTIL_VERSION   5
#define REDIRECT_KERNELMALLOC   1
#define REDIRECT_KERNELFREE   2
#define REDIRECT_MALLOC   3
#define REDIRECT_FREE   4
#define REDIRECT_MALLOCDIRTY   5
#define REDIRECT_TINIEXPORT_MM_DEREF   6
#define REDIRECT_GETFREERAM   7
#define REDIRECT_GETTIMEMILLIS   8
#define REDIRECT_GETTHREADID   9
#define REDIRECT_THREADRESUME   10
#define REDIRECT_THREADIOSLEEP   11
#define REDIRECT_THREADIOSLEEPNC   12
#define REDIRECT_THREADSAVE   13
#define REDIRECT_THREADRESTORE   14
#define REDIRECT_SLEEP   15
#define REDIRECT_GETTASKID   16
#define REDIRECT_INFOSENDCHAR   17
#define REDIRECT_IP_COMPUTECHECKSUM_SOFTWARE   18
#define REDIRECT_0   19
#define REDIRECT_DHCPNOTIFY   20
#define REDIRECT_ROM_TASK_CREATE   21
#define REDIRECT_ROM_TASK_DUPLICATE   22
#define REDIRECT_ROM_TASK_DESTROY   23
#define REDIRECT_ROM_TASK_SWITCH_IN   24
#define REDIRECT_ROM_TASK_SWITCH_OUT   25
#define REDIRECT_OWIP_READCONFIG   26
#define REDIRECT_SETMACID   27
#define REDIRECT_MM_UNDEREF   28
#define REDIRECT_USER_IOPOLL   29
#define REDIRECT_ERROR_NOTIFICATION   30

Functions

unsigned int util_crc16 (unsigned char value, unsigned int seed)
 Generates a 16-bit CRC given a seed.
unsigned char util_getpseudorandom (void)
 Gets a pseudo-random byte.
void util_setrandomseed (unsigned int seed)
 Sets the seed of the random number generator.
void util_memclear (void *target, unsigned int length)
 Clears a block of memory.
void util_memcopy (void *source, void *dest, unsigned int length)
 Copies a block of memory.
unsigned char util_memcompare (void *block0, void *block1, unsigned int length)
 Compares the values in 2 blocks of memory.
void util_infosendchar (unsigned char ch)
 Sends a character to serial port 0.
void util_installhook (void *fncptr, unsigned int fncindex)
 Installs a new function pointer into the ROM redirect table.
unsigned int util_version (void)
 Returns the version number of this utility library.


Define Documentation

#define REDIRECT_0   19
 

Reserved for future use with the util_installhook method.

See also:
util_installhook

#define REDIRECT_DHCPNOTIFY   20
 

Value to be used in conjunction with the util_installhook method to override the DHCPNotify method.

See also:
util_installhook

#define REDIRECT_ERROR_NOTIFICATION   30
 

Value to be used in conjunction with the util_installhook method to override the ErrorNotification method.

See also:
util_installhook

#define REDIRECT_FREE   4
 

Value to be used in conjunction with the util_installhook method to override the mem_free method.

See also:
util_installhook

#define REDIRECT_GETFREERAM   7
 

Value to be used in conjunction with the util_installhook method to override the mem_getfreeram method.

See also:
util_installhook

#define REDIRECT_GETTASKID   16
 

Value to be used in conjunction with the util_installhook method to override the task_gettaskid method.

See also:
util_installhook

#define REDIRECT_GETTHREADID   9
 

Value to be used in conjunction with the util_installhook method to override the task_getthreadid method.

See also:
util_installhook

#define REDIRECT_GETTIMEMILLIS   8
 

Value to be used in conjunction with the util_installhook method to override the task_gettimemillis method.

See also:
util_installhook

#define REDIRECT_INFOSENDCHAR   17
 

Value to be used in conjunction with the util_installhook method to override the util_infosendchar method.

See also:
util_installhook

#define REDIRECT_IP_COMPUTECHECKSUM_SOFTWARE   18
 

Value to be used in conjunction with the util_installhook method to override the IP_ComputeChecksum method.

See also:
util_installhook

#define REDIRECT_KERNELFREE   2
 

Value to be used in conjunction with the util_installhook method to override the KernelFree method.

See also:
util_installhook

#define REDIRECT_KERNELMALLOC   1
 

Value to be used in conjunction with the util_installhook method to override the KernelMalloc method.

See also:
util_installhook

#define REDIRECT_MALLOC   3
 

Value to be used in conjunction with the util_installhook method to override the mem_malloc method.

See also:
util_installhook

#define REDIRECT_MALLOCDIRTY   5
 

Value to be used in conjunction with the util_installhook method to override the mem_mallocdirty method.

See also:
util_installhook

#define REDIRECT_MM_UNDEREF   28
 

Value to be used in conjunction with the util_installhook method to override the M_UnDeref method.

See also:
util_installhook

#define REDIRECT_OWIP_READCONFIG   26
 

Value to be used in conjunction with the util_installhook method to override the OWIP_ReadConfig method.

See also:
util_installhook

#define REDIRECT_ROM_TASK_CREATE   21
 

Value to be used in conjunction with the util_installhook method to override the TaskCreate method.

See also:
util_installhook

#define REDIRECT_ROM_TASK_DESTROY   23
 

Value to be used in conjunction with the util_installhook method to override the task_kill method.

See also:
util_installhook

#define REDIRECT_ROM_TASK_DUPLICATE   22
 

Value to be used in conjunction with the util_installhook method to override the TaskDuplicate method.

See also:
util_installhook

#define REDIRECT_ROM_TASK_SWITCH_IN   24
 

Value to be used in conjunction with the util_installhook method to override the TaskSwitchIn method.

See also:
util_installhook

#define REDIRECT_ROM_TASK_SWITCH_OUT   25
 

Value to be used in conjunction with the util_installhook method to override the TaskSwitchOut method.

See also:
util_installhook

#define REDIRECT_SETMACID   27
 

Value to be used in conjunction with the util_installhook method to override the SetMACID method.

See also:
util_installhook

#define REDIRECT_SLEEP   15
 

Value to be used in conjunction with the util_installhook method to override the task_sleep method.

See also:
util_installhook

#define REDIRECT_THREADIOSLEEP   11
 

Value to be used in conjunction with the util_installhook method to override the task_threadiosleep method.

See also:
util_installhook

#define REDIRECT_THREADIOSLEEPNC   12
 

Value to be used in conjunction with the util_installhook method to override the task_threadiosleepnc method.

See also:
util_installhook

#define REDIRECT_THREADRESTORE   14
 

Value to be used in conjunction with the util_installhook method to override the task_threadrestore method.

See also:
util_installhook

#define REDIRECT_THREADRESUME   10
 

Value to be used in conjunction with the util_installhook method to override the task_threadresume method.

See also:
util_installhook

#define REDIRECT_THREADSAVE   13
 

Value to be used in conjunction with the util_installhook method to override the task_threadsave method.

See also:
util_installhook

#define REDIRECT_TINIEXPORT_MM_DEREF   6
 

Value to be used in conjunction with the util_installhook method to override the MM_Deref method.

See also:
util_installhook

#define REDIRECT_USER_IOPOLL   29
 

Value to be used in conjunction with the util_installhook method to override the User_IOPoll method.

See also:
util_installhook

#define ROM400_UTIL_VERSION   5
 

Version number associated with this header file. Should be the same as the version number returned by the util_version function.

See also:
util_version


Function Documentation

unsigned int util_crc16 unsigned char  value,
unsigned int  seed
 

Generates a 16-bit CRC given a seed.

Implements the Cyclic-Redundancy Check CRC16. This CRC is based on the polynomial X^16 + X^15 + X^2 + 1. It is used extensively in operations with Dallas Semiconductor 1-Wire devices.

This function is safe to be called from multiple processes at the same time.

Parameters:
value single byte input value to the crc function
seed 16 bit 'previous result' seed
Returns:
16 bit CRC result

unsigned char util_getpseudorandom void   ) 
 

Gets a pseudo-random byte.

Returns a pseudo-random byte generated with the help of the CRC function. This is not a true random byte, as there is no real source of entropy.

This function is safe to be called from multiple processes at the same time.

Returns:
One pseudorandom byte.

void util_infosendchar unsigned char  ch  ) 
 

Sends a character to serial port 0.

This is a redirected function. The DS80C400 silicon software version of this function accesses the serial loader pin (P1.7) and does nothing if this pin is in the logic low state. The DS80C400 silicon software does not use interrupt driver I/O to the serial port.

This function is safe to be called from multiple processes at the same time.

Parameters:
ch character to send to the debug port

void util_installhook void *  fncptr,
unsigned int  fncindex
 

Installs a new function pointer into the ROM redirect table.

This function alters the redirect table, which allows functions in the ROM to be overridden by intredpid users. The function that is redirected will now call the code at address fncptr. It is not advised that fncptr point to a C function unless no arguments are expected (there is no way without writing an assembler wrapper to get the arguments to the C function in the Keil compiler).

See the DS80C400 User's Guide Supplement for more on the meaning of redirected functions.

This function is safe to be called from multiple processes at the same time.

Parameters:
fncptr address of the function that will be inserted into the redirect table
fncindex number of the redirected function that will be altered (i.e. REDIRECT_KERNELMALLOC)

void util_memclear void *  target,
unsigned int  length
 

Clears a block of memory.

Sets length bytes to zero starting at address target.

This function is safe to be called from multiple processes at the same time.

Parameters:
target beginning address of memory to clear
length number of bytes to clear

unsigned char util_memcompare void *  block0,
void *  block1,
unsigned int  length
 

Compares the values in 2 blocks of memory.

Compares length bytes from block0 to length bytes from block1 for equality. If the two memory blocks are identical, the function returns 0.

Warning:
This function is not multi-process safe. If two processes try to call this function at the same time, its parameters may be destroyed, yielding unpredictable results.
Parameters:
block0 first input block to compare
block1 second input block to compare
length maximum number of bytes to compare
Returns:
0 if the blocks are identical, non-zero otherwise

void util_memcopy void *  source,
void *  dest,
unsigned int  length
 

Copies a block of memory.

Copies length bytes of data from the source pointer to the dest pointer. The copy operation starts from the beginning of the source pointer, placing bytes from the beginning of the dest buffer. Therefore, f the buffers referenced by source and dest overlap, some bytes from source bytes will be overwritten prior to being copied to the target.

Warning:
This function is not multi-process safe. If two processes try to call this function at the same time, its parameters may be destroyed, yielding unpredictable results.
Parameters:
source pointer to bytes that will be the source of the copy
dest pointer to the bytes that will to copied to
length number of bytes to copy from source to dest

void util_setrandomseed unsigned int  seed  ) 
 

Sets the seed of the random number generator.

Changes the current value of the random seed to the random number generator, allowing for additional randomness to be inserted into the generation. Note that additional randomness is also generated by the timer bytes and the millisecond counter, so this seed is not the only source.

This function is safe to be called from multiple processes at the same time.

Parameters:
seed new random seed

unsigned int util_version void   ) 
 

Returns the version number of this utility library.

This function is safe to be called from multiple processes at the same time.

Returns:
Version number of this UTIL library.


Copyright 2005 Dallas Semiconductor, Inc.. Documentation generated by Doxygen.