pic24_ports.h File Reference

Go to the source code of this file.

Defines

Low-level port configuration macros
These macros support low-level pin configuration in the following areas:

#define ENABLE_Rxy_ANALOG()   _PCFGn = 0
#define DISABLE_Rxy_ANALOG()   _PCFGn = 1
#define CONFIG_RPy_AS_DIG_PIN()   _PCFG = 1
#define ENABLE_Rxy_OPENDRAIN()   _ODCxy = 1
#define DISABLE_Rxy_OPENDRAIN()   _ODCxy = 0
#define ENABLE_Rxy_PULLUP()   _CNmPUE = 1
#define DISABLE_Rxy_PULLUP()   _CNmPUE = 1
#define ENABLE_Rxy_CN_INTERRUPT()   _CNmIE = 1
#define DISABLE_Rxy_CN_INTERRUPT()   _CNmIE = 0
Remappable peripheral input support
These funcions map an input internal to the PIC to an input pin. For example, CONFIG_INT1_TO_RP(10) maps the INT1 edge-triggered interrupt to port P, pin 10.

Not all devices support remappable peripherals. In these cases, the macros below evalaute to nothing: CONFIG_INT1_TO_RP(10) is a valid C statement which does nothing.

#define CONFIG_INT1_TO_RP(pin)   _INT1R = pin
#define CONFIG_INT2_TO_RP(pin)   _INT2R = pin
#define CONFIG_T2CK_TO_RP(pin)   _T2CKR = pin
#define CONFIG_T3CK_TO_RP(pin)   _T3CKR = pin
#define CONFIG_T4CK_TO_RP(pin)   _T4CKR = pin
#define CONFIG_T5CK_TO_RP(pin)   _T5CKR = pin
#define CONFIG_IC1_TO_RP(pin)   _IC1R = pin
#define CONFIG_IC2_TO_RP(pin)   _IC2R = pin
#define CONFIG_IC3_TO_RP(pin)   _IC3R = pin
#define CONFIG_IC4_TO_RP(pin)   _IC4R = pin
#define CONFIG_IC5_TO_RP(pin)   _IC5R = pin
#define CONFIG_IC6_TO_RP(pin)   _IC6R = pin
#define CONFIG_IC7_TO_RP(pin)   _IC7R = pin
#define CONFIG_IC8_TO_RP(pin)   _IC8R = pin
#define CONFIG_OCFA_TO_RP(pin)   _OCFAR = pin
#define CONFIG_OCFB_TO_RP(pin)   _OCFBR = pin
#define CONFIG_U1RX_TO_RP(pin)   _U1RXR = pin
#define CONFIG_U1CTS_TO_RP(pin)   _U1CTSR = pin
#define CONFIG_U2RX_TO_RP(pin)   _U2RXR = pin
#define CONFIG_U2CTS_TO_RP(pin)   _U2CTSR = pin
#define CONFIG_SDI1_TO_RP(pin)   _SDI1R = pin
#define CONFIG_SCK1IN_TO_RP(pin)   _SCK1R = pin
#define CONFIG_SS1IN_TO_RP(pin)   _SS1R = pin
#define CONFIG_SDI2_TO_RP(pin)   _SDI2R = pin
#define CONFIG_SCK2IN_TO_RP(pin)   _SCK2R = pin
#define CONFIG_SS2IN_TO_RP(pin)   _SS2R = pin
#define CONFIG_C1RXR_TO_RP(pin)   _C1RXR = pin
#define CONFIG_C2RXR_TO_RP(pin)   _C2RXR = pin
Remappable peripheral output support
These functions maps an output internal to the PIC to an output pin. For example, CONFIG_C1OUT_TO_RP(10) maps the C1OUT comparator output to port P, pin 10.

Not all devices support remappable peripherals. In these cases, the macros below evalaute to nothing: CONFIG_C1OUT_TO_RP(10) is a valid C statement which does nothing.

CONFIG_NULL_TO_RP(n) will return RPn to an 'unmapped' state (i.e, the reset condition).

