Netcruzer Library API  V2.03
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
nz_ioPorts.h File Reference

Code for using and configuring I/O ports. More...

#include "nz_ioPortDefs.h"

Go to the source code of this file.

Macros

#define portReadBitadr_MACRO(bitAdr)   (*((volatile WORD*)((bitAdr)&0xFFF)) & (0x01 << ((bitAdr)>>12)))
 
#define portSetBitadr_MACRO(bitAdr)   (*((volatile WORD*)((bitAdr)&0xFFF)) |= (0x01 << ((bitAdr)>>12)))
 
#define portClearBitadr_MACRO(bitAdr)   (*((volatile WORD*)((bitAdr)&0xFFF)) &= (~(0x01 << ((bitAdr)>>12))))
 
#define portWriteBitadr_MACRO(bitAdr, value)   ((value==0) ? (*((volatile WORD*)((bitAdr)&0xFFF)) &= (~(0x01 << ((bitAdr)>>12)))) : (*((volatile WORD*)((bitAdr)&0xFFF)) |= (0x01 << ((bitAdr)>>12))))
 
#define portGetTRIS_MACRO(portID)   ((portID>PORT_ID_MAX) ? (BITADR_NA/*Returns BITADR_NA if not available or error*/) : TRIS_PORTID_BITADR_MAP[portID])
 
#define HIGH   1
 
#define LOW   0
 

Functions

void portInit (void)
 
BYTE portConfig (BYTE portID, WORD typeConf)
 
BYTE ucportGetIndex (BYTE portID)
 
BYTE portGetUcportID (BYTE portID)
 
BYTE getPortIdForStr (const char *str)
 
BOOL portReadBitadr (WORD bitAdr)
 
void portSetBitadr (WORD bitAdr)
 
void portClearBitadr (WORD bitAdr)
 
void portWriteBitadr (WORD bitAdr, BOOL value)
 
WORD portGetLAT (BYTE portID)
 
WORD ucportGetLAT (BYTE ucportID)
 
WORD portGetPIN (BYTE portID)
 
WORD ucportGetPIN (BYTE ucportID)
 
WORD portGetODC (BYTE portID)
 
WORD ucportGetODC (BYTE ucportID)
 
WORD portGetTRIS (BYTE portID)
 
WORD portGetTRISwOffset (BYTE portID, BYTE offset)
 
WORD ucportGetTRIS (BYTE ucportID)
 
WORD ucportGetTRISwOffset (BYTE ucportID, BYTE offset)
 
WORD portGetCNPD (BYTE portID)
 
WORD portGetCNPDwOffset (BYTE portID, BYTE offset)
 
WORD ucportGetCNPD (BYTE ucportID)
 
WORD ucportGetCNPDwOffset (BYTE ucportID, BYTE offset)
 
WORD ucportGetCNPU (BYTE ucportID)
 
WORD portGetCNIE (BYTE portID)
 
WORD ucportGetCNIE (BYTE ucportID)
 
void portWritePullup (BYTE portID, BOOL val)
 
void portWritePulldown (BYTE portID, BOOL val)
 
void portConfigDir (BYTE portID, BOOL dir)
 
void portWrite (BYTE portID, BYTE value)
 
BOOL portRead (BYTE portID)
 
void digitalWrite (BYTE portID, BYTE value)
 
BOOL digitalRead (BYTE portID)
 

Detailed Description

Code for using and configuring I/O ports.

Author
Modtronix Engineering
Compiler:
MPLAB XC16

Description

Code for using and configuring I/O ports

Configuration

The following defines are used to configure this module, and should be placed in projdefs.h. Note that all items marked [-DEFAULT-] are defaults, and do not have to be placed in projdefs.h if they contain desired configuration! For details, see Project Configuration.

// *********************************************************************
// ---------------------- ioPorts Configuration ------------------------
// *********************************************************************
//Optimize for size, not speed!
#define IOPORTS_OPTIMIZE_SIZE

Software License Agreement

The software supplied herewith is owned by Modtronix Engineering, and is protected under applicable copyright laws. The software supplied herewith is intended and supplied to you, the Company customer, for use solely and exclusively on products manufactured by Modtronix Engineering. The code may be modified and can be used free of charge for commercial and non commercial applications. All rights are reserved. Any use in violation of the foregoing restrictions may subject the user to criminal sanctions under applicable laws, as well as to civil liability for the breach of the terms and conditions of this license.

