PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
Provides Propeller 2 specific functions. More...
Go to the source code of this file.
Macros | |
#define | PINA _PINA |
PINA by default allows reading or writing P2 P[00:31] values. More... | |
#define | PINB _PINB |
PINB by default allows reading or writing P2 P[32:63] values. | |
#define | PINC _PINC |
PINC by default allows reading or writing P2 P[64:91] values. | |
#define | PIND _PIND |
PIND by default allows reading or writing P2 PIND shadow register. | |
#define | DIRA _DIRA |
DIRA by default allows setting P2 P[00:31] to input/output or input only. More... | |
#define | DIRB _DIRB |
DIRB by default allows setting P2 P[32:63] to input/output or input only. | |
#define | DIRC _DIRC |
DIRC by default allows setting P2 P[64:91] to input/output or input only. | |
#define | DIRD _DIRD |
DIRD by default allows setting P2 PIND shadow register to input/output or input only. | |
Functions | |
static __inline__ int | coginit (int id, void *image, void *par) |
Start a cog with a parameter. More... | |
static __inline__ uint32_t | getcnt (void) |
CNT register accessor. More... | |
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... | |
Provides Propeller 2 specific functions.
Propeller 2 (P2) provides hardware registers that may be accessed differently from P8x32a (P1). This header provides access to the P2 hardware resources. Similar functions are provided for P1 users for portability.
Common registers are DIRA and DIRB (only DIRA is used in P1). To access other pin hardware on P2 requires the use of DIRA, PINA, and other variations for more than 32 pins.
The P2 Propeller-GCC compiler/assembler provides direct access to PINx and DIRx registers. Pins of P2 are also accessible individually by ASM instructions getpin, setpc, and notp. The ASM code is encapsulated by inline functions getpin, setpin, and togglepin.
The CNT value in P2 is not a register as in P1. The CNT value can be read by the getcnt instruction. The getcnt inline function provides access to the ASM for C users.
Copyright (c) 2011-2013 by Parallax, Inc. MIT Licensed
Definition in file propeller2.h.
#define DIRA _DIRA |
DIRA by default allows setting P2 P[00:31] to input/output or input only.
DIRx definitions are variables which map to the register defaults in the P2 COG. They are used to to set PINx pins as inputs only or outputs which can be read. DIRx means DIRA, DIRB, DIRC, or DIRD. The DIRx registers may be remapped by instructions to point to each-other.
Definition at line 171 of file propeller2.h.
#define PINA _PINA |
PINA by default allows reading or writing P2 P[00:31] values.
PINx definitions are variables which map to the register defaults in the P2 COG. They are used to read the actual pin states if set to input or output by DIRx. They are used to write the pin states if enabled as outputs by DIRx. PINx means PINA, PINB, PINC, or PIND. The PINx registers may be remapped by instructions to point to each-other.
Definition at line 156 of file propeller2.h.
|
static |
Start a cog with a parameter.
id | The COG id to initialize |
image | Start address of PASM code to load. |
par | address |
Definition at line 41 of file propeller2.h.
|
static |
CNT register accessor.
P2 provides a shared CNT register, but it is not register memory mapped as in P1. The CNT is only readable with the getcnt instruction.
Definition at line 65 of file propeller2.h.
|
static |
getpin accessor used to read the state of a pin.
P2 provides pin registers and instructions. This inline macro provides access to read a given pin.
pin | Pin to read in the range 0:127. |
Definition at line 87 of file propeller2.h.
|
static |
setpin accessor used to write the state of a pin.
P2 provides pin registers and instructions. This inline macro provides access to write the value to a given pin.
pin | Pin to read in the range 0:127. |
value | The value to set to the pin 0:1 |
Definition at line 113 of file propeller2.h.
|
static |
togglepin accessor used to toggle the state of a pin.
P2 provides pin registers and instructions. This inline macro provides access to toggle the value of a given pin. Toggle means to set the opposite of the existing state.
pin | Pin to read in the range 0:127. |
Definition at line 137 of file propeller2.h.