#define CONFIG_NULL_TO_RP(pin)   _RP##pin##R = 0
#define CONFIG_C1OUT_TO_RP(pin)   _RP##pin##R = 1
#define CONFIG_C2OUT_TO_RP(pin)   _RP##pin##R = 2
#define CONFIG_U1TX_TO_RP(pin)   _RP##pin##R = 3
#define CONFIG_U1RTS_TO_RP(pin)   _RP##pin##R = 4
#define CONFIG_U2TX_TO_RP(pin)   _RP##pin##R = 5
#define CONFIG_U2RTS_TO_RP(pin)   _RP##pin##R = 6
#define CONFIG_SDO1_TO_RP(pin)   _RP##pin##R = 7
#define CONFIG_SCK1OUT_TO_RP(pin)   _RP##pin##R = 8
#define CONFIG_SS1OUT_TO_RP(pin)   _RP##pin##R = 9
#define CONFIG_SDO2_TO_RP(pin)   _RP##pin##R = 10
#define CONFIG_SCK2OUT_TO_RP(pin)   _RP##pin##R = 11
#define CONFIG_SS2OUT_TO_RP(pin)   _RP##pin##R = 12
#define CONFIG_C1TX_TO_RP(pin)   _RP##pin##R = 16
#define CONFIG_OC1_TO_RP(pin)   _RP##pin##R = 18
#define CONFIG_OC2_TO_RP(pin)   _RP##pin##R = 19
#define CONFIG_OC3_TO_RP(pin)   _RP##pin##R = 20
#define CONFIG_OC4_TO_RP(pin)   _RP##pin##R = 21
#define CONFIG_OC5_TO_RP(pin)   _RP##pin##R = 22

Functions

High-level port configuration
These macros choose digital or analog, input or output, open-drain or standard. Use the low-level ENABLE/DISABLE_Rxy_PULLUP() to configure the pullup.

static void CONFIG_Rxy_AS_DIG_OUTPUT ()
static void CONFIG_Rxy_AS_DIG_OD_OUTPUT ()
static void CONFIG_Rxy_AS_DIG_INPUT ()
static void CONFIG_ANx_AS_ANALOG ()


Detailed Description

This file supports configuration of IO ports on the PIC24. Support includes:

Summary of port configuration macros

The port configuration macros are available in two forms. Higher-level routines completely configure a pin for a specific operation, while low-level routines provide a more readable name for changing the value of a single bit (_PCFGn, _TRISxy, _CNmPU, or _ODCxy).

To reduce the confusing variety of naming schemes for these bits, the macros refer to a pin either by its port letter x plus pin number y (for example, _TRISB3 for the TRIS bit of port B, pin 3) or by the analog input number n (for example, AN0 refers to analog input 0).

The macros provided as "smart" - only functions applicable to that pin are contained in a given macro. For example, CONFIG_RA1_AS_DIG_OUTPUT on the PIC24HJ32GP202 disables the pin's pullup, disables the open-drain driver, disables analog functionality, then sets the pin as an output. CONFIG_RA7_AS_DIG_OUTPUT on the PIC24HJ32GP204 only disables the open-drain driver and sets the pin as an output, because that pin supports neither analog nor pullup functionality.

Todo:
Put stub documentation for ALL port macros (doxygen only) so they hyperlink in source code
Todo:
Add a macro in for TRIS bit configuration
Todo:
Brief documentation for all remappable peripherals

Definition in file pic24_ports.h.


Define Documentation

#define CONFIG_C1OUT_TO_RP ( pin   )     _RP##pin##R = 1

Maps C1OUT to a remappable pin; see remappable peripheral output support for more information.

Definition at line 458 of file pic24_ports.h.

#define CONFIG_C2OUT_TO_RP ( pin   )     _RP##pin##R = 2

Maps C2OUT to a remappable pin; see remappable peripheral output support for more information.

Definition at line 467 of file pic24_ports.h.

#define CONFIG_IC1_TO_RP ( pin   )     _IC1R = pin

Maps IC1 to a remappable pin; see remappable peripheral input support for more informatino.

Definition at line 261 of file pic24_ports.h.

#define CONFIG_IC2_TO_RP ( pin   )     _IC2R = pin

Maps IC2 to a remappable pin; see remappable peripheral input support for more informatino.

Definition at line 270 of file pic24_ports.h.

#define CONFIG_IC3_TO_RP ( pin   )     _IC3R = pin

Maps IC3 to a remappable pin; see remappable peripheral input support for more informatino.

Definition at line 279 of file pic24_ports.h.

#define CONFIG_IC4_TO_RP ( pin   )     _IC4R = pin

Maps IC4 to a remappable pin; see remappable peripheral input support for more informatino.

Definition at line 288 of file pic24_ports.h.

#define CONFIG_IC5_TO_RP ( pin   )     _IC5R = pin

Maps IC5 to a remappable pin; see remappable peripheral input support for more informatino.

Definition at line 297 of file pic24_ports.h.

#define CONFIG_IC6_TO_RP ( pin   )     _IC6R = pin

Maps IC6 to a remappable pin; see remappable peripheral input support for more informatino.

Definition at line 306 of file pic24_ports.h.

#define CONFIG_IC7_TO_RP ( pin   )     _IC7R = pin

Maps IC7 to a remappable pin; see remappable peripheral input support for more informatino.