THIS SOFTWARE IS PROVIDED IN AN 'AS IS' CONDITION. NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.

File History

2013-11-20, David H. (DH):

  • Initial version

Macro Definition Documentation

#define portClearBitadr_MACRO (   bitAdr)    (*((volatile WORD*)((bitAdr)&0xFFF)) &= (~(0x01 << ((bitAdr)>>12))))
Function:
void portClearBitadr_MACRO(WORD bitAdr)

Set a Port bit with given "Port bitAdr". A "Port bitAdr" can be used to identify any of a port's control bits:
LAT, ODC (Open Drain), PORT, TRIS, Pullup and Pulldown registers
This function is useful if a variable (16-bit WORD) is required to represent a Port bit address. It is done by ORing the SRF's address with it's bit position (for PIC32 add 0x0088 for upper Word). The bit position is stored in the upper nibble (bits 12 to 15). For example, to represent bit 2 of a register with address 0x0C18, use 0x2C18.

If the "Port bitAdr" is available as a literal constant, the portClearBitadr_MACRO() macro will generate a single line of code!

Many "Port bitAdr" constants have been defined in the "brd_xxx.h" include file for selected board. For example PIN_xx_BITADR and LAT_xx_BITADR defines are available for accessing bits in the PORT and LAT registers. Various portGetXxx() and getUcportXxx() functions are also available for getting the "Port bitAdr" for port TRIS, LAT, PORT, ODC, PULLUP and PULLDOWN registers.

Parameters
bitAdrThe "Port bitAdr" of the bit to clear.
#define portGetTRIS_MACRO (   portID)    ((portID>PORT_ID_MAX) ? (BITADR_NA/*Returns BITADR_NA if not available or error*/) : TRIS_PORTID_BITADR_MAP[portID])
Function:
WORD portGetTRIS(BYTE portID)

Gets a "Port bitAdr" for the requested port's TRIS register's. The port is identified by it's "Port ID". The returned "Port bitAdr" can be used to set or clear the port using the portWriteBitadr(), portSetBitadr() and portClearBitadr() functions.

Parameters
portIDThe "Port ID" of the requested port. Is a number from 0 to 41, also known as the "Netcruzer Port Name".
Returns
Returns a "Port bitAdr" for the requested port's TRIS register. Returns BITADR_NA if not available, or error.
#define portReadBitadr_MACRO (   bitAdr)    (*((volatile WORD*)((bitAdr)&0xFFF)) & (0x01 << ((bitAdr)>>12)))
Function:
BOOL portReadBitadr_MACRO(WORD bitAdr)

Reads a Port bit with given "port bitAdr". A "Port bitAdr" can be used to identify any of a port's control bits:
LAT, ODC (Open Drain), PORT, TRIS, Pullup and Pulldown registers
This function is useful if a variable (16-bit WORD) is required to represent a Port bit address. It is done by ORing the SRF's address with it's bit position (for PIC32 add 0x0088 for upper Word). The bit position is stored in the upper nibble (bits 12 to 15). For example, to represent bit 2 of a register with address 0x0C18, use 0x2C18.

If the "Port bitAdr" is available as a literal constant, the portReadBitadr_MACRO() macro will generate a single line of code!

Many "Port bitAdr" constants have been defined in the "brd_xxx.h" include file for selected board. For example PIN_xx_BITADR and LAT_xx_BITADR defines are available for accessing bits in the PORT and LAT registers. Various portGetXxx() and getUcportXxx() functions are also available for getting the "Port bitAdr" for port TRIS, LAT, PORT, ODC, PULLUP and PULLDOWN registers.

Parameters
bitAdrThe "Port bitAdr" of the bit to set or clear.
Returns
Returns 0 if requested bit is clear, or 1 if set
#define portSetBitadr_MACRO (   bitAdr)    (*((volatile WORD*)((bitAdr)&0xFFF)) |= (0x01 << ((bitAdr)>>12)))
Function:
void portSetBitadr_MACRO(WORD bitAdr)

