#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) |
#define ABS | ( | val | ) | ((val < 0) ? -val : val) |
Get absolute value of a number.
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
#define CLR | ( | val, | |||
bit | ) | do { (val) &= ~(1 << (bit)); } while (0) |
Clear a bit in val
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)
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)
val | contains data as defined in propeller manual for coginit instruction. |
#define COGSTOP | ( | val | ) |
Value:
do { \ asm("COGSTOP %" #val); \ } while(0)
val | contains cog number. |
#define DECODE | ( | bitnum | ) | (1<<(bitnum)) |
Get the integer value of a single bit 2^bit or 1<<bit.
bitnum | contains bit number. |
#define ENCODE | ( | val, | |||
bitnum | ) |
Value:
do { \ (bitnum) = 0; \ while((val) != 0) { \ (bitnum)++; \ (val) >>= 1; \ } \ (bitnum)--; \ } while(0)
val | contains integer value to encode; val will not be preserved. | |
bitnum | is most significant bit number power of 2 of value. |
#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
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)
flag | is return variable. |
#define GETCOGID | ( | val | ) |
Value:
do { \ asm("cogid %" #val); \ } while(0)
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)
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
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
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
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
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
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
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)
lock | is lock identifier and must be a variable; |
#define LOCKNEW | ( | lock | ) |
Value:
do { \ asm("locknew %" #lock " wc wz"); \ } while(0)
lock | is lock identifier return and must be a variable; |
#define LOCKRET | ( | lock | ) |
Value:
do { \ asm("lockret %" #lock); \ } while(0)
lock | is lock identifier and must be a variable; |
#define LOCKSET | ( | lock | ) |
Value:
do { \ asm("lockset %" #lock " wc wz"); \ } while(0)
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)
#define SET | ( | val, | |||
bit | ) | do { (val) += (1 << (bit)); } while (0) |
Set a bit in val
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.
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)
Using a count under 20 will make the program hang.
If you need a wait with a constant, use the wait function.
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)
This macro has restrictions on use; it can not be used as a parameter; parameters passed to it must be variables.
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)
This macro has restrictions on use; it can not be used as a parameter; parameters passed to it must be variables.
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)
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)
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)
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. |
int cognew_nativeparm | ( | void * | addr, | |
void * | parm | |||
) |
Start a new cog running native code with parameters.
addr | is start address of native code | |
parm | is start address of native parameters |
int encode | ( | int | value | ) |
Get the most significant bit number represented by an integer value.
value | contains integer value to encode. |
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
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 |
void longfill | ( | long * | R0, | |
long | R1, | |||
int | R2 | |||
) |
Fill count longs to destination
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
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
ms | is number of milli-seconds to wait. |
void sleep | ( | int | s | ) |
pause program execution for number of seconds
s | is number of seconds to wait. |
get the integer square root of a number.
n | is number |
void wait | ( | int | ticks | ) |
Pause program execution for number of clock ticks.
ticks | is number of clock ticks to wait. |
void wordfill | ( | short * | R0, | |
short | R1, | |||
int | R2 | |||
) |
Fill count source word to destination
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
R0 | is pointer to destination to copy | |
R1 | is pointer to source of copy | |
R2 | is number of words to copy |