Definition at line 315 of file pic24_ports.h.

#define CONFIG_IC8_TO_RP ( pin   )     _IC8R = pin

Maps IC8 to a remappable pin; see remappable peripheral input support for more informatino.

Definition at line 324 of file pic24_ports.h.

#define CONFIG_INT1_TO_RP ( pin   )     _INT1R = pin

Maps INT1 to a remappable pin; see remappable peripheral input support for more informatino.

Definition at line 207 of file pic24_ports.h.

#define CONFIG_INT2_TO_RP ( pin   )     _INT2R = pin

Maps INT2 to a remappable pin; see remappable peripheral input support for more informatino.

Definition at line 216 of file pic24_ports.h.

#define CONFIG_OCFA_TO_RP ( pin   )     _OCFAR = pin

Maps OCFA to a remappable pin; see remappable peripheral input support for more informatino.

Definition at line 333 of file pic24_ports.h.

#define CONFIG_OCFB_TO_RP ( pin   )     _OCFBR = pin

Maps OCFB to a remappable pin; see remappable peripheral input support for more informatino.

Definition at line 342 of file pic24_ports.h.

 
#define CONFIG_RPy_AS_DIG_PIN (  )     _PCFG = 1

Makes port P, pin y a digital pin by disabling analog functionality on that pin. This is done by setting the corresponding _PCFGn bit. For example, CONFIG_RP10_AS_DIG_PIN() makes port P, pin 10 a digital pin by disabling analog its functionality.

Definition at line 155 of file pic24_ports.h.

#define CONFIG_SCK1OUT_TO_RP ( pin   )     _RP##pin##R = 8

Maps SCK1OUT to a remappable pin; see remappable peripheral output support for more information.

Definition at line 521 of file pic24_ports.h.

#define CONFIG_SCK2OUT_TO_RP ( pin   )     _RP##pin##R = 11

Maps SCK2OUT to a remappable pin; see remappable peripheral output support for more information.

Definition at line 548 of file pic24_ports.h.

#define CONFIG_SDO1_TO_RP ( pin   )     _RP##pin##R = 7

Maps SDO1 to a remappable pin; see remappable peripheral output support for more information.

Definition at line 512 of file pic24_ports.h.

#define CONFIG_SDO2_TO_RP ( pin   )     _RP##pin##R = 10

Maps SDO2 to a remappable pin; see remappable peripheral output support for more information.

Definition at line 539 of file pic24_ports.h.

#define CONFIG_SS1OUT_TO_RP ( pin   )     _RP##pin##R = 9

Maps SS11OUT to a remappable pin; see remappable peripheral output support for more information.

Definition at line 530 of file pic24_ports.h.

#define CONFIG_SS2OUT_TO_RP ( pin   )     _RP##pin##R = 12

Maps SS2OUT to a remappable pin; see remappable peripheral output support for more information.

Definition at line 557 of file pic24_ports.h.

#define CONFIG_T2CK_TO_RP ( pin   )     _T2CKR = pin

Maps T2CK to a remappable pin; see remappable peripheral input support for more informatino.

Definition at line 225 of file pic24_ports.h.

#define CONFIG_T3CK_TO_RP ( pin   )     _T3CKR = pin

Maps T3CK to a remappable pin; see remappable peripheral input support for more informatino.

Definition at line 234 of file pic24_ports.h.

#define CONFIG_T4CK_TO_RP ( pin   )     _T4CKR = pin

Maps T4CK to a remappable pin; see remappable peripheral input support for more informatino.

Definition at line 243 of file pic24_ports.h.

#define CONFIG_T5CK_TO_RP ( pin   )     _T5CKR = pin

Maps T5CK to a remappable pin; see remappable peripheral input support for more informatino.

Definition at line 252 of file pic24_ports.h.

#define CONFIG_U1CTS_TO_RP ( pin   )     _U1CTSR = pin

Maps U1CTS to a remappable pin; see remappable peripheral input support for more informatino.

Definition at line 360 of file pic24_ports.h.

#define CONFIG_U1RTS_TO_RP ( pin   )     _RP##pin##R = 4

Maps U1RTS to a remappable pin; see remappable peripheral output support for more information.

Definition at line 485 of file pic24_ports.h.

#define CONFIG_U1RX_TO_RP ( pin   )     _U1RXR = pin

Maps U1RX to a remappable pin; see remappable peripheral input support for more informatino.

Definition at line 351 of file pic24_ports.h.

#define CONFIG_U1TX_TO_RP ( pin   )     _RP##pin##R = 3

Maps U1TX to a remappable pin; see remappable peripheral output support for more information.

Definition at line 476 of file pic24_ports.h.