Set a Port bit with given "Port bitAdr". A "Port bitAdr" can be used to identify any of a port's control bits:
LAT, ODC (Open Drain), PORT, TRIS, Pullup and Pulldown registers
This function is useful if a variable (16-bit WORD) is required to represent a Port bit address. It is done by ORing the SRF's address with it's bit position (for PIC32 add 0x0088 for upper Word). The bit position is stored in the upper nibble (bits 12 to 15). For example, to represent bit 2 of a register with address 0x0C18, use 0x2C18.

If the "Port bitAdr" is available as a literal constant, the portSetBitadr_MACRO() macro will generate a single line of code!

Many "Port bitAdr" constants have been defined in the "brd_xxx.h" include file for selected board. For example PIN_xx_BITADR and LAT_xx_BITADR defines are available for accessing bits in the PORT and LAT registers. Various portGetXxx() and getUcportXxx() functions are also available for getting the "Port bitAdr" for port TRIS, LAT, PORT, ODC, PULLUP and PULLDOWN registers.

Parameters
bitAdrThe "Port bitAdr" of the bit to set.
#define portWriteBitadr_MACRO (   bitAdr,
  value 
)    ((value==0) ? (*((volatile WORD*)((bitAdr)&0xFFF)) &= (~(0x01 << ((bitAdr)>>12)))) : (*((volatile WORD*)((bitAdr)&0xFFF)) |= (0x01 << ((bitAdr)>>12))))
Function:
void portWriteBitadr_MACRO(WORD bitAdr, BOOL value);

Set a Port bit with given "port bitAdr". A "Port bitAdr" can be used to identify any of a port's control bits:
LAT, ODC (Open Drain), PORT, TRIS, Pullup and Pulldown registers
This function is useful if a variable (16-bit WORD) is required to represent a Port bit address. It is done by ORing the SRF's address with it's bit position (for PIC32 add 0x0088 for upper Word). The bit position is stored in the upper nibble (bits 12 to 15). For example, to represent bit 2 of a register with address 0x0C18, use 0x2C18.

If the "Port bitAdr" is available as a literal constant, the portWriteBitadr_MACRO() macro will generate a single line of code!

Many "Port bitAdr" constants have been defined in the "brd_xxx.h" include file for selected board. For example PIN_xx_BITADR and LAT_xx_BITADR defines are available for accessing bits in the PORT and LAT registers. Various portGetXxx() and getUcportXxx() functions are also available for getting the "Port bitAdr" for port TRIS, LAT, PORT, ODC, PULLUP and PULLDOWN registers.

Parameters
bitAdrThe "Port bitAdr" of the bit to set or clear.
value0 will clear given port bit, 1 will set it

Function Documentation

BOOL digitalRead ( BYTE  portID)
Function:
BOOL digitalRead(BYTE portID)

Read a Digital port.

Parameters
portIDThe "Port ID" of the requested port. Is a number from 0 to 41, also known as the "Netcruzer Port Name".
Returns
Returns the value of the requested digitial port, will be 0 (LOW = 0V) if not set, or 1 (HIGH = 3.3V) if set.
void digitalWrite ( BYTE  portID,
BYTE  value 
)
Function:
void digitalWrite(BYTE portID, BYTE value)

Write a Digital port.

Parameters
portIDThe "Port ID" of the requested port. Is a number from 0 to 41, also known as the "Netcruzer Port Name".
valueHIGH will set the port(3.3V), and LOW will clear(0V) the port pin.
BYTE getPortIdForStr ( const char *  str)

Gets the "Port ID" (a number from 0 to 41, also known as the "Netcruzer Port Name") for the given string. String must contain 1 or 2 digits. For numbers less than 10, can have an optional leading 0.

Parameters
strA string representing the "Port ID" of the requested port. Is a number from 0 to 41, also known as the "Netcruzer Port Name". Can be "00" to "41", or "0" to "41".
Returns
Returns the "Port ID" of the requested port. Is a number from 0 to 41, also known as the "Netcruzer Port Name". Will return IOPORT_ID_NA if the given string was could not be associated with an IO Port(port of SBC).
void portClearBitadr ( WORD  bitAdr)
Function:
void portClearBitadr(WORD bitAdr)

Set a Port bit with given "Port bitAdr". A "Port bitAdr" can be used to identify any of a port's control bits:
LAT, ODC (Open Drain), PORT, TRIS, Pullup and Pulldown registers
This function is useful if a variable (16-bit WORD) is required to represent a Port bit address. It is done by ORing the SRF's address with it's bit position (for PIC32 add 0x0088 for upper Word). The bit position is stored in the upper nibble (bits 12 to 15). For example, to represent bit 2 of a register with address 0x0C18, use 0x2C18.

