propeller.h File Reference

#include <propclock.h>

Go to the source code of this file.

Defines

#define PAR   (*(volatile unsigned *)0x1F0)
#define CNT   (*(volatile unsigned *)0x1F1)
#define INA   (*(volatile unsigned *)0x1F2)
#define INB   (*(volatile unsigned *)0x1F3)
#define OUTA   (*(volatile unsigned *)0x1F4)
#define OUTB   (*(volatile unsigned *)0x1F5)
#define DIRA   (*(volatile unsigned *)0x1F6)
#define DIRB   (*(volatile unsigned *)0x1F7)
#define CTRA   (*(volatile unsigned *)0x1F8)
#define CTRB   (*(volatile unsigned *)0x1F9)
#define FRQA   (*(volatile unsigned *)0x1FA)
#define FRQB   (*(volatile unsigned *)0x1FB)
#define PHSA   (*(volatile unsigned *)0x1FC)
#define PHSB   (*(volatile unsigned *)0x1FD)
#define VCFG   (*(volatile unsigned *)0x1FE)
#define VSCL   (*(volatile unsigned *)0x1FF)
#define cognew_native(f, par)   coginit_native(0x4, f, par)
#define FALSE   0
#define TRUE   -1
#define NULL   (char*) 0
#define MAXNEG   (0x80000000)
#define MAXPOS   (0x7fffffff)
#define PI   3.141593
#define ABS(val)   ((val < 0) ? -val : val)
#define CHIPVER   (*(volatile unsigned char*)(PROP_CHIP_VERSION_ADDR))
#define CLKFREQ   (*(volatile long*)(PROP_CLKFREQ_ADDR))
#define CLKMODE   (*(volatile unsigned char *)(PROP_CLKMODE_ADDR))
#define GETCOGID(val)
#define COGINIT(val)
#define COGNEW(val)
#define COGSTOP(val)
#define DECODE(bitnum)   (1<<(bitnum))
#define ENCODE(val, bitnum)
#define INDEXC(arr, dat, len)   (indexOf(arr,1,len,0,0,dat))
#define INDEXH(arr, dat, len)   (indexOf(arr,2,len,0,0,dat))
#define INDEX(arr, dat, len)   (indexOf(arr,4,len,0,0,dat))
#define INDEXRC(arr, dat, len)   (indexOf(arr,1,len,(len)-1,1,dat))
#define INDEXRH(arr, dat, len)   (indexOf(arr,2,len,(len)-1,1,dat))
#define INDEXR(arr, dat, len)   (indexOf(arr,4,len,(len)-1,1,dat))
#define GETCARRY(flag)
#define GETZERO(flag)
#define LOCKCLR(lock)
#define LOCKNEW(lock)
#define LOCKRET(lock)
#define LOCKSET(lock)
#define CLR(val, bit)   do { (val) &= ~(1 << (bit)); } while (0)
#define SET(val, bit)   do { (val) += (1 << (bit)); } while (0)
#define FLIP(val, bit)   do { (val) ^= (1 << (bit)); } while (0)
#define REBOOT(var)
#define TRUNC(num)   (int)(num)
#define WAIT(count)
#define WAITCNT(count, ticks)
#define WAITCNTN(count, ticks)
#define WAITPEQ(bitmask, pinmask)
#define WAITPNE(bitmask, pinmask)
#define WAITVID(color, pixel)

Functions

int cognew (void(*func)(void), long *stacks)
int coginit (int cogid, void(*func)(void), long *stacks)
int cogid (void)
int coginit_native (int cogid, void(*func)(void *), void *par)
void clkset (int mode, int frequency)
int cognew_nativeparm (void *addr, void *parm)
int encode (int value)
int indexOf (void *array, int width, int length, int start, int reverse, int data)
void longfill (long *R0, long R1, int R2)
void longmove (long *R0, long *R1, int R2)
void sleep (int s)
void msleep (int ms)
void wait (int ticks)
void wordfill (short *R0, short R1, int R2)
void wordmove (short *R0, short *R1, int R2)