#define CONFIG_U2CTS_TO_RP ( pin   )     _U2CTSR = pin

Maps U2CTS to a remappable pin; see remappable peripheral input support for more informatino.

Definition at line 378 of file pic24_ports.h.

#define CONFIG_U2RTS_TO_RP ( pin   )     _RP##pin##R = 6

Maps U2RTS to a remappable pin; see remappable peripheral output support for more information.

Definition at line 503 of file pic24_ports.h.

#define CONFIG_U2RX_TO_RP ( pin   )     _U2RXR = pin

Maps U2RX to a remappable pin; see remappable peripheral input support for more informatino.

Definition at line 369 of file pic24_ports.h.

#define CONFIG_U2TX_TO_RP ( pin   )     _RP##pin##R = 5

Maps U2TX to a remappable pin; see remappable peripheral output support for more information.

Definition at line 494 of file pic24_ports.h.

 
#define DISABLE_Rxy_ANALOG (  )     _PCFGn = 1

Disables analog functionality on port x of pin y by setting the corresponding _PCFGn bit. For example, DISABLE_RA10_ANALOG() disables analog functionality on port A pin 10.

Definition at line 148 of file pic24_ports.h.

 
#define DISABLE_Rxy_CN_INTERRUPT (  )     _CNmIE = 0

Disables the change notification interrupt on port x, pin y. For example, DISABLE_RA10_CN_INTERRUPT() disables the change notification interrupt on port A, pin 10.

Definition at line 187 of file pic24_ports.h.

 
#define DISABLE_Rxy_OPENDRAIN (  )     _ODCxy = 0

Disables the open-drain driver on port x, pin y. For example, DISABLE_Rxy_OPENDRAIN()

Definition at line 165 of file pic24_ports.h.

 
#define DISABLE_Rxy_PULLUP (  )     _CNmPUE = 1

Disable the pullup on port x, pin y. For example, DISABLE_RA10_PULLUP() disables the pullup on port A, pin 10.

Definition at line 175 of file pic24_ports.h.

 
#define ENABLE_Rxy_ANALOG (  )     _PCFGn = 0

Enables analog functionality on port x of pin y by clearing the corresponding _PCFGn bit. For example, ENABLE_RA10_ANALOG() enables analog functionality on port A pin 10.

Definition at line 142 of file pic24_ports.h.

 
#define ENABLE_Rxy_CN_INTERRUPT (  )     _CNmIE = 1

Enables the change notification interrupt on port x, pin y. For example, ENABLE_RA10_CN_INTERRUPT() enables the change notification interrupt on port A, pin 10.

Definition at line 181 of file pic24_ports.h.

 
#define ENABLE_Rxy_OPENDRAIN (  )     _ODCxy = 1

Enables the open-drain driver on port x, pin y. For example, ENABLE_Rxy_OPENDRAIN()

Definition at line 160 of file pic24_ports.h.

 
#define ENABLE_Rxy_PULLUP (  )     _CNmPUE = 1

Enable the pullup on port x, pin y. For example, ENABLE_RA10_PULLUP() enables the pullup on port A, pin 10.

Definition at line 170 of file pic24_ports.h.


Function Documentation

static void CONFIG_ANx_AS_ANALOG (  )  [inline, static]

This macro first calls CONFIG_Rxy_AS_DIG_INPUT() to disable pullups on the pin then enables analog functionality on the pin. For example, CONFIG_AN1_AS_ANALOG() makes AN1 an analog input pin.

Definition at line 117 of file pic24_ports.h.

static void CONFIG_Rxy_AS_DIG_INPUT (  )  [inline, static]

This macro disables pullups and analog functionality and sets the pin as an input. For example, CONFIG_RA10_AS_DIG_OUTPUT() makes port A, pin 10 a digital input.

Definition at line 111 of file pic24_ports.h.

static void CONFIG_Rxy_AS_DIG_OD_OUTPUT (  )  [inline, static]

This macro enables open-drain, disables pullups, configures port x pin y for digital (not analog) operation, and sets the pin as an output. For example, CONFIG_RA10_AS_DIG_OD_OUTPUT() makes port A, pin 10 a digital output.

Definition at line 105 of file pic24_ports.h.

static void CONFIG_Rxy_AS_DIG_OUTPUT (  )  [inline, static]

This macro disables open-drain and pullups, configures port x pin y for digital (not analog) operation, and sets the pin as an output. For example, CONFIG_RA10_AS_DIG_OUTPUT() makes port A, pin 10 a digital output.

Definition at line 98 of file pic24_ports.h.


Generated on Mon Oct 18 07:40:48 2010 for Python-on-a-chip by  doxygen 1.5.9