If the "Port bitAdr" is available as a literal constant, the portClearBitadr_MACRO() macro will generate a single line of code!

Many "Port bitAdr" constants have been defined in the "brd_xxx.h" include file for selected board. For example PIN_xx_BITADR and LAT_xx_BITADR defines are available for accessing bits in the PORT and LAT registers. Various portGetXxx() and getUcportXxx() functions are also available for getting the "Port bitAdr" for port TRIS, LAT, PORT, ODC, PULLUP and PULLDOWN registers.

Parameters
bitAdrThe "Port bitAdr" of the bit to clear.
BYTE portConfig ( BYTE  portID,
WORD  typeConf 
)

Configure I/O Port (ports of SBC) with the given configuration data. The first parameter is the "Port ID", and the second is an ORed combination of PCFG_XX and PTYPE_XX defines. The PTYPE_XX define gives the type of port, and the PCFG_XX define give optional configuration. Common combinations are:

  • Digital input pin = (PTYPE_DIN)
  • Digital input pin, with pull-up resistor = (PTYPE_DIN | PCFG_DIN_PULLUP)
  • Digital input pin, with pull-down resistor = (PTYPE_DIN | PCFG_DIN_PULLDOWN)
  • Digital output pin = (PTYPE_DOUT)
  • Analog input pin = (PTYPE_ADC)
  • PWM output pin = (PTYPE_PWM)

--— Details --— The upper byte (bit 8-15) of the given typeConf parameter is a PCFG_XXX_TYPE define, like PCFG_DIN_TYPE for example. The lower byte (bit 0-7) are PCFG_XXX flags, like PCFG_IN_FL_PULLUP for example.

The following example configures port 5 as a digital output:

portConfig(10, PTYPE_DOUT)

The following example configures port 10 as a digital input, with pull-up resistor enabled:

portConfig(10, PTYPE_DIN | PCFG_DIN_PULLUP)
Parameters
portIDThe "Port ID" of the requested port. Is a number from 0 to 41, also known as the "Netcruzer Port Name".
typeConfType and configuration
Returns
Returns 0 if successful, else error occurred.
void portConfigDir ( BYTE  portID,
BOOL  dir 
)

Set direction of Digital port.

Parameters
portIDThe "Port ID" of the requested port. Is a number from 0 to 41, also known as the "Netcruzer Port Name".
dirDirection of port, 0 sets port as an output, 1 as an input.
WORD portGetCNIE ( BYTE  portID)
Function:
WORD portGetCNIE(BYTE portID)

Gets a "Port bitAdr" for the requested port's CNIE (CN Interrupt Enable) register. The port is identified by it's "Port ID". The returned "Port bitAdr" can be used to enable or disable the port's CN interrupts using the portWriteBitadr(), portSetBitadr() and portClearBitadr() functions.

Parameters
portIDThe "Port ID" of the requested port. Is a number from 0 to 41, also known as the "Netcruzer Port Name".
Returns
Returns a "Port bitAdr" for the requested port's CNIE (CN Interrupt Enable) register. Returns BITADR_NA if not available, or error.
WORD portGetCNPD ( BYTE  portID)
Function:
WORD portGetCNPD(BYTE portID)

Gets a "Port bitAdr" for the requested port's CNPD (Pull-Down) register. The port is identified by it's "Port ID". The returned "Port bitAdr" can be used to enable or disable the port's Pull-Down resistor using the portWriteBitadr(), portSetBitadr() and portClearBitadr() functions.

Parameters
portIDThe "Port ID" of the requested port. Is a number from 0 to 41, also known as the "Netcruzer Port Name".
Returns
Returns a "Port bitAdr" for the requested port's CNPD (Pull-Down) register. Returns BITADR_NA if not available, or error.
WORD portGetCNPDwOffset ( BYTE  portID,
BYTE  offset 
)
Function:
WORD portGetCNPDwOffset(BYTE portID, BYTE offset)

!!!!!!! IMPORTANT !!!!!!!!! This functions if used by the system, is not meant for general purpose use!

