PropWare  3.0.0.224
C++ objects and CMake build system for Parallax Propeller
Macros | Functions
propeller1.h File Reference

Provides Propeller 1 specific functions. More...

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define coginit(id, code, param)
 Start a cog with a parameter. More...
 
#define getcnt()   _CNT
 CNT register accessor. More...
 
#define shiftout(val, mask, port)
 shiftout send the low bit of a register to a pin or pins More...
 
#define PAR   _PAR
 Parameter register is used for sharing HUB RAM address info with the COG.
 
#define CNT   _CNT
 The system clock count.
 
#define INA   _INA
 Use to read the pins when corresponding DIRA bits are 0.
 
#define INB   _INB
 Unused in P8X32A.
 
#define OUTA   _OUTA
 Use to set output pin states when corresponding DIRA bits are 1.
 
#define OUTB   _OUTB
 Unused in P8X32A.
 
#define DIRA   _DIRA
 Use to set pins to input (0) or output (1).
 
#define DIRB   _DIRB
 Unused in P8X32A.
 
#define CTRA   _CTRA
 Counter A control register.
 
#define CTRB   _CTRB
 Counter B control register.
 
#define FRQA   _FRQA
 Counter A frequency register.
 
#define FRQB   _FRQB
 Counter B frequency register.
 
#define PHSA   _PHSA
 Counter A phase accumulation register.
 
#define PHSB   _PHSB
 Counter B phase accumulation register.
 
#define VCFG   _VCFG
 Video Configuration register can be used for other special output.
 
#define VSCL   _VSCL
 Video Scale register for setting pixel and frame clocks.
 
#define RCFAST   0x00
 Constants uses with clkset()
 
#define RCSLOW   0x01
 
#define XINPUT   0x22
 
#define XTAL1   0x2a
 
#define XTAL2   0x32
 
#define XTAL3   0x3a
 
#define PLL1X   0x41
 
#define PLL2X   0x42
 
#define PLL4X   0x43
 
#define PLL8X   0x44
 
#define PLL16X   0x45
 

Functions

static __inline__ int getpin (int pin)
 getpin accessor used to read the state of a pin. More...
 
static __inline__ void setpin (int pin, int value)
 setpin accessor used to write the state of a pin. More...
 
static __inline__ void togglepin (int pin)
 togglepin accessor used to toggle the state of a pin. More...
 

Detailed Description

Provides Propeller 1 specific functions.

Copyright (c) 2011-2013 by Parallax, Inc. MIT Licensed

Definition in file propeller1.h.

Macro Definition Documentation

◆ coginit

#define coginit (   id,
  code,
  param 
)
Value:
__builtin_propeller_coginit( \
(((uint32_t)(param) << 16) & 0xfffc0000) \
|(((uint32_t)(code) << 2) & 0x0003fff0) \
|(((id) ) & 0x0000000f))

Start a cog with a parameter.

The fields in parameters are:

  • 31:18 = 14-bit Long address for PAR Register
  • 17:4 = 14-bit Long address of CODE to load
  • 3 = New bit
  • 2:0 = Cog ID. New bit 3 is 0.

It is important to realize that a 14 bit address means that long aligned addresses or pointers should be use. That is if you pass a value to the PAR such as 3, the value will be truncated to 0. A value 5 will be interpreted as 4.

Parameters
idThe COG id to initialize
codeStart address of PASM code to load.
paramPAR address
Returns
COG ID provided by the builtin function or -1 on failure.

Definition at line 39 of file propeller1.h.

◆ getcnt

#define getcnt (   void)    _CNT

CNT register accessor.

P1 provides a COG accessible CNT register.

This macro is a convenience for portability between P1/P2 code.

Returns
the global CNT value.

Definition at line 53 of file propeller1.h.

◆ shiftout

#define shiftout (   val,
  mask,
  port 
)
Value:
__extension__({ \
unsigned int ret = val; \
__asm__ volatile( \
" shr %[_ret],#1 wc\n" \
" muxc %[_port], %[_mask]\n" \
: /* outputs */ \
/* "+r" means a register operand that is both read and written */ \
[_ret] "+rC" (ret), \
[_port] "+rC" (port) \
: /* inputs */ \
[_mask] "r" (mask) \
: /* clobbered registers */ \
"cc" /* only the condition codes */ \
); ret; })

shiftout send the low bit of a register to a pin or pins

This inline macro provides an efficient way to send the low bit of a value out a port.

Parameters
valValue to be shift right; (val&1) will be placed in port
maskIndicates which bits of port should receive the value of (val&1); wherever mask has a 1 bit this will be replaced with the low bit of val. Wherever mask has a 0 bit port will be left unchanged.
portRegister to be modified according to val and mask; typically this will be _OUTA
Returns
val shifted right by 1 (val>>1)

Definition at line 131 of file propeller1.h.

Function Documentation

◆ getpin()

static __inline__ int getpin ( int  pin)
static

getpin accessor used to read the state of a pin.

P1 provides pin access via registers only. This inline macro provides access to read a given pin.

This macro is a convenience for portability between P1/P2 code.

Parameters
pinPin to read in the range 0:31.
Returns
State of the requested pin with range 0:1.

Definition at line 66 of file propeller1.h.

◆ setpin()

static __inline__ void setpin ( int  pin,
int  value 
)
static

setpin accessor used to write the state of a pin.

P1 provides pin access via registers only. This inline macro provides access to write the value to a given pin.

This macro is a convenience for portability between P1/P2 code.

Parameters
pinPin to read in the range 0:31.
valueThe value to set to the pin 0:1
Returns
Nothing.

Definition at line 85 of file propeller1.h.

◆ togglepin()

static __inline__ void togglepin ( int  pin)
static

togglepin accessor used to toggle the state of a pin.

P1 provides pin access via registers only. This inline macro provides access to toggle the value of a given pin. Toggle means to set the opposite of the existing state.

This macro is a convenience for portability between P1/P2 code.

Parameters
pinPin to read in the range 0:31.
Returns
Nothing.

Definition at line 107 of file propeller1.h.