Detailed Description


Define Documentation

#define ABS ( val   )     ((val < 0) ? -val : val)

Get absolute value of a number.

Parameters:
val is constant or variable

#define CHIPVER   (*(volatile unsigned char*)(PROP_CHIP_VERSION_ADDR))

GetChip Version This depends on the masked rom version.

#define CLKFREQ   (*(volatile long*)(PROP_CLKFREQ_ADDR))

Get clock frequency stored at address 0

Returns:
clock frequency

#define CLR ( val,
bit   )     do { (val) &= ~(1 << (bit)); } while (0)

Clear a bit in val

Parameters:
val variable where bit will be cleared
bit is bit number to clear.

#define COGINIT ( val   ) 

Value:

do {    \
    asm("COGINIT %" #val " WR WC WZ"); \
} while(0)
Start a cog running as specified by val parameter.
Parameters:
val contains data as defined in propeller manual for coginit instruction.

#define COGNEW ( val   ) 

Value:

{ \
do {    \
    asm("OR %" #val ", #8");            \
    asm("COGINIT %" #val " WR WC WZ");  \
} while(0)
Start a new cog running as specified by val parameter. New bit will always be set.
Parameters:
val contains data as defined in propeller manual for coginit instruction.

#define COGSTOP ( val   ) 

Value:

do {    \
    asm("COGSTOP %" #val);   \
} while(0)
Stop a running cog as specified by val parameter.
Parameters:
val contains cog number.

#define DECODE ( bitnum   )     (1<<(bitnum))

Get the integer value of a single bit 2^bit or 1<<bit.

Parameters:
bitnum contains bit number.
Returns:
integer value of bit power of 2.

#define ENCODE ( val,
bitnum   ) 

Value:

do {    \
    (bitnum) = 0;       \
    while((val) != 0) { \
        (bitnum)++;     \
        (val) >>= 1;    \
    }                   \
    (bitnum)--;         \
} while(0)
Get the most significant bit number represented by an integer value
Note:
This macro has restrictions on use; it can not be used as a parameter; parameters passed to it must be variables.
Parameters:
val contains integer value to encode; val will not be preserved.
bitnum is most significant bit number power of 2 of value.
Returns:
bit number in the bitnum parameter.

#define FALSE   0

Chip Version address. FALSE is a convenience macro representing zero symbolically.

#define FLIP ( val,
bit   )     do { (val) ^= (1 << (bit)); } while (0)

Flip a bit in val

Parameters:
val variable where bit will be toggled
bit is bit number to toggle.

#define GETCARRY ( flag   ) 

Value:

do {    \
    asm("if_c  mov %" #flag ", #1");   \
    asm("if_nc mov %" #flag ", #0");   \
} while(0)
Gets carry flag state
Parameters:
flag is return variable.

#define GETCOGID ( val   ) 

Value:

do {    \
    asm("cogid %" #val); \
} while(0)
Get the current propeller COG identifier where code is running. While the macro version is faster, it has restrictions. This macro will cause compiler failures if used as an argument to a function. User must provide a variable to "val" and not a constant or literal.
Parameters:
val is variable where COGID will be returned.

#define GETZERO ( flag   ) 

Value:

do {    \
    asm("if_c  mov %" #flag ", #1");   \
    asm("if_nc mov %" #flag ", #0");   \
} while(0)
Gets zero flag state
Parameters:
flag is return variable.

#define INDEX ( arr,
dat,
len   )     (indexOf(arr,4,len,0,0,dat))

Get index of integer data item in array of length from index 0

Parameters:
arr is pointer to array
dat is data value
len is array length

#define INDEXC ( arr,
dat,
len   )     (indexOf(arr,1,len,0,0,dat))

Get index of char data item in array of length from index 0

Parameters:
arr is pointer to array
dat is data value
len is array length

#define INDEXH ( arr,
dat,
len   )     (indexOf(arr,2,len,0,0,dat))

Get index of half or short data item in array of length from index 0

Parameters:
arr is pointer to array
dat is data value
len is array length

#define INDEXR ( arr,
dat,
len   )     (indexOf(arr,4,len,(len)-1,1,dat))

Get index of integer data item in array of length from end of array

Parameters:
arr is pointer to array
dat is data value
len is array length

#define INDEXRC ( arr,
dat,
len   )     (indexOf(arr,1,len,(len)-1,1,dat))

Get index of char data item in array of length from end of array

Parameters:
arr is pointer to array
dat is data value
len is array length

#define INDEXRH ( arr,
dat,
len   )     (indexOf(arr,2,len,(len)-1,1,dat))

Get index of half or short data item in array of length from end of array

Parameters:
arr is pointer to array
dat is data value
len is array length

#define LOCKCLR ( lock   ) 

Value:

do {    \
    asm("lockclr %" #lock " wc wz");   \
} while(0)
Clear lock - use GETCARRY/GETZERO to get lock state.
Parameters:
lock is lock identifier and must be a variable;

#define LOCKNEW ( lock   ) 

Value:

do {    \
    asm("locknew %" #lock " wc wz");   \
} while(0)
New lock - use GETCARRY/GETZERO to get lock state.
Parameters:
lock is lock identifier return and must be a variable;

#define LOCKRET ( lock   ) 

Value:

do {    \
    asm("lockret %" #lock);   \
} while(0)
Return lock to lock pool
Parameters:
lock is lock identifier and must be a variable;

#define LOCKSET ( lock   ) 

Value:

do {    \
    asm("lockset %" #lock " wc wz");   \
} while(0)
Set lock - use GETCARRY/GETZERO to get previous lock state.
Parameters:
lock is lock identifier and must be a variable

#define MAXNEG   (0x80000000)

Maximum negative number

#define MAXPOS   (0x7fffffff)

Maximum positive number

#define NULL   (char*) 0

NULL is a convenience macro for c-string termination.

#define PI   3.141593

Value for PI

#define REBOOT ( var   ) 

Value:

do {    \
    asm("mov TEMP0,#1");    \
    asm("shl TEMP0,#15");   \
    asm("sub TEMP0,#4");    \
    asm("jmp TEMP0");    \
} while(0)
Reboot Propeller ... does not return

#define SET ( val,
bit   )     do { (val) += (1 << (bit)); } while (0)

Set a bit in val

Parameters:
val variable where bit will be set
bit is bit number to set.

#define TRUE   -1

TRUE is a convenience macro representing non-zero symbolically.

#define TRUNC ( num   )     (int)(num)

Round a floating point number to the nearest integer. Not implemented without floating point support.

Parameters:
num is number to round define ROUND(num) Return integer part of a number
num is number to truncate

#define WAIT ( count   ) 

Value:

do { \
    asm("mov     TEMP0,%" #count); \
    asm("add     TEMP0,cnt"); \
    asm("waitcnt TEMP0,%" #count " WZ WC NR"); \
} while(0)
Pause program execution for number of variable count clock ticks.
Note:
This macro gives higher resolution than the wait function.

Using a count under 20 will make the program hang.

If you need a wait with a constant, use the wait function.

Parameters:
count is number of clock ticks to wait and must be a variable.

#define WAITCNT ( count,
ticks   ) 

Value:

do { \
    asm("waitcnt %" #count ", %" #ticks " WZ WC"); \
} while(0)
Make program wait until per ticks have passed; the count variable will be updated with new count from waitcnt.
Note:
If count < current CNT value, the instruction will wait until CNT rolls over resulting in several minutes or more of delay; this is the way waitcnt works.

This macro has restrictions on use; it can not be used as a parameter; parameters passed to it must be variables.

Parameters:
count is previously measured cnt from val = CNT for example.
ticks is number of clock ticks to wait.

#define WAITCNTN ( count,
ticks   ) 

Value:

do { \
    asm("waitcnt %" #count ", %" #ticks " WZ WC NR"); \
} while(0)
Make program wait until per ticks have passed; the count variable will not be updated with new count from waitcnt.
Note:
If count < current CNT value, the instruction will wait until CNT rolls over resulting in several minutes or more of delay; this is the way waitcnt works.

This macro has restrictions on use; it can not be used as a parameter; parameters passed to it must be variables.

Parameters:
count is previously measured cnt from val = CNT for example.
ticks is number of clock ticks to wait.

#define WAITPEQ ( bitmask,
pinmask   ) 

Value:

do { \
    asm("waitpeq %" #bitmask ", %" #pinmask " WZ"); \
} while(0)
Make program wait until a pin set specified by pinmask equals value of bitmask.
Note:
This macro has restrictions on use; it can not be used as a parameter; parameters passed to it must be variables.
Parameters:
bitmask is value to detect to stop waiting.
pinmask is mask specifying pins to monitor; each bit position set to 1 indicates that the corresponding pin will be monitored.

#define WAITPNE ( bitmask,
pinmask   ) 

Value:

do { \
    asm("waitpne %" #bitmask ", %" #pinmask " WZ"); \
} while(0)
Make program wait until a pin set specified by pinmask is not equal value of bitmask.
Note:
This macro has restrictions on use; it can not be used as a parameter; parameters passed to it must be variables.
Parameters:
bitmask is the "not" value to detect.
pinmask is mask specifying pins to monitor; each bit position set to 1 indicates that the corresponding pin will be monitored.

#define WAITVID ( color,
pixel   ) 

Value:

do { \
    asm("waitvid %" #color ", %" #pixel " WZ"); \
} while(0)
Pause a cog’s execution until its Video Generator is available to take pixel data.
Note:
This macro has restrictions on use; it can not be used as a parameter; parameters passed to it must be variables.
Parameters:
color is the pixel color set to write when the video generator is ready.
pixel is the pixel data to write when the video generator is ready.


Function Documentation

int cognew_nativeparm ( void *  addr,
void *  parm 
)

Start a new cog running native code with parameters.

Parameters:
addr is start address of native code
parm is start address of native parameters
Returns:
non-zero cogid if ok.

int encode ( int  value  ) 

Get the most significant bit number represented by an integer value.

See also:
also ENCODE macro which will be faster, but input value not preserved.
Parameters:
value contains integer value to encode.
Returns:
most significant bit number power of 2 represented by value.

int indexOf ( void *  array,
int  width,
int  length,
int  start,
int  reverse,
int  data 
)

Get index of data item in array of width and length from index start and reverse

Parameters:
array is pointer to array
width is data width of array elements
length is number of array elements
start index to search for data
reverse is bool if non-zero forces reverse search
data data to find
Returns:
index or -1 if data not found

void longfill ( long *  R0,
long  R1,
int  R2 
)

Fill count longs to destination

Parameters:
R0 is pointer to destination to fill
R1 is value to fill
R2 is number of words to fill

void longmove ( long *  R0,
long *  R1,
int  R2 
)

Copy count source longs to destination

Parameters:
R0 is pointer to destination to copy
R1 is pointer to source of copy
R2 is number of longs to copy

void msleep ( int  ms  ) 

pause program execution for number of milli-seconds

Parameters:
ms is number of milli-seconds to wait.

void sleep ( int  s  ) 

pause program execution for number of seconds

Parameters:
s is number of seconds to wait.

get the integer square root of a number.

Parameters:
n is number
Returns:
square root of number

void wait ( int  ticks  ) 

Pause program execution for number of clock ticks.

Parameters:
ticks is number of clock ticks to wait.

void wordfill ( short *  R0,
short  R1,
int  R2 
)

Fill count source word to destination

Parameters:
R0 is pointer to destination to fill
R1 is value to fill
R2 is number of words to fill

void wordmove ( short *  R0,
short *  R1,
int  R2 
)

Copy count source words to destination

Parameters:
R0 is pointer to destination to copy
R1 is pointer to source of copy
R2 is number of words to copy


Generated on Sun Dec 28 10:27:38 2008 by  doxygen 1.5.4