Gets a "Port bitAdr" for the requested port's CNPD (Pull-Down) register, adding the given offset to it.

Parameters
portIDThe "Port ID" of the requested port. Is a number from 0 to 41, also known as the "Netcruzer Port Name".
offsetAn offset to add to returned value if it is NOT 0.
Returns
Returns a "Port bitAdr" for the requested port's CNPD (Pull-Down) register. Returns BITADR_NA if not available, or error.
WORD portGetLAT ( BYTE  portID)
Function:
WORD portGetLAT(BYTE portID)

Gets a "Port bitAdr" for the requested port's LAT register's. The port is identified by it's "Port ID". The returned "Port bitAdr" can be used to set or clear the port using the portWriteBitadr(), portSetBitadr() and portClearBitadr() functions.

The "Port bitAdr" for all ports are also defined by the LAT_xx_BITADR defines! The following two lines will both return the requested port's "Port bitAdr" value:

WORD portX0;
WORD portX1;
portX0 = LAT_00_BITADR;
portX1 = portGetLAT(1);
Parameters
portIDThe "Port ID" of the requested port. Is a number from 0 to 41, also known as the "Netcruzer Port Name".
Returns
Returns a "Port bitAdr" for the requested port's LAT register. Returns BITADR_NA if not available, or error.
WORD portGetODC ( BYTE  portID)
Function:
WORD portGetODC(BYTE portID)

Gets a "Port bitAdr" for the requested port's ODC (Open Drain Control) register's. The port is identified by it's "Port ID". The returned "Port bitAdr" can be used to enable or disable the Open Collector feature of the port using the portWriteBitadr(), portSetBitadr() and portClearBitadr() functions.

Parameters
portIDThe "Port ID" of the requested port. Is a number from 0 to 41, also known as the "Netcruzer Port Name".
Returns
Returns a "Port bitAdr" for the requested port's ODC (Open Drain Control) register. Returns BITADR_NA if not available, or error.
WORD portGetPIN ( BYTE  portID)

WORD portGetPIN(BYTE portID)

Gets a "Port bitAdr" for the requested port's PORT register's. The port is identified by it's "Port ID". The returned "Port bitAdr" can be used to read or write the digital pin value of the port. The portWriteBitadr(), portSetBitadr() and portClearBitadr() functions can be used.

IMPORTANT! When writing a port pin, the LAT registers (port output latch) should be used in stead! Using the PORT register could fail if the port is driving low impedance loads (read-write effect)!

The "Port bitAdr" for all ports are also defined by the PIN_xx_BITADR defines! The following two lines will both return the requested port's "Port bitAdr" value:

WORD pinX0;
WORD pinX1;
pinX0 = PIN_00_BITADR;
pinX1 = portGetPIN(1);
Parameters
portIDThe "Port ID" of the requested port. Is a number from 0 to 41, also known as the "Netcruzer Port Name".
Returns
Returns a "Port bitAdr" for the requested port's PORT register. Returns BITADR_NA if not available, or error.
WORD portGetTRIS ( BYTE  portID)
Function:
WORD portGetTRIS(BYTE portID)

Gets a "Port bitAdr" for the requested port's TRIS register's. The port is identified by it's "Port ID". The returned "Port bitAdr" can be used to set or clear the port using the portWriteBitadr(), portSetBitadr() and portClearBitadr() functions.

Parameters
portIDThe "Port ID" of the requested port. Is a number from 0 to 41, also known as the "Netcruzer Port Name".
Returns
Returns a "Port bitAdr" for the requested port's TRIS register. Returns BITADR_NA if not available, or error.
WORD portGetTRISwOffset ( BYTE  portID,
BYTE  offset 
)
Function:
WORD portGetTRISwOffset(BYTE portID)

!!!!!!! IMPORTANT !!!!!!!!! This functions if used by the system, is not meant for general purpose use!

Gets a "Port bitAdr" for the requested port's TRIS register's, adding the given offset to it.

Parameters
portIDThe "Port ID" of the requested port. Is a number from 0 to 41, also known as the "Netcruzer Port Name".
offsetAn offset to add to returned value if it is NOT 0.
Returns
Returns a "Port bitAdr" for the requested port's TRIS register. Returns BITADR_NA if not available, or error.
BYTE portGetUcportID ( BYTE  portID)

Gets the "Microcontroller port ID"(a UCPORT_ID_xx define) that is mapped to the given "Port ID" (a number from 0 to 41, also known as the "Netcruzer Port Name"). For example, on the SBC66EC, port 1 is connected to Microcontroller port RB1. The following function will return UCPORT_ID_B1:

BYTE ucport;
ucport = portGetUcportID(1);

The returned "Microcontroller port ID" is used by many port functions.

Parameters
portIDThe "Port ID" of the requested port. Is a number from 0 to 41, also known as the "Netcruzer Port Name".
Returns
Returns the "Microcontroller Port ID" (a UCPORT_ID_xx define) for the given "Port ID". For example UCPORT_ID_B1. Will return UCPORT_ID_NA if the given IO Port(port of SBC) is not connected to a Microcontroller port.
void portInit ( void  )

Initialization

BOOL portRead ( BYTE  portID)

Read a Digital port.

Parameters
portIDThe "Port ID" of the requested port. Is a number from 0 to 41, also known as the "Netcruzer Port Name".
Returns
Returns the value of the requested digitial port, will be 0 (LOW = 0V) if not set, or 1 (HIGH = 3.3V) if set.
BOOL portReadBitadr ( WORD  bitAdr)

Reads a Port bit with given "port bitAdr". A "Port bitAdr" can be used to identify any of a port's control bits:
LAT, ODC (Open Drain), PORT, TRIS, Pullup and Pulldown registers
This function is useful if a variable (16-bit WORD) is required to represent a Port bit address. It is done by ORing the SRF's address with it's bit position (for PIC32 add 0x0088 for upper Word). The bit position is stored in the upper nibble (bits 12 to 15). For example, to represent bit 2 of a register with address 0x0C18, use 0x2C18.

If the "Port bitAdr" is available as a literal constant, the portReadBitadr_MACRO() macro will generate a single line of code!

Many "Port bitAdr" constants have been defined in the "brd_xxx.h" include file for selected board. For example PIN_xx_BITADR and LAT_xx_BITADR defines are available for accessing bits in the PORT and LAT registers. Various portGetXxx() and getUcportXxx() functions are also available for getting the "Port bitAdr" for port TRIS, LAT, PORT, ODC, PULLUP and PULLDOWN registers.

Parameters
bitAdrThe "Port bitAdr" of the bit to set or clear.
Returns
Returns 0 if requested bit is clear, or 1 if set
void portSetBitadr ( WORD  bitAdr)
Function:
void portSetBitadr(WORD bitAdr)

Set a Port bit with given "Port bitAdr". A "Port bitAdr" can be used to identify any of a port's control bits:
LAT, ODC (Open Drain), PORT, TRIS, Pullup and Pulldown registers
This function is useful if a variable (16-bit WORD) is required to represent a Port bit address. It is done by ORing the SRF's address with it's bit position (for PIC32 add 0x0088 for upper Word). The bit position is stored in the upper nibble (bits 12 to 15). For example, to represent bit 2 of a register with address 0x0C18, use 0x2C18.

If the "Port bitAdr" is available as a literal constant, the portSetBitadr_MACRO() macro will generate a single line of code!

Many "Port bitAdr" constants have been defined in the "brd_xxx.h" include file for selected board. For example PIN_xx_BITADR and LAT_xx_BITADR defines are available for accessing bits in the PORT and LAT registers. Various portGetXxx() and getUcportXxx() functions are also available for getting the "Port bitAdr" for port TRIS, LAT, PORT, ODC, PULLUP and PULLDOWN registers.

Parameters
bitAdrThe "Port bitAdr" of the bit to set.
void portWrite ( BYTE  portID,
BYTE  value 
)

Write a Digital port.

Parameters
portIDThe "Port ID" of the requested port. Is a number from 0 to 41, also known as the "Netcruzer Port Name".
valueHIGH will set the port(3.3V), and LOW will clear(0V) the port pin.
void portWriteBitadr ( WORD  bitAdr,
BOOL  value 
)

Set a Port bit with given "port bitAdr". A "Port bitAdr" can be used to identify any of a port's control bits:
LAT, ODC (Open Drain), PORT, TRIS, Pullup and Pulldown registers
This function is useful if a variable (16-bit WORD) is required to represent a Port bit address. It is done by ORing the SRF's address with it's bit position (for PIC32 add 0x0088 for upper Word). The bit position is stored in the upper nibble (bits 12 to 15). For example, to represent bit 2 of a register with address 0x0C18, use 0x2C18.

If the "Port bitAdr" is available as a literal constant, the portWriteBitadr_MACRO() macro will generate a single line of code!

Many "Port bitAdr" constants have been defined in the "brd_xxx.h" include file for selected board. For example PIN_xx_BITADR and LAT_xx_BITADR defines are available for accessing bits in the PORT and LAT registers. Various portGetXxx() and getUcportXxx() functions are also available for getting the "Port bitAdr" for port TRIS, LAT, PORT, ODC, PULLUP and PULLDOWN registers.

Parameters
bitAdrThe "Port bitAdr" of the bit to set or clear.
value0 will clear given port bit, 1 will set it
void portWritePulldown ( BYTE  portID,
BOOL  val 
)

Enables or disabled the pull-down resistor for the given port

Parameters
portIDThe "Port ID" of the requested port. Is a number from 0 to 41, also known as the "Netcruzer Port Name".
valIf 0, the pull-down resistor is disabled, else it is enabled.
void portWritePullup ( BYTE  portID,
BOOL  val 
)

Enables of disabled the pull-up resistor for the given port

Parameters
portIDThe "Port ID" of the requested port. Is a number from 0 to 41, also known as the "Netcruzer Port Name".
valIf 0, the pull-up resistor is disabled, else it is enabled.
WORD ucportGetCNIE ( BYTE  ucportID)
Function:
WORD ucportGetCNIE(BYTE ucportID)

Gets a "Port bitAdr" for the requested port's CNIE (CN Interrupt Enable) register. The port is identified by it's "Microcontroller Port ID", is a UCPORT_ID_xx define (UCPORT_ID_01 for example). The returned "Port bitAdr" can be used to enable or disable the port's CN interrupts using the portWriteBitadr(), portSetBitadr() and portClearBitadr() functions.

Parameters
ucportIDThe port's "Microcontroller Port ID", is a UCPORT_ID_xx define (UCPORT_ID_01 for example).
Returns
Returns a "Port bitAdr" for the requested port's CNIE (CN Interrupt Enable) register. Returns BITADR_NA if not available, or error.
WORD ucportGetCNPD ( BYTE  ucportID)

Gets a "Port bitAdr" for the requested port's CNPD (Pull-Down) register. The port is identified by it's "Microcontroller Port ID", is a UCPORT_ID_xx define (UCPORT_ID_01 for example). The returned "Port bitAdr" can be used to enable or disable the port's Pull-Down resistor using the portWriteBitadr(), portSetBitadr() and portClearBitadr() functions.

Parameters
ucportIDThe port's "Microcontroller Port ID", is a UCPORT_ID_xx define (UCPORT_ID_01 for example).
Returns
Returns a "Port bitAdr" for the requested port's CNPD (Pull-Down) register. Returns BITADR_NA if not available, or error.
WORD ucportGetCNPDwOffset ( BYTE  ucportID,
BYTE  offset 
)

!!!!!!! IMPORTANT !!!!!!!!! This functions if used by the system, is not meant for general purpose use!

Gets a "Port bitAdr" for the requested port's CNPD (Pull-Down) register, adding the given offset to it.

Parameters
ucportIDThe port's "Microcontroller Port ID", is a UCPORT_ID_xx define (UCPORT_ID_01 for example).
offsetAn offset to add to returned value if it is NOT 0.
Returns
Returns a "Port bitAdr" for the requested port's CNPD (Pull-Down) register. Returns BITADR_NA if not available, or error.
WORD ucportGetCNPU ( BYTE  ucportID)
Function:
WORD ucportGetCNPU(BYTE ucportID)

Gets a "Port bitAdr" for the requested port's CNPU (Pull-Up) register. The port is identified by it's "Microcontroller Port ID", is a UCPORT_ID_xx define (UCPORT_ID_01 for example). The returned "Port bitAdr" can be used to enable or disable the port's Pull-Up resistor using the portWriteBitadr(), portSetBitadr() and portClearBitadr() functions.

Parameters
ucportIDThe port's "Microcontroller Port ID", is a UCPORT_ID_xx define (UCPORT_ID_01 for example).
Returns
Returns a "Port bitAdr" for the requested port's CNPU (Pull-Up) register. Returns BITADR_NA if not available, or error.
BYTE ucportGetIndex ( BYTE  portID)

Gets an index for the given "Port ID". The index is for:

Parameters
portIDThe "Port ID" of the requested port. Is a number from 0 to 41, also known as the "Netcruzer Port Name".
Returns
Returns the index of UCPORT_PROP element in TABLE_BLOCK_UC66_PORT, and UCPORT_CONFIG element in CFG_BLOCK_UC66_PORT. Return UCPORT_INDEX_NA if not available, or error.
WORD ucportGetLAT ( BYTE  ucportID)

WORD ucportGetLAT(BYTE ucportID)

Gets a "Port bitAdr" for the requested port's LAT register's. The port is identified by it's "Microcontroller Port ID", is a UCPORT_ID_xx define (UCPORT_ID_01 for example). The returned "Port bitAdr" can be used to set or clear the port using the portWriteBitadr(), portSetBitadr() and portClearBitadr() functions.

WORD portB1;
portB1 = ucportGetLAT(UCPORT_ID_B1);
Parameters
ucportIDThe port's "Microcontroller Port ID", is a UCPORT_ID_xx define (UCPORT_ID_01 for example).
Returns
Returns a "Port bitAdr" for the requested port's LAT register. Returns BITADR_NA if not available, or error.
WORD ucportGetODC ( BYTE  ucportID)
Function:
WORD ucportGetODC(BYTE ucportID)

Gets a "Port bitAdr" for the requested port's ODC (Open Drain Control) register's. The port is identified by it's "Microcontroller Port ID", is a UCPORT_ID_xx define (UCPORT_ID_01 for example). The returned "Port bitAdr" can be used to enable or disable the Open Collector feature of the port using the portWriteBitadr(), portSetBitadr() and portClearBitadr() functions.

Parameters
ucportIDThe port's "Microcontroller Port ID", is a UCPORT_ID_xx define (UCPORT_ID_01 for example).
Returns
Returns a "Port bitAdr" for the requested port's ODC (Open Drain Control) register. Returns BITADR_NA if not available, or error.
WORD ucportGetPIN ( BYTE  ucportID)

WORD ucportGetPIN(BYTE ucportID)

Gets a "Port bitAdr" for the requested port's PORT register's. The port is identified by it's "Microcontroller Port ID", is a UCPORT_ID_xx define (UCPORT_ID_01 for example). The returned "Port bitAdr" can be used to read or write the digital pin value of the port. The portWriteBitadr(), portSetBitadr() and portClearBitadr() functions can be used.

IMPORTANT! When writing a port pin, the LAT registers (port output latch) should be used in stead! Using the PORT register could fail if the port is driving low impedance loads (read-write effect)!

Parameters
ucportIDThe port's "Microcontroller Port ID", is a UCPORT_ID_xx define (UCPORT_ID_01 for example).
Returns
Returns a "Port bitAdr" for the requested port's PORT register. Returns BITADR_NA if not available, or error.
WORD ucportGetTRIS ( BYTE  ucportID)

Gets a "Port bitAdr" for the requested port's TRIS register's. The port is identified by it's "Microcontroller Port ID", is a UCPORT_ID_xx define (UCPORT_ID_01 for example). The returned "Port bitAdr" can be used to set or clear the port using the portWriteBitadr(), portSetBitadr() and portClearBitadr() functions.

Parameters
ucportIDThe port's "Microcontroller Port ID", is a UCPORT_ID_xx define (UCPORT_ID_01 for example).
Returns
Returns a "Port bitAdr" for the requested port's TRIS register. Returns BITADR_NA if not available, or error.
WORD ucportGetTRISwOffset ( BYTE  ucportID,
BYTE  offset 
)

!!!!!!! IMPORTANT !!!!!!!!! This functions if used by the system, is not meant for general purpose use!

Gets a "Port bitAdr" for the requested port's TRIS register's, adding the given offset to it.

Parameters
ucportIDThe port's "Microcontroller Port ID", is a UCPORT_ID_xx define (UCPORT_ID_01 for example).
offsetAn offset to add to returned value if it is NOT 0.
Returns
Returns a "Port bitAdr" for the requested port's TRIS register. Returns BITADR_NA if not